From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id ldVQBagcJ2iiPyUAWB0awg (envelope-from ) for ; Fri, 16 May 2025 07:08:24 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=US78JZGn; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 041EF1E10E; Fri, 16 May 2025 07:08:24 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-10.1 required=5.0 tests=ARC_SIGNED,ARC_VALID, BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED, RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id C86871E092 for ; Fri, 16 May 2025 07:08:22 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 506963857BAF for ; Fri, 16 May 2025 11:08:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 506963857BAF Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=US78JZGn Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 1F6C43858C56 for ; Fri, 16 May 2025 11:07:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1F6C43858C56 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1F6C43858C56 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747393672; cv=none; b=lhfhbR4KM9cV8mIaccBoU5eO2J5Y3reR4+fL5rkr6zCKIocrbl80lFonlrggYS5ii7KklEPoJZfMp/gRileRLlwHecESqrcujoiIQgAkM8tvsjKLP7YvHa4LnN+0WieBVrCnF9c0hJ+LzXyd6LI0LN4fd5tkBLt545iPvYLV9tI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747393672; c=relaxed/simple; bh=SEAfilVVszUfjdmQiJUI6QMFI+hIk0R2/mj1TU4ZiNk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=qvxDnJzKx21sqNwQIdoGnIohuGkXfXhs3zPVJutFuWC+HHnnz5jUPqgNOacogg1tGtbyhcl11bE0DDVVHLp8qGJnoYsRYuXz/Hl/UwCb2vA9UHdqCpCy7PJA26017VrZ6s1mAC+tr8pUEMHsaGzn+5L/1hXaNQ7fYu7nZEYLuYc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1F6C43858C56 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747393671; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6sNuA4D6DYHeKgzv6nE8lSG2vJaP7S46jiihdJQUYIs=; b=US78JZGnYARENgJqCNgkv/wCZikzJ2e5X8zSKIrEQts7UHifjy7/vEaTbDHXqD7krhKmQp u+Nuttsyqssj7Di7bAgJzUTYstD0wa28mz/DqgjMkUQTGLXnbWVKb2JPMm+uH9w6IHO6H+ 5MUGP0NSo2p75T4avqhI82gfnNzYDRI= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-137-3z_RDxkmN7yRTDztOrhF3A-1; Fri, 16 May 2025 07:07:50 -0400 X-MC-Unique: 3z_RDxkmN7yRTDztOrhF3A-1 X-Mimecast-MFC-AGG-ID: 3z_RDxkmN7yRTDztOrhF3A_1747393669 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-43eea5a5d80so11102895e9.1 for ; Fri, 16 May 2025 04:07:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747393669; x=1747998469; h=mime-version:message-id:date:references:in-reply-to:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6sNuA4D6DYHeKgzv6nE8lSG2vJaP7S46jiihdJQUYIs=; b=NNgLdvCiPG6z36ZrrUN9NI8jOM3WvfyiwVJaU2iU3m+Io2so6dvJl9/Gcq7hLh+gql k9nt3Cjg+4GHGeQtZ3XOJiF4hsWC931+80YDYjKcdmJbhuXKwOz/4Xi99EVc2d5GBrg8 OE+8ga1/qyiS2vuKjlmnku6zuIxdNpPsQJwaukd2vosbxskXyEq79+Mcf4mqS2m5gzC2 epAhKehdfGVezLAOBfbNQxxYTXosazc+RTEOn9I12B9vWe2kwNd2NhjkiQOBnqGsFZFr Sl1j4kg5EKhuIpIpa6WkC2WAbGrLqDbWEMxnBeZftJqxOWf4xqpCRm29aHr+5DSkAVDD yPyw== X-Forwarded-Encrypted: i=1; AJvYcCVVwyoIzL7ncBx5EHq10bhHUyE6p2aSC9TVQ9XMN+XIw2cvNZ06794SPtTlxriINrLljKnJYNHhAM5Zfg==@sourceware.org X-Gm-Message-State: AOJu0Yz+UKtoc+8SsDXGO9oL41XOCkYhlVCHwhR2PmQUmtPwknQW7pwr JFfTNS/a3+/2Am3nm8sTdAXBZzPEdEAwLAGOq1xQtk2RKL/lXhjDd6/ZoBwJgvoDKlJkdm0xQe/ GL0LEx6pm/udzLshIIBGZpCgYMIzNMB11nKTSQW5oYUfPu04LDAIF/kSej7u+hko= X-Gm-Gg: ASbGnctC8SaoT6GvUidgaWMb4rqPtdzae8Fvr9BoQEQxM7QK19Rjl1xept99jGLvP5l aOXIBZjSisT0V+/ZkjMb1dfg73s+gLb2zi7ThXoD3AH6IFe+4GDbBZWsSuGwUb/vNZhn7DspiZ6 vP1dIqKoNDeQyJrXMjdKbF5t/d/mzQBCNs2EYHVgV9co8NJUoDs2jznCUBzVUJZcZrFvx8hQmPG rtmljVrGna6zQVt7SbQeyuUTNd8KDWYPWInAxy0uFwWp8H2XZ8JMkj/w4EZTts1SfKozER9SzsP sfi7tg0lvxjY1ete6zaN3J3IbZkSXsbdNX81 X-Received: by 2002:a05:600c:3511:b0:43c:eea9:f45d with SMTP id 5b1f17b1804b1-442feffb5e7mr22152265e9.18.1747393669310; Fri, 16 May 2025 04:07:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFz0R3feNLPq4CFrvdEmUykIs9z0hJYqgN6nzcNR3/nFhsWDzFyw8BgPSFOqekAF4HJIpjIWg== X-Received: by 2002:a05:600c:3511:b0:43c:eea9:f45d with SMTP id 5b1f17b1804b1-442feffb5e7mr22151975e9.18.1747393668819; Fri, 16 May 2025 04:07:48 -0700 (PDT) Received: from localhost (30.226.159.143.dyn.plus.net. [143.159.226.30]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-442f39e84acsm105630405e9.25.2025.05.16.04.07.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 May 2025 04:07:48 -0700 (PDT) From: Andrew Burgess To: Klaus Gerlicher , gdb-patches@sourceware.org Subject: Re: [PATCH v3 1/1] gdb: avoid conversion of SIGSEGV to SIGTRAP on user breakpoints In-Reply-To: <20241127110132.125667-2-klaus.gerlicher@intel.com> References: <20241127110132.125667-1-klaus.gerlicher@intel.com> <20241127110132.125667-2-klaus.gerlicher@intel.com> Date: Fri, 16 May 2025 12:07:47 +0100 Message-ID: <87zffcn798.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: kTYNDzLE5Xj-HWSeRhOzWAVFqwjV8JVGx6P8BF8zlDY_1747393669 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Klaus Gerlicher writes: > From: "Gerlicher, Klaus" > > GDB converts signals GDB_SIGNAL_ILL, GDB_SIGNAL_SEGV and GDB_SIGNAL_EMT to > GDB_SIGNAL_SEGV if a breakpoint is inserted at the fault location. If, due > to imprecise page fault reporting, a breakpoint is at the same address as > the fault address, this signal would always be reported as GDB_SIGNAL_TRAP. > > Add a new gdbarch function that allows the signal conversion from SIGNAL_SEGV > to SIGNAL_TRAP to be skipped for an architecture. LGTM. Approved-By: Andrew Burgess Thanks, Andrew > --- > 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(-) > > diff --git a/gdb/gdbarch-gen.c b/gdb/gdbarch-gen.c > index d05c7a3cbdf..255f851ffa3 100644 > --- a/gdb/gdbarch-gen.c > +++ b/gdb/gdbarch-gen.c > @@ -260,6 +260,7 @@ struct gdbarch > gdbarch_get_pc_address_flags_ftype *get_pc_address_flags = default_get_pc_address_flags; > gdbarch_read_core_file_mappings_ftype *read_core_file_mappings = default_read_core_file_mappings; > gdbarch_use_target_description_from_corefile_notes_ftype *use_target_description_from_corefile_notes = default_use_target_description_from_corefile_notes; > + gdbarch_imprecise_pagefault_reporting_ftype *imprecise_pagefault_reporting = [] () -> bool {return false;}; > }; > > /* Create a new ``struct gdbarch'' based on information provided by > @@ -531,6 +532,7 @@ verify_gdbarch (struct gdbarch *gdbarch) > /* Skip verify of get_pc_address_flags, invalid_p == 0. */ > /* Skip verify of read_core_file_mappings, invalid_p == 0. */ > /* Skip verify of use_target_description_from_corefile_notes, invalid_p == 0. */ > + /* Skip verify of imprecise_pagefault_reporting, invalid_p == 0. */ > if (!log.empty ()) > internal_error (_("verify_gdbarch: the following are invalid ...%s"), > log.c_str ()); > @@ -1396,6 +1398,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file) > gdb_printf (file, > "gdbarch_dump: use_target_description_from_corefile_notes = <%s>\n", > host_address_to_string (gdbarch->use_target_description_from_corefile_notes)); > + gdb_printf (file, > + "gdbarch_dump: imprecise_pagefault_reporting = <%s>\n", > + host_address_to_string (gdbarch->imprecise_pagefault_reporting)); > if (gdbarch->dump_tdep != NULL) > gdbarch->dump_tdep (gdbarch, file); > } > @@ -5507,3 +5512,20 @@ set_gdbarch_use_target_description_from_corefile_notes (struct gdbarch *gdbarch, > { > gdbarch->use_target_description_from_corefile_notes = use_target_description_from_corefile_notes; > } > + > +bool > +gdbarch_imprecise_pagefault_reporting (struct gdbarch *gdbarch) > +{ > + gdb_assert (gdbarch != NULL); > + gdb_assert (gdbarch->imprecise_pagefault_reporting != NULL); > + if (gdbarch_debug >= 2) > + gdb_printf (gdb_stdlog, "gdbarch_imprecise_pagefault_reporting called\n"); > + return gdbarch->imprecise_pagefault_reporting (); > +} > + > +void > +set_gdbarch_imprecise_pagefault_reporting (struct gdbarch *gdbarch, > + gdbarch_imprecise_pagefault_reporting_ftype imprecise_pagefault_reporting) > +{ > + gdbarch->imprecise_pagefault_reporting = imprecise_pagefault_reporting; > +} > diff --git a/gdb/gdbarch-gen.h b/gdb/gdbarch-gen.h > index 9fda85f860f..e2ca6e59680 100644 > --- a/gdb/gdbarch-gen.h > +++ b/gdb/gdbarch-gen.h > @@ -1778,3 +1778,10 @@ extern void set_gdbarch_read_core_file_mappings (struct gdbarch *gdbarch, gdbarc > typedef bool (gdbarch_use_target_description_from_corefile_notes_ftype) (struct gdbarch *gdbarch, struct bfd *corefile_bfd); > extern bool gdbarch_use_target_description_from_corefile_notes (struct gdbarch *gdbarch, struct bfd *corefile_bfd); > extern void set_gdbarch_use_target_description_from_corefile_notes (struct gdbarch *gdbarch, gdbarch_use_target_description_from_corefile_notes_ftype *use_target_description_from_corefile_notes); > + > +/* Returns true if architecture has imprecise pagefault reporting. This is > + used in conversion of SIGSEGV to SIGTRAP for an architecture. */ > + > +typedef bool (gdbarch_imprecise_pagefault_reporting_ftype) (); > +extern bool gdbarch_imprecise_pagefault_reporting (struct gdbarch *gdbarch); > +extern void set_gdbarch_imprecise_pagefault_reporting (struct gdbarch *gdbarch, gdbarch_imprecise_pagefault_reporting_ftype *imprecise_pagefault_reporting); > diff --git a/gdb/gdbarch_components.py b/gdb/gdbarch_components.py > index cc7c6d8677b..8f518e1052a 100644 > --- a/gdb/gdbarch_components.py > +++ b/gdb/gdbarch_components.py > @@ -2815,3 +2815,15 @@ The corefile's bfd is passed through COREFILE_BFD. > predefault="default_use_target_description_from_corefile_notes", > invalid=False, > ) > + > +Function( > + comment=""" > +Returns true if architecture has imprecise pagefault reporting. This is > +used in conversion of SIGSEGV to SIGTRAP for an architecture. > +""", > + type="bool", > + name="imprecise_pagefault_reporting", > + params=[], > + predefault="[] () -> bool {return false;}", > + invalid=False > +) > 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 ())) > || ecs->ws.sig () == GDB_SIGNAL_EMT)) > { > struct regcache *regcache = get_thread_regcache (ecs->event_thread); > -- > 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