Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Sébastien Darche" <sdarche@efficios.com>
To: Andrew Burgess <aburgess@redhat.com>, simark@simark.ca
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb: ensure bp_location::section is set correct to avoid an assert
Date: Thu, 2 Oct 2025 15:40:12 -0400	[thread overview]
Message-ID: <6c31b667-db2d-453e-9597-9fe011c4766e@efficios.com> (raw)
In-Reply-To: <87ldm2dxcl.fsf@redhat.com>

On 9/25/25 17:40, Andrew Burgess wrote:
> Maybe the answer is as simple as moving the .section assignment into the
> earlier if block, something like:
> 
>    if (is_function && want_start_sal)
>      {
>        sal = find_function_start_sal (func_addr, NULL, self->funfirstline);
> 
>        /* This breakpoint is for the ifunc case, FUNC_ADDR is can be
>           anywhere, in a completely different section to MSYMBOL, or even
>           in a different objfile!
> 
>           TODO: I haven't checked, maybe find_function_start_sal already
>           fills this stuff in for us?  Or maybe it could be made too?
>           For now I'm assuming all we have is an address, but this needs
>           checking.  */
>        sal.section = find_pc_overlay (func_addr);
>        if (sal.section == nullptr)
>          sal.section = find_pc_section (func_addr);
>      }
>    else
>      {
>        sal.objfile = objfile;
>        sal.msymbol = msymbol;
>        /* Store func_addr, not the minsym's address in case this was an
> 	 ifunc that hasn't been resolved yet.  */
>        if (is_function)
> 	sal.pc = func_addr;
>        else
> 	sal.pc = msymbol->value_address (objfile);
>        sal.pspace = current_program_space;
> 
>        /* We can assign the section based on MSYMBOL here because the
>           breakpoint is actually being placed at (or near) MSYMBOL.  */
>        sal.section = msymbol->obj_section (objfile);
>      }
> 

To answer your question on whether find_function_start_sal does fill 
this for us : it depends. It manages to do it on amd64 but not on amdgpu.

By default, the sal does not contain a valid section. It's only when we 
try to adjust the pc past the prologue (skip_prologue_sal) that a 
section is computed for the pc at the start of the function. If we do 
have a prologue, then we assign that section (symtab.c:3914). If not 
(and that is the case on amdgpu), then we're left with an empty 
sal.section. I would say the behavior is not really consistent.

I would agree it could be made to.
> Does this look like a valid path forward maybe?

Your solution seems to work for the gnu-ifunc test and fixes the 
regression for gdb.rocm/displaced-stepping.exp - so I'd say it's a good 
aproach. I am not familiar with overlays, so I can't really judge if the 
change would impact how they are handled.

I think it would be best to ensure find_function_start_sal has a 
consistent behavior across architectures. I'll submit a small patch 
which should address this. This would also at least reduce the chance 
for another bug like this to appear somewhere else :

 > So then you'll have to add a find_pc_section in _another_ place....


Sébastien

  parent reply	other threads:[~2025-10-02 19:41 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
2025-09-25 21:40         ` Andrew Burgess
2025-09-25 22:30           ` Simon Marchi
2025-10-02 19:40           ` Sébastien Darche [this message]
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=6c31b667-db2d-453e-9597-9fe011c4766e@efficios.com \
    --to=sdarche@efficios.com \
    --cc=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simark@simark.ca \
    /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