Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I move the debugger context up and down the stack?

Tags:

debugging

perl

Basically I'm looking for the perl equivalent of gdb's "up" and "down" commands. If I break on subroutine bar, and I have a call stack that looks like this:

foo
  \
   baz
    \
     bar

I'd like to be able to (without returning from bar or baz) navigate up the foo frame and see what it was doing by manipulating variables as I ordinarily would using arguments to p or x.

like image 233
gcbenison Avatar asked Feb 04 '13 06:02

gcbenison


People also ask

What is Debug call stack?

The call stack is a list of all the active functions that have been called to get to the current point of execution. The call stack includes an entry for each function called, as well as which line of code will be returned to when the function returns.

How do I stack trace in Visual Studio?

To open the Call Stack window in Visual Studio, from the Debug menu, choose Windows>Call Stack. To set the local context to a particular row in the stack trace display, select and hold (or double click) the first column of the row.


1 Answers

Use the y command.

$ cat frames.pl
sub bar {
    my $fnord = 42;
    1
}
sub baz { bar }
sub foo {
    my $fnord = 23;
    baz
};
foo;
$ perl -d frames.pl

Loading DB routines from perl5db.pl version 1.37
Editor support available.

Enter h or 'h h' for help, or 'man perldebug' for more help.

main::(frames.pl:10):   foo;
DB<1> c 3
main::bar(frames.pl:3):     1
DB<2> y 2 fnord
$fnord = 23
DB<3> T
. = main::bar() called from file 'frames.pl' line 5
. = main::baz() called from file 'frames.pl' line 8
. = main::foo() called from file 'frames.pl' line 10
like image 87
daxim Avatar answered Oct 23 '22 11:10

daxim