aBothe / Mono-D

D Add-In for MonoDevelop
http://wiki.dlang.org/Mono-D
Other
113 stars 26 forks source link

Debugger shows values only for the top most function #592

Open ghost opened 9 years ago

ghost commented 9 years ago

Repro code:

module main;

import std.stdio;

void main(string[] args)
{
    int mainVal = 10;
    mainVal++;
    myFunc();
    otherFunc();
}

void myFunc()
{
    int myVal = 5;
    myVal++;
}

void otherFunc()
{
    int otherVal = 9;
    otherVal++;
}

In this case I can see only args and mainVal values because they're on the top most function of the file, main:

If I continue debugging and jump to any other function which is placed below main, I see nothing for their variables:

Notice that Value of myVal in Locals window is empty, as well as in the field hovered by mouse. Same happens for otherFunc.

Now if I change the order of functions in the file so that, say, myFunc will be at the top of the file:

module main;

import std.stdio;

void myFunc()
{
    int myVal = 5;
    myVal++;
}

void main(string[] args)
{
    int mainVal = 10;
    mainVal++;
    myFunc();
    otherFunc();
}

void otherFunc()
{
    int otherVal = 9;
    otherVal++;
}

All variables of main function won't show their values now, but if I continue debugging to jump to myFunc:

Suddenly, myVal shows its value because now it's on the top of the file. Same will happen if I move otherFunc to the top.

I use Monodevelop 5.7 from official repo on Ubuntu 15.04 with D Language Binding v. 2.7.14

aBothe commented 9 years ago

The debugger binding that examines D local values fully-fledged hasn't been finished yet. The current situation is of (on my side as Mono-D's programmer) expected behaviour, unfortunately.

ghost commented 9 years ago

So what needs to happen to make debugging work? :)

aBothe commented 9 years ago

I didn't know where I stopped back then, pretty much was already finished. I guess there were design problems with examining objects' types (i.e. associating a given type name with Mono-D's AST representation), deducing their memory offsets and reading their values. The API that wraps reading memory itself works, iirc.

ghost commented 9 years ago

Yea, it works flawlessly for the top one, if only it worked for other functions I would have absolutely no problems with it... Thanks for your work, by the way! Take your time on this...

aBothe commented 9 years ago

Thanks, I will - perhaps I can catch up some of the things that aren't working well atm :)

aBothe commented 9 years ago

Okay, I spent some time trying to get the gdb D addin working.. I hate how I just can't fluently debug all the crap -- it's giving me headaches all the time :/ Oh and it's crashing on gdb's initialisation phase..it's awful.

ghost commented 9 years ago

I hate how I just can't fluently debug all the crap -- it's giving me headaches all the time :/

This pretty much sums up my experience with programming in general :) Man these high level languages are out of control...

aBothe commented 9 years ago

Apparently it seems that the problem is some errornous interaction with gdb which wasn't there before:

gdb: gdb<: -inferior-tty-set /dev/pts/0
gdb: dbg>: =thread-group-added,id="i1"
gdb: dbg>: =cmd-param-changed,param="auto-load safe-path",value="/"
gdb: dbg>: (gdb) 
gdb: dbg>: ^done
gdb: dbg>: (gdb) 
gdb: gdb<: -file-exec-and-symbols /home/lx/Desktop/dump/D/dubTest/dubtest
gdb: dbg>: ^done
gdb: dbg>: (gdb) 
gdb: gdb<: -environment-cd /home/lx/Desktop/dump/D/dubTest
gdb: dbg>: ^done
gdb: dbg>: (gdb) 
gdb: gdb<: -data-evaluate-expression mono_pmip
gdb: dbg>: ^error,msg="No symbol table is loaded.  Use the \"file\" command"
gdb: dbg>: (gdb) 
gdb: gdb<: -data-evaluate-expression sizeof(void*)
gdb: dbg>: ^error,msg="A syntax error in expression, near `sizeof(void*)'."

I also tried doing this in the terminal..same error.

ghost commented 9 years ago

Ok, I've upgraded language bindings to 2.9 and debugging works now!

aBothe commented 9 years ago

I haven't changed anything in the debugging-parts, I've only discovered some symptoms that show gdb is misbehaving. :/

ghost commented 9 years ago

Yeah, I wonder what was that. Nonetheless I can see the values in other functions now...