public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "dblaikie at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug c++/15502] New: DW_AT_decl_line ignored in DW_TAG_imported_declaration
Date: Mon, 20 May 2013 16:56:00 -0000	[thread overview]
Message-ID: <bug-15502-4717@http.sourceware.org/bugzilla/> (raw)

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.


             reply	other threads:[~2013-05-20 16:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-20 16:56 dblaikie at gmail dot com [this message]
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

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-15502-4717@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).