public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug symtab/31725] New: [gdb/symtab]
Date: Fri, 10 May 2024 13:40:44 +0000	[thread overview]
Message-ID: <bug-31725-4717@http.sourceware.org/bugzilla/> (raw)

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

            Bug ID: 31725
           Summary: [gdb/symtab]
           Product: gdb
           Version: 14.1
            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 hello world, compiled as the fission board does, with -g3 added:
...
$ gcc -gdwarf-4 -gsplit-dwarf -ggnu-pubnames -fdebug-types-section
-Wl,--gdb-index -fuse-ld=gold ~/gdb/hello.c -g3
...

When loading the exec in gdb, we get:
...
$ gdb -q a.out
Reading symbols from a.out...
DW_FORM_strp pointing outside of .debug_str section [in module
/home/vries/binutils/a.out]
(gdb) 
...

Debugging this shows that this is triggered from:
...
207       if (str_offset >= size)
208         error (_("%s pointing outside of %s section [in module %s]"),
209                form_name, get_name (), get_file_name ());
...
with:
...
(gdb) p size
$3 = 33
(gdb) p str_offset
$4 = 553845450
...

Clearly there's something going wrong with the str_offset, that's way too big.

But the size of 33 is very small.  It's correct though, it's the size of the
.debug_str section in a.out.

Going up to dwarf_decode_macro_bytes, we see this is the reason we're using
that .debug_str section:
...
533                       body = per_objfile->per_bfd->str.read_string
(objfile,         
...

However, there's a str_section argument that points to the .debug_str section
in a-hello.dwo:
...
gdb) p *str_section
$6 = {s = {section = 0xaaaaabc1a718, containing_section = 0xaaaaabc1a718}, 
  buffer = 0xaaaaabc1b5b0 "__LDBL_DECIMAL_DIG__ 36", size = 24351,
virtual_offset = 0, 
  readin = true, is_virtual = false}
...

I wonder if we shouldn't be using that one.

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

             reply	other threads:[~2024-05-10 13:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-10 13:40 vries at gcc dot gnu.org [this message]
2024-05-10 13:41 ` [Bug symtab/31725] [gdb/symtab] wrong .debug_str section used in dwarf_decode_macro_bytes vries at gcc dot gnu.org
2024-05-10 13:46 ` vries at gcc dot gnu.org
2024-05-10 14:36 ` vries at gcc dot gnu.org
2024-05-13 10:32 ` vries at gcc dot gnu.org
2024-05-13 11:58 ` vries at gcc dot gnu.org
2024-05-13 12:05 ` vries at gcc dot gnu.org
2024-05-13 15:58 ` vries at gcc dot gnu.org
2024-05-22  6:12 ` vries at gcc dot gnu.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-31725-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).