Re: [patch] GDB 7.2: new feature for "backtrace" that cuts path to file (remain filename)

Jan Kratochvil
2011-12-06T23:01:42Z

Hi Eldar,

I really miss a testcase here as I had no clue what the settings print in
fact. Also I expect you have a compiler producing:
<11> DW_AT_name : (indirect string, offset: 0x4d): /home/jkratoch/redhat/gdb-clean/gdb/35d/35l.c
<15> DW_AT_comp_dir : (indirect string, offset: 0x4d): /home/jkratoch/redhat/gdb-clean/gdb
in some case but I do not see how to get such DWARF from Fedora 16 GCC.
Therefore to test all the DWARF cases one needs a gdb.dwarf2/ testcase for it.
I will write one if you do not want to. One may easily break the behavior with
future changes otherwise.

The doc should also IMO contain some samples, what is "full filename".
I would assume it means /home/jkratoch/redhat/gdb-clean/gdb/35d/35l.c but
apparently it does not.

Test commands expects ./gdb-clean to be FSF GDB HEAD and ./gdb patched gdb.
for d in "" $PWD/;do rm -rf 35 35.c 35d 35l.so;mkdir 35d;echo 'extern void f (void); int main (void) { f (); return 0; }' >35.c;echo 'void f (void) {}' >35d/35l.c;gcc -o 35l.so -Wl,-soname,./35l.so -shared -fPIC -Wall -g ${d}35d/35l.c; gcc -o 35 35.c -Wall -g ./35l.so;./gdb-clean -ex 'set break pend on' -q -nx ./35 -ex 'b f' -ex r -ex 'bt' -ex c -ex q | grep ' f ';for i in basename full without-compilation-directory;do echo ---$i;./gdb -ex "set backtrace filename-display $i" -ex 'set break pend on' -q -nx ./35 -ex 'b f' -ex r -ex 'bt' -ex c -ex q | grep ' f ';done;readelf -wi 35l.so|grep -E 'DW_AT_(producer|name|comp_dir)';done

gcc 35d/35l.c ...
<c> DW_AT_producer : (indirect string, offset: 0x0): GNU C 4.6.2 20111027 (Red Hat 4.6.2-1) -mtune=generic -march=x86-64 -g -fPIC
<11> DW_AT_name : (indirect string, offset: 0x71): 35d/35l.c
<15> DW_AT_comp_dir : (indirect string, offset: 0x4d): /home/jkratoch/redhat/gdb-clean/gdb
- FSF GDB HEAD:
#0 f () at 35d/35l.c:1
- set backtrace filename-display basename
#0 f () at 35l.c:1
- set backtrace filename-display full
#0 f () at 35d/35l.c:1
- set backtrace filename-display without-compilation-directory
#0 f () at 35d/35l.c:1

gcc $PWD/35d/35l.c ...
<c> DW_AT_producer : (indirect string, offset: 0x0): GNU C 4.6.2 20111027 (Red Hat 4.6.2-1) -mtune=generic -march=x86-64 -g -fPIC
<11> DW_AT_name : (indirect string, offset: 0x4d): /home/jkratoch/redhat/gdb-clean/gdb/35d/35l.c
- FSF GDB HEAD
#0 f () at /home/jkratoch/redhat/gdb-clean/gdb/35d/35l.c:1
- set backtrace filename-display basename
#0 f () at 35l.c:1
- set backtrace filename-display full
#0 f () at /home/jkratoch/redhat/gdb-clean/gdb/35d/35l.c:1
- set backtrace filename-display without-compilation-directory
#0 f () at 35l.c:1

I miss there an option to print the output of symtab_to_fullname which was
requested by Red Hat desktop developers, therefore to print:
#0 f () at /home/jkratoch/redhat/gdb-clean/gdb/35d/35l.c:1
even if it was compiled as 35d/35l.c and not $PWD/35d/35l.c.

Thanks,
Jan