public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/15502] New: DW_AT_decl_line ignored in DW_TAG_imported_declaration
@ 2013-05-20 16:56 dblaikie at gmail dot com
  2013-05-20 16:58 ` [Bug c++/15502] " dblaikie at gmail dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: dblaikie at gmail dot com @ 2013-05-20 16:56 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=15502

             Bug #: 15502
           Summary: DW_AT_decl_line ignored in DW_TAG_imported_declaration
           Product: gdb
           Version: 7.6
            Status: NEW
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned@sourceware.org
        ReportedBy: dblaikie@gmail.com
    Classification: Unclassified


The final test ("print x (from M::x)") in gdb.cp/nsusing.cc appears to be
passing by coincidence rather than design.

While testing GDB with Clang I discovered this bug as Clang fails this test
while its debug info looks wholely correct.

Given this:

namespace M
{
  int x = 911;
}

namespace N
{
  int x = 912;
}

int marker10 ()
{
  using namespace M;
  int y = x + 1; // marker10 stop
  using namespace N;
  return y;
}

GCC outputs two DW_TAG_imported_modules:
     DW_TAG_imported_module
       DW_AT_decl_file [DW_FORM_data1]  (0x01)
       DW_AT_decl_line [DW_FORM_data1]  (0x11)
       DW_AT_import [DW_FORM_ref4]      ("N")

     DW_TAG_imported_module
       DW_AT_decl_file [DW_FORM_data1]  (0x01)
       DW_AT_decl_line [DW_FORM_data1]  (0x11)
       DW_AT_import [DW_FORM_ref4]      ("M")

Notice that their line numbers are identical (that of the function) and
incorrect, and that they're in the reverse order of their appearance in the
source - leaving "M" second.

If you break at "return y" and print x with GCC's debug info you still print
M::x - it seems GDB is just taking the imported_modules in order & so the last
one "wins"

With Clang's debug info:
     DW_TAG_imported_module
       DW_AT_decl_file [DW_FORM_data1]  (0x01)
       DW_AT_decl_line [DW_FORM_data1]  (0x0d)
       DW_AT_import [DW_FORM_ref4]      ("M")

     DW_TAG_imported_module
       DW_AT_decl_file [DW_FORM_data1]  (0x01)
       DW_AT_decl_line [DW_FORM_data1]  (0x0f)
       DW_AT_import [DW_FORM_ref4]      ("N")

GDB, breaking at either marker10 stop or the return, print x finds N::x in both
cases - supporting the theory that GDB is just taking the "last" (or searching
in reverse order until it finds a successful lookup, presumably) rather than
using the source line information to correctly resolve these constructs.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- 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 c++/15502] DW_AT_decl_line ignored in DW_TAG_imported_declaration
  2013-05-20 16:56 [Bug c++/15502] New: DW_AT_decl_line ignored in DW_TAG_imported_declaration dblaikie at gmail dot com
@ 2013-05-20 16:58 ` dblaikie at gmail dot com
  2023-01-14 19:27 ` tromey at sourceware dot org
  2023-01-17 19:30 ` dblaikie at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: dblaikie at gmail dot com @ 2013-05-20 16:58 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=15502

David Blaikie <dblaikie at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dje at google dot com,
                   |                            |echristo at gmail dot com

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- 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 c++/15502] DW_AT_decl_line ignored in DW_TAG_imported_declaration
  2013-05-20 16:56 [Bug c++/15502] New: DW_AT_decl_line ignored in DW_TAG_imported_declaration dblaikie at gmail dot com
  2013-05-20 16:58 ` [Bug c++/15502] " dblaikie at gmail dot com
@ 2023-01-14 19:27 ` tromey at sourceware dot org
  2023-01-17 19:30 ` dblaikie at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: tromey at sourceware dot org @ 2023-01-14 19:27 UTC (permalink / raw)
  To: gdb-prs

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

Tom Tromey <tromey at sourceware dot org> changed:

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

--- Comment #2 from Tom Tromey <tromey at sourceware dot org> ---
Maybe this series:
https://sourceware.org/pipermail/gdb-patches/2023-January/195333.html

-- 
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 c++/15502] DW_AT_decl_line ignored in DW_TAG_imported_declaration
  2013-05-20 16:56 [Bug c++/15502] New: DW_AT_decl_line ignored in DW_TAG_imported_declaration dblaikie at gmail dot com
  2013-05-20 16:58 ` [Bug c++/15502] " dblaikie at gmail dot com
  2023-01-14 19:27 ` tromey at sourceware dot org
@ 2023-01-17 19:30 ` dblaikie at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: dblaikie at gmail dot com @ 2023-01-17 19:30 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #3 from David Blaikie <dblaikie at gmail dot com> ---
(In reply to Tom Tromey from comment #2)
> Maybe this series:
> https://sourceware.org/pipermail/gdb-patches/2023-January/195333.html

Yeah, that sounds OK. Doesn't produce the same behavior as the compiler - which
resolves to the closer declaration - but lines could be incorrect/ambiguous
anyway (#included code and other situations that lead to lines not being
strictly increasing or in the scope order, etc - or two using decls on the same
line, etc). 

Certainly an improvement, in any 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

end of thread, other threads:[~2023-01-17 19:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-20 16:56 [Bug c++/15502] New: DW_AT_decl_line ignored in DW_TAG_imported_declaration dblaikie at gmail dot com
2013-05-20 16:58 ` [Bug c++/15502] " dblaikie at gmail dot com
2023-01-14 19:27 ` tromey at sourceware dot org
2023-01-17 19:30 ` dblaikie at gmail dot com

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).