octave_call_stack changes

John W. Eaton jwe at bevo.che.wisc.edu
Sat Jun 28 18:48:34 CDT 2008


Earlier today, I checked in some changes to the way the call stack is
handled so that for a function like

  function fx (n)
    if (n == 0)
      'a'
      x = 1
      fx (n+1)
      'e'
      x
    else
      'b'
      x = 2
      'c'
      evalin ('caller', 'x');
      'd'
      x
    end
  end

the call

  octave:1> fx (0)
  ans = a
  x =  1
  ans = b
  x =  2
  ans = c
  x =  1
  ans = d
  x =  2
  ans = e
  x =  1

will work as shown above.  I don't think evalin ('caller', ...)
ever worked properly for recursive calls until now.

Also, given a set of functions like

  function f ()
    x = 'f';
    g ();
  endfunction
  function g ()
    x = 'g';
    h ();
  endfunction
  function h ()
    x = 'h';
  endfunction

things like this should now be possible:

  octave:1> dbstop h
  ans =  2
  octave:2> f
  h: line 2, column 5
  x = 'h'
  keyboard: stopped in /scratch/jwe/build/octave/h.m at line 2
  debug> dbstack
  Stopped in:

  --> h at line 2 column 1
      g at line 3 column 3
      f at line 3 column 3
  debug> dbup
  g:  line 3, column 3
  debug> dbstack
  Stopped in:

      h at line 2 column 1
  --> g at line 3 column 3
      f at line 3 column 3
  debug> dbdown
  h:  line 2, column 1
  debug> dbstack
  Stopped in:

  --> h at line 2 column 1
      g at line 3 column 3
      f at line 3 column 3

I don't think this kind of thing ever really worked properly before
now.

Although I'm sure there is still room for improvement, these changes
appear to be working for me.  There could also be some problems
that I haven't seen yet.  Unfortunately, if there are problems, I
won't be able to do anything about then until after July 7, but I
thought it would be best to go ahead and check in these changes so
they could get some additional testing.

jwe


More information about the Octave-maintainers mailing list