www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - addr2line not showing line numbers

reply Shachar Shemesh <shachar weka.io> writes:
Title pretty much says it all. True whether I use -g or -gc, for both 
dmd and ldc2.

gdb, for some reason, does manage to show line numbers, but only sort of:
$ cat d.d
import std.stdio;

void main() {
     writeln("Hello, world");
}

$ dmd -g -gc d.d
$ gdb d
GNU gdb (Ubuntu 7.12.50.20170314-0ubuntu1.1) 7.12.50.20170314-git
Copyright (C) 2017 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 "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from d...done.
(gdb) break main
Breakpoint 1 at 0x463c4
(gdb) run
Starting program: /tmp/scratch/d
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Breakpoint 1, 0x000055555559a3c4 in main ()
(gdb) bt


argc=1, argv=0x7fffffffddb8, init=<optimized out>,
     fini=<optimized out>, rtld_fini=<optimized out>, 
stack_end=0x7fffffffdda8) at ../csu/libc-start.c:291


 Important Point <<<<<<<<<<<<<<<<<<<<<<
(gdb) step Single stepping until exit from function main, which has no line number information. Hello, world __libc_start_main (main=0x55555559a3c0 <main>, argc=1, argv=0x7fffffffddb8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffdda8) at ../csu/libc-start.c:325 325 ../csu/libc-start.c: No such file or directory. (gdb) kill Kill the program being debugged? (y or n) y (gdb) delete 1 (gdb) break d.d:4 Breakpoint 2 at 0x555555599c64: file d.d, line 4. (gdb) run Starting program: /tmp/scratch/d [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Breakpoint 2, _Dmain () at d.d:4 4 writeln("Hello, world"); (gdb) bt (gdb) quit A debugging session is active. Inferior 1 [process 15126] will be killed. Quit anyway? (y or n) y $ addr2line -e d 0x555555599c64 ??:0 $ dmd -v DMD64 D Compiler v2.074.1 To summarize: gdb can break on function name, but cannot single step from that point, as it claims it has no line information. It can break on file:line combination. addr2line cannot convert that address into a file:line Shachar
Aug 05 2017
parent Nemanja Boric <4burgos gmail.com> writes:
On Sunday, 6 August 2017 at 06:20:28 UTC, Shachar Shemesh wrote:
 gdb can break on function name, but cannot single step from 
 that point, as it claims it has no line information.
Judging by the stack trace for 1) it looks like it's not breaking for the user provided main function (called by druntime), but on the druntime's main, called by glibc, which is possible to be built with no debug info?
Aug 06 2017