Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH v3 0/1] gdb: avoid conversion of SIGSEGV to SIGTRAP on user breakpoints
@ 2024-11-27 11:01 Klaus Gerlicher
  2024-11-27 11:01 ` [PATCH v3 1/1] " Klaus Gerlicher
  2025-04-29  7:47 ` [PATCH v3 0/1] " Gerlicher, Klaus
  0 siblings, 2 replies; 9+ messages in thread
From: Klaus Gerlicher @ 2024-11-27 11:01 UTC (permalink / raw)
  To: gdb-patches, aburgess

Hi Andrew,

thanks for the feedback. 

You replied: 

> But, I wonder if there's a different approach that could be used?
> 
> I assume that your out of tree architecture with these imprecise page
> faults has a new gdbarch to represent it.
> 
> You are limiting the SIGSEGV -> SIGTRAP conversion because, I assume,
> you've hit cases where a SIGSEGV occurs and then your target has run on
> and reported the stop at the address of a user breakpoint.  But all
> you're really doing is reducing the scope for errors.  It could be the
> case that the SIGSEGV is reported at the site of an internal breakpoint,
> and then you'll still have issues.
> 
> So what if, instead, you added a new gdbarch method, something like:
> 
>   bool gdbarch_has_imprecise_page_faults (struct gdbarch *gdbarch);
> 
> The default for this, and for all currently in-tree targets, would be to
> return true.  For your target this will return false.
> 
> Then in this code we would do:
> 
>   if (ecs->ws.kind () == TARGET_WAITKIND_STOPPED
>       && (ecs->ws.sig () == GDB_SIGNAL_ILL
> 	  || (ecs->ws.sig () == GDB_SIGNAL_SEGV
>               !gdbarch_has_imprecise_page_faults (gdbarch))
> 	  || ecs->ws.sig () == GDB_SIGNAL_EMT))
> 
> How does this approach sound?

I think for now this would be a viable solution and I implemented it in the V3 
patch.

However, we had a little discussion internally and we were wondering if this now
feels more like a workaround in a workaround.

It seems to me that the conversion of any of these signals should really be
only done for a specific target.  Even though the SIG_ILL and SIG_EMT
conversions  obviously have no side effects for most targets, I would think
these should be avoided.

Do you think there's a way to limit these more specifically or are we unsure
which targets actually need these? Maybe some of the users are already obsolete?

I would assume it would be difficult to limit to a specific target when we used
the remote target since we would then have to update GDB server to also support
this.

I'm of course fine if we fix it with the architecture method but maybe others
would disagree?

Thanks
Klaus

Gerlicher, Klaus (1):
  gdb: avoid conversion of SIGSEGV to SIGTRAP on user breakpoints

 gdb/gdbarch-gen.c         | 22 ++++++++++++++++++++++
 gdb/gdbarch-gen.h         |  7 +++++++
 gdb/gdbarch_components.py | 12 ++++++++++++
 gdb/infrun.c              |  4 +++-
 4 files changed, 44 insertions(+), 1 deletion(-)

-- 
2.34.1

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: [PATCH v3 1/1] gdb: avoid conversion of SIGSEGV to SIGTRAP on user breakpoints
@ 2026-05-13  8:19 Aktemur, Baris
  2026-05-19 10:29 ` Gerlicher, Klaus
  0 siblings, 1 reply; 9+ messages in thread
From: Aktemur, Baris @ 2026-05-13  8:19 UTC (permalink / raw)
  To: klaus.gerlicher, gdb-patches; +Cc: aburgess

AMD General

Hi Klaus,

This is a reply to

 https://inbox.sourceware.org/gdb-patches/87zffcn798.fsf@redhat.com/

It seems the patch is not merged to upstream master, yet.  I assume it's
simply an oversight.  Could you take a look?

I have one comment below:

> diff --git a/gdb/infrun.c b/gdb/infrun.c
> index 43eca814e29..eb34aed09e0 100644
> --- a/gdb/infrun.c
> +++ b/gdb/infrun.c
> @@ -6138,7 +6138,9 @@ handle_inferior_event (struct execution_control_state *ecs)
>       stack.  */
>    if (ecs->ws.kind () == TARGET_WAITKIND_STOPPED
>        && (ecs->ws.sig () == GDB_SIGNAL_ILL
> -       || ecs->ws.sig () == GDB_SIGNAL_SEGV
> +       || (ecs->ws.sig () == GDB_SIGNAL_SEGV
> +           && !gdbarch_imprecise_pagefault_reporting
> +             (current_inferior ()->arch ()))

In a case like AMD GPUs, the inferior contains a mixture of CPU and GPU threads.
The imprecise reporting property would depend on the kind of the thread.  Therefore,
instead of

  current_inferior ()->arch ()

I'd propose

  target_thread_architecture (ecs->event_thread->ptid)

That should still give the same behavior for Intel's case because by default a
process stratum target returns the inferior's arch.

Best,
-Baris



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

end of thread, other threads:[~2026-07-17  7:47 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-27 11:01 [PATCH v3 0/1] gdb: avoid conversion of SIGSEGV to SIGTRAP on user breakpoints Klaus Gerlicher
2024-11-27 11:01 ` [PATCH v3 1/1] " Klaus Gerlicher
2025-05-16 11:07   ` Andrew Burgess
2025-04-29  7:47 ` [PATCH v3 0/1] " Gerlicher, Klaus
2025-05-14 12:01   ` [PING V2][PATCH " Gerlicher, Klaus
2026-05-13  8:19 [PATCH v3 1/1] " Aktemur, Baris
2026-05-19 10:29 ` Gerlicher, Klaus
2026-07-07  6:35   ` Aktemur, Baris
2026-07-17  7:46     ` Gerlicher, Klaus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox