+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.
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:
+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.
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);
+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.
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);
+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
#include "sim-main.h"
#include "sim-assert.h"
+#include "sim-cpu.h"
#include "libiberty.h"
#include <string.h>
watch_sim_le_4,
watch_sim_le_8,
+ /* pc */
+ watch_pc,
+
/* wallclock */
watch_clock,
#endif
+#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,
}
#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);
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.
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,
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? */
+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.
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);
+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.
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);
+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.
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);
+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.
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. */
+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.
* Makefile.in, config.in, configure, configure.in: New files.
* gencode.c, interp.c, mn10300_sim.h, simops.c: New files.
-
/* 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;
+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.
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);
+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.
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;