X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=sim%2Fcommon%2Fsim-events.h;h=60f331558fa2312e0c133fd6481eb2e8fc4e6c6d;hb=b0b8c9e07a7ee9e5d6d4c6d2757da921071add7f;hp=8c419276f837d1e063e4afc48821d3a0652a8e02;hpb=f03b093cd34bc352ad89334a43a34b00a5e5c60c;p=deliverable%2Fbinutils-gdb.git diff --git a/sim/common/sim-events.h b/sim/common/sim-events.h index 8c419276f8..60f331558f 100644 --- a/sim/common/sim-events.h +++ b/sim/common/sim-events.h @@ -1,26 +1,29 @@ -/* This file is part of the program psim. +/* The common simulator framework for GDB, the GNU Debugger. - Copyright (C) 1994-1997, Andrew Cagney + Copyright 2002, 2007 Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + Contributed by Andrew Cagney and Red Hat. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - */ + This file is part of GDB. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -#ifndef _SIM_EVENTS_H_ -#define _SIM_EVENTS_H_ + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + + +#ifndef SIM_EVENTS_H +#define SIM_EVENTS_H /* Notes: @@ -75,17 +78,22 @@ typedef struct _sim_event sim_event; typedef struct _sim_events sim_events; struct _sim_events { - int processing; + int nr_ticks_to_process; sim_event *queue; sim_event *watchpoints; sim_event *watchedpoints; + sim_event *free_list; /* flag additional work needed */ volatile int work_pending; /* the asynchronous event queue */ - sim_event *volatile held; - sim_event *volatile *volatile held_end; +#ifndef MAX_NR_SIGNAL_SIM_EVENTS +#define MAX_NR_SIGNAL_SIM_EVENTS 2 +#endif + sim_event *held; + volatile int nr_held; /* timekeeping */ - SIM_ELAPSED_TIME initial_wallclock; + unsigned long elapsed_wallclock; + SIM_ELAPSED_TIME resume_wallclock; signed64 time_of_event; int time_from_event; int trace; @@ -95,102 +103,96 @@ struct _sim_events { /* Install the "events" module. */ -EXTERN_SIM_EVENTS\ -(SIM_RC) sim_events_install (SIM_DESC sd); - - -/* Uninstall the "events" subsystem. */ +extern SIM_RC sim_events_install (SIM_DESC sd); -EXTERN_SIM_EVENTS\ -(void) -sim_events_uninstall (SIM_DESC sd); +/* Schedule an event DELTA_TIME ticks into the future */ - -/* Initialization */ - -EXTERN_SIM_EVENTS\ -(SIM_RC) sim_events_init (SIM_DESC sd); - - -/* Set Tracing Level */ - -EXTERN_SIM_EVENTS\ -(void) sim_events_set_trace +extern sim_event *sim_events_schedule (SIM_DESC sd, - int level); - + signed64 delta_time, + sim_event_handler *handler, + void *data); -/* Schedule an event DELTA_TIME ticks into the future */ +extern sim_event *sim_events_schedule_tracef +(SIM_DESC sd, + signed64 delta_time, + sim_event_handler *handler, + void *data, + const char *fmt, + ...) __attribute__ ((format (printf, 5, 6))); -EXTERN_SIM_EVENTS\ -(sim_event *) sim_events_schedule +extern sim_event *sim_events_schedule_vtracef (SIM_DESC sd, signed64 delta_time, sim_event_handler *handler, - void *data); + void *data, + const char *fmt, + va_list ap); -EXTERN_SIM_EVENTS\ -(sim_event *) sim_events_schedule_after_signal + +extern void sim_events_schedule_after_signal (SIM_DESC sd, signed64 delta_time, sim_event_handler *handler, void *data); +/* NB: signal level events can't have trace strings as malloc isn't + available */ + + -/* Schedule an event WALLCLOCK milli-seconds from the start of the - simulation. The exact interpretation of wallclock is host - dependant. */ +/* Schedule an event milli-seconds from NOW. The exact interpretation + of wallclock is host dependant. */ -EXTERN_SIM_EVENTS\ -(sim_event *) sim_events_watch_clock +extern sim_event *sim_events_watch_clock (SIM_DESC sd, - unsigned wallclock_ms_time, + unsigned delta_ms_time, sim_event_handler *handler, void *data); -/* Schedule an event when the NR_BYTES value at HOST_ADDR with - BYTE_ORDER lies within LB..UB (unsigned). +/* 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. HOST_ADDR: pointer into the host address space. BYTE_ORDER: 0 - host endian; BIG_ENDIAN; LITTLE_ENDIAN */ -EXTERN_SIM_EVENTS\ -(sim_event*) sim_events_watch_sim +extern sim_event *sim_events_watch_sim (SIM_DESC sd, void *host_addr, int nr_bytes, int byte_order, + int is_within, unsigned64 lb, unsigned64 ub, sim_event_handler *handler, void *data); -/* Schedule an event when the NR_BYTES value at CORE_ADDR with BYTE_ORDER - lies between LB..UB. +/* Schedule an event when the test (IS_WITHIN == (VAL >= LB && VAL <= + UB)) of the NR_BYTES value at CORE_ADDR in BYTE_ORDER endian is + true. CORE_ADDR/MAP: pointer into the target address space. BYTE_ORDER: 0 - current target endian; BIG_ENDIAN; LITTLE_ENDIAN */ -EXTERN_SIM_EVENTS\ -(sim_event*) sim_events_watch_core +extern sim_event *sim_events_watch_core (SIM_DESC sd, address_word core_addr, - sim_core_maps core_map, + unsigned map, int nr_bytes, int byte_order, + int is_within, unsigned64 lb, unsigned64 ub, sim_event_handler *handler, void *data); - /* Deschedule the specified event */ -EXTERN_SIM_EVENTS\ -(void) sim_events_deschedule +extern void sim_events_deschedule (SIM_DESC sd, sim_event *event_to_remove); @@ -199,7 +201,7 @@ EXTERN_SIM_EVENTS\ is not event processing. If the simulator halted part way through event processing then both - EVENTS_WERE_LAST and EVENTS_WERE_FIRST shall be true. + EVENTS_WERE_LAST and EVENTS_WERE_NEXT shall be true. If the simulator halted after processing the last cpu, then only EVENTS_WERE_NEXT shall be true. */ @@ -211,24 +213,68 @@ INLINE_SIM_EVENTS\ int events_were_next); -/* Progress time - separated into two parts so that the main loop can - save its context before the event queue is processed */ +/* Progress time. + + Separated into two parts so that the main loop can save its context + before the event queue is processed. When sim_events_tick*() + returns true, any simulation context should be saved and + sim_events_process() called. + + SIM_EVENTS_TICK advances the clock by 1 cycle. + + SIM_EVENTS_TICKN advances the clock by N cycles (1..MAXINT). */ INLINE_SIM_EVENTS\ (int) sim_events_tick (SIM_DESC sd); +INLINE_SIM_EVENTS\ +(int) sim_events_tickn +(SIM_DESC sd, + int n); + INLINE_SIM_EVENTS\ (void) sim_events_process (SIM_DESC sd); +/* Advance the clock by an additional SLIP cycles at the next call to + sim_events_tick*(). For multiple calls, the effect is + accumulative. */ + +INLINE_SIM_EVENTS\ +(void) sim_events_slip +(SIM_DESC sd, + int slip); + + +/* Progress time such that an event shall occur upon the next call to + sim_events tick */ -/* local concept of time */ +#if 0 +INLINE_SIM_EVENTS\ +(void) sim_events_timewarp +(SIM_DESC sd); +#endif + + +/* local concept of elapsed target time */ INLINE_SIM_EVENTS\ (signed64) sim_events_time (SIM_DESC sd); +/* local concept of elapsed host time (milliseconds) */ + +INLINE_SIM_EVENTS\ +(unsigned long) sim_events_elapsed_time +(SIM_DESC sd); + +/* Returns the time that remains before the event is raised. */ +INLINE_SIM_EVENTS\ +(signed64) sim_events_remain_time +(SIM_DESC sd, sim_event *event); + + #endif