help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

debug parent from child


From: ahowe42
Subject: debug parent from child
Date: Mon, 19 Mar 2012 05:28:49 -0700 (PDT)

Hello everyone

I have occasionally had the need to have a breakpoint dynamically inserted
in a function/script to identify situations that don't occur with every run
(usually because of simulations).  This is easy to do with something like
this:

if *test condition*
[st,ind] = dbstack; feval("dbstop",st(ind).name,st(ind).line+1)
disp('situation occurred')
end

Since this can be so useful, I decided to write a function to do this that I
could just call inside my if branch (hence generalizing the dynamic debug). 
However, from much testing it seems that dbstop cannot put a breakpoint on a
parent in the stack.  The breakpoint is actually applied in the child
function.

My parent function (for testing) uses this code:

/if 1 == 1
        DebugTest;
        1/1;
end/

and the DebugTest function is:

/function DebugTest
% get the current execution stack up to the calling function
[st,ind] = dbstack;
% now place the break point at the next execution line
feval("dbstop",st(ind+1).name,st(ind+1).line+1);/

Since dbstop is a built-in function, I can't place a breakpoint to debug it
:-).  I'll try to check the sourcecode to figure out what's going on, but
wondered if anyone had any ideas about it?

Thanks.

Andrew


--
View this message in context: 
http://octave.1599824.n4.nabble.com/debug-parent-from-child-tp4484585p4484585.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]