public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "vcollod at nvidia dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/25663] New: dwarf2_name caching bug
Date: Thu, 12 Mar 2020 16:37:41 +0000	[thread overview]
Message-ID: <bug-25663-4717@http.sourceware.org/bugzilla/> (raw)

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

            Bug ID: 25663
           Summary: dwarf2_name caching bug
           Product: gdb
           Version: HEAD
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: vcollod at nvidia dot com
  Target Milestone: ---

Hello!

While working on cuda-gdb, I noticed dwarf2_name does not behave as described.

It's supposed to return the name of a dwarf DIE, as described by the following
comment:

/* Get name of a die, return NULL if not found. Anonymous namespaces are
converted to their magic string. */

It does some processing, stores the results into a cache, then strips the C++
namespaces of the name. The last step should probably be done before storing
the result into the cache.

The following code sample should help reproduce the issue.

I did not fix it myself as I am concerned some code relies on this odd
behavior.

cat > dwarf2_name_repro.gdb <<EOF
b dwarf2_name
run
while 1
      fin
      printf "logged dwarf2_name(%p) = %s\n", (size_t)die, $
      continue
end
EOF

cat > dwarf2_name_repro.cc <<EOF
namespace TestSpace {
        typedef struct {
                int a;
        } type;
}

int main() {
        TestSpace::type test{42};
        return test.a;
}
EOF

make CFLAGS='-O0 -g' dwarf2_name_repro

gdb -q -batch -x dwarf2_name_repro.gdb -arg PATH_TO_GDB_WITH_DEBUG_INFO -ex
'quit' ./dwarf2_name_repro | grep logged | grep type

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

             reply	other threads:[~2020-03-12 16:37 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-12 16:37 vcollod at nvidia dot com [this message]
2020-03-12 16:38 ` [Bug gdb/25663] " vcollod at nvidia dot com
2020-03-12 20:22 ` tromey at sourceware dot org
2020-03-12 20:25 ` tromey at sourceware dot org
2020-03-12 20:27 ` tromey at sourceware dot org
2020-03-12 20:28 ` vcollod at nvidia dot com
2020-03-12 20:50 ` tromey at sourceware dot org
2020-03-12 20:55 ` tromey at sourceware dot org
2020-03-12 21:01 ` vcollod at nvidia dot com
2020-03-12 21:21 ` tromey at sourceware dot org
2020-03-13 15:20 ` tromey at sourceware dot org
2020-03-16 21:03 ` cvs-commit at gcc dot gnu.org
2024-01-05 12:50 ` ssbssa at sourceware dot org
2024-01-10 18:38 ` tromey at sourceware dot 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-25663-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).