aboutsummaryrefslogtreecommitdiff
path: root/gdb/record-btrace.c
diff options
context:
space:
mode:
authorTim Wiederhake <tim.wiederhake@intel.com>2016-07-25 10:57:06 +0200
committerTim Wiederhake <tim.wiederhake@intel.com>2016-07-25 11:03:43 +0200
commitc0272db5854a799a9f3bb3803c3d03d1a62b9ac2 (patch)
treeebd295aa3734c916316b96ed8a1481e5d13c6c39 /gdb/record-btrace.c
parent95804507f2645c1cce29f2e1a33031accaa6aa24 (diff)
downloadgdb-c0272db5854a799a9f3bb3803c3d03d1a62b9ac2.zip
gdb-c0272db5854a799a9f3bb3803c3d03d1a62b9ac2.tar.gz
gdb-c0272db5854a799a9f3bb3803c3d03d1a62b9ac2.tar.bz2
btrace: Resume recording after disconnect.
This patch allows gdbserver to continue recording after disconnect. On reconnect, the recorded data is accessible to gdb as if no disconnect happened. A possible application for this feature is remotely examine bugs that occur at irregular intervals, where maintaining a gdb connection is inconvenient. This also fixes the issue mentioned here: https://sourceware.org/ml/gdb-patches/2015-11/msg00424.html Signed-off-by: Tim Wiederhake <tim.wiederhake@intel.com> gdb/ChangeLog: * NEWS: Resume btrace on reconnect. * record-btrace.c: Added record-btrace.h include. (record_btrace_open): Split into this and ... (record_btrace_push_target): ... this. (record_btrace_disconnect): New function. (init_record_btrace_ops): Use record_btrace_disconnect. * record-btrace.h: New file. * remote.c: Added record-btrace.h include. (remote_start_remote): Check recording status. (remote_btrace_maybe_reopen): New function. gdb/doc/ChangeLog: * gdb.texinfo: Resume btrace on reconnect. gdb/testsuite/ChangeLog: * gdb.btrace/reconnect.c: New file. * gdb.btrace/reconnect.exp: New file. Change-Id: I95e8b0ab8a89e58591aba0e63818cee82fd211bc
Diffstat (limited to 'gdb/record-btrace.c')
-rw-r--r--gdb/record-btrace.c51
1 files changed, 38 insertions, 13 deletions
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 24594a9..4a51b8e 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -21,6 +21,7 @@
#include "defs.h"
#include "record.h"
+#include "record-btrace.h"
#include "gdbthread.h"
#include "target.h"
#include "gdbcmd.h"
@@ -199,6 +200,26 @@ record_btrace_handle_async_inferior_event (gdb_client_data data)
inferior_event_handler (INF_REG_EVENT, NULL);
}
+/* See record-btrace.h. */
+
+void
+record_btrace_push_target (void)
+{
+ const char *format;
+
+ record_btrace_auto_enable ();
+
+ push_target (&record_btrace_ops);
+
+ record_btrace_async_inferior_event_handler
+ = create_async_event_handler (record_btrace_handle_async_inferior_event,
+ NULL);
+ record_btrace_generating_corefile = 0;
+
+ format = btrace_format_short_string (record_btrace_conf.format);
+ observer_notify_record_changed (current_inferior (), 1, "btrace", format);
+}
+
/* The to_open method of target record-btrace. */
static void
@@ -206,7 +227,6 @@ record_btrace_open (const char *args, int from_tty)
{
struct cleanup *disable_chain;
struct thread_info *tp;
- const char *format;
DEBUG ("open");
@@ -226,17 +246,7 @@ record_btrace_open (const char *args, int from_tty)
make_cleanup (record_btrace_disable_callback, tp);
}
- record_btrace_auto_enable ();
-
- push_target (&record_btrace_ops);
-
- record_btrace_async_inferior_event_handler
- = create_async_event_handler (record_btrace_handle_async_inferior_event,
- NULL);
- record_btrace_generating_corefile = 0;
-
- format = btrace_format_short_string (record_btrace_conf.format);
- observer_notify_record_changed (current_inferior (), 1, "btrace", format);
+ record_btrace_push_target ();
discard_cleanups (disable_chain);
}
@@ -257,6 +267,21 @@ record_btrace_stop_recording (struct target_ops *self)
btrace_disable (tp);
}
+/* The to_disconnect method of target record-btrace. */
+
+static void
+record_btrace_disconnect (struct target_ops *self, const char *args,
+ int from_tty)
+{
+ struct target_ops *beneath = self->beneath;
+
+ /* Do not stop recording, just clean up GDB side. */
+ unpush_target (self);
+
+ /* Forward disconnect. */
+ beneath->to_disconnect (beneath, args, from_tty);
+}
+
/* The to_close method of target record-btrace. */
static void
@@ -2824,7 +2849,7 @@ init_record_btrace_ops (void)
ops->to_close = record_btrace_close;
ops->to_async = record_btrace_async;
ops->to_detach = record_detach;
- ops->to_disconnect = record_disconnect;
+ ops->to_disconnect = record_btrace_disconnect;
ops->to_mourn_inferior = record_mourn_inferior;
ops->to_kill = record_kill;
ops->to_stop_recording = record_btrace_stop_recording;