public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug symtab/28094] New: Support executable with only line debug section
@ 2021-07-15 14:26 vries at gcc dot gnu.org
  2021-07-15 14:30 ` [Bug symtab/28094] " vries at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: vries at gcc dot gnu.org @ 2021-07-15 14:26 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=28094

            Bug ID: 28094
           Summary: Support executable with only line debug section
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: symtab
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

In the dwarf 5 standard we find:
...
Prior to DWARF Version 5, the current directory was not represented in the
directories field and a directory index of 0 implicitly referred to that
directory as found in the DW_AT_comp_dir attribute of the compilation unit
debugging information entry.  In DWARF Version 5, the current directory is
explicitly present in the directories field. This is needed to support the
common practice of stripping all but the line number sections (.debug_line and
.debug_line_str) from an executable.
...

FWIW, the change comes from issue
http://dwarfstd.org/ShowIssue.php?issue=140724.1 .

I tried an experiment where I compiled a hello world with gcc (and dwarf-4) and
stripped all but the .debug_line section:
...
$ gcc -g hello.c
$ for s in $(readelf -S -W a.out | grep debug | awk '{print $2}'| grep -v
.debug_line); do objcopy --remove-section=$s a.out; done
...

But gdb doesn't do well with that:
...
$ gdb -q a.out -ex start
Reading symbols from a.out...
(No debugging symbols found in a.out)
Temporary breakpoint 1 at 0x40054b
Starting program: /home/vries/a.out 

Temporary breakpoint 1, 0x000000000040054b in main ()
(gdb) 
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug symtab/28094] Support executable with only line debug section
  2021-07-15 14:26 [Bug symtab/28094] New: Support executable with only line debug section vries at gcc dot gnu.org
@ 2021-07-15 14:30 ` vries at gcc dot gnu.org
  2021-07-15 14:33 ` [Bug symtab/28094] Support executable with only line debug section(s) vries at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: vries at gcc dot gnu.org @ 2021-07-15 14:30 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=28094

--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
I also found that gold has some option (
https://sourceware.org/legacy-ml/binutils/2008-05/msg00232.html ):
...
$ gcc -fuse-ld=gold -Wl,--strip-debug-non-line hello.c -g
...
which gives better results:
...
$ gdb -q a.out -ex start
Reading symbols from a.out...
Temporary breakpoint 1 at 0x4005cf: file hello.c, line 7.
Starting program: /home/vries/a.out 

Temporary breakpoint 1, main () at hello.c:7
7         void *p = malloc (10);
(gdb) 
...

We could use a test-case with strip-debug-non-line.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug symtab/28094] Support executable with only line debug section(s)
  2021-07-15 14:26 [Bug symtab/28094] New: Support executable with only line debug section vries at gcc dot gnu.org
  2021-07-15 14:30 ` [Bug symtab/28094] " vries at gcc dot gnu.org
@ 2021-07-15 14:33 ` vries at gcc dot gnu.org
  2021-07-15 14:34 ` vries at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: vries at gcc dot gnu.org @ 2021-07-15 14:33 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=28094

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Support executable with     |Support executable with
                   |only line debug section     |only line debug section(s)

--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
Update $summary.  For dwarf 5, we have .debug_line and .debug_line_str.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug symtab/28094] Support executable with only line debug section(s)
  2021-07-15 14:26 [Bug symtab/28094] New: Support executable with only line debug section vries at gcc dot gnu.org
  2021-07-15 14:30 ` [Bug symtab/28094] " vries at gcc dot gnu.org
  2021-07-15 14:33 ` [Bug symtab/28094] Support executable with only line debug section(s) vries at gcc dot gnu.org
@ 2021-07-15 14:34 ` vries at gcc dot gnu.org
  2021-07-15 14:56 ` vries at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: vries at gcc dot gnu.org @ 2021-07-15 14:34 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=28094

--- Comment #3 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom de Vries from comment #1)
> I also found that gold has some option (
> https://sourceware.org/legacy-ml/binutils/2008-05/msg00232.html ):

FWIW, this is a patch for lld to add the same option, which describes the
functionality a bit more verbosely: https://reviews.llvm.org/D46628?id=206198

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug symtab/28094] Support executable with only line debug section(s)
  2021-07-15 14:26 [Bug symtab/28094] New: Support executable with only line debug section vries at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-07-15 14:34 ` vries at gcc dot gnu.org
@ 2021-07-15 14:56 ` vries at gcc dot gnu.org
  2021-07-15 15:09 ` vries at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: vries at gcc dot gnu.org @ 2021-07-15 14:56 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=28094

--- Comment #4 from Tom de Vries <vries at gcc dot gnu.org> ---
I've also tried strip-debug-non-line in combination with dwarf-5, but even with
gold build from trunk:
...
$ PATH=~/binutils/install/bin:$PATH gcc -fuse-ld=gold
-Wl,--strip-debug-non-line hello.c -g -gdwarf-5
/home/vries/binutils/install/bin/ld.gold: warning: Invalid DIE in debug info;
failed to reduce debug info
/home/vries/binutils/install/bin/ld.gold: internal error in finalize_data_size,
at /home/vries/binutils/src/gold/output.h:355
collect2: error: ld returned 1 exit status
...

It looks like the option didn't get its dwarf-5 update yet.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug symtab/28094] Support executable with only line debug section(s)
  2021-07-15 14:26 [Bug symtab/28094] New: Support executable with only line debug section vries at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-07-15 14:56 ` vries at gcc dot gnu.org
@ 2021-07-15 15:09 ` vries at gcc dot gnu.org
  2021-07-15 15:28 ` pedro at palves dot net
  2021-07-16 11:51 ` vries at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: vries at gcc dot gnu.org @ 2021-07-15 15:09 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=28094

--- Comment #5 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom de Vries from comment #4)
> I've also tried strip-debug-non-line in combination with dwarf-5, but even
> with gold build from trunk:
> ...
> $ PATH=~/binutils/install/bin:$PATH gcc -fuse-ld=gold
> -Wl,--strip-debug-non-line hello.c -g -gdwarf-5
> /home/vries/binutils/install/bin/ld.gold: warning: Invalid DIE in debug
> info; failed to reduce debug info
> /home/vries/binutils/install/bin/ld.gold: internal error in
> finalize_data_size, at /home/vries/binutils/src/gold/output.h:355
> collect2: error: ld returned 1 exit status
> ...
> 
> It looks like the option didn't get its dwarf-5 update yet.

Filed PR28095 - "--strip-debug-non-line doesn't work with dwarf-5"

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug symtab/28094] Support executable with only line debug section(s)
  2021-07-15 14:26 [Bug symtab/28094] New: Support executable with only line debug section vries at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2021-07-15 15:09 ` vries at gcc dot gnu.org
@ 2021-07-15 15:28 ` pedro at palves dot net
  2021-07-16 11:51 ` vries at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: pedro at palves dot net @ 2021-07-15 15:28 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=28094

Pedro Alves <pedro at palves dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pedro at palves dot net

--- Comment #6 from Pedro Alves <pedro at palves dot net> ---
Also, Clang has "-gline-tables-only".  I think the "--strip-debug-non-line" lld
patch was never merged because it was considered legacy, as in, it's better to
not emit the debug info in the first place, with "-gline-tables-only".

I'm not aware of a an equivalent option in GCC.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug symtab/28094] Support executable with only line debug section(s)
  2021-07-15 14:26 [Bug symtab/28094] New: Support executable with only line debug section vries at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2021-07-15 15:28 ` pedro at palves dot net
@ 2021-07-16 11:51 ` vries at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: vries at gcc dot gnu.org @ 2021-07-16 11:51 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=28094

--- Comment #7 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Pedro Alves from comment #6)
> Also, Clang has "-gline-tables-only".  I think the "--strip-debug-non-line"
> lld patch was never merged because it was considered legacy, as in, it's
> better to not emit the debug info in the first place, with
> "-gline-tables-only".
> 

Ack, interesting, thanks.

> I'm not aware of a an equivalent option in GCC.

Filed gcc PR https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101470 .

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-07-16 11:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-15 14:26 [Bug symtab/28094] New: Support executable with only line debug section vries at gcc dot gnu.org
2021-07-15 14:30 ` [Bug symtab/28094] " vries at gcc dot gnu.org
2021-07-15 14:33 ` [Bug symtab/28094] Support executable with only line debug section(s) vries at gcc dot gnu.org
2021-07-15 14:34 ` vries at gcc dot gnu.org
2021-07-15 14:56 ` vries at gcc dot gnu.org
2021-07-15 15:09 ` vries at gcc dot gnu.org
2021-07-15 15:28 ` pedro at palves dot net
2021-07-16 11:51 ` vries at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).