aboutsummaryrefslogtreecommitdiff
path: root/gdb/remote.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/remote.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/remote.c')
-rw-r--r--gdb/remote.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/gdb/remote.c b/gdb/remote.c
index 5568346..7944983 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -70,6 +70,7 @@
#include "ax-gdb.h"
#include "agent.h"
#include "btrace.h"
+#include "record-btrace.h"
/* Temp hacks for tracepoint encoding migration. */
static char *target_buf;
@@ -231,6 +232,8 @@ static int remote_can_run_breakpoint_commands (struct target_ops *self);
static void remote_btrace_reset (void);
+static void remote_btrace_maybe_reopen (void);
+
static int stop_reply_queue_length (void);
static void readahead_cache_invalidate (void);
@@ -4298,6 +4301,10 @@ remote_start_remote (int from_tty, struct target_ops *target, int extended_p)
merge_uploaded_tracepoints (&uploaded_tps);
}
+ /* Possibly the target has been engaged in a btrace record started
+ previously; find out where things are at. */
+ remote_btrace_maybe_reopen ();
+
/* The thread and inferior lists are now synchronized with the
target, our symbols have been relocated, and we're merged the
target's tracepoints with ours. We're done with basic start
@@ -12774,6 +12781,60 @@ btrace_read_config (struct btrace_config *conf)
}
}
+/* Maybe reopen target btrace. */
+
+static void
+remote_btrace_maybe_reopen (void)
+{
+ struct remote_state *rs = get_remote_state ();
+ struct cleanup *cleanup;
+ struct thread_info *tp;
+ int btrace_target_pushed = 0;
+ int warned = 0;
+
+ cleanup = make_cleanup_restore_current_thread ();
+ ALL_NON_EXITED_THREADS (tp)
+ {
+ set_general_thread (tp->ptid);
+
+ memset (&rs->btrace_config, 0x00, sizeof (struct btrace_config));
+ btrace_read_config (&rs->btrace_config);
+
+ if (rs->btrace_config.format == BTRACE_FORMAT_NONE)
+ continue;
+
+#if !defined (HAVE_LIBIPT)
+ if (rs->btrace_config.format == BTRACE_FORMAT_PT)
+ {
+ if (!warned)
+ {
+ warned = 1;
+ warning (_("GDB does not support Intel Processor Trace. "
+ "\"record\" will not work in this session."));
+ }
+
+ continue;
+ }
+#endif /* !defined (HAVE_LIBIPT) */
+
+ /* Push target, once, but before anything else happens. This way our
+ changes to the threads will be cleaned up by unpushing the target
+ in case btrace_read_config () throws. */
+ if (!btrace_target_pushed)
+ {
+ btrace_target_pushed = 1;
+ record_btrace_push_target ();
+ printf_filtered (_("Target is recording using %s.\n"),
+ btrace_format_string (rs->btrace_config.format));
+ }
+
+ tp->btrace.target = XCNEW (struct btrace_target_info);
+ tp->btrace.target->ptid = tp->ptid;
+ tp->btrace.target->conf = rs->btrace_config;
+ }
+ do_cleanups (cleanup);
+}
+
/* Enable branch tracing. */
static struct btrace_target_info *