aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Wiederhake <tim.wiederhake@intel.com>2016-12-13 11:24:56 +0100
committerTim Wiederhake <tim.wiederhake@intel.com>2017-02-14 10:57:56 +0100
commitb158a20f26f1d226088122e8c4fa5a23bb893a48 (patch)
tree8a7d017304027dce8495465ab478e9effb499d23
parent45b196c59065cd2c5b750b78a0329d42f6e924b1 (diff)
downloadgdb-b158a20f26f1d226088122e8c4fa5a23bb893a48.zip
gdb-b158a20f26f1d226088122e8c4fa5a23bb893a48.tar.gz
gdb-b158a20f26f1d226088122e8c4fa5a23bb893a48.tar.bz2
Add method to query current recording method to target_ops.
Signed-off-by: Tim Wiederhake <tim.wiederhake@intel.com> gdb/ChangeLog * record-btrace.c (record_btrace_record_method): New function. (init_record_btrace_ops): Initialize to_record_method. * record-full.c (record_full_record_method): New function. (init_record_full_ops, init_record_full_core_ops): Add record_full_record_method. * record.h (enum record_method): New enum. * target-debug.h (target_debug_print_enum_record_method: New define. * target-delegates.c: Regenerate. * target.c (target_record_method): New function. * target.h: Include record.h. (struct target_ops) <to_record_method>: New field. (target_record_method): New export. Change-Id: I05daa70e4e08a19901e848c731bb7d60cd87cc5a
-rw-r--r--gdb/record-btrace.c18
-rw-r--r--gdb/record-full.c10
-rw-r--r--gdb/record.h13
-rw-r--r--gdb/target-debug.h2
-rw-r--r--gdb/target-delegates.c33
-rw-r--r--gdb/target.c8
-rw-r--r--gdb/target.h8
7 files changed, 92 insertions, 0 deletions
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 19b9222..f7683f2 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -1258,6 +1258,23 @@ record_btrace_call_history_from (struct target_ops *self,
record_btrace_call_history_range (self, begin, end, flags);
}
+/* The to_record_method method of target record-btrace. */
+
+static enum record_method
+record_btrace_record_method (struct target_ops *self, ptid_t ptid)
+{
+ const struct btrace_config *config;
+ struct thread_info * const tp = find_thread_ptid (ptid);
+
+ if (tp == NULL)
+ error (_("No thread."));
+
+ if (tp->btrace.target == NULL)
+ return RECORD_METHOD_NONE;
+
+ return RECORD_METHOD_BTRACE;
+}
+
/* The to_record_is_replaying method of target record-btrace. */
static int
@@ -2833,6 +2850,7 @@ init_record_btrace_ops (void)
ops->to_call_history = record_btrace_call_history;
ops->to_call_history_from = record_btrace_call_history_from;
ops->to_call_history_range = record_btrace_call_history_range;
+ ops->to_record_method = record_btrace_record_method;
ops->to_record_is_replaying = record_btrace_is_replaying;
ops->to_record_will_replay = record_btrace_will_replay;
ops->to_record_stop_replaying = record_btrace_stop_replaying_all;
diff --git a/gdb/record-full.c b/gdb/record-full.c
index fdd613b..bd95acc 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -1803,6 +1803,14 @@ record_full_execution_direction (struct target_ops *self)
return record_full_execution_dir;
}
+/* The to_record_method method of target record-full. */
+
+enum record_method
+record_full_record_method (struct target_ops *self, ptid_t ptid)
+{
+ return RECORD_METHOD_FULL;
+}
+
static void
record_full_info (struct target_ops *self)
{
@@ -1992,6 +2000,7 @@ init_record_full_ops (void)
record_full_ops.to_get_bookmark = record_full_get_bookmark;
record_full_ops.to_goto_bookmark = record_full_goto_bookmark;
record_full_ops.to_execution_direction = record_full_execution_direction;
+ record_full_ops.to_record_method = record_full_record_method;
record_full_ops.to_info_record = record_full_info;
record_full_ops.to_save_record = record_full_save;
record_full_ops.to_delete_record = record_full_delete;
@@ -2242,6 +2251,7 @@ init_record_full_core_ops (void)
record_full_core_ops.to_goto_bookmark = record_full_goto_bookmark;
record_full_core_ops.to_execution_direction
= record_full_execution_direction;
+ record_full_core_ops.to_record_method = record_full_record_method;
record_full_core_ops.to_info_record = record_full_info;
record_full_core_ops.to_delete_record = record_full_delete;
record_full_core_ops.to_record_is_replaying = record_full_is_replaying;
diff --git a/gdb/record.h b/gdb/record.h
index cff4506..a54a08f 100644
--- a/gdb/record.h
+++ b/gdb/record.h
@@ -37,6 +37,19 @@ extern struct cmd_list_element *info_record_cmdlist;
extern const struct frame_unwind record_btrace_frame_unwind;
extern const struct frame_unwind record_btrace_tailcall_frame_unwind;
+/* A list of different recording methods. */
+enum record_method
+{
+ /* No or unknown record method. */
+ RECORD_METHOD_NONE,
+
+ /* Record method "full". */
+ RECORD_METHOD_FULL,
+
+ /* Record method "btrace". */
+ RECORD_METHOD_BTRACE
+};
+
/* A list of flags specifying what record target methods should print. */
enum record_print_flag
{
diff --git a/gdb/target-debug.h b/gdb/target-debug.h
index 857cece..6923608 100644
--- a/gdb/target-debug.h
+++ b/gdb/target-debug.h
@@ -148,6 +148,8 @@
target_debug_do_print (host_address_to_string (X))
#define target_debug_print_enum_btrace_format(X) \
target_debug_do_print (plongest (X))
+#define target_debug_print_enum_record_method(X) \
+ target_debug_do_print (plongest (X))
#define target_debug_print_const_struct_btrace_config_p(X) \
target_debug_do_print (host_address_to_string (X))
#define target_debug_print_const_struct_btrace_target_info_p(X) \
diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c
index 73e45dd..470b7e4 100644
--- a/gdb/target-delegates.c
+++ b/gdb/target-delegates.c
@@ -3579,6 +3579,35 @@ debug_btrace_conf (struct target_ops *self, const struct btrace_target_info *arg
return result;
}
+static enum record_method
+delegate_record_method (struct target_ops *self, ptid_t arg1)
+{
+ self = self->beneath;
+ return self->to_record_method (self, arg1);
+}
+
+static enum record_method
+tdefault_record_method (struct target_ops *self, ptid_t arg1)
+{
+ return RECORD_METHOD_NONE;
+}
+
+static enum record_method
+debug_record_method (struct target_ops *self, ptid_t arg1)
+{
+ enum record_method result;
+ fprintf_unfiltered (gdb_stdlog, "-> %s->to_record_method (...)\n", debug_target.to_shortname);
+ result = debug_target.to_record_method (&debug_target, arg1);
+ fprintf_unfiltered (gdb_stdlog, "<- %s->to_record_method (", debug_target.to_shortname);
+ target_debug_print_struct_target_ops_p (&debug_target);
+ fputs_unfiltered (", ", gdb_stdlog);
+ target_debug_print_ptid_t (arg1);
+ fputs_unfiltered (") = ", gdb_stdlog);
+ target_debug_print_enum_record_method (result);
+ fputs_unfiltered ("\n", gdb_stdlog);
+ return result;
+}
+
static void
delegate_stop_recording (struct target_ops *self)
{
@@ -4386,6 +4415,8 @@ install_delegators (struct target_ops *ops)
ops->to_read_btrace = delegate_read_btrace;
if (ops->to_btrace_conf == NULL)
ops->to_btrace_conf = delegate_btrace_conf;
+ if (ops->to_record_method == NULL)
+ ops->to_record_method = delegate_record_method;
if (ops->to_stop_recording == NULL)
ops->to_stop_recording = delegate_stop_recording;
if (ops->to_info_record == NULL)
@@ -4565,6 +4596,7 @@ install_dummy_methods (struct target_ops *ops)
ops->to_teardown_btrace = tdefault_teardown_btrace;
ops->to_read_btrace = tdefault_read_btrace;
ops->to_btrace_conf = tdefault_btrace_conf;
+ ops->to_record_method = tdefault_record_method;
ops->to_stop_recording = tdefault_stop_recording;
ops->to_info_record = tdefault_info_record;
ops->to_save_record = tdefault_save_record;
@@ -4723,6 +4755,7 @@ init_debug_target (struct target_ops *ops)
ops->to_teardown_btrace = debug_teardown_btrace;
ops->to_read_btrace = debug_read_btrace;
ops->to_btrace_conf = debug_btrace_conf;
+ ops->to_record_method = debug_record_method;
ops->to_stop_recording = debug_stop_recording;
ops->to_info_record = debug_info_record;
ops->to_save_record = debug_save_record;
diff --git a/gdb/target.c b/gdb/target.c
index 3c409f0..0ff8515 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -3789,6 +3789,14 @@ target_delete_record (void)
/* See target.h. */
+enum record_method
+target_record_method (ptid_t ptid)
+{
+ return current_target.to_record_method (&current_target, ptid);
+}
+
+/* See target.h. */
+
int
target_record_is_replaying (ptid_t ptid)
{
diff --git a/gdb/target.h b/gdb/target.h
index 8df117e..943a0e2 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -72,6 +72,7 @@ struct inferior;
#include "vec.h"
#include "gdb_signals.h"
#include "btrace.h"
+#include "record.h"
#include "command.h"
#include "break-common.h" /* For enum target_hw_bp_type. */
@@ -1149,6 +1150,10 @@ struct target_ops
const struct btrace_target_info *)
TARGET_DEFAULT_RETURN (NULL);
+ /* Current recording method. */
+ enum record_method (*to_record_method) (struct target_ops *, ptid_t ptid)
+ TARGET_DEFAULT_RETURN (RECORD_METHOD_NONE);
+
/* Stop trace recording. */
void (*to_stop_recording) (struct target_ops *)
TARGET_DEFAULT_IGNORE ();
@@ -2495,6 +2500,9 @@ extern int target_supports_delete_record (void);
/* See to_delete_record in struct target_ops. */
extern void target_delete_record (void);
+/* See to_record_method. */
+extern enum record_method target_record_method (ptid_t ptid);
+
/* See to_record_is_replaying in struct target_ops. */
extern int target_record_is_replaying (ptid_t ptid);