The problem is that when you ask for the traceback, the program has already died, so the call stack is destroyed.
To solve the problem, you have to arrange to stop the program before it dies.
In this case for example, first put the die in a separate line:
Then run the code and see it dies at line 10255[am]king ~/a$ cat a print "Hello\n"; a(0); print "Middle\n"; a(1); print "Goodbye\n"; sub a { $parameter = shift; if( $parameter ) { die # <--- line 10 }; }
Than put a breakpoint to line 10[am]king ~/a$ perl a Hello Middle Died at a line 10.
And you'll see that the subroutine was called from line 4.255[am]king ~/a$ perl -wd a Loading DB routines from perl5db.pl version 1.27 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(a:1): print "Hello\n"; DB<1> b 10 DB<2> c Hello Middle main::a(a:10): die # <--- line 10 DB<2> T . = main::a(1) called from file `a' line 4 DB<2> Died at a line 10. at a line 10 main::a(1) called at a line 4 255[am]king ~/a$
In reply to Re: Perl debug. How do I find calling line number?
by ambrus
in thread Perl debug. How do I find calling line number?
by brycen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |