From: Andrew Burgess <aburgess@redhat.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>
Subject: [PATCH 2/3] gdb: remove gdbarch_displaced_step_fixup_p
Date: Thu, 23 Feb 2023 15:46:53 +0000 [thread overview]
Message-ID: <7765b441d498a0acade8965fe041f2d9e7422d02.1677167018.git.aburgess@redhat.com> (raw)
In-Reply-To: <cover.1677167018.git.aburgess@redhat.com>
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);
--
2.25.4
next prev parent reply other threads:[~2023-02-23 15:47 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-23 15:46 [PATCH 0/3] AMD64 Displaced Stepping Fix Andrew Burgess
2023-02-23 15:46 ` [PATCH 1/3] gdb: more debug output for displaced stepping Andrew Burgess
2023-02-23 15:46 ` Andrew Burgess [this message]
2023-02-23 15:46 ` [PATCH 3/3] gdb: fix reg corruption from displaced stepping on amd64 Andrew Burgess
2023-03-16 16:39 ` [PATCHv2 0/4] AMD64 Displaced Stepping Fix Andrew Burgess
2023-03-16 16:39 ` [PATCHv2 1/4] gdb: more debug output for displaced stepping Andrew Burgess
2023-03-21 12:29 ` Pedro Alves
2023-03-21 14:41 ` Simon Marchi
2023-03-22 21:17 ` [PATCHv2 0/2] displaced stepping debug improvements Andrew Burgess
2023-03-22 21:17 ` [PATCHv2 1/2] gdb: more debug output for displaced stepping Andrew Burgess
2023-03-22 21:17 ` [PATCHv2 2/2] gdb: move displaced_step_dump_bytes into gdbsupport (and rename) Andrew Burgess
2023-03-27 12:35 ` [PATCHv2 0/2] displaced stepping debug improvements Andrew Burgess
2023-03-21 14:45 ` [PATCHv2 1/4] gdb: more debug output for displaced stepping Simon Marchi
2023-03-16 16:39 ` [PATCHv2 2/4] gdb: remove gdbarch_displaced_step_fixup_p Andrew Burgess
2023-03-21 13:10 ` Pedro Alves
2023-03-22 21:22 ` Andrew Burgess
2023-03-16 16:39 ` [PATCHv2 3/4] gdb: fix reg corruption from displaced stepping on amd64 Andrew Burgess
2023-03-21 13:23 ` Pedro Alves
2023-03-16 16:39 ` [PATCHv2 4/4] gdb: remove redundant signal passing Andrew Burgess
2023-03-27 12:32 ` [PATCHv3 0/3] AMD64 Displaced Stepping Fix Andrew Burgess
2023-03-27 12:32 ` [PATCHv3 1/3] gdb: more debug output for displaced stepping Andrew Burgess
2023-03-28 13:05 ` Simon Marchi
2023-03-28 15:08 ` Andrew Burgess
2023-03-28 15:11 ` Simon Marchi
2023-03-29 9:42 ` Andrew Burgess
2023-03-27 12:32 ` [PATCHv3 2/3] gdb: move displaced_step_dump_bytes into gdbsupport (and rename) Andrew Burgess
2023-03-28 13:10 ` Simon Marchi
2023-03-29 9:43 ` Andrew Burgess
2023-03-27 12:32 ` [PATCHv3 3/3] gdb: fix reg corruption from displaced stepping on amd64 Andrew Burgess
2023-03-29 9:43 ` Pedro Alves
2023-03-28 12:33 ` [PATCHv3 0/3] AMD64 Displaced Stepping Fix Simon Marchi
2023-03-28 15:29 ` Andrew Burgess
2023-03-29 13:46 ` [PATCHv4] gdb: fix reg corruption from displaced stepping on amd64 Andrew Burgess
2023-04-04 13:03 ` Pedro Alves
2023-04-06 13:29 ` Andrew Burgess
2023-04-06 15:38 ` 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=7765b441d498a0acade8965fe041f2d9e7422d02.1677167018.git.aburgess@redhat.com \
--to=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).