* tracepoint.h (set_traceframe_number)

(cleanup_restore_current_traceframe): Declare.
	* tracepoint.c (set_traceframe_number): New.
	(struct current_traceframe_cleanup): New.
	(do_restore_current_traceframe_cleanup)
	(restore_current_traceframe_cleanup_dtor)
	(make_cleanup_restore_current_traceframe): New.
	* infrun.c: Include tracepoint.h.
	(fetch_inferior_event): Switch out and in of tfind mode.
This commit is contained in:
Pedro Alves 2010-02-24 01:06:28 +00:00
parent ab92d69b1e
commit 06cd862c01
4 changed files with 88 additions and 0 deletions

View file

@ -2538,6 +2538,67 @@ get_traceframe_number (void)
return traceframe_number;
}
/* Make the traceframe NUM be the current trace frame. Does nothing
if NUM is already current. */
void
set_traceframe_number (int num)
{
int newnum;
if (traceframe_number == num)
{
/* Nothing to do. */
return;
}
newnum = target_trace_find (tfind_number, num, 0, 0, NULL);
if (newnum != num)
warning (_("could not change traceframe"));
traceframe_number = newnum;
/* Changing the traceframe changes our view of registers and of the
frame chain. */
registers_changed ();
}
/* A cleanup used when switching away and back from tfind mode. */
struct current_traceframe_cleanup
{
/* The traceframe we were inspecting. */
int traceframe_number;
};
static void
do_restore_current_traceframe_cleanup (void *arg)
{
struct current_traceframe_cleanup *old = arg;
set_traceframe_number (old->traceframe_number);
}
static void
restore_current_traceframe_cleanup_dtor (void *arg)
{
struct current_traceframe_cleanup *old = arg;
xfree (old);
}
struct cleanup *
make_cleanup_restore_current_traceframe (void)
{
struct current_traceframe_cleanup *old;
old = xmalloc (sizeof (struct current_traceframe_cleanup));
old->traceframe_number = traceframe_number;
return make_cleanup_dtor (do_restore_current_traceframe_cleanup, old,
restore_current_traceframe_cleanup_dtor);
}
/* Given a number and address, return an uploaded tracepoint with that
number, creating if necessary. */