public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/25663] New: dwarf2_name caching bug
@ 2020-03-12 16:37 vcollod at nvidia dot com
  2020-03-12 16:38 ` [Bug gdb/25663] " vcollod at nvidia dot com
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: vcollod at nvidia dot com @ 2020-03-12 16:37 UTC (permalink / raw)
  To: gdb-prs

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.

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

end of thread, other threads:[~2024-01-10 18:38 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-12 16:37 [Bug gdb/25663] New: dwarf2_name caching bug vcollod at nvidia dot com
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

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