Re: Setting break point for particular condition in the subroutine
by LanX (Saint) on Mar 07, 2013 at 08:22 UTC
|
> I tried to set as b Engine::_Execute /INITIAL/i but my script runs without wait.
you're setting a breakpoint on the routine with a condition which checks $_ which doesn't make much sense.
If I where you I would set the breakpoint at first line of body of if($cmd =~ /INITIAL/i) condition, that is unless (fork)
There is more than one way to do it.
Find the line number by investigating the routine with l Engine::_Execute and set b line_number.
Or manipulate your source and include $DB::single=1 before the line you want to break.
| [reply] [Watch: Dir/Any] [d/l] [select] |
|
| [reply] [Watch: Dir/Any] [d/l] |
|
I am getting the below error only when I try to create child process using fork in the code mentioned in this Thread.
Engine::_Execute(..\..\perl\modules/Engine.pm:122):
122: unless (fork) {
DB<1> s
Bizarre SvTYPE [37] at ..\..\perl\modules/Engine.pm line 122.
Engine::_Execute(C:/Perl/lib/Carp.pm:97):
97: { local $@; require Carp::Heavy; } # XXX fix require to not clea
+r $@?
It means there are some localized scalar variables are trying to restore in a child process hence throwing error
"Attempt to free unreferenced scalar"
There is some modules where carp.pm is used. I replaced all the places of carp with warn and tried
but no luck still it is showing the same. Please let me know how to debug this issue.
| [reply] [Watch: Dir/Any] [d/l] |
|
| [reply] [Watch: Dir/Any] [d/l] [select] |
|
Please, do not use <pre> tags for text. Read <pre> Versus <code> Tags for more information as already advised in a /msg.
| [reply] [Watch: Dir/Any] [d/l] |
Re: Setting break point for particular condition in the subroutine
by rjt (Curate) on Mar 07, 2013 at 08:15 UTC
|
It sounds like you want to insert the breakpoint at the if ($cmd =~ /INITIAL/i) line. Let's say that's line 123. Then, type:
b 123 $cmd =~ /INITIAL/i
Setting it to the subroutine entry is problematic because $cmd isn't set yet (or at least isn't set to a member of @commands. In addition to that, simply using /INITIAL/i as your condition would be running that regexp on $_, not $cmd.
See perldebug for more info.
| [reply] [Watch: Dir/Any] [d/l] [select] |
|
This subroutine is called from other subroutine which is intern called from my perl script.
So setting break point b 123 $cmd =~ /INITIAL/i throws error
Line 118 not breakable. because my script does not have those many lines.
From the google docs I found the below statement b subname [condition] Can we use this in anyway?
| [reply] [Watch: Dir/Any] [d/l] |
|
Yes, that's why you need to figure out the actual line number. "123" was just an example. You can determine the line number with l Engine::_Execute ... lines that are breakable will show with a colon (:) after the line number in the debugger. Hence, if you see this:
100 sub Engine::Execute
101 {
102
103: foreach (@commands)
104 {
105: $cmd = $_;
106: if($cmd =~ /INITIAL/i)
107 {
... then you would type b 106 $cmd =~ /INITIAL/i
Again, these numbers are just examples. You need to determine the actual line number for yourself with l Engine::_Execute! | [reply] [Watch: Dir/Any] [d/l] [select] |
|
| [reply] [Watch: Dir/Any] [d/l] |
Re: Setting break point for particular condition in the subroutine
by choroba (Cardinal) on Mar 07, 2013 at 15:13 UTC
|
Please, do not use <pre> tags for text. Read <pre> Versus <code> Tags for more information as already advised in a /msg.
| [reply] [Watch: Dir/Any] [d/l] |
Re: Setting break point for particular condition in the subroutine
by clueless newbie (Curate) on Mar 07, 2013 at 12:22 UTC
|
my @caller=caller(0);
$DB::single=1 if ($caller[0] eq 'package::of::interest' and $caller[3]
+ eq 'thatsub');
| [reply] [Watch: Dir/Any] [d/l] |