diff options
Diffstat (limited to 'gdb/tracepoint.c')
-rw-r--r-- | gdb/tracepoint.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index f38d6c1..1d2785f 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -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. */ |