From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id n/tWA3X8RmetmQEAWB0awg (envelope-from ) for ; Wed, 27 Nov 2024 06:03:17 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=YRUGPdL4; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id E145E1E097; Wed, 27 Nov 2024 06:03:16 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 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 autolearn=ham autolearn_force=no version=4.0.0 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 879BF1E05C for ; Wed, 27 Nov 2024 06:03:14 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 006843858CD9 for ; Wed, 27 Nov 2024 11:03:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 006843858CD9 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=YRUGPdL4 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) by sourceware.org (Postfix) with ESMTPS id A21C93858C78 for ; Wed, 27 Nov 2024 11:01:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A21C93858C78 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A21C93858C78 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1732705313; cv=none; b=sdjXW6mJI9uoNN8WmME/bayn3E3qBf5uJqFg6ABhNaU/3uYSxv4ZPfCYRN9Wd9tpPl6De538vNZcqyv9hrn1Wm1RLQh0nHF1u9AtkuMZ25Qfki5Wi+sZnb5aVvmY4l1vZC6Po6zwxv0v/t+UnBtMDlUASoveLV5kwnM4FmZ9RdA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1732705313; c=relaxed/simple; bh=7KxjY2B3XFNUhQXsSEkPqavIgfEmneDT6HQtuEu0q1U=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=D1mTuTZ7uNO5ZSZBaEvygIU+j35dF1GNjrnQKd31sUzEjPNmTkSkqeJvNk0Y8u2PhWwwU7AGg48/4Zh6Cji65KqrxpHwqnozuXp4YiDgEyKE4TLHrxEncDmnpWyWQBK1ZRxClaCUelrGObFYr2m7BHmvilFphmF4LDbur3ozz4A= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A21C93858C78 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1732705314; x=1764241314; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=7KxjY2B3XFNUhQXsSEkPqavIgfEmneDT6HQtuEu0q1U=; b=YRUGPdL4o3nMnv/Xg7kHxz3V1LesXGlLmYtKmoroHQTljQ/VgACnaNlb oGzhJMPrgU5KM5mKggOcu4z9tmqO9qNoYT8JxAy+/zD8uRXIqShEu/9zZ R9Q6ta56Xq+8DWXZzFb5o2OXcBJOVEZ1iVuFWWT4e2XqT5VYNX6PNy5P6 aTMIg2hdN3cE8UhU7r8npUmnI5nP3Tx6Ms1lCEq9mYf/Blo8eTMKDLRAw W63ai/lKPKq+3k9RZiXxR2Ghj9oCdJ715ROjY8oDEhjnnsS6fV+wmxabd N5JjP+gB5Xtgmk42aQJ2b+jW0nCN4iuFYBLyaY+QT3Ri/QcZieBfz5b5M A==; X-CSE-ConnectionGUID: Wzf9TZA7QG+7wsCFcwR6Rw== X-CSE-MsgGUID: 7niLzZ33Sj2fmrPxlx3AJQ== X-IronPort-AV: E=McAfee;i="6700,10204,11268"; a="44292058" X-IronPort-AV: E=Sophos;i="6.12,189,1728975600"; d="scan'208";a="44292058" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Nov 2024 03:01:53 -0800 X-CSE-ConnectionGUID: 5PS4OVFVT8+Ah1yMJGt7lA== X-CSE-MsgGUID: cdCnRVgBQD2CEcoXPvdgUA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,189,1728975600"; d="scan'208";a="122873716" Received: from dut1505dg2frd.igk.intel.com (HELO localhost) ([10.102.46.29]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Nov 2024 03:01:52 -0800 From: Klaus Gerlicher To: gdb-patches@sourceware.org, aburgess@redhat.com Subject: [PATCH v3 1/1] gdb: avoid conversion of SIGSEGV to SIGTRAP on user breakpoints Date: Wed, 27 Nov 2024 11:01:32 +0000 Message-Id: <20241127110132.125667-2-klaus.gerlicher@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241127110132.125667-1-klaus.gerlicher@intel.com> References: <20241127110132.125667-1-klaus.gerlicher@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 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. --- 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