From: markus.t.metzger@intel.com
To: jan.kratochvil@redhat.com
Cc: gdb-patches@sourceware.org, markus.t.metzger@gmail.com,
Markus Metzger <markus.t.metzger@intel.com>
Subject: [rfc 4/5] record: default target methods.
Date: Fri, 08 Feb 2013 15:31:00 -0000 [thread overview]
Message-ID: <1360337423-27095-5-git-send-email-markus.t.metzger@intel.com> (raw)
In-Reply-To: <1360337423-27095-1-git-send-email-markus.t.metzger@intel.com>
From: Markus Metzger <markus.t.metzger@intel.com>
Provide default target methods for record targets that are likely to be shared
between different record targets.
2013-02-08 Markus Metzger <markus.t.metzger@intel.com>
* 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
next prev parent reply other threads:[~2013-02-08 15:31 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-08 15:30 [rfc 0/5] record-btrace markus.t.metzger
2013-02-08 15:30 ` [rfc 1/5] target: add add_deprecated_target_alias markus.t.metzger
2013-02-10 22:10 ` Jan Kratochvil
2013-02-08 15:30 ` [rfc 5/5] record, disas: add record disassemble command markus.t.metzger
2013-02-10 22:11 ` Jan Kratochvil
2013-02-08 15:31 ` markus.t.metzger [this message]
2013-02-10 22:11 ` [rfc 4/5] record: default target methods Jan Kratochvil
2013-02-08 15:31 ` [rfc 3/5] record: make it build again markus.t.metzger
2013-02-10 22:11 ` Jan Kratochvil
2013-02-11 13:41 ` Metzger, Markus T
2013-02-11 14:15 ` Jan Kratochvil
2013-02-11 17:13 ` [draft patch] <unavailable> unwinder for btrace [Re: [rfc 3/5] record: make it build again] Jan Kratochvil
2013-02-11 21:24 ` Tom Tromey
2013-02-13 7:35 ` Metzger, Markus T
2013-02-13 7:58 ` Jan Kratochvil
2013-02-13 8:08 ` Metzger, Markus T
2013-03-27 18:09 ` Metzger, Markus T
2013-03-28 12:38 ` Markus Metzger
[not found] ` <20130328062747.GA27157@host2.jankratochvil.net>
2013-03-28 14:28 ` Metzger, Markus T
2013-03-28 14:38 ` Jan Kratochvil
2013-03-28 17:37 ` Metzger, Markus T
2013-02-08 15:32 ` [rfc 2/5] record: split record markus.t.metzger
2013-02-10 22:11 ` Jan Kratochvil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1360337423-27095-5-git-send-email-markus.t.metzger@intel.com \
--to=markus.t.metzger@intel.com \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@redhat.com \
--cc=markus.t.metzger@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox