From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2260 invoked by alias); 13 Feb 2017 12:38:15 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 2007 invoked by uid 89); 13 Feb 2017 12:38:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.3 required=5.0 tests=AWL,BAYES_50,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=beneath, sk:host_ad, timwiederhakeintelcom, tim.wiederhake@intel.com X-HELO: mga06.intel.com Received: from mga06.intel.com (HELO mga06.intel.com) (134.134.136.31) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 13 Feb 2017 12:38:12 +0000 Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP; 13 Feb 2017 04:38:11 -0800 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga006.fm.intel.com with ESMTP; 13 Feb 2017 04:38:09 -0800 Received: from ulvlx001.iul.intel.com (ulvlx001.iul.intel.com [172.28.207.17]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id v1DCc92r010236; Mon, 13 Feb 2017 12:38:09 GMT Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id v1DCc9XT011607; Mon, 13 Feb 2017 13:38:09 +0100 Received: (from twiederh@localhost) by ulvlx001.iul.intel.com with œ id v1DCc8bT011603; Mon, 13 Feb 2017 13:38:09 +0100 From: Tim Wiederhake To: gdb-patches@sourceware.org Cc: markus.t.metzger@intel.com, palves@redhat.com, xdje42@gmail.com Subject: [PATCH v6 5/9] Add method to query current recording method to target_ops. Date: Mon, 13 Feb 2017 12:38:00 -0000 Message-Id: <1486989450-11313-6-git-send-email-tim.wiederhake@intel.com> In-Reply-To: <1486989450-11313-1-git-send-email-tim.wiederhake@intel.com> References: <1486989450-11313-1-git-send-email-tim.wiederhake@intel.com> X-IsSubscribed: yes X-SW-Source: 2017-02/txt/msg00332.txt.bz2 2017-02-13 Tim Wiederhake 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) : New field. (target_record_method): New export. --- gdb/record-btrace.c | 18 ++++++++++++++++++ gdb/record-full.c | 10 ++++++++++ gdb/record.h | 13 +++++++++++++ gdb/target-debug.h | 2 ++ gdb/target-delegates.c | 33 +++++++++++++++++++++++++++++++++ gdb/target.c | 8 ++++++++ gdb/target.h | 8 ++++++++ 7 files changed, 92 insertions(+) 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 (¤t_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); -- 2.7.4