public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug symtab/25755] Means to not keep decls in symtab
Date: Wed, 01 Apr 2020 13:29:35 +0000	[thread overview]
Message-ID: <bug-25755-4717-IhFMb8U1sJ@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-25755-4717@http.sourceware.org/bugzilla/>

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

--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom de Vries from comment #0)

> V.
> 
> Consider a simpler test-case, test3.c:
> ...
> extern int aaa;
> 
> int aaa;
> 
> int
> main (void)
> {
>   return 0;
> }
> ...
> compiled with debug info, with an older gcc:
> ...
> $ gcc-4.8 -g test3.c
> ...
> 
> There's just one DIE describing the variable:
> ...
>  <1><118>: Abbrev Number: 4 (DW_TAG_variable)
>     <119>   DW_AT_name        : aaa
>     <11d>   DW_AT_decl_file   : 1
>     <11e>   DW_AT_decl_line   : 3
>     <11f>   DW_AT_type        : <0x111>
>     <123>   DW_AT_external    : 1
>     <123>   DW_AT_location    : 9 byte block: 3 2c 10 60 0 0 0 0 0     
> (DW_OP_addr: 60102c)
> ...
> 
> But with a more recent gcc (7.5.0), we have a def and a decl:
> ...
>  <1><f4>: Abbrev Number: 2 (DW_TAG_variable)
>     <f5>   DW_AT_name        : aaa
>     <f9>   DW_AT_decl_file   : 1
>     <fa>   DW_AT_decl_line   : 1
>     <fb>   DW_AT_type        : <0xff>
>     <ff>   DW_AT_external    : 1
>     <ff>   DW_AT_declaration : 1
>  <1><106>: Abbrev Number: 4 (DW_TAG_variable)
>     <107>   DW_AT_specification: <0xf4>
>     <10b>   DW_AT_decl_line   : 3
>     <10c>   DW_AT_location    : 9 byte block: 3 2c 10 60 0 0 0 0 0     
> (DW_OP_addr: 60102c)
> ...
> 
> This more accurately describes the source, but gdb makes a symbol for both
> the def and the decl:
> ...
> Blockvector:
> 
> block #000, object at 0x560017e71f40, 1 syms/buckets in 0x400497..0x4004a2
>  int aaa; unresolved
>  int aaa; static at 0x60102c section .bss
>  int main(void); block object 0x560017e71e30, 0x400497..0x4004a2 section
> .text
>   block #001, object at 0x560017e71e90 under 0x560017e71f40, 1 syms/buckets
> in 0x400497..0x4004a2
>    typedef int int; 
>     block #002, object at 0x560017e71e30 under 0x560017e71e90, 0
> syms/buckets in 0x400497..0x4004a2, function main
> ...
> which is not useful at all.
> 
> 
> VI.
> 
> This situation is further aggravated by -flto, which for a test-case test4.c:
> ...
> int aaa;
> 
> int
> main (void)
> {
>   return 0;
> }
> ... 
> compiled like this:
> ...
> $ gcc-8 -O0 test4.c -g -flto -flto-partition=none -ffat-lto-objects
> ...
> generates a def and a decl:
> ...
>  <0><d2>: Abbrev Number: 1 (DW_TAG_compile_unit)
>     <d8>   DW_AT_name        : <artificial>
>  <1><110>: Abbrev Number: 4 (DW_TAG_variable)
>     <111>   DW_AT_abstract_origin: <0x13d>
>     <115>   DW_AT_location    : 9 byte block: 3 2c 10 60 0 0 0 0 0     
> (DW_OP_addr: 60102c)
>  <0><12b>: Abbrev Number: 1 (DW_TAG_compile_unit)
>     <131>   DW_AT_name        : test4.c
>  <1><13d>: Abbrev Number: 2 (DW_TAG_variable)
>     <13e>   DW_AT_name        : aaa
>     <142>   DW_AT_decl_file   : 1
>     <143>   DW_AT_decl_line   : 1
>     <144>   DW_AT_decl_column : 5
>     <145>   DW_AT_type        : <0x149>
>     <149>   DW_AT_external    : 1
> ...
> even though there's no seperate decl in the file, and gdb again keeps two
> entries in the symbol tables:
> ...
> Symtab for file test4.c
> 
> Blockvector:
> 
> block #000, object at 0x555e7afafb70, 1 syms/buckets in 0x0..0x0
>  int aaa; unresolved
>   block #001, object at 0x555e7afafac0 under 0x555e7afafb70, 1 syms/buckets
> in 0x0..0x0
>    typedef int int; 
> 
> 
> Symtab for file <artificial>
> 
> Blockvector:
> 
> block #000, object at 0x555e7afaf7d0, 1 syms/buckets in 0x400492..0x40049e
>  int main(void); block object 0x555e7afaf6c0, 0x400492..0x40049e section
> .text
>  int aaa; static at 0x60102c section .bss
>   block #001, object at 0x555e7afaf770 under 0x555e7afaf7d0, 0 syms/buckets
> in 0x400492..0x40049e
>     block #002, object at 0x555e7afaf6c0 under 0x555e7afaf770, 0
> syms/buckets in 0x400492..0x40049e, function main
> ...
> 

I've filed a PR to ignore these useless symbols: PR25759 - "Remove useless
decls from symtab".

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

  reply	other threads:[~2020-04-01 13:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-01  8:13 [Bug symtab/25755] New: " vries at gcc dot gnu.org
2020-04-01 13:29 ` vries at gcc dot gnu.org [this message]
2020-04-02 12:01 ` [Bug symtab/25755] " vries at gcc dot gnu.org
2020-04-02 23:14 ` vries at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-25755-4717-IhFMb8U1sJ@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).