Bug 1507150 - gdb can't find source with DebugFission (-gsplit-dwarf)
Summary: gdb can't find source with DebugFission (-gsplit-dwarf)
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Developer Toolset
Classification: Red Hat
Component: gdb
Version: DTS 6.0 RHEL 6
Hardware: All
OS: Linux
unspecified
medium
Target Milestone: alpha
: 7.0
Assignee: Jan Kratochvil
QA Contact: Michal Kolar
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-10-27 20:09 UTC by Paulo Andrade
Modified: 2020-12-14 10:41 UTC (History)
9 users (show)

Fixed In Version: devtoolset-6-gdb-7.12.1-48.el6
Doc Type: Bug Fix
Doc Text:
Previously, when the "-gsplit-dwarf" option (DWO) was used during compilation with the GCC compiler, the GDB debugger did not recognize strings of the "DW_FORM_GNU_str_index" form in the resulting debug information files. As a consequence, GDB could not find source files and display symbol names for programs compiled using DWO. GDB has been extended to recognize the "DW_FORM_GNU_str_index" form of DWARF string attributes. As a result, debugging of programs works correctly regardless of whether they are compiled using DWO or not.
Clone Of:
Environment:
Last Closed: 2017-11-20 15:37:53 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
split-dwarf.tar.gz (2.66 KB, application/x-gzip)
2017-10-27 20:09 UTC, Paulo Andrade
no flags Details
gdb-7.12.1-sfdc01959158.patch (578 bytes, patch)
2017-10-30 23:32 UTC, Paulo Andrade
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2017:3250 0 normal SHIPPED_LIVE devtoolset-6-gdb bug fix update 2017-11-20 20:37:35 UTC

Description Paulo Andrade 2017-10-27 20:09:10 UTC
Created attachment 1344519 [details]
split-dwarf.tar.gz

Steps to reproduce on rhel6:

$ scl enable devtoolset-6 bash
$ make CXXFLAGS="-fuse-ld=gold -gsplit-dwarf -Wl,--gdb-index" clean all
$ gdb exec/simple-calls.noopt
<< see gdb-transcript for extra steps in gdb, basically, it should
   show listing of ../libsrc/foo-bar.C but fails >>

  This issue does not happen on Fedora with:

$ rpm -q gdb
gdb-8.0.1-26.fc26.x86_64

*but* if rebuilding plain gdb-8.0.1 from git://sourceware.org/git/binutils-gdb.git,
the issue still happens. Might be some Red Hat patch, but comparing sources after
all patches, and checking diffs for the gdb/dwarf*.c files does not show anything
clear as root cause of the problem.

  On Fedora 26 run:
$ make CXX=g++ CXXFLAGS="-fuse-ld=gold -gsplit-dwarf -Wl,--gdb-index" clean all

  On rhel6 please make sure to use the devtoolset-6-gdb. The system gdb
will happen to work, but it is ignoring the .dwo files.

[pcpa@rhel6 split-dwarf]$ which gdb
/opt/rh/devtoolset-6/root/usr/bin/gdb
[pcpa@rhel6 split-dwarf]$ rpm -qf $(which gdb)
devtoolset-6-gdb-7.12.1-47.el6.x86_64

  Running gdb under gdb, in the environment the test case works (f26), the openp
of the source file shows this:
"""
Thread 1 "gdb" hit Breakpoint 1, openp (path=path@entry=0x7fffffffd540 "/home/pcpa/sfdc/01959158/split-dwarf/libobj:$cwd", opts=opts@entry=6, string=string@entry=0x555556a25790 "../libsrc/foo-bar.C", 
    mode=mode@entry=0, filename_opened=filename_opened@entry=0x555556ab6228) at ../../gdb/source.c:758
758	{
(gdb) bt
#0  openp (path=path@entry=0x7fffffffd540 "/home/pcpa/sfdc/01959158/split-dwarf/libobj:$cwd", opts=opts@entry=6, string=string@entry=0x555556a25790 "../libsrc/foo-bar.C", mode=mode@entry=0, 
    filename_opened=filename_opened@entry=0x555556ab6228) at ../../gdb/source.c:758
#1  0x000055555593d120 in find_and_open_source (filename=0x555556a25790 "../libsrc/foo-bar.C", dirname=<optimized out>, fullname=fullname@entry=0x555556ab6228) at ../../gdb/source.c:1120
#2  0x000055555593d694 in open_source_file (s=0x555556ab61f0) at ../../gdb/source.c:1146
#3  print_source_lines_base (s=0x555556ab61f0, line=25, stopline=26, flags=...) at ../../gdb/source.c:1374
#4  0x000055555593e614 in print_source_lines (s=<optimized out>, line=<optimized out>, stopline=<optimized out>, flags=...) at ../../gdb/source.c:1510
#5  0x0000555555947e66 in print_frame_info (frame=frame@entry=0x5555562db690, print_level=print_level@entry=0, print_what=print_what@entry=SRC_AND_LOC, print_args=print_args@entry=1, 
    set_current_sal=set_current_sal@entry=1) at ../../gdb/stack.c:918
#6  0x0000555555947f56 in print_stack_frame (frame=0x5555562db690, print_level=0, print_what=SRC_AND_LOC, set_current_sal=1) at ../../gdb/stack.c:175
#7  0x00005555558d448f in print_stop_location (ws=<synthetic pointer>) at ../../gdb/infrun.c:8107
#8  print_stop_event (uiout=0x5555569e6fb0) at ../../gdb/infrun.c:8124
#9  0x000055555577eaea in tui_on_normal_stop (bs=<optimized out>, print_frame=<optimized out>) at ../../gdb/tui/tui-interp.c:99
#10 0x000055555590695d in generic_observer_notify (args=0x7fffffffd8f0, subject=<optimized out>) at ../../gdb/observer.c:167
#11 observer_notify_normal_stop (bs=<optimized out>, print_frame=print_frame@entry=1) at ./observer.inc:61
#12 0x00005555558d49d3 in normal_stop () at ../../gdb/infrun.c:8398
#13 0x00005555558dd785 in fetch_inferior_event (client_data=<optimized out>) at ../../gdb/infrun.c:3986
#14 0x000055555589843d in gdb_wait_for_event (block=block@entry=0) at ../../gdb/event-loop.c:859
#15 0x000055555589862f in gdb_do_one_event () at ../../gdb/event-loop.c:322
#16 0x000055555589871e in gdb_do_one_event () at ../../gdb/event-loop.c:304
#17 start_event_loop () at ../../gdb/event-loop.c:371
#18 0x00005555558f1138 in captured_command_loop (data=data@entry=0x0) at ../../gdb/main.c:326
#19 0x000055555589a8e3 in catch_errors (func=func@entry=0x5555558f1110 <captured_command_loop(void*)>, func_args=func_args@entry=0x0, errstring=errstring@entry=0x555555b1c792 "", 
    mask=mask@entry=RETURN_MASK_ALL) at ../../gdb/exceptions.c:236
#20 0x00005555558f2476 in captured_main (data=0x7fffffffdd30) at ../../gdb/main.c:1246
#21 gdb_main (args=0x7fffffffdd30) at ../../gdb/main.c:1257
#22 0x000055555565f72b in main (argc=<optimized out>, argv=<optimized out>) at ../../gdb/gdb.c:40
(gdb) frame 2
#2  0x000055555593d694 in open_source_file (s=0x555556ab61f0) at ../../gdb/source.c:1146
1146	  return find_and_open_source (s->filename, SYMTAB_DIRNAME (s), &s->fullname);
(gdb) p s
$1 = (symtab *) 0x555556ab61f0
(gdb) p *s
$2 = {next = 0x555556ab6170, compunit_symtab = 0x555556ab60f0, linetable = 0x5555570dc5e0, filename = 0x555556a25790 "../libsrc/foo-bar.C", nlines = 0, line_charpos = 0x0, language = language_cplus, 
  fullname = 0x0}
(gdb) p *s.compunit_symtab
$3 = {next = 0x555556a54e30, objfile = 0x55555634b9c0, name = 0x555556ab6160 "foo-bar.C", filetabs = 0x555556ab61f0, last_filetab = 0x555556ec0240, debugformat = 0x555555b83af3 "DWARF 2", 
  producer = 0x555556e8e5b8 "GNU C++14 7.2.1 20170915 (Red Hat 7.2.1-2) -mtune=generic -march=x86-64 -gsplit-dwarf -fuse-ld=gold", dirname = 0x5555570dc7e0 "/home/pcpa/sfdc/01959158/split-dwarf/libobj", 
  blockvector = 0x5555570dc2a0, block_line_section = 12, locations_valid = 0, epilogue_unwind_valid = 1, call_site_htab = 0x0, macro_table = 0x0, includes = 0x0, user = 0x0}
"""


  And when it fails:
"""
Breakpoint 1, openp (path=0x13c2af0 ".:/usr/lib/debug", opts=4, string=0x151f400 "/home/pcpa/split-dwarf/libobj/foo-bar.noopt.dwo", mode=0, filename_opened=0x7fffffffd3a8) at ../../gdb/source.c:757
757	{
(gdb) c
Continuing.
foo (din=4) at ../libsrc/foo-bar.C:25

Breakpoint 1, openp (path=0xfe1440 "$cdir:$cwd", opts=6, string=0x1254930 "../libsrc/foo-bar.C", mode=0, filename_opened=0x13903e8) at ../../gdb/source.c:757
757	{
(gdb) bt
#0  openp (path=0xfe1440 "$cdir:$cwd", opts=6, string=0x1254930 "../libsrc/foo-bar.C", mode=0, filename_opened=0x13903e8) at ../../gdb/source.c:757
#1  0x0000000000599dd3 in find_and_open_source (filename=0x1254930 "../libsrc/foo-bar.C", dirname=<optimized out>, fullname=0x13903e8) at ../../gdb/source.c:1120
#2  0x000000000059a2f7 in print_source_lines_base (s=0x13903b0, line=25, stopline=26, flags=...) at ../../gdb/source.c:1373
#3  0x000000000059a741 in print_source_lines (s=<optimized out>, line=<optimized out>, stopline=<optimized out>, flags=...) at ../../gdb/source.c:1512
#4  0x00000000005f5a50 in print_frame_info (frame=0x10185c0, print_level=<optimized out>, print_what=<optimized out>, print_args=-1, set_current_sal=1) at ../../gdb/stack.c:935
#5  0x00000000005f60fb in print_stack_frame (frame=0x10185c0, print_level=0, print_what=SRC_AND_LOC, set_current_sal=1) at ../../gdb/stack.c:182
#6  0x00000000005e6071 in print_stop_location (ws=0x7fffffffdbf0) at ../../gdb/infrun.c:8117
#7  print_stop_event (uiout=0x10ef550) at ../../gdb/infrun.c:8135
#8  0x000000000051cedf in tui_on_normal_stop (bs=<optimized out>, print_frame=<optimized out>) at ../../gdb/tui/tui-interp.c:89
#9  0x0000000000646995 in generic_observer_notify (subject=<optimized out>, args=0x7fffffffdc90) at ../../gdb/observer.c:167
#10 0x00000000006479db in observer_notify_normal_stop (bs=<optimized out>, print_frame=<optimized out>) at ./observer.inc:61
#11 0x00000000005e5dd1 in normal_stop () at ../../gdb/infrun.c:8412
#12 0x00000000005eed4d in fetch_inferior_event (client_data=<optimized out>) at ../../gdb/infrun.c:4021
#13 0x0000000000605a08 in gdb_wait_for_event (block=<optimized out>) at ../../gdb/event-loop.c:859
#14 0x0000000000605b78 in gdb_do_one_event () at ../../gdb/event-loop.c:322
#15 0x0000000000605c7f in start_event_loop () at ../../gdb/event-loop.c:371
#16 0x00000000005fe9f8 in captured_command_loop (data=<optimized out>) at ../../gdb/main.c:325
#17 0x00000000005fb805 in catch_errors (func=0x5fe9d0 <captured_command_loop(void*)>, func_args=0x0, errstring=0x8ac0a6 "", mask=RETURN_MASK_ALL) at ../../gdb/exceptions.c:236
#18 0x00000000005ffeee in captured_main (data=<optimized out>) at ../../gdb/main.c:1246
#19 gdb_main (args=<optimized out>) at ../../gdb/main.c:1257
#20 0x000000000040a1e5 in main (argc=<optimized out>, argv=<optimized out>) at ../../gdb/gdb.c:40
(gdb) frame 2
#2  0x000000000059a2f7 in print_source_lines_base (s=0x13903b0, line=25, stopline=26, flags=...) at ../../gdb/source.c:1373
1373		  desc = open_source_file (s);
(gdb) p s
$1 = (symtab *) 0x13903b0
(gdb) p* s
$2 = {next = 0x13903f0, compunit_symtab = 0x13902b0, linetable = 0x1c92a90, filename = 0x1254930 "../libsrc/foo-bar.C", nlines = 0, line_charpos = 0x0, language = language_cplus, fullname = 0x0}
(gdb) p* s.compunit_symtab 
$3 = {next = 0x1199760, objfile = 0x11701f0, name = 0x1390320 "<unknown>", filetabs = 0x1c92df0, last_filetab = 0x1c92df0, debugformat = 0x945c15 "DWARF 2", producer = 0x0, dirname = 0x0, 
  blockvector = 0x1c92890, block_line_section = 12, locations_valid = 0, epilogue_unwind_valid = 0, call_site_htab = 0x0, macro_table = 0x0, includes = 0x0, user = 0x0}
"""

Comment 8 Paulo Andrade 2017-10-30 23:32:45 UTC
Created attachment 1345667 [details]
gdb-7.12.1-sfdc01959158.patch

This patch works for the test case and the devtoolset-6.

Adding the extra test for DW_FORM_line_strp is not required for
the test case and/or devtoolset-6, and adding it would require
a significantly large backport.

Comment 9 Jan Kratochvil 2017-10-31 14:39:40 UTC
Is this a request for Brew build of devtoolset-6-gdb?

Comment 10 Paulo Andrade 2017-10-31 14:59:49 UTC
For the moment the patch was added mostly for documentation.

It works for the test case.

I am waiting feedback from the user, to know if it works for their needs, as
the test case may not cover all usages.

Comment 11 Joe Wright 2017-10-31 22:44:37 UTC
Customer confirms test patch successfully addresses the problem.

Comment 13 Paulo Andrade 2017-11-01 11:11:23 UTC
  Can an official build be done with the proposed patch?

  The customer is happy with the patch, and from what they could test, it is
fully functional with their DTS-6-produced -gsplit-dwarf executables.

  But their IT is hesitating to install an unofficial, unsupported, patch globally
to their developers.

Comment 21 Michal Kolar 2017-11-08 12:35:55 UTC
Reproduced against devtoolset-6-gdb-7.12.1-47.el6 and verified against devtoolset-6-gdb-7.12.1-48.el6.

Comment 27 errata-xmlrpc 2017-11-20 15:37:53 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2017:3250


Note You need to log in before you can comment on or make changes to this bug.