[Changeset]: filemarker and fix for 'dbstep in'

David Bateman adb014 at gmail.com
Sun May 25 08:44:35 CDT 2008


The attached changeset fixes a bug my previous debug patch introduced
and adds the filemarker function that is also useful for debugging. The
bug was that the "dbstep in" command executed parts of the line
individually rather than prevent the next breakpoint before the next
line of executed of the function, as occurs with "dbstep", etc.

The filemarker command itself is trivial, however it is then used to
identify subfunctions. Consider that you have a function

# string 1
function z = testfun (x)
# string 2
  y = 1;
  z = testfun2 (x, y);
end
# string 3
function z = testfun2 (x, y)
# string 4
  z = x + y;
end

then filemarker can be used like

help (["testfun", filemarker, "testfun2"])

or knowing that filemarker is by default ">", then

help testfun>testfun2

gives the same result. Other uses include in dbstop to set a breakpoint
in a subfunction, for example

dbstop testfun>testfun2

set the breakpoint at the first line of the testfun2 subfunction. I also
adapted the backtrace method so that dbstack gives the name of the
subfunctions including their parent functions..

Note that the symbol_table:;find_function method will have to be adapted
if we ever decide to implement nested functions as matlab stupidly uses
the filesep character to define the nesting rather than the filemarker
character. That is, if we have a function like

function f1
  function f2
  end
  function f3
  end
end
function f2
end

then to set breakpoints in each of these functions is done like

dbstop f1
dbstop f1>f1/f2
dbstop f1>f3
dbstop f1>f2

If matlab had used filemarker instead of filesep for the nesting, then
the current adaptation of symbol_table::find_function would already be
correct.

Note that I allowed the filemarker character to be set, but prevented it
from being set to a valid character for a function name. Matlab doesn't
allow filemarker to be set. Also note that on all platforms I tested
filemarker was ">" in Matlab (linux and windows), so I believe that the
default is always ">" though Matlab on a Mac might have a different value.

D.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch8136
Url: https://www.cae.wisc.edu/pipermail/octave-maintainers/attachments/20080525/32f89313/attachment.ksh 


More information about the Octave-maintainers mailing list