* [review] Add read_pc / write_pc support to win32-low
@ 2019-11-26 17:12 Tom Tromey (Code Review)
2019-11-27 1:03 ` Luis Machado (Code Review)
2019-11-29 20:57 ` Pedro Alves (Code Review)
0 siblings, 2 replies; 5+ messages in thread
From: Tom Tromey (Code Review) @ 2019-11-26 17:12 UTC (permalink / raw)
To: gdb-patches
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/721
......................................................................
Add read_pc / write_pc support to win32-low
This changes win32-low.c to implement the read_pc and write_pc
methods. A subsequent patch will need these.
Note that I have no way to test, or even compile, the win32-arm-low.c
change.
2019-11-26 Tom Tromey <tromey@adacore.com>
* win32-low.c (win32_read_pc, win32_write_pc): New functions.
(win32_target_ops): Update.
* win32-i386-low.c (i386_win32_get_pc, i386_win32_set_pc): New
functions.
(the_low_target): Update.
* win32-arm-low.c (arm_win32_get_pc, arm_win32_set_pc): New
functions.
(the_low_target): Update.
Change-Id: I83552edd4ec61204a7e56f1adbd5a9c941bb52e5
---
M gdb/gdbserver/ChangeLog
M gdb/gdbserver/win32-arm-low.c
M gdb/gdbserver/win32-i386-low.c
M gdb/gdbserver/win32-low.c
M gdb/gdbserver/win32-low.h
5 files changed, 103 insertions(+), 2 deletions(-)
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index d05734a..df6206e 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,16 @@
2019-11-26 Tom Tromey <tromey@adacore.com>
+ * win32-low.c (win32_read_pc, win32_write_pc): New functions.
+ (win32_target_ops): Update.
+ * win32-i386-low.c (i386_win32_get_pc, i386_win32_set_pc): New
+ functions.
+ (the_low_target): Update.
+ * win32-arm-low.c (arm_win32_get_pc, arm_win32_set_pc): New
+ functions.
+ (the_low_target): Update.
+
+2019-11-26 Tom Tromey <tromey@adacore.com>
+
* win32-low.c (win32_kill, get_child_debug_event): Use
wait_for_debug_event.
diff --git a/gdb/gdbserver/win32-arm-low.c b/gdb/gdbserver/win32-arm-low.c
index c465aed..c13089a 100644
--- a/gdb/gdbserver/win32-arm-low.c
+++ b/gdb/gdbserver/win32-arm-low.c
@@ -113,6 +113,27 @@
static const unsigned long arm_wince_breakpoint = 0xe6000010;
#define arm_wince_breakpoint_len 4
+/* Implement win32_target_ops "get_pc" method. */
+
+static CORE_ADDR
+arm_win32_get_pc (struct regcache *regcache)
+{
+ uint32_t pc;
+
+ collect_register_by_name (regcache, "pc", &pc);
+ return (CORE_ADDR) pc;
+}
+
+/* Implement win32_target_ops "set_pc" method. */
+
+static void
+arm_win32_set_pc (struct regcache *regcache, CORE_ADDR pc)
+{
+ uint32_t newpc = pc;
+
+ supply_register_by_name (regcache, "pc", &newpc);
+}
+
struct win32_target_ops the_low_target = {
arm_arch_setup,
sizeof (mappings) / sizeof (mappings[0]),
@@ -125,6 +146,8 @@
NULL, /* single_step */
(const unsigned char *) &arm_wince_breakpoint,
arm_wince_breakpoint_len,
+ arm_win32_get_pc,
+ arm_win32_set_pc,
/* Watchpoint related functions. See target.h for comments. */
NULL, /* supports_z_point_type */
NULL, /* insert_point */
diff --git a/gdb/gdbserver/win32-i386-low.c b/gdb/gdbserver/win32-i386-low.c
index b834b16..b99afcf 100644
--- a/gdb/gdbserver/win32-i386-low.c
+++ b/gdb/gdbserver/win32-i386-low.c
@@ -448,6 +448,50 @@
win32_tdesc = tdesc;
}
+/* Implement win32_target_ops "get_pc" method. */
+
+static CORE_ADDR
+i386_win32_get_pc (struct regcache *regcache)
+{
+ bool use_64bit = register_size (regcache->tdesc, 0) == 8;
+
+ if (use_64bit)
+ {
+ uint64_t pc;
+
+ collect_register_by_name (regcache, "rip", &pc);
+ return (CORE_ADDR) pc;
+ }
+ else
+ {
+ uint32_t pc;
+
+ collect_register_by_name (regcache, "eip", &pc);
+ return (CORE_ADDR) pc;
+ }
+}
+
+/* Implement win32_target_ops "set_pc" method. */
+
+static void
+i386_win32_set_pc (struct regcache *regcache, CORE_ADDR pc)
+{
+ bool use_64bit = register_size (regcache->tdesc, 0) == 8;
+
+ if (use_64bit)
+ {
+ uint64_t newpc = pc;
+
+ supply_register_by_name (regcache, "rip", &newpc);
+ }
+ else
+ {
+ uint32_t newpc = pc;
+
+ supply_register_by_name (regcache, "eip", &newpc);
+ }
+}
+
struct win32_target_ops the_low_target = {
i386_arch_setup,
sizeof (mappings) / sizeof (mappings[0]),
@@ -460,6 +504,8 @@
i386_single_step,
&i386_win32_breakpoint,
i386_win32_breakpoint_len,
+ i386_win32_get_pc,
+ i386_win32_set_pc,
i386_supports_z_point_type,
i386_insert_point,
i386_remove_point,
diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c
index 7b5ae07..9d88d1a 100644
--- a/gdb/gdbserver/win32-low.c
+++ b/gdb/gdbserver/win32-low.c
@@ -1585,6 +1585,22 @@
return the_low_target.breakpoint;
}
+/* Implementation of the target_ops method "read_pc". */
+
+static CORE_ADDR
+win32_read_pc (struct regcache *regcache)
+{
+ return (*the_low_target.get_pc) (regcache);
+}
+
+/* Implementation of the target_ops method "write_pc". */
+
+static void
+win32_write_pc (struct regcache *regcache, CORE_ADDR pc)
+{
+ return (*the_low_target.set_pc) (regcache, pc);
+}
+
static struct target_ops win32_target_ops = {
win32_create_inferior,
NULL, /* post_create_inferior */
@@ -1637,8 +1653,8 @@
NULL, /* read_loadmap */
NULL, /* process_qsupported */
NULL, /* supports_tracepoints */
- NULL, /* read_pc */
- NULL, /* write_pc */
+ win32_read_pc,
+ win32_write_pc,
NULL, /* thread_stopped */
win32_get_tib_address,
NULL, /* pause_all */
diff --git a/gdb/gdbserver/win32-low.h b/gdb/gdbserver/win32-low.h
index 5a94686..73ceb4b 100644
--- a/gdb/gdbserver/win32-low.h
+++ b/gdb/gdbserver/win32-low.h
@@ -63,6 +63,11 @@
const unsigned char *breakpoint;
int breakpoint_len;
+ /* Get the PC register from REGCACHE. */
+ CORE_ADDR (*get_pc) (struct regcache *regcache);
+ /* Set the PC register in REGCACHE. */
+ void (*set_pc) (struct regcache *regcache, CORE_ADDR newpc);
+
/* Breakpoint/Watchpoint related functions. See target.h for comments. */
int (*supports_z_point_type) (char z_type);
int (*insert_point) (enum raw_bkpt_type type, CORE_ADDR addr,
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I83552edd4ec61204a7e56f1adbd5a9c941bb52e5
Gerrit-Change-Number: 721
Gerrit-PatchSet: 1
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-MessageType: newchange
^ permalink raw reply [flat|nested] 5+ messages in thread
* [review] Add read_pc / write_pc support to win32-low
2019-11-26 17:12 [review] Add read_pc / write_pc support to win32-low Tom Tromey (Code Review)
@ 2019-11-27 1:03 ` Luis Machado (Code Review)
2019-11-29 20:57 ` Pedro Alves (Code Review)
1 sibling, 0 replies; 5+ messages in thread
From: Luis Machado (Code Review) @ 2019-11-27 1:03 UTC (permalink / raw)
To: Tom Tromey, gdb-patches
Luis Machado has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/721
......................................................................
Patch Set 1: Code-Review+1
I'll see if i can find a way to build the win32-arm target. But the change looks fairly simple.
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I83552edd4ec61204a7e56f1adbd5a9c941bb52e5
Gerrit-Change-Number: 721
Gerrit-PatchSet: 1
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Luis Machado <luis.machado@linaro.org>
Gerrit-Comment-Date: Wed, 27 Nov 2019 01:03:26 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
^ permalink raw reply [flat|nested] 5+ messages in thread
* [review] Add read_pc / write_pc support to win32-low
2019-11-26 17:12 [review] Add read_pc / write_pc support to win32-low Tom Tromey (Code Review)
2019-11-27 1:03 ` Luis Machado (Code Review)
@ 2019-11-29 20:57 ` Pedro Alves (Code Review)
1 sibling, 0 replies; 5+ messages in thread
From: Pedro Alves (Code Review) @ 2019-11-29 20:57 UTC (permalink / raw)
To: Tom Tromey, gdb-patches; +Cc: Luis Machado
Pedro Alves has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/721
......................................................................
Patch Set 1: Code-Review+2
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I83552edd4ec61204a7e56f1adbd5a9c941bb52e5
Gerrit-Change-Number: 721
Gerrit-PatchSet: 1
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Luis Machado <luis.machado@linaro.org>
Gerrit-Reviewer: Pedro Alves <palves@redhat.com>
Gerrit-Comment-Date: Fri, 29 Nov 2019 20:57:30 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
^ permalink raw reply [flat|nested] 5+ messages in thread
* [review] Add read_pc / write_pc support to win32-low
2019-10-29 17:58 Tom Tromey (Code Review)
@ 2019-11-21 18:43 ` Pedro Alves (Code Review)
0 siblings, 0 replies; 5+ messages in thread
From: Pedro Alves (Code Review) @ 2019-11-21 18:43 UTC (permalink / raw)
To: Tom Tromey, gdb-patches
Pedro Alves has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/430
......................................................................
Patch Set 1: Code-Review+2
(4 comments)
LGTM. Minor nits below.
| --- gdb/gdbserver/win32-i386-low.c
| +++ gdb/gdbserver/win32-i386-low.c
| @@ -443,8 +443,42 @@ #else
| const char **expedite_regs = i386_expedite_regs;
| #endif
|
| init_target_desc (tdesc, expedite_regs);
|
| win32_tdesc = tdesc;
| }
|
| +static CORE_ADDR
| +i386_win32_get_pc (struct regcache *regcache)
PS1, Line 452:
Missing typical intro comment.
| +{
| + int use_64bit = register_size (regcache->tdesc, 0) == 8;
PS1, Line 454:
bool
| +
| + if (use_64bit)
| + {
| + uint64_t pc;
| +
| + collect_register_by_name (regcache, "rip", &pc);
| + return (CORE_ADDR) pc;
| + }
| + else
| + {
| + uint32_t pc;
| +
| + collect_register_by_name (regcache, "eip", &pc);
| + return (CORE_ADDR) pc;
| + }
| +}
| +
| +static void
| +i386_win32_set_pc (struct regcache *regcache, CORE_ADDR pc)
PS1, Line 473:
Ditto.
| +{
| + int use_64bit = register_size (regcache->tdesc, 0) == 8;
PS1, Line 475:
bool
| +
| + if (use_64bit)
| + {
| + uint64_t newpc = pc;
| +
| + supply_register_by_name (regcache, "rip", &newpc);
| + }
| + else
| + {
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I4dcb72f262b778c2db554f6ff9b675a35f14318b
Gerrit-Change-Number: 430
Gerrit-PatchSet: 1
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-Reviewer: Pedro Alves <palves@redhat.com>
Gerrit-Comment-Date: Thu, 21 Nov 2019 18:43:04 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
^ permalink raw reply [flat|nested] 5+ messages in thread
* [review] Add read_pc / write_pc support to win32-low
@ 2019-10-29 17:58 Tom Tromey (Code Review)
2019-11-21 18:43 ` Pedro Alves (Code Review)
0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey (Code Review) @ 2019-10-29 17:58 UTC (permalink / raw)
To: gdb-patches
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/430
......................................................................
Add read_pc / write_pc support to win32-low
This changes win32-low.c to implement the read_pc and write_pc
methods. A subsequent patch will need these.
Note that I have no way to test, or even compile, the win32-arm-low.c
change.
Change-Id: I83552edd4ec61204a7e56f1adbd5a9c941bb52e5
gdb/gdbserver/ChangeLog
2019-10-29 Tom Tromey <tromey@adacore.com>
* win32-low.c (win32_read_pc, win32_write_pc): New functions.
(win32_target_ops): Update.
* win32-i386-low.c (i386_win32_get_pc, i386_win32_set_pc): New
functions.
(the_low_target): Update.
* win32-arm-low.c (arm_win32_get_pc, arm_win32_set_pc): New
functions.
(the_low_target): Update.
Change-Id: I4dcb72f262b778c2db554f6ff9b675a35f14318b
---
M gdb/gdbserver/ChangeLog
M gdb/gdbserver/win32-arm-low.c
M gdb/gdbserver/win32-i386-low.c
M gdb/gdbserver/win32-low.c
M gdb/gdbserver/win32-low.h
5 files changed, 95 insertions(+), 2 deletions(-)
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index c36dcb0..fb2fbef 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,16 @@
2019-10-29 Tom Tromey <tromey@adacore.com>
+ * win32-low.c (win32_read_pc, win32_write_pc): New functions.
+ (win32_target_ops): Update.
+ * win32-i386-low.c (i386_win32_get_pc, i386_win32_set_pc): New
+ functions.
+ (the_low_target): Update.
+ * win32-arm-low.c (arm_win32_get_pc, arm_win32_set_pc): New
+ functions.
+ (the_low_target): Update.
+
+2019-10-29 Tom Tromey <tromey@adacore.com>
+
* win32-low.c (win32_kill, get_child_debug_event): Use
wait_for_debug_event.
diff --git a/gdb/gdbserver/win32-arm-low.c b/gdb/gdbserver/win32-arm-low.c
index c465aed..f2052c6 100644
--- a/gdb/gdbserver/win32-arm-low.c
+++ b/gdb/gdbserver/win32-arm-low.c
@@ -113,6 +113,23 @@
static const unsigned long arm_wince_breakpoint = 0xe6000010;
#define arm_wince_breakpoint_len 4
+static CORE_ADDR
+arm_win32_get_pc (struct regcache *regcache)
+{
+ uint32_t pc;
+
+ collect_register_by_name (regcache, "pc", &pc);
+ return (CORE_ADDR) pc;
+}
+
+static void
+arm_win32_set_pc (struct regcache *regcache, CORE_ADDR pc)
+{
+ uint32_t newpc = pc;
+
+ supply_register_by_name (regcache, "pc", &newpc);
+}
+
struct win32_target_ops the_low_target = {
arm_arch_setup,
sizeof (mappings) / sizeof (mappings[0]),
@@ -125,6 +142,8 @@
NULL, /* single_step */
(const unsigned char *) &arm_wince_breakpoint,
arm_wince_breakpoint_len,
+ arm_win32_get_pc,
+ arm_win32_set_pc,
/* Watchpoint related functions. See target.h for comments. */
NULL, /* supports_z_point_type */
NULL, /* insert_point */
diff --git a/gdb/gdbserver/win32-i386-low.c b/gdb/gdbserver/win32-i386-low.c
index b834b16..421f969 100644
--- a/gdb/gdbserver/win32-i386-low.c
+++ b/gdb/gdbserver/win32-i386-low.c
@@ -448,6 +448,46 @@
win32_tdesc = tdesc;
}
+static CORE_ADDR
+i386_win32_get_pc (struct regcache *regcache)
+{
+ int use_64bit = register_size (regcache->tdesc, 0) == 8;
+
+ if (use_64bit)
+ {
+ uint64_t pc;
+
+ collect_register_by_name (regcache, "rip", &pc);
+ return (CORE_ADDR) pc;
+ }
+ else
+ {
+ uint32_t pc;
+
+ collect_register_by_name (regcache, "eip", &pc);
+ return (CORE_ADDR) pc;
+ }
+}
+
+static void
+i386_win32_set_pc (struct regcache *regcache, CORE_ADDR pc)
+{
+ int use_64bit = register_size (regcache->tdesc, 0) == 8;
+
+ if (use_64bit)
+ {
+ uint64_t newpc = pc;
+
+ supply_register_by_name (regcache, "rip", &newpc);
+ }
+ else
+ {
+ uint32_t newpc = pc;
+
+ supply_register_by_name (regcache, "eip", &newpc);
+ }
+}
+
struct win32_target_ops the_low_target = {
i386_arch_setup,
sizeof (mappings) / sizeof (mappings[0]),
@@ -460,6 +500,8 @@
i386_single_step,
&i386_win32_breakpoint,
i386_win32_breakpoint_len,
+ i386_win32_get_pc,
+ i386_win32_set_pc,
i386_supports_z_point_type,
i386_insert_point,
i386_remove_point,
diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c
index 10b14df..14bd79f 100644
--- a/gdb/gdbserver/win32-low.c
+++ b/gdb/gdbserver/win32-low.c
@@ -1585,6 +1585,22 @@
return the_low_target.breakpoint;
}
+/* Implementation of the target_ops method "read_pc". */
+
+static CORE_ADDR
+win32_read_pc (struct regcache *regcache)
+{
+ return (*the_low_target.get_pc) (regcache);
+}
+
+/* Implementation of the target_ops method "write_pc". */
+
+static void
+win32_write_pc (struct regcache *regcache, CORE_ADDR pc)
+{
+ return (*the_low_target.set_pc) (regcache, pc);
+}
+
static struct target_ops win32_target_ops = {
win32_create_inferior,
NULL, /* post_create_inferior */
@@ -1637,8 +1653,8 @@
NULL, /* read_loadmap */
NULL, /* process_qsupported */
NULL, /* supports_tracepoints */
- NULL, /* read_pc */
- NULL, /* write_pc */
+ win32_read_pc,
+ win32_write_pc,
NULL, /* thread_stopped */
win32_get_tib_address,
NULL, /* pause_all */
diff --git a/gdb/gdbserver/win32-low.h b/gdb/gdbserver/win32-low.h
index 5a94686..73ceb4b 100644
--- a/gdb/gdbserver/win32-low.h
+++ b/gdb/gdbserver/win32-low.h
@@ -63,6 +63,11 @@
const unsigned char *breakpoint;
int breakpoint_len;
+ /* Get the PC register from REGCACHE. */
+ CORE_ADDR (*get_pc) (struct regcache *regcache);
+ /* Set the PC register in REGCACHE. */
+ void (*set_pc) (struct regcache *regcache, CORE_ADDR newpc);
+
/* Breakpoint/Watchpoint related functions. See target.h for comments. */
int (*supports_z_point_type) (char z_type);
int (*insert_point) (enum raw_bkpt_type type, CORE_ADDR addr,
--
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I4dcb72f262b778c2db554f6ff9b675a35f14318b
Gerrit-Change-Number: 430
Gerrit-PatchSet: 1
Gerrit-Owner: Tom Tromey <tromey@sourceware.org>
Gerrit-MessageType: newchange
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-11-29 20:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-26 17:12 [review] Add read_pc / write_pc support to win32-low Tom Tromey (Code Review)
2019-11-27 1:03 ` Luis Machado (Code Review)
2019-11-29 20:57 ` Pedro Alves (Code Review)
-- strict thread matches above, loose matches on Subject: below --
2019-10-29 17:58 Tom Tromey (Code Review)
2019-11-21 18:43 ` Pedro Alves (Code Review)
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).