Invisible variables in Perl debugger

V

Volker Nicolai

Hi,

under the Perl debugger I ran a script which invokes another one
at the end with

require "gen_spec.pl";

In this invoked script gen_spec.pl I can not see/trace any variable.
I can tell the debugger with

b load gen_spec.pl

to stop when loading this script, that works.
I can also tell it with

b 160

to break at line 160, works too.
But if I set a condition for the breakpoint, like

b 160 ($reg_key =~ /LAYER1_START/)

it fails.
To verify that I tried to print the value of $reg_key

p $reg_key

but nothing comes out though it should and I can see in a print
statement in my code-to-be-debugged that $reg_key does have a value.

Does anyone know where the problem is??
Thanks for helping
Volker
 
I

Ilya Zakharevich

[A complimentary Cc of this posting was sent to
Volker Nicolai
require "gen_spec.pl";
....

To verify that I tried to print the value of $reg_key

p $reg_key

but nothing comes out though it should and I can see in a print
statement in my code-to-be-debugged that $reg_key does have a value.

On a surface, it looks that this may be a true bug. However, what you
write is very ambiguous (and I suspect that English is not your first
language, so it may take a lot of time to clear through...). If you
can create a short example, please post it.

Thanks,
Ilya
 
V

Volker Nicolai

Ilya Zakharevich said:
On a surface, it looks that this may be a true bug. However, what you
write is very ambiguous (and I suspect that English is not your first
language, so it may take a lot of time to clear through...). If you
can create a short example, please post it.

Thanks,
Ilya

I am not too sure what sort of example you want but here is one (hope
that does it):
(I have tested $casn too, that works but not $i...

--------------------------------------------------

DB<49> l 1027-1045
1027==>b if (exists $case[$casn+1]) { # A
next case exists?
1028: for($i=0; $i < scalar(@{$case[$casn]}); $i++) { # For
all sequences of this case (incl. general one)...
1029: print "Restore: i: $i \n"; # DEBUG!
1030: foreach $reg_key (keys (%{$case[$casn][$i]})) { # For
all register keys of this case + sequence...
1031: next if (defined
$case[$casn][$i]{$reg_key}{_RESTORE_} &&
$case[$casn][$i]{$reg_key}{_RESTORE_} eq "n");
1032 # Skip case
reg if restore to orig spec shall be done.
1033: foreach $field_key (keys
(%{$case[$casn][$i]{$reg_key}})) {
1034 # For all
slice keys of each register ...
1035: if (defined $case[$casn+1][$i] && ! defined
$case[$casn+1][$i]{$reg_key} &&
1036 ! defined
$case[$casn+1][$i]{$reg_key}{$field_key}){
1037 # Reg/slice
key not (re-)defined in next case? (->prevent overwriting)
1038: $case[$casn+1][$i]{$reg_key}{$field_key} =
$case[$casn][$i]{$reg_key}{$field_key};
1039 } # Take last's
cases rule or specical key and copy it to next one.
1040 }
1041 }
1042 }
1043 }
1044
1045: print CMDFILE "\nprint_msg (\"FINISHED PROGRAMMING
REGISTERS\"); \n\n";
DB<50> s
main::(gen_specs.pl:1028): for($i=0; $i <
scalar(@{$case[$casn]}); $i++) { # For all sequences of this case
(incl. general one)...
DB<50> s
main::(gen_specs.pl:1028): for($i=0; $i <
scalar(@{$case[$casn]}); $i++) { # For all sequences of this case
(incl. general one)...
DB<50>
main::(gen_specs.pl:1029): print "Restore: i: $i \n";
# DEBUG!
DB<50>
Restore: i: 0
main::(gen_specs.pl:1030): foreach $reg_key (keys
(%{$case[$casn][$i]})) { # For all register keys of this case +
sequence...
DB<50> p $i
Use of uninitialized value in print at (eval
21)[/cadappl/perl/5.6.1/lib/5.6.1/perl5db.pl:1521] line 2.

DB<51> print $i
Use of uninitialized value in print at (eval
22)[/cadappl/perl/5.6.1/lib/5.6.1/perl5db.pl:1521] line 2.

DB<52> p $casn
0

------------------------------------------------------
The related lines of code are inside gen_spec.pl:

if (exists $case[$casn+1]) {
for($i=0; $i < scalar(@{$case[$casn]}); $i++) {
print "Restore: i: $i \n"; # DEBUG!
foreach $reg_key (keys (%{$case[$casn][$i]})) {
next if (defined $case[$casn][$i]{$reg_key}{_RESTORE_} &&
$case[$casn][$i]{$reg_key}{_RESTORE_} eq "n");
foreach $field_key (keys (%{$case[$casn][$i]{$reg_key}})) {
if (defined $case[$casn+1][$i] &&
! defined $case[$casn+1][$i]{$reg_key} &&
! defined $case[$casn+1][$i]{$reg_key}{$field_key}){
$case[$casn+1][$i]{$reg_key}{$field_key} =
$case[$casn][$i]{$reg_key}{$field_key};
}
}
}
}



(Sorry for long lines above)
gen_spec.pl is invoked by another script with:

require "gen_specs.pl" ;

Hope that does it.
Thanks for helping, sorry for the delay of my response.
Volker
 
I

Ilya Zakharevich

[A complimentary Cc of this posting was sent to
Volker Nicolai
I am not too sure what sort of example you want but here is one (hope
that does it):

Do not see anything I can run...

Yours,
Ilya
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top