#651 Problem showing variables in debug

v0.6.x
open
Debugger (177)
5
2016-05-15
2012-10-22
Anonymous
No

Hi

I am trying to debug perl code with eclipse Juno 4.2.1 Build id: M20120914-1800 on Mac OS X Mountain Lion with EPIC v 0.6.45 (Debug plug-in v. 0.6.32). What happens is that I get the following error in the Variables view or if I just try to see the local variables I get an empty view without any variables.

--------
An error occurred while dumping Perl internal variables; contents of the Variables view may become invalid
--------

Debug view shows:
--------
DB<12> ;{
do 'dumpvar_epic.pm' unless defined &dumpvar_epic::dump_package_vars;

my $savout = select($DB::OUT);
dumpvar_epic::_dump_entity('@_', \@_);
dumpvar_epic::dump_package_vars();
select($savout);
};

2|@_
DB<13>
--------

and error log shows

java.lang.StringIndexOutOfBoundsException: String index out of range: 4
at java.lang.String.charAt(String.java:686)
at org.epic.debug.db.DumpedEntityReader.token(DumpedEntityReader.java:46)
at org.epic.debug.db.DumpedEntityReader.nextEntity(DumpedEntityReader.java:34)
at org.epic.debug.db.StackFrame.dumpInternalVars(StackFrame.java:303)
at org.epic.debug.db.StackFrame.getVariables(StackFrame.java:187)
at org.eclipse.debug.internal.ui.model.elements.StackFrameContentProvider.getAllChildren(StackFrameContentProvider.java:51)
at org.eclipse.debug.internal.ui.model.elements.StackFrameContentProvider.getChildCount(StackFrameContentProvider.java:28)
at org.eclipse.debug.internal.ui.model.elements.ElementContentProvider.retrieveChildCount(ElementContentProvider.java:114)
at org.eclipse.debug.internal.ui.model.elements.ElementContentProvider$2.run(ElementContentProvider.java:63)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)

What could I do to fix this?

Regards,

Lauri

Discussion

  • Jan Ploski

    Jan Ploski - 2012-10-22

    You could probably work around the immediate problem by disabling "Show Perl Internal Variables" in Variables view.

    But it shows that something is seriously broken. Here is what a logged dump of @_ should look like for a sub with no passed parameters:

    DB<9> ;{
    do 'dumpvar_epic.pm' unless defined &dumpvar_epic::dump_package_vars;

    my $savout = select($DB::OUT);
    dumpvar_epic::_dump_entity('@_', \@_);
    dumpvar_epic::dump_package_vars();
    select($savout);
    };

    2|@_|1|1|16|ARRAY(0x12310a0)|3|...|1|3
    ...

    In our case the line is cut off after 2|@_ for some reason.

    If you want to debug it, you will need to have a closer look at dumpvar_epic.pm. The expected format description is found in the POD at the end of this file. IIRC, a copy of dumpvar_epic.pm from the org.epic.debug plugin directory is written before each launch to the workspace/.metadata/.plugins/org.epic.debug directory - so watch out which file you edit; you may also wish to tweak your include path so that your tweaked version is picked up in place of the standard one.

     
  • Nobody/Anonymous

    Thanks for info, but I still don't get it. Now when trying to select "Show Global Variables" I get this:

    DB<4> ;{
    do 'dumpvar_epic.pm' unless defined &dumpvar_epic::dump_package_vars;

    my $savout = select($DB::OUT);
    dumpvar_epic::dump_package_vars(__PACKAGE__);
    select($savout);
    };

    3|$^A|1|1|22|SCALAR(0x7ffe70833da8)|2|''|1|2
    3|$^D|1|1|22|SCALAR(0x7ffe70827348)|3|'0'|1|3
    3|$^E|1|1|22|SCALAR(0x7ffe70894c10)|2|''|1|2
    3|$^F|1|1|22|SCALAR(0x7ffe7089d488)|3|'2'|1|3
    3|$^H|1|1|22|SCALAR(0x7ffe70806ff8)|5|'256'|1|5
    3|$^L|1|1|22|SCALAR(0x7ffe70833b50)|3|' '|1|3
    3|$^O|1|1|22|SCALAR(0x7ffe7082e4f0)|8|'darwin'|1|8
    3|$^P|1|1|22|SCALAR(0x7ffe708fce30)|6|'1855'|1|6
    16|$^RE_TRIE_MAXBUF|1|1|22|SCALAR(0x7ffe7083a4c0)|7|'65536'|1|7
    3|$^S|1|1|22|SCALAR(0x7ffe709051d8)|3|'1'|1|3
    7|$^TAINT|1|1|22|SCALAR(0x7ffe70925828)|3|'1'|1|3
    9|$^UNICODE|1|1|22|SCALAR(0x7ffe70ae5540)|3|'0'|1|3
    3|$^V|1|2|19|REF(0x7ffe70907760)|28|version=HASH(0x7ffe70907790)|9|'v5.12.4'|1|9
    3|$^W|1|1|22|SCALAR(0x7ffe70483620)|3|'1'|1|3
    14|$^WARNING_BITS|1|1|22|SCALAR(0x7ffe70858d00)|14|'UUUUUUUUUUUU'|2|14
    3|$^X|1|1|22|SCALAR(0x7ffe70807388)|6|'perl'|1|6
    2|$!2|$"2|$$2|$%2|$-2|$/2|$02|$:2|$;2|$<2|$=2|$?2|$@4|%ENV4|@INC4|%SIG18|FileHandle(STDERR)17|FileHandle(STDIN)18|FileHandle(STDOUT)2|$]2|$^8|$columns18|FileHandle(stderr)17|FileHandle(stdin)18|FileHandle(stdout)2|$|2|$~
    DB<5>

    But in the Variables view I get error:

    An error occurred while dumping global variables; contents of the Variables view may become invalid

    It seems like having some problems with linefeeds on the last line?

    How could I debug this?

     
  • Jan Ploski

    Jan Ploski - 2012-10-23

    A more detailed description of the error reported in Variables view can be found in file workspace/.metadata/.log

    The last line seems wrong, but it may also be that it only appears so because of the carriage return (\r) character somewhere in between.

    To debug this sort of problems you must be able to tweak dumpvar_epic.pm as described before - for example to write its output to a file and examine with hexeditor if need be, and you must understand what output is expected (documented at the end of dumpvar_epic.pm itself). You can also compare the Java side, which parses whatever dumpvar_epic.pm prints in order to populate the Variables view:

    https://github.com/jploski/epic-ide/blob/testing/org.epic.debug/src/org/epic/debug/db/DumpedEntityReader.java

     
  • Nobody/Anonymous

    I would like to debug, but it seems that I can't debug by changing the dumpvar_epic.pm in the .metadata/.plugins/org.epic.debug directory, because it is already in the memory. Where should I define a different version of that file to be used? I mean how to define the include path so that another version will be used?

     
  • Jan Ploski

    Jan Ploski - 2012-10-23

    dumpvar_epic.pm is being overwritten on each debugger launch with the original version extracted from eclipse/plugins/org.epic.debug*.jar

    But rather than repack the jar each time, it is easier to right-click on the Project, go to Properties, add "." (which resolves to your project's top-level directory) to Perl Include Path (don't forget to click "Add" after you enter it). Then you can work on a copy of dumpvar_epic.pm living in your project and it will be picked up instead of the default one. Still, you will have to restart a debugging session after making changes for them to become effective. I recommed that while tweaking dumpvar_epic.pm you write whatever diagnostic output you need to a separate file, so as not to disrupt the rest of it (until you want to try a fix, of course).

     
  • Nobody/Anonymous

    Thanks! Now I am getting something out!
    I still can't understand why is there something like this:

    ;{
    do 'dumpvar_epic.pm' unless defined &dumpvar_epic::dump_lexical_vars;

    my $offset = 0;
    my $savout = select($DB::OUT);
    dumpvar_epic::dump_lexical_vars($offset);
    select($savout);
    };

    4|$url
    |
    1|1
    |
    22|SCALAR(0x7ff183007358)
    |
    5|'hgf'
    |
    1|5

    for a simple line like:
    my $url = "hgf";

     
  • Jan Ploski

    Jan Ploski - 2012-10-23

    I'm not sure where the line breaks are coming from in your example. The correct output should be just one line:

    4|$url|1|1|17|SCALAR(0x181ab50)|5|'hgf'|1|5

    All of this is specified at the end of dumpvar_epic.pm, as I mentioned.

     
  • Nobody/Anonymous

    Well, it seems like I have two problems:

    in dump_lexical_vars sometimes it helps to have:

    my ($dollar_comma, $dollar_backslash) = ($,, $\);
    ($,, $\) = undef;
    my $h = eval { PadWalker::peek_my(3 + $frame_index) };
    if (!$@) { _dump_keys($h, 0); }
    ($,, $\) = ($dollar_comma, $dollar_backslash);

    instead of

    my $h = eval { PadWalker::peek_my(3 + $frame_index) };
    if (!$@) { _dump_keys($h, 0); }

    and the second thing is that in dump_package_vars I get:

    2|$!2|$"2|$$2|$%2|$-2|$/2|$02|$:2|$<2|$=2|$?2|$@4|%ENV4|@INC4|%SIG18|FileHandle(STDERR)17|FileHandle(STDIN)18|FileHandle(STDOUT)2|$]2|$^18|FileHandle(stderr)17|FileHandle(stdin)18|FileHandle(stdout)2|$|2|$~

    where I should get much more information for each variable and each on its own line.

    I just don't understand where these problems come from. Maybe it is the version of Perl on my computer that is behaving strange...

     
  • Jan Ploski

    Jan Ploski - 2012-10-23

    I think the problems you are experiencing are related to the difference in the platform's default line terminator character (compiled into Perl, I guess?), which is \r on Mac and \n on Unix (and \r\n on Windows). The "too much on a single line" issue is probably same thing and also a red herring in a sense, just coming from a \r being interpreted by whichever tool you use to display the string as "move cursor to the beginning of line" rather than an actual line break (thus line contents wraps where there should be a newline).

    However, it seems quite strange that you would be the first Mac user who tried debugging with EPIC (and failed), so I'm puzzled. I can't check it out myself (no Mac), but I vaguely recall other people having better luck than you.

    It sounds sensible though that dumpvar_epic.pm should be made robust enough not to depend on whichever default separator characters are established by the platform. Howevr, I'm somewhat reluctant to integrate crude fixes for setting/resetting the special variables because these code segments are performance-critical - invoked a great number of times when stepping through the code (which is already regrettably slow). So it would be nice if you could find out if it's just your particular installation that is special somehow (maybe you have access to other Mac computers to try and compare).

     
  • Lauri Parikka

    Lauri Parikka - 2012-10-27

    Hi again,

    Having Perl Internal and Local Variables On and Global off with this code, I get the following debug view:

    CODE

    #!/usr/bin/perl

    $a = 1;
    my $b = 'test';
    $c = 'second';

    print $c.$b.$a;

    ---------------------
    DEBUG

    3: $a = 1;
    DB<3> ;{
    do 'dumpvar_epic.pm' unless defined &dumpvar_epic::dump_package_vars;

    my $savout = select($DB::OUT);
    dumpvar_epic::_dump_entity('@_', \@_);
    dumpvar_epic::dump_package_vars();
    select($savout);
    };

    2|@_|1|1|21|ARRAY(0x7fdd6c007040)|3|...|1|3
    3|$^A|1|1|22|SCALAR(0x7fdd6c033d90)|2|''|1|2
    3|$^D|1|1|22|SCALAR(0x7fdd6c027330)|3|'0'|1|3
    3|$^E|1|1|22|SCALAR(0x7fdd6c094bf8)|2|''|1|2
    3|$^F|1|1|22|SCALAR(0x7fdd6c09d470)|3|'2'|1|3
    3|$^H|1|1|22|SCALAR(0x7fdd6c006ff8)|5|'256'|1|5
    3|$^L|1|1|22|SCALAR(0x7fdd6c033b38)|3|' '|1|3
    3|$^O|1|1|22|SCALAR(0x7fdd6c02d4d8)|8|'darwin'|1|8
    3|$^P|1|1|22|SCALAR(0x7fdd6c0fce18)|6|'1855'|1|6
    16|$^RE_TRIE_MAXBUF|1|1|22|SCALAR(0x7fdd6c03a4a8)|7|'65536'|1|7
    3|$^S|1|1|22|SCALAR(0x7fdd6c1051c0)|3|'1'|1|3
    7|$^TAINT|1|1|22|SCALAR(0x7fdd6c125040)|3|'1'|1|3
    9|$^UNICODE|1|1|22|SCALAR(0x7fdd6c089c10)|3|'0'|1|3
    3|$^V|1|2|19|REF(0x7fdd6c107778)|28|version=HASH(0x7fdd6c1077a8)|9|'v5.12.4'|1|9
    3|$^W|1|1|22|SCALAR(0x7fdd6bc833a8)|3|'1'|1|3
    14|$^WARNING_BITS|1|1|22|SCALAR(0x7fdd6c058ce8)|14|'UUUUUUUUUUUU'|2|14
    3|$^X|1|1|22|SCALAR(0x7fdd6c007388)|6|'perl'|1|6
    2|$!2|$"2|$$2|$%2|$-2|$/2|$02|$:2|$<2|$=2|$?2|$@4|%ENV4|@INC4|%SIG18|FileHandle(STDERR)17|FileHandle(STDIN)18|FileHandle(STDOUT)2|$]2|$^18|FileHandle(stderr)17|FileHandle(stdin)18|FileHandle(stdout)2|$|2|$~
    DB<4> .
    main::(/Users/xxx/Documents/workspacejuno/DebugTesti/testi.pl:3):
    3: $a = 1;
    DB<4> n
    main::(/Users/xxx/Documents/workspacejuno/DebugTesti/testi.pl:4):
    4: my $b = 'test';
    DB<4> .
    main::(/Users/xxx/Documents/workspacejuno/DebugTesti/testi.pl:4):
    4: my $b = 'test';
    DB<4> .
    main::(/Users/xxx/Documents/workspacejuno/DebugTesti/testi.pl:4):
    4: my $b = 'test';
    DB<4> .
    main::(/Users/xxx/Documents/workspacejuno/DebugTesti/testi.pl:4):
    4: my $b = 'test';
    DB<4> T
    DB<4> .
    main::(/Users/xxx/Documents/workspacejuno/DebugTesti/testi.pl:4):
    4: my $b = 'test';
    DB<4> ;{
    do 'dumpvar_epic.pm' unless defined &dumpvar_epic::dump_package_vars;

    my $savout = select($DB::OUT);
    dumpvar_epic::_dump_entity('@_', \@_);
    dumpvar_epic::dump_package_vars();
    select($savout);
    };

    2|@_
    DB<5> ;{
    do 'dumpvar_epic.pm' unless defined &dumpvar_epic::dump_package_vars;

    my $savout = select($DB::OUT);
    dumpvar_epic::_dump_entity('@_', \@_);
    dumpvar_epic::dump_package_vars();
    select($savout);
    };

    2|@_
    DB<6>

    The strange thing is this:

    2|$@4|%ENV4|@INC4|%SIG18|FileHandle(STDERR)17|FileHandle(STDIN)18|FileHandle(STDOUT)2|$]2|$^18|FileHandle(stderr)17|FileHandle(stdin)18|FileHandle(stdout)2|$|2|$~

    and also

    2|@_

    because for some reason that I don't understand only the first part of the line gets printed like "2|@_".

    Do you have any idea what could be slurping away the rest of the line above?

    I have tried this now with Juno 4.2.1 on both Mountain Lion and Snow Leopard and there are problems on both machines and OS versions. I have also Indigo and even Galileo and none of those have a working debugger where Variables view would be without problems. The problems seem to be a bit different on different versions.

    I don't understand either that I would be the first Mac user to try debugging with EPIC… But definitely there is some problems with this. I just am not so clever as to find the error.

    How could I help to solve this?

     
  • David Vavra

    David Vavra - 2014-03-15

    FWIW, I have a similar problem. I've discovered that if $\ is undefined then I can view variables. However, if $\ is redefined (to say "\n") then this problem occurs immediately after the redefinition.

    Of course, this may not be the only cause.

    dumpvar_epic.pm should be changed otherwise it will not be possible to view variables in any block containing a modified $\

    I've been trying to find the source used to create ./workspace/.metadata/.plugins/org.epic.debug/dumpvar_epic.pm to modify it but haven't been able to locate it so far. Maybe somebody can give me a hint? Above it says:

    a copy of dumpvar_epic.pm from the org.epic.debug plugin directory is written before each launch the workspace/.metadata/.plugins/org.epic.debug directory

    However, the only thing less helpful would be that it's stored somewhere on the hard drive. Where would the org.epic.debug plugin directory be located?

    If it's any help, I'm using

    Eclipse Platform

    Version: 4.2.1
    Build id: M20120914-1800

    Epic plugin 0.6.39
    PadWalker-1.98

    UPDATE:
    I modified workspace/.metadata/.plugins/org.epic.debug/dumpvar_epic.pm and placed it in the project directory which is first in the include path.

    The change I made was:

    ...
    sub _dump_entity
    {
    local $\ = undef;
    ...

    Near line 120. Haven't had display problems since.

    Still can't locate where the one in workspace/.metadata/.plugins/org.epic.debug/dumpvar_epic.pm is coming from. I searched my entire drive for "dumpvar*epic*" and could only find the one that gets changed on every debug so it seems to be called something else.

    It's not really important but I would like to fix it more or less permanently so I don't have to go through this for every project.

    UPDATE2:
    I located a copy in /usr/share/eclipse/dropins/epic/eclipse/plugins/org.epic.debug_0.6.32.jar but after I updated the jar file I got strange errors (which I've forgotten) from Eclipse. I'm running short of time so I restored the jar file and am using the modifications I specified above in the first update.

    BTW: I just noticed that the 0.6.32 doesn't match the Epic plugin version of 0.6.39. probably not important as I can't find any other but ... ?

     
    Last edit: David Vavra 2014-03-16
  • DonComo da Como

    DonComo da Como - 2015-09-20

    Hi

    I'm using
    Eclipse CDT Platform
    Version: 4.5.0
    Build id: 20150621-1200

    Epic plugin 0.6.57
    PadWalker-2.1

    I also encountered the same problem when using code that modified the $\ variable.
    I've made the modifications proposed by David Vavra

    The change I made was:

    ...
    sub _dump_entity
    {
    local $\ = undef;
    ...

    Near line 120. Haven't had display problems since.

    and it seems to have solved the problem.

    Regarding David Vavras

    I've been trying to find the source used to create ./workspace/.metadata/.plugins/org.epic.debug/dumpvar_epic.pm to modify it but haven't been able to locate it so far. Maybe somebody can give me a hint?

    the source file dumpvar_epic.pm is the one found in <eclipse install>\plugins\org.epic.debug_0.6.xx.jar.
    I've applied the patch here and it seems to work across workspaces. Hope it helps.

    By the way, how do you guys get to see this type of debug trace using EPIC?
    (from OP)

    Debug view shows:

    DB<12> ;{
    do 'dumpvar_epic.pm' unless defined &dumpvar_epic::dump_package_vars;

    my $savout = select($DB::OUT);
    dumpvar_epic::dump_entity('@', \@_);
    dumpvar_epic::dump_package_vars();
    select($savout);
    };

    2|@_
    DB<13>

     
  • Philippe A.

    Philippe A. - 2016-01-21

    Awesome. I applied David Vavra's suggestion and it fixed my problem with the debugger not showing variables value. I tend to put -l on my perl script headers, which is equivalent to setting $\.

     
    Last edit: Philippe A. 2016-01-21
  • Oliver Trosien

    Oliver Trosien - 2016-05-15

    @jploski - do you recall if you considered applying the suggested change in dumpvar_epic.pm ?

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks