Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging with GDB Cannot Lookup D Program symbols

I have successfully built and installed Ian Buclaw's (ibuclaw) GDB branch on github on my Ubuntu 13.10 x86_64 with its default compiler GCC 4.8.1.

I had to remove the file ld from the bin sub-directory otherwise DMD complains about a sysroot thing in link phase.

When I then compile my test program and run it through GDB I have problems.

I can do break main, run and GDB stops at the beginning of main but when I do next I get the following undesired output

  Single stepping until exit from function main,
  which has no line number information.
  0x00007ffff760ede5 in __libc_start_main () from 
  /lib/x86_64-linux-gnu/libc.so.6

Isn't ibuclaw's GDB supposed to work here?

My test program was compiled as

dmd -debug -g -gs -wi t_array.d -oft_array

without any warnings nor errors. I've also tried to pretend to be C

dmd -debug -g -gc -gs -wi t_array.d -oft_array

with same result.

Further when I do b followed by tab, most of the symbols in the completion list are not demangled.

My test program looks like

import std.stdio, std.algorithm;

void main(string args[]) {
    int[] x;
    writeln(x.sizeof);

    if (x) {
        writeln("Here!");
    } else {
        writeln("There!");
    }

    int xx[2];
    auto xc = xx;
    xc[0] = 1;
    writeln(xx);
    writeln(xc);
    int[2] xx_;


    auto hit = x.find(1);
    if (hit) {
        writeln("Hit: ", hit);
    } else {
        writeln("No hit");
    }
    int[2] z;                   // arrays are zero initialized
    writeln(z);

    assert([].ptr == null);
    assert("ab"[$..$] == []);
    auto p = "ab"[$..$].ptr;
    writeln(p);
    assert(p != null);
}
like image 659
Nordlöw Avatar asked Jan 09 '14 17:01

Nordlöw


1 Answers

Works well for me with monodevelop and GDB debugger (not with gdb debuger for D), you should use start command instead of break main. More details in yours dlangs forum thread: http://forum.dlang.org/thread/[email protected]

like image 134
Kozzi11 Avatar answered Oct 22 '22 01:10

Kozzi11