From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5619 invoked by alias); 8 Feb 2013 15:31:17 -0000 Received: (qmail 5510 invoked by uid 22791); 8 Feb 2013 15:31:14 -0000 X-SWARE-Spam-Status: No, hits=-7.8 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_SPAMHAUS_DROP,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mga14.intel.com (HELO mga14.intel.com) (143.182.124.37) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 08 Feb 2013 15:31:05 +0000 Received: from azsmga002.ch.intel.com ([10.2.17.35]) by azsmga102.ch.intel.com with ESMTP; 08 Feb 2013 07:31:00 -0800 X-ExtLoop1: 1 Received: from swsutil001.isw.intel.com ([10.237.237.11]) by AZSMGA002.ch.intel.com with ESMTP; 08 Feb 2013 07:30:39 -0800 Received: from ulslx001.iul.intel.com (ulslx001.iul.intel.com [172.28.207.63]) by swsutil001.isw.intel.com (8.13.6/8.13.6/MailSET/Hub) with ESMTP id r18FUbwl002896; Fri, 8 Feb 2013 15:30:38 GMT Received: from ulslx001.iul.intel.com (localhost [127.0.0.1]) by ulslx001.iul.intel.com with ESMTP id r18FUbk0027153; Fri, 8 Feb 2013 16:30:37 +0100 Received: (from mmetzger@localhost) by ulslx001.iul.intel.com with id r18FUbtS027149; Fri, 8 Feb 2013 16:30:37 +0100 From: markus.t.metzger@intel.com To: jan.kratochvil@redhat.com Cc: gdb-patches@sourceware.org, markus.t.metzger@gmail.com, Markus Metzger Subject: [rfc 4/5] record: default target methods. Date: Fri, 08 Feb 2013 15:31:00 -0000 Message-Id: <1360337423-27095-5-git-send-email-markus.t.metzger@intel.com> In-Reply-To: <1360337423-27095-1-git-send-email-markus.t.metzger@intel.com> References: <1360337423-27095-1-git-send-email-markus.t.metzger@intel.com> X-IsSubscribed: yes 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 X-SW-Source: 2013-02/txt/msg00216.txt.bz2 From: Markus Metzger Provide default target methods for record targets that are likely to be shared between different record targets. 2013-02-08 Markus Metzger * record.h (record_disconnect): New. (record_detach): New. (record_mourn_inferior): New. (record_kill): New. * record-full.c (record_disconnect, record_detach, record_mourn_inferior, record_kill): Move to... * record.c: ...here. (DEBUG): New. (record_unpush): New. (cmd_record_stop): Use record_unpush. (record_disconnect, record_detach, record_mourn_inferior, record_kill): Use record_unpush and DEBUG. --- gdb/record-full.c | 49 ---------------------------------------- gdb/record.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++ gdb/record.h | 15 +++++++++++- 3 files changed, 78 insertions(+), 50 deletions(-) diff --git a/gdb/record-full.c b/gdb/record-full.c index 4e61c5a..6aa0033 100644 --- a/gdb/record-full.c +++ b/gdb/record-full.c @@ -1515,55 +1515,6 @@ record_stopped_by_watchpoint (void) return record_beneath_to_stopped_by_watchpoint (); } -/* "to_disconnect" method for process record target. */ - -static void -record_disconnect (struct target_ops *target, char *args, int from_tty) -{ - if (record_debug) - fprintf_unfiltered (gdb_stdlog, "Process record: record_disconnect\n"); - - unpush_target (&record_ops); - target_disconnect (args, from_tty); -} - -/* "to_detach" method for process record target. */ - -static void -record_detach (struct target_ops *ops, char *args, int from_tty) -{ - if (record_debug) - fprintf_unfiltered (gdb_stdlog, "Process record: record_detach\n"); - - unpush_target (&record_ops); - target_detach (args, from_tty); -} - -/* "to_mourn_inferior" method for process record target. */ - -static void -record_mourn_inferior (struct target_ops *ops) -{ - if (record_debug) - fprintf_unfiltered (gdb_stdlog, "Process record: " - "record_mourn_inferior\n"); - - unpush_target (&record_ops); - target_mourn_inferior (); -} - -/* Close process record target before killing the inferior process. */ - -static void -record_kill (struct target_ops *ops) -{ - if (record_debug) - fprintf_unfiltered (gdb_stdlog, "Process record: record_kill\n"); - - unpush_target (&record_ops); - target_kill (); -} - static int record_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p) { diff --git a/gdb/record.c b/gdb/record.c index 5293417..7f26b41 100644 --- a/gdb/record.c +++ b/gdb/record.c @@ -32,6 +32,10 @@ struct cmd_list_element *set_record_cmdlist = NULL; struct cmd_list_element *show_record_cmdlist = NULL; struct cmd_list_element *info_record_cmdlist = NULL; +#define DEBUG(msg, args...) \ + if (record_debug) \ + fprintf_unfiltered (gdb_stdlog, "record: " msg "\n", ##args) + /* Find the record target in the target stack. */ static struct target_ops * @@ -60,6 +64,66 @@ require_record_target (void) return t; } +/* Unpush the record target. */ + +static void +record_unpush (void) +{ + struct target_ops *t; + + t = find_record_target (); + if (t == NULL) + internal_error (__FILE__, __LINE__, _("Couldn't find record target.")); + + DEBUG ("unpush %s", t->to_shortname); + + unpush_target (t); +} + +/* See record.h. */ + +void +record_disconnect (struct target_ops *target, char *args, int from_tty) +{ + DEBUG ("disconnect"); + + record_unpush (); + target_disconnect (args, from_tty); +} + +/* See record.h. */ + +void +record_detach (struct target_ops *ops, char *args, int from_tty) +{ + DEBUG ("detach"); + + record_unpush (); + target_detach (args, from_tty); +} + +/* See record.h. */ + +void +record_mourn_inferior (struct target_ops *ops) +{ + DEBUG ("mourn_inferior"); + + record_unpush (); + target_mourn_inferior (); +} + +/* See record.h. */ + +void +record_kill (struct target_ops *ops) +{ + DEBUG ("kill"); + + record_unpush (); + target_kill (); +} + /* Implement "show record debug" command. */ static void diff --git a/gdb/record.h b/gdb/record.h index dfd8361..fe93184 100644 --- a/gdb/record.h +++ b/gdb/record.h @@ -32,6 +32,19 @@ extern struct cmd_list_element *set_record_cmdlist; extern struct cmd_list_element *show_record_cmdlist; extern struct cmd_list_element *info_record_cmdlist; -extern void cmd_record_goto (char *arg, int from_tty); +/* The default "to_disconnect" target method for record targets. */ +extern void record_disconnect (struct target_ops *, char *, int); + +/* The default "to_detach" target method for record targets. */ +extern void record_detach (struct target_ops *, char *, int); + +/* The default "to_mourn_inferior" target method for record targets. */ +extern void record_mourn_inferior (struct target_ops *); + +/* The default "to_kill" target method for record targets. */ +extern void record_kill (struct target_ops *); + +/* The "record goto" command. */ +extern void cmd_record_goto (char *, int); #endif /* _RECORD_H_ */ -- 1.7.0.7