public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug symtab/25798] New: symbol in non-imported PU should not appear in symtabs
@ 2020-04-07 15:10 vries at gcc dot gnu.org
  2020-04-07 15:12 ` [Bug symtab/25798] " vries at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: vries at gcc dot gnu.org @ 2020-04-07 15:10 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 25798
           Summary: symbol in non-imported PU should not appear in symtabs
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: symtab
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

Consider a test-case with the following dwarf:
...
  Compilation Unit @ offset 0xc7:
   Length:        0x35 (32-bit)
   Version:       4
   Abbrev Offset: 0x64
   Pointer Size:  8
 <0><d2>: Abbrev Number: 2 (DW_TAG_partial_unit)
    <d3>   DW_AT_language    : 2        (non-ANSI C)
    <d4>   DW_AT_name        : imported_unit.c
 <1><e4>: Abbrev Number: 3 (DW_TAG_base_type)
    <e5>   DW_AT_byte_size   : 4
    <e6>   DW_AT_encoding    : 5        (signed)
    <e7>   DW_AT_name        : int
 <1><eb>: Abbrev Number: 4 (DW_TAG_variable)
    <ec>   DW_AT_name        : aaa
    <f0>   DW_AT_type        : <0xe4>
 <1><f4>: Abbrev Number: 5 (DW_TAG_subprogram)
    <f5>   DW_AT_name        : main
    <fa>   DW_AT_type        : <0xe4>
    <fe>   DW_AT_external    : 1
 <1><ff>: Abbrev Number: 0
  Compilation Unit @ offset 0x100:
   Length:        0x3b (32-bit)
   Version:       4
   Abbrev Offset: 0x8e
   Pointer Size:  8
 <0><10b>: Abbrev Number: 2 (DW_TAG_compile_unit)
    <10c>   DW_AT_language    : 2       (non-ANSI C)
    <10d>   DW_AT_name        : <artificial>
 <1><11a>: Abbrev Number: 3 (DW_TAG_variable)
    <11b>   DW_AT_location    : 9 byte block: 3 28 10 60 0 0 0 0 0     
(DW_OP_addr: 601028)
    <125>   DW_AT_abstract_origin: <0xeb>
 <1><129>: Abbrev Number: 4 (DW_TAG_subprogram)
    <12a>   DW_AT_abstract_origin: <0xf4>
    <12e>   DW_AT_low_pc      : 0x4004a7
    <136>   DW_AT_high_pc     : 0x4004b2
 <1><13e>: Abbrev Number: 0
...

When running gdb with -readnow, and printing aaa, we have:
...
(gdb) p aaa^M
$1 = <optimized out>^M
...

This is due to aaa appearing both in (using "maint print symbols"):
...
Symtab for file imported_unit.c at 0x3422e70^M
Read from object file
/data/gdb_versions/devel/build/gdb/testsuite/outputs/gdb.dwarf2/imported-unit-2/imported-unit-2
(0x2e3c220)^M
Language: c^M
^M
Blockvector:^M
^M
block #000, object at 0x3422df0, 0 syms/buckets in 0x0..0x0^M
  block #001, object at 0x3422d40 under 0x3422df0, 1 syms/buckets in 0x0..0x0^M
   typedef int int; ^M
   int aaa; optimized out^M
...
and:
...
Symtab for file <artificial> at 0x3422bf0^M
Read from object file
/data/gdb_versions/devel/build/gdb/testsuite/outputs/gdb.dwarf2/imported-unit-2/imported-unit-2
(0x2e3c220)^M
Language: c^M
^M
Blockvector:^M
^M
block #000, object at 0x3422b10, 1 syms/buckets in 0x4004a7..0x4004b2^M
 int main(); block object 0x3422a00, 0x4004a7..0x4004b2 section .text^M
  block #001, object at 0x3422a60 under 0x3422b10, 1 syms/buckets in
0x4004a7..0x4004b2^M
   int aaa; static at 0x601028 section .data^M
    block #002, object at 0x3422a00 under 0x3422a60, 0 syms/buckets in
0x4004a7..0x4004b2, function main^M
...

My mental model is:
- a PU represents a dwarf repository
- a CU represents a symtab (as well as a dwarf repository)
- an import imports dwarf from one dwarf repository into another
- an inter-cu ref does not represent an implicit import

So, AFAIU, the aaa in the PU should never appear in any symtab.

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

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

* [Bug symtab/25798] symbol in non-imported PU should not appear in symtabs
  2020-04-07 15:10 [Bug symtab/25798] New: symbol in non-imported PU should not appear in symtabs vries at gcc dot gnu.org
@ 2020-04-07 15:12 ` vries at gcc dot gnu.org
  2020-04-07 15:14 ` vries at gcc dot gnu.org
  2020-08-09 20:44 ` tromey at sourceware dot org
  2 siblings, 0 replies; 4+ messages in thread
From: vries at gcc dot gnu.org @ 2020-04-07 15:12 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
Created attachment 12445
  --> https://sourceware.org/bugzilla/attachment.cgi?id=12445&action=edit
Test-case patch

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

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

* [Bug symtab/25798] symbol in non-imported PU should not appear in symtabs
  2020-04-07 15:10 [Bug symtab/25798] New: symbol in non-imported PU should not appear in symtabs vries at gcc dot gnu.org
  2020-04-07 15:12 ` [Bug symtab/25798] " vries at gcc dot gnu.org
@ 2020-04-07 15:14 ` vries at gcc dot gnu.org
  2020-08-09 20:44 ` tromey at sourceware dot org
  2 siblings, 0 replies; 4+ messages in thread
From: vries at gcc dot gnu.org @ 2020-04-07 15:14 UTC (permalink / raw)
  To: gdb-prs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at sourceware dot org

--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
Tom, could you comment on the validity of the test-case?

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

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

* [Bug symtab/25798] symbol in non-imported PU should not appear in symtabs
  2020-04-07 15:10 [Bug symtab/25798] New: symbol in non-imported PU should not appear in symtabs vries at gcc dot gnu.org
  2020-04-07 15:12 ` [Bug symtab/25798] " vries at gcc dot gnu.org
  2020-04-07 15:14 ` vries at gcc dot gnu.org
@ 2020-08-09 20:44 ` tromey at sourceware dot org
  2 siblings, 0 replies; 4+ messages in thread
From: tromey at sourceware dot org @ 2020-08-09 20:44 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #3 from Tom Tromey <tromey at sourceware dot org> ---
(In reply to Tom de Vries from comment #2)
> Tom, could you comment on the validity of the test-case?

Sorry, I missed this query.

I tend to agree; I don't think I considered this case
when implementing PUs.
However, I'd suggest double-checking what DWARF says before
proceeding.

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

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

end of thread, other threads:[~2020-08-09 20:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-07 15:10 [Bug symtab/25798] New: symbol in non-imported PU should not appear in symtabs vries at gcc dot gnu.org
2020-04-07 15:12 ` [Bug symtab/25798] " vries at gcc dot gnu.org
2020-04-07 15:14 ` vries at gcc dot gnu.org
2020-08-09 20:44 ` tromey at sourceware dot 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).