aboutsummaryrefslogtreecommitdiff
path: root/gdb/tracepoint.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2010-02-24 01:06:28 +0000
committerPedro Alves <palves@redhat.com>2010-02-24 01:06:28 +0000
commit06cd862c015ff7285816de9e36290b5b1a7b090e (patch)
treed053a8ccb0bdadc5088e59e7728b7f4a2961b66f /gdb/tracepoint.c
parentab92d69b1e3a3db7bd4f9564ad3b5bbccc9a7988 (diff)
downloadfsf-binutils-gdb-06cd862c015ff7285816de9e36290b5b1a7b090e.zip
fsf-binutils-gdb-06cd862c015ff7285816de9e36290b5b1a7b090e.tar.gz
fsf-binutils-gdb-06cd862c015ff7285816de9e36290b5b1a7b090e.tar.bz2
* 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.
Diffstat (limited to 'gdb/tracepoint.c')
-rw-r--r--gdb/tracepoint.c61
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. */