aboutsummaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2015-03-23 00:44:54 -0400
committerMike Frysinger <vapier@gentoo.org>2021-02-06 12:12:51 -0500
commit4c0d76b9c420bb29cb3365c5edc9c78c50d2b231 (patch)
tree1cbf362654cf185294337a5f27e6d3c94fdb9d65 /sim
parentcd89c53f6d475cd05a1858b9195770e347fb2e9e (diff)
downloadgdb-4c0d76b9c420bb29cb3365c5edc9c78c50d2b231.zip
gdb-4c0d76b9c420bb29cb3365c5edc9c78c50d2b231.tar.gz
gdb-4c0d76b9c420bb29cb3365c5edc9c78c50d2b231.tar.bz2
sim: watchpoints: use common sim_pc_get
Few arches implement STATE_WATCHPOINTS()->pc while all of them implement sim_pc_get. Lets switch the sim-watch core for monitoring pc events to the sim_pc_get API so this module works for all ports, and then we can delete this old back channel of snooping in the port's cpu state -- the code needs the pointer to the pc storage so that it can read out bytes and compare them to the watchrange. This also fixes the logic on multi-cpu sims by removing the limitation of only being able to watch CPU0's state.
Diffstat (limited to 'sim')
-rw-r--r--sim/ChangeLog4
-rw-r--r--sim/README-HACKING4
-rw-r--r--sim/avr/ChangeLog4
-rw-r--r--sim/avr/interp.c6
-rw-r--r--sim/bfin/ChangeLog4
-rw-r--r--sim/bfin/interp.c6
-rw-r--r--sim/common/ChangeLog11
-rw-r--r--sim/common/sim-events.c58
-rw-r--r--sim/common/sim-events.h11
-rw-r--r--sim/common/sim-watch.c16
-rw-r--r--sim/common/sim-watch.h1
-rw-r--r--sim/frv/ChangeLog4
-rw-r--r--sim/frv/sim-if.c8
-rw-r--r--sim/iq2000/ChangeLog4
-rw-r--r--sim/iq2000/sim-if.c8
-rw-r--r--sim/m32r/ChangeLog4
-rw-r--r--sim/m32r/sim-if.c8
-rw-r--r--sim/mips/ChangeLog4
-rw-r--r--sim/mips/interp.c1
-rw-r--r--sim/mn10300/ChangeLog5
-rw-r--r--sim/mn10300/interp.c1
-rw-r--r--sim/moxie/ChangeLog4
-rw-r--r--sim/moxie/interp.c2
-rw-r--r--sim/v850/ChangeLog4
-rw-r--r--sim/v850/interp.c1
25 files changed, 129 insertions, 54 deletions
diff --git a/sim/ChangeLog b/sim/ChangeLog
index e982291..0c53c96 100644
--- a/sim/ChangeLog
+++ b/sim/ChangeLog
@@ -1,5 +1,9 @@
2021-02-06 Mike Frysinger <vapier@gentoo.org>
+ * README-HACKING: Replace STATE_WATCHPOINTS with CPU_PC_FETCH.
+
+2021-02-06 Mike Frysinger <vapier@gentoo.org>
+
* configure.ac (HDEFINES): Delete AC_SUBST call.
* configure: Regenerate.
diff --git a/sim/README-HACKING b/sim/README-HACKING
index 9953f99..2f985bd 100644
--- a/sim/README-HACKING
+++ b/sim/README-HACKING
@@ -267,8 +267,8 @@ And in your insn fetcher:
PROFILE_COUNT_CORE (cpu, target_addr, size_in_bytes, map_exec);
To use the PC profiling code, you simply have to tell the system where to find
-your simulator's PC. So in your sim_open() function:
- STATE_WATCHPOINTS (sd)->pc = address_of_cpu0_pc;
+your simulator's PC. So in your model initialization function:
+ CPU_PC_FETCH (cpu) = function_that_fetches_the_pc;
To profile branches, in every location where a branch insn is executed, call
one of the related helpers:
diff --git a/sim/avr/ChangeLog b/sim/avr/ChangeLog
index 505e284..b67888b 100644
--- a/sim/avr/ChangeLog
+++ b/sim/avr/ChangeLog
@@ -1,5 +1,9 @@
2021-02-06 Mike Frysinger <vapier@gentoo.org>
+ * interp.c (sim_open): Delete call to STATE_WATCHPOINTS.
+
+2021-02-06 Mike Frysinger <vapier@gentoo.org>
+
* configure: Regenerate.
2021-01-30 Mike Frysinger <vapier@gentoo.org>
diff --git a/sim/avr/interp.c b/sim/avr/interp.c
index ba89eb5..cce84a9 100644
--- a/sim/avr/interp.c
+++ b/sim/avr/interp.c
@@ -1690,12 +1690,6 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
return 0;
}
- {
- /* XXX: Only first core gets profiled ? */
- SIM_CPU *cpu = STATE_CPU (sd, 0);
- STATE_WATCHPOINTS (sd)->pc = &cpu->pc;
- }
-
if (sim_pre_argv_init (sd, argv[0]) != SIM_RC_OK)
{
free_state (sd);
diff --git a/sim/bfin/ChangeLog b/sim/bfin/ChangeLog
index ee76d3e..7643141 100644
--- a/sim/bfin/ChangeLog
+++ b/sim/bfin/ChangeLog
@@ -1,5 +1,9 @@
2021-02-06 Mike Frysinger <vapier@gentoo.org>
+ * interp.c (sim_open): Delete call to STATE_WATCHPOINTS.
+
+2021-02-06 Mike Frysinger <vapier@gentoo.org>
+
* configure: Regenerate.
2021-01-30 Mike Frysinger <vapier@gentoo.org>
diff --git a/sim/bfin/interp.c b/sim/bfin/interp.c
index ef23de3..ceb5939 100644
--- a/sim/bfin/interp.c
+++ b/sim/bfin/interp.c
@@ -729,12 +729,6 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback,
return 0;
}
- {
- /* XXX: Only first core gets profiled ? */
- SIM_CPU *cpu = STATE_CPU (sd, 0);
- STATE_WATCHPOINTS (sd)->pc = &PCREG;
- }
-
if (sim_pre_argv_init (sd, argv[0]) != SIM_RC_OK)
{
free_state (sd);
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index 1351cd0..ba0febf 100644
--- a/sim/common/ChangeLog
+++ b/sim/common/ChangeLog
@@ -1,5 +1,16 @@
2021-02-06 Mike Frysinger <vapier@gentoo.org>
+ * sim-events.c: Include sim-cpu.h.
+ (sim_event_watchpoints): Define watch_pc.
+ (sim_events_watch_pc): New function.
+ (WATCH_SIM): Handle watch_pc.
+ * sim-events.h (sim_events_watch_pc): New prototype.
+ * sim-watch.c (schedule_watchpoint): Replace sim_events_watch_sim with
+ sim_events_watch_pc.
+ * sim-watch.h (sim_watchpoints): Delete pc.
+
+2021-02-06 Mike Frysinger <vapier@gentoo.org>
+
* acinclude.m4 (SIM_AC_COMMON): Replace AC_CONFIG_HEADER with
AC_CONFIG_HEADERS.
diff --git a/sim/common/sim-events.c b/sim/common/sim-events.c
index 6dd0474..207c867 100644
--- a/sim/common/sim-events.c
+++ b/sim/common/sim-events.c
@@ -25,6 +25,7 @@
#include "sim-main.h"
#include "sim-assert.h"
+#include "sim-cpu.h"
#include "libiberty.h"
#include <string.h>
@@ -66,6 +67,9 @@ typedef enum {
watch_sim_le_4,
watch_sim_le_8,
+ /* pc */
+ watch_pc,
+
/* wallclock */
watch_clock,
@@ -610,6 +614,45 @@ sim_events_watch_clock (SIM_DESC sd,
#if EXTERN_SIM_EVENTS_P
sim_event *
+sim_events_watch_pc (SIM_DESC sd,
+ int is_within,
+ unsigned64 lb,
+ unsigned64 ub,
+ sim_event_handler *handler,
+ void *data)
+{
+ sim_events *events = STATE_EVENTS (sd);
+ sim_event *new_event = sim_events_zalloc (sd);
+ /* type */
+ new_event->watching = watch_pc;
+ /* handler */
+ new_event->data = data;
+ new_event->handler = handler;
+ /* data */
+ new_event->lb = lb;
+ new_event->lb64 = lb;
+ new_event->ub = ub;
+ new_event->ub64 = ub;
+ new_event->is_within = (is_within != 0);
+ /* insert */
+ new_event->next = events->watchpoints;
+ events->watchpoints = new_event;
+ events->work_pending = 1;
+ ETRACE ((_ETRACE,
+ "event watching pc at %ld - tag 0x%lx - pc 0x%lx..0x%lx, handler 0x%lx, data 0x%lx\n",
+ (long)sim_events_time (sd),
+ (long)new_event,
+ (long)new_event->lb,
+ (long)new_event->ub,
+ (long)new_event->handler,
+ (long)new_event->data));
+ return new_event;
+}
+#endif
+
+
+#if EXTERN_SIM_EVENTS_P
+sim_event *
sim_events_watch_sim (SIM_DESC sd,
void *host_addr,
int nr_bytes,
@@ -965,6 +1008,21 @@ sim_watch_valid (SIM_DESC sd,
}
#undef WATCH_SIM
+ case watch_pc:
+ {
+ int c;
+
+ for (c = 0; c < MAX_NR_PROCESSORS; ++c)
+ {
+ sim_cpu *cpu = STATE_CPU (sd, c);
+ sim_cia cia = sim_pc_get (cpu);
+
+ if (to_do->is_within == (cia >= to_do->lb64 && cia <= to_do->ub64))
+ return 1;
+ }
+ return 0;
+ }
+
case watch_clock: /* wallclock */
{
unsigned long elapsed_time = sim_events_elapsed_time (sd);
diff --git a/sim/common/sim-events.h b/sim/common/sim-events.h
index 823fd8c..7a5fc96 100644
--- a/sim/common/sim-events.h
+++ b/sim/common/sim-events.h
@@ -149,6 +149,17 @@ extern sim_event *sim_events_watch_clock
void *data);
+/* Schedule an event when a PC matches a range. */
+
+extern sim_event *sim_events_watch_pc
+(SIM_DESC sd,
+ int is_within,
+ unsigned64 lb,
+ unsigned64 ub,
+ sim_event_handler *handler,
+ void *data);
+
+
/* Schedule an event when the test (IS_WITHIN == (VAL >= LB && VAL <=
UB)) of the NR_BYTES value at HOST_ADDR with BYTE_ORDER endian is
true.
diff --git a/sim/common/sim-watch.c b/sim/common/sim-watch.c
index 9ccd472..8630b06 100644
--- a/sim/common/sim-watch.c
+++ b/sim/common/sim-watch.c
@@ -167,18 +167,16 @@ schedule_watchpoint (SIM_DESC sd,
sim_watch_point *point)
{
sim_watchpoints *watch = STATE_WATCHPOINTS (sd);
+
switch (point->type)
{
case pc_watchpoint:
- point->event = sim_events_watch_sim (sd,
- watch->pc,
- sizeof (sim_cia),
- HOST_BYTE_ORDER,
- point->is_within,
- point->arg0, point->arg1,
- /* PC in arg0..arg1 */
- handle_watchpoint,
- point);
+ point->event = sim_events_watch_pc (sd,
+ point->is_within,
+ point->arg0, point->arg1,
+ /* PC in arg0..arg1 */
+ handle_watchpoint,
+ point);
return SIM_RC_OK;
case clock_watchpoint:
point->event = sim_events_watch_clock (sd,
diff --git a/sim/common/sim-watch.h b/sim/common/sim-watch.h
index 52a8d12..bbe2029 100644
--- a/sim/common/sim-watch.h
+++ b/sim/common/sim-watch.h
@@ -49,7 +49,6 @@ typedef struct _sim_watchpoints {
address/size of the program-counter */
/* FIXME: In the future this shall be generalized so that any of the
N processors M registers can be watched */
- void *pc;
/* Pointer to the handler for interrupt watchpoints */
/* FIXME: can this be done better? */
diff --git a/sim/frv/ChangeLog b/sim/frv/ChangeLog
index 47c4bea..1223fe1 100644
--- a/sim/frv/ChangeLog
+++ b/sim/frv/ChangeLog
@@ -1,5 +1,9 @@
2021-02-06 Mike Frysinger <vapier@gentoo.org>
+ * sim-if.c (sim_open): Delete call to STATE_WATCHPOINTS.
+
+2021-02-06 Mike Frysinger <vapier@gentoo.org>
+
* configure: Regenerate.
2021-01-30 Mike Frysinger <vapier@gentoo.org>
diff --git a/sim/frv/sim-if.c b/sim/frv/sim-if.c
index bea8400..45cbd16 100644
--- a/sim/frv/sim-if.c
+++ b/sim/frv/sim-if.c
@@ -61,14 +61,6 @@ sim_open (kind, callback, abfd, argv)
return 0;
}
-#if 0 /* FIXME: pc is in mach-specific struct */
- /* FIXME: watchpoints code shouldn't need this */
- {
- SIM_CPU *current_cpu = STATE_CPU (sd, 0);
- STATE_WATCHPOINTS (sd)->pc = &(PC);
- }
-#endif
-
if (sim_pre_argv_init (sd, argv[0]) != SIM_RC_OK)
{
free_state (sd);
diff --git a/sim/iq2000/ChangeLog b/sim/iq2000/ChangeLog
index d5816bf..7ab017f 100644
--- a/sim/iq2000/ChangeLog
+++ b/sim/iq2000/ChangeLog
@@ -1,5 +1,9 @@
2021-02-06 Mike Frysinger <vapier@gentoo.org>
+ * sim-if.c (sim_open): Delete call to STATE_WATCHPOINTS.
+
+2021-02-06 Mike Frysinger <vapier@gentoo.org>
+
* configure: Regenerate.
2021-01-30 Mike Frysinger <vapier@gentoo.org>
diff --git a/sim/iq2000/sim-if.c b/sim/iq2000/sim-if.c
index de90e73..496b106 100644
--- a/sim/iq2000/sim-if.c
+++ b/sim/iq2000/sim-if.c
@@ -67,14 +67,6 @@ sim_open (kind, callback, abfd, argv)
return 0;
}
-#if 0 /* FIXME: pc is in mach-specific struct */
- /* FIXME: watchpoints code shouldn't need this */
- {
- SIM_CPU *current_cpu = STATE_CPU (sd, 0);
- STATE_WATCHPOINTS (sd)->pc = &(PC);
- }
-#endif
-
if (sim_pre_argv_init (sd, argv[0]) != SIM_RC_OK)
{
free_state (sd);
diff --git a/sim/m32r/ChangeLog b/sim/m32r/ChangeLog
index b3b5823..42c3506 100644
--- a/sim/m32r/ChangeLog
+++ b/sim/m32r/ChangeLog
@@ -1,5 +1,9 @@
2021-02-06 Mike Frysinger <vapier@gentoo.org>
+ * sim-if.c (sim_open): Delete call to STATE_WATCHPOINTS.
+
+2021-02-06 Mike Frysinger <vapier@gentoo.org>
+
* configure: Regenerate.
2021-01-30 Mike Frysinger <vapier@gentoo.org>
diff --git a/sim/m32r/sim-if.c b/sim/m32r/sim-if.c
index 2d2f5e4..58d4694 100644
--- a/sim/m32r/sim-if.c
+++ b/sim/m32r/sim-if.c
@@ -61,14 +61,6 @@ sim_open (kind, callback, abfd, argv)
return 0;
}
-#if 0 /* FIXME: pc is in mach-specific struct */
- /* FIXME: watchpoints code shouldn't need this */
- {
- SIM_CPU *current_cpu = STATE_CPU (sd, 0);
- STATE_WATCHPOINTS (sd)->pc = &(PC);
- }
-#endif
-
if (sim_pre_argv_init (sd, argv[0]) != SIM_RC_OK)
{
free_state (sd);
diff --git a/sim/mips/ChangeLog b/sim/mips/ChangeLog
index 1fb767c..b3da89b 100644
--- a/sim/mips/ChangeLog
+++ b/sim/mips/ChangeLog
@@ -1,5 +1,9 @@
2021-02-06 Mike Frysinger <vapier@gentoo.org>
+ * interp.c (sim_open): Delete call to STATE_WATCHPOINTS.
+
+2021-02-06 Mike Frysinger <vapier@gentoo.org>
+
* configure: Regenerate.
2021-01-30 Mike Frysinger <vapier@gentoo.org>
diff --git a/sim/mips/interp.c b/sim/mips/interp.c
index 852f362..fd93a12 100644
--- a/sim/mips/interp.c
+++ b/sim/mips/interp.c
@@ -355,7 +355,6 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
cpu = STATE_CPU (sd, 0); /* FIXME */
/* FIXME: watchpoints code shouldn't need this */
- STATE_WATCHPOINTS (sd)->pc = &(PC);
STATE_WATCHPOINTS (sd)->interrupt_handler = interrupt_event;
/* Initialize the mechanism for doing insn profiling. */
diff --git a/sim/mn10300/ChangeLog b/sim/mn10300/ChangeLog
index 44f8cbe..7eefac9 100644
--- a/sim/mn10300/ChangeLog
+++ b/sim/mn10300/ChangeLog
@@ -1,5 +1,9 @@
2021-02-06 Mike Frysinger <vapier@gentoo.org>
+ * interp.c (sim_open): Delete call to STATE_WATCHPOINTS.
+
+2021-02-06 Mike Frysinger <vapier@gentoo.org>
+
* configure: Regenerate.
2021-01-30 Mike Frysinger <vapier@gentoo.org>
@@ -1573,4 +1577,3 @@ Mon Nov 25 12:46:38 1996 Jeffrey A Law (law@cygnus.com)
* Makefile.in, config.in, configure, configure.in: New files.
* gencode.c, interp.c, mn10300_sim.h, simops.c: New files.
-
diff --git a/sim/mn10300/interp.c b/sim/mn10300/interp.c
index c41797a..1c9c690 100644
--- a/sim/mn10300/interp.c
+++ b/sim/mn10300/interp.c
@@ -102,7 +102,6 @@ sim_open (SIM_OPEN_KIND kind,
/* FIXME: should be better way of setting up interrupts. For
moment, only support watchpoints causing a breakpoint (gdb
halt). */
- STATE_WATCHPOINTS (sd)->pc = &(PC);
STATE_WATCHPOINTS (sd)->interrupt_handler = NULL;
STATE_WATCHPOINTS (sd)->interrupt_names = NULL;
diff --git a/sim/moxie/ChangeLog b/sim/moxie/ChangeLog
index 193933d..a1206bd 100644
--- a/sim/moxie/ChangeLog
+++ b/sim/moxie/ChangeLog
@@ -1,5 +1,9 @@
2021-02-06 Mike Frysinger <vapier@gentoo.org>
+ * interp.c (sim_open): Delete call to STATE_WATCHPOINTS.
+
+2021-02-06 Mike Frysinger <vapier@gentoo.org>
+
* configure: Regenerate.
2021-01-31 Mike Frysinger <vapier@gentoo.org>
diff --git a/sim/moxie/interp.c b/sim/moxie/interp.c
index 87e1c15..da97397 100644
--- a/sim/moxie/interp.c
+++ b/sim/moxie/interp.c
@@ -1203,8 +1203,6 @@ sim_open (SIM_OPEN_KIND kind, host_callback *cb,
return 0;
}
- STATE_WATCHPOINTS (sd)->pc = &cpu.asregs.regs[PC_REGNO];
-
if (sim_pre_argv_init (sd, argv[0]) != SIM_RC_OK)
{
free_state (sd);
diff --git a/sim/v850/ChangeLog b/sim/v850/ChangeLog
index 5085030..d981a02 100644
--- a/sim/v850/ChangeLog
+++ b/sim/v850/ChangeLog
@@ -1,5 +1,9 @@
2021-02-06 Mike Frysinger <vapier@gentoo.org>
+ * interp.c (sim_open): Delete call to STATE_WATCHPOINTS.
+
+2021-02-06 Mike Frysinger <vapier@gentoo.org>
+
* configure: Regenerate.
2021-01-31 Mike Frysinger <vapier@gentoo.org>
diff --git a/sim/v850/interp.c b/sim/v850/interp.c
index 24d7ddc..76ecab7 100644
--- a/sim/v850/interp.c
+++ b/sim/v850/interp.c
@@ -202,7 +202,6 @@ sim_open (SIM_OPEN_KIND kind,
simulator = sd;
/* FIXME: should be better way of setting up interrupts */
- STATE_WATCHPOINTS (sd)->pc = &(PC);
STATE_WATCHPOINTS (sd)->interrupt_handler = do_interrupt;
STATE_WATCHPOINTS (sd)->interrupt_names = interrupt_names;