From: Simon Marchi <simark@simark.ca>
To: "Andrew Burgess" <aburgess@redhat.com>,
"Sébastien Darche" <sdarche@efficios.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb: ensure bp_location::section is set correct to avoid an assert
Date: Thu, 25 Sep 2025 17:05:48 -0400 [thread overview]
Message-ID: <e9350a13-3c56-432e-9ac7-0c7f9a461458@simark.ca> (raw)
In-Reply-To: <87tt0qe7qf.fsf@redhat.com>
On 9/25/25 1:56 PM, Andrew Burgess wrote:
> Part of the reason I'd push for a wider fix is that there are lots
> different linespec formats, and I don't think they all pass through
> minsym_found (or maybe they do?).
It's certainly possble to create SALs without going through
minsym_found.
> If they don't then it feels like you should be able to adjust your
> original test such that minsym_found isn't called, and you'll have the
> same incorrect gdbarch problem. So then you'll have to add a
> find_pc_section in _another_ place....
If the test was compiled with DWARF info, the SAL would be created from
a full (DWARF) symbol, and we'd go through another path that would cause
the section field to be set. I think find_function_start_sal ->
find_function_start_sal_1. In this case the section would be known from
the struct symbol.
I went a bit down the overlay rabbit hole, and I think that your change
might have broken that (but... I don't know how to test that). Here's
the summary of my findings (I'm perhaps completely wrong).
Two ELF sections overlay each other if they have the same VMA but
different LMA.
- LMA is the address where the code is permanently stored (e.g. large
flash memory, non-executable). Unique for each section.
- VMA is the address where the code gets copied when executed (e.g.
small RAM, executable).
An overlay manager in the program takes care of copying the right
section from its LMA to its VMA before executing it.
My understanding is that the ELF symbols for the various functions in
these overlaying region have VMA region of memory. So, you would have
overlapping ELF symbols, but you can know which ELF symbol is part of
which section, because ELF symbols have a "section index" property. We
record that in minimal_symbol::m_section.
Before your patch, when seting a breakpoint by minimal symbol in an
overlay situation, this:
sal.section = msymbol->obj_section (objfile);
would return the right section based on the minimal symbol you
specified. I guess this is important later. To know if it should
insert the breakpoint location, GDB must decide if the breakpoint
location is in the section currently mapped at the VMA or not. For
that, it needs to know in which section you intended to put the
breakpoint. However, the new line:
sal.section = find_pc_overlay (sal.pc);
would return one of the multiple sections in which sal.pc (a VMA)
appears, possibly the wrong one. This would mess up the "should we
insert this location" logic later.
This is what I gathered from an hour of reading the code, it's perhaps
wrong. I need to go for now, but I thought I'd share these findings.
Simon
next prev parent reply other threads:[~2025-09-25 21:06 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-04 20:16 Andrew Burgess
2025-09-05 3:10 ` Simon Marchi
2025-09-25 15:16 ` Sébastien Darche
2025-09-25 17:56 ` Andrew Burgess
2025-09-25 21:05 ` Simon Marchi [this message]
2025-09-25 21:40 ` Andrew Burgess
2025-09-25 22:30 ` Simon Marchi
2025-10-02 19:40 ` Sébastien Darche
2025-10-06 12:11 ` Andrew Burgess
2026-02-02 8:49 ` Rohr, Stephan
2026-02-02 18:45 ` Simon Marchi
2026-02-04 11:55 ` Andrew Burgess
2026-02-04 12:59 ` Andrew Burgess
2026-02-04 16:25 ` Rohr, Stephan
2026-02-12 13:10 ` Andrew Burgess
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=e9350a13-3c56-432e-9ac7-0c7f9a461458@simark.ca \
--to=simark@simark.ca \
--cc=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=sdarche@efficios.com \
/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