From patchwork Thu Feb 23 15:46:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 65524 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C8DD73858425 for ; Thu, 23 Feb 2023 15:48:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C8DD73858425 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677167300; bh=S3UUsVYpBMQI/vvXx6MqCu7Ohe9NEAZqAyLwtjFuiyA=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=JRk7ZILQsgf6VCfEwwS72JYOpPk5z1SYGjV+8G0+3VzMz32ckJUGwRppIRFix0ql8 X5907NUCHvOnjtTckvK4Q2/rjpxmVSpEGDYNFwpt/iC7M4KtCBlT4lY3fADpcyvJJg C2M/jQJgUaklTvJv8p93lTbfDXCWqNdRiMcHQl3Q= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 643AB3857BA4 for ; Thu, 23 Feb 2023 15:47:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 643AB3857BA4 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-74-bySL8k9VO7aLmKozFYrBaw-1; Thu, 23 Feb 2023 10:47:03 -0500 X-MC-Unique: bySL8k9VO7aLmKozFYrBaw-1 Received: by mail-wm1-f69.google.com with SMTP id x18-20020a1c7c12000000b003e1e7d3cf9fso5387439wmc.3 for ; Thu, 23 Feb 2023 07:47:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=S3UUsVYpBMQI/vvXx6MqCu7Ohe9NEAZqAyLwtjFuiyA=; b=FJg2PzfDPwNc5KmgbY38FKK45yuF/4Lx8E2GwHfjk9z2TVrrnCZOeG7sAWUMGM0ddP OhASJniIojlnY/jv2uODGwbvivq1JryXvPk4i/+e3n8AC8P+uXmxJ/R8WuTpht1eREF9 QICWaNYsPSJIXBSgjPTEVUjWcTpAeClOUL3j/7+UTcVjnEWcf1bZ9+jX9mNc5uYqob/q ROHejsfUQ9T3dk8hvIhttZyC6UdBhu1DnoF/RdJqvcKSLfjrTj1T2rIRkNXsyoK3uVMZ 7iKzUO+n7NbCgJ/nlvNRWPY8wjAkJ9IN+2mz05Aj7QoqL1UmxUVj4MBmd+jFZpukMA4v 5l7w== X-Gm-Message-State: AO0yUKV9QMFxN0i9R9Or3Pwmad41jAnBTj2DeNAsRzPWGBmOsrApjwEe Z/XWOBbQ+BNu2DGIC/7gq9xT9/G3u9eksDUQajiouou9v/3O4akUQoSvfTsDPv/ibLsnjfht/Ir OYfksaE0bZt/SySDqydLbPQae99cil8vMK5UGZCX9M2m6T6+VfgN7rfxJH0hWtCGIPHtxaRLXgx Rl9oM= X-Received: by 2002:a05:600c:22ce:b0:3e7:6a59:d9d3 with SMTP id 14-20020a05600c22ce00b003e76a59d9d3mr7833917wmg.37.1677167222441; Thu, 23 Feb 2023 07:47:02 -0800 (PST) X-Google-Smtp-Source: AK7set9KhhXVqlvgB1zQ34sKumj6OJXkOK2QV90hFlMB9/GR7I32t73crAO11nX28eqmnO545Sx4RA== X-Received: by 2002:a05:600c:22ce:b0:3e7:6a59:d9d3 with SMTP id 14-20020a05600c22ce00b003e76a59d9d3mr7833902wmg.37.1677167222128; Thu, 23 Feb 2023 07:47:02 -0800 (PST) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id h3-20020adff4c3000000b002c70a0e2cd0sm5169404wrp.101.2023.02.23.07.47.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 07:47:01 -0800 (PST) To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 2/3] gdb: remove gdbarch_displaced_step_fixup_p Date: Thu, 23 Feb 2023 15:46:53 +0000 Message-Id: <7765b441d498a0acade8965fe041f2d9e7422d02.1677167018.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" The comment on the gdbarch_displaced_step_fixup gdbarch method indicates that this method is optional and that GDB will perform some default if this method is not supplied. As such we define a predicate gdbarch_displaced_step_fixup_p. It may have been true at one point that the fixup method was optional, but it is no longer true. If this method is not defined and GDB tries to complete a displaced step, then GDB is going to crash. Additionally the gdbarch_displaced_step_fixup_p predicate is not used anywhere in GDB. In this commit I have removed the gdbarch_displaced_step_fixup_p predicate, and I have updated the validation check for the gdbarch_displaced_step_fixup method; if the gdbarch_displaced_step_copy_insn method is defined then the fixup method must also be defined. I believe I've manually checked all the current places where gdbarch_displaced_step_copy_insn is defined and they all also define the fixup method, so this change should cause no problems for anyone. There should be no user visible changes after this commit. --- gdb/gdbarch-components.py | 4 ++-- gdb/gdbarch-gen.h | 2 -- gdb/gdbarch.c | 14 ++------------ 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/gdb/gdbarch-components.py b/gdb/gdbarch-components.py index 76ad2832d8a..06be4b57051 100644 --- a/gdb/gdbarch-components.py +++ b/gdb/gdbarch-components.py @@ -1851,9 +1851,9 @@ see the comments in infrun.c. ("CORE_ADDR", "to"), ("struct regcache *", "regs"), ], - predicate=True, + predicate=False, predefault="NULL", - invalid=True, + invalid="(gdbarch->displaced_step_copy_insn == nullptr) != (gdbarch->displaced_step_fixup == nullptr)", ) Method( diff --git a/gdb/gdbarch-gen.h b/gdb/gdbarch-gen.h index 32b2d96fbe0..ac63e84b191 100644 --- a/gdb/gdbarch-gen.h +++ b/gdb/gdbarch-gen.h @@ -1085,8 +1085,6 @@ extern void set_gdbarch_displaced_step_hw_singlestep (struct gdbarch *gdbarch, g For a general explanation of displaced stepping and how GDB uses it, see the comments in infrun.c. */ -extern bool gdbarch_displaced_step_fixup_p (struct gdbarch *gdbarch); - typedef void (gdbarch_displaced_step_fixup_ftype) (struct gdbarch *gdbarch, struct displaced_step_copy_insn_closure *closure, CORE_ADDR from, CORE_ADDR to, struct regcache *regs); extern void gdbarch_displaced_step_fixup (struct gdbarch *gdbarch, struct displaced_step_copy_insn_closure *closure, CORE_ADDR from, CORE_ADDR to, struct regcache *regs); extern void set_gdbarch_displaced_step_fixup (struct gdbarch *gdbarch, gdbarch_displaced_step_fixup_ftype *displaced_step_fixup); diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 04fcc92f8f9..4958d3c5fc6 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -447,7 +447,8 @@ verify_gdbarch (struct gdbarch *gdbarch) /* Skip verify of max_insn_length, has predicate. */ /* Skip verify of displaced_step_copy_insn, has predicate. */ /* Skip verify of displaced_step_hw_singlestep, invalid_p == 0 */ - /* Skip verify of displaced_step_fixup, has predicate. */ + if ((gdbarch->displaced_step_copy_insn == nullptr) != (gdbarch->displaced_step_fixup == nullptr)) + log.puts ("\n\tdisplaced_step_fixup"); /* Skip verify of displaced_step_prepare, has predicate. */ if ((! gdbarch->displaced_step_finish) != (! gdbarch->displaced_step_prepare)) log.puts ("\n\tdisplaced_step_finish"); @@ -1087,9 +1088,6 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file) gdb_printf (file, "gdbarch_dump: displaced_step_hw_singlestep = <%s>\n", host_address_to_string (gdbarch->displaced_step_hw_singlestep)); - gdb_printf (file, - "gdbarch_dump: gdbarch_displaced_step_fixup_p() = %d\n", - gdbarch_displaced_step_fixup_p (gdbarch)); gdb_printf (file, "gdbarch_dump: displaced_step_fixup = <%s>\n", host_address_to_string (gdbarch->displaced_step_fixup)); @@ -4046,19 +4044,11 @@ set_gdbarch_displaced_step_hw_singlestep (struct gdbarch *gdbarch, gdbarch->displaced_step_hw_singlestep = displaced_step_hw_singlestep; } -bool -gdbarch_displaced_step_fixup_p (struct gdbarch *gdbarch) -{ - gdb_assert (gdbarch != NULL); - return gdbarch->displaced_step_fixup != NULL; -} - void gdbarch_displaced_step_fixup (struct gdbarch *gdbarch, struct displaced_step_copy_insn_closure *closure, CORE_ADDR from, CORE_ADDR to, struct regcache *regs) { gdb_assert (gdbarch != NULL); gdb_assert (gdbarch->displaced_step_fixup != NULL); - /* Do not check predicate: gdbarch->displaced_step_fixup != NULL, allow call. */ if (gdbarch_debug >= 2) gdb_printf (gdb_stdlog, "gdbarch_displaced_step_fixup called\n"); gdbarch->displaced_step_fixup (gdbarch, closure, from, to, regs);