Bug 2575 – gdb: can not show code

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2009-01-10T16:28:00Z
Last change time
2015-06-09T01:21:09Z
Assigned to
bugzilla
Creator
jason.james.house
Blocks
3207

Comments

Comment #0 by jason.james.house — 2009-01-10T16:28:53Z
The URL shows how this bug typically manifests itself. GDB seems to look for .s files for assembly code and can't seem to find them. This behavior exhibits itself with all D2 programs I've tried, including void main(){}
Comment #1 by jason.james.house — 2009-01-24T11:16:01Z
After a lot of help from volodya on irc #gdb, it looks like the issue is that the low_pc and high_pc attributes are missing. GDB can try to compensate for this (as if it was some legacy producer of debug info) by walking the children, but it only looks at "namespace" and "subprogram". D has "module" which stops it.
Comment #2 by mihail.zenkov — 2009-01-24T16:09:34Z
Break points don't work with demangled name. Not sure but imho problem in incorrect DW_AT_name and/or not provided DW_AT_MIPS_linkage by DMD. DMD put mangled name to DW_AT_name: <2><91>: Abbrev Number: 6 (DW_TAG_subprogram) DW_AT_sibling : <c8> DW_AT_name : _D5crash3fooFZv DW_AT_decl_file : 1 DW_AT_decl_line : 12 DW_AT_low_pc : 0 DW_AT_high_pc : 0x16 DW_AT_frame_base : 1 byte block: 55 (DW_OP_reg5) GDC/GCC put mangled name to DW_AT_MIPS_linkage_name and demandled to DW_AT_name: <1><bd>: Abbrev Number: 6 (DW_TAG_subprogram) DW_AT_external : 1 DW_AT_name : foo DW_AT_decl_file : 1 DW_AT_decl_line : 12 DW_AT_MIPS_linkage_name: _D5crash3fooFZv DW_AT_low_pc : 0x3b DW_AT_high_pc : 0x51 DW_AT_frame_base : 0x43 (location list) After fix DW_TAG_module you can try use mangled name, for example main - _Dmain
Comment #3 by mihail.zenkov — 2009-02-07T20:56:12Z
GDB also work fine with LDC debug info. <1><a7>: Abbrev Number: 3 (DW_TAG_subprogram) DW_AT_name : crash.foo DW_AT_MIPS_linkage_name: _D5crash3fooFZv DW_AT_external : 1 DW_AT_prototyped : 1 DW_AT_decl_file : 1 DW_AT_decl_line : 11 DW_AT_low_pc : 0x20 DW_AT_high_pc : 0x21 DW_AT_frame_base : 1 byte block: 54 (DW_OP_reg4)
Comment #4 by jason.james.house — 2009-02-15T10:00:38Z
It looks like the URL showing the problem has expired. Here's a sample session. I upped the severity because this is a really painful bug in dmd for me. I'm forced to place tons of writefln statements into the code instead of being able to step through it in the debugger jhouse@jhouse-laptop:~/housebot/0.8$ gdb ./housebot-0.8 GNU gdb 6.8-debian Copyright (C) 2008 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i486-linux-gnu"... (gdb) break main Breakpoint 1 at 0x8059e87 (gdb) run Starting program: /home/jhouse/housebot/0.8/housebot-0.8 [Thread debugging using libthread_db enabled] [New Thread 0xb7c3eb00 (LWP 23503)] [Switching to Thread 0xb7c3eb00 (LWP 23503)] Breakpoint 1, 0x08059e87 in main () Current language: auto; currently asm (gdb) list 1 /tmp/ccPssJzP.s: No such file or directory. in /tmp/ccPssJzP.s (gdb) quit The program is running. Exit anyway? (y or n) y jhouse@jhouse-laptop:~/housebot/0.8$
Comment #5 by bugzilla — 2009-02-20T04:42:07Z
But dmd does emit the low_pc and high_pc data. Compile: int foo(int i) { return i * i; } with: dmd -c -g foo.d Then run dumpobj on it: dumpobj -p foo.o which will pretty-print the dwarf debug into. The attributes are there.
Comment #6 by jason.james.house — 2009-02-20T07:54:59Z
D'oh, if only I reported more information when I remembered it. Trying now, I'm doing "objdump -Wgs <executable>" and then searching for module. What I see right before it is DW_TAG_compile_unit. I don't see DW_AT_high_pc and DW_AT_low_pc in that section, but I don't know if it's supposed to be there. The impression I got from my chats on #gdb was that the debug data was stored in somewhat of a hierarchical structure. In order to figure out the offsets for the source file, it wanted to find the high and low attributes but did not. There's a workaround inside gdb that will walk the children in order to get around the behavior of old compilers, but it's fragile. Having modern stuff such as DW_TAG_module stops it from operating (since it doesn't match what old compilers did). That's all I can remember/reproduce with some experimentation with objdump. Can you reproduce the problem? Maybe chat with someone on #gdb? I had to wait ~12 hours to get a response. Once I did, they were very helpful. I'll guess the compile_unit should have high_pc and low_pc, but I'm only guessing. If you can reproduce the issue, then it should be easy to see if what you did works or not. Sorry for the lack of detail :(
Comment #7 by bugzilla — 2009-02-25T00:30:08Z
Looks like DW_AT_MIPS_linkage_name is an undocumented vendor extension to Dwarf.
Comment #8 by mihail.zenkov — 2009-02-25T20:46:19Z
It undocumented but widely used. IMHO better use them for mangled name than DW_AT_name. Current way violates DWARF: "Because the names of program objects described by DWARF are the names as they appear in the source program, implementations of language translators that use some form of mangled name (as do many implementations of C++) should use the unmangled form of the name in the DWARF DW_AT_name attribute, including the keyword operator (in names such as “operator +”), if present. Sequences of multiple whitespace characters may be compressed."
Comment #9 by bugzilla — 2009-08-05T01:21:42Z
I'll add the MIPS_linkage tag and change the name tag. We'll see how far that gets us.
Comment #10 by bugzilla — 2009-09-03T13:24:21Z
Fixed dmd 1.047 and 2.032
Comment #11 by leandro.lucarella — 2009-10-12T16:16:19Z
This is not entirely fixed for DMD 2, see bug 3368.
Comment #12 by leandro.lucarella — 2009-10-12T16:23:21Z
Woops! Closing it again since it doesn't look like the same problem. The bug I meant to reopen was bug 1079.