From: Markus Metzger <markus.t.metzger@intel.com>
To: jan.kratochvil@redhat.com
Cc: gdb-patches@sourceware.org, markus.t.metzger@gmail.com
Subject: [patch v9 16/23] record: default target methods.
Date: Mon, 04 Mar 2013 17:07:00 -0000 [thread overview]
Message-ID: <1362416770-19750-17-git-send-email-markus.t.metzger@intel.com> (raw)
In-Reply-To: <1362416770-19750-1-git-send-email-markus.t.metzger@intel.com>
Provide default target methods for record targets that are likely to be shared
between different record targets.
Approved by Jan Kratochvil.
2013-03-04 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 | 58 +++---------------------------------------
gdb/record.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++---
gdb/record.h | 12 +++++++++
3 files changed, 84 insertions(+), 58 deletions(-)
diff --git a/gdb/record-full.c b/gdb/record-full.c
index 5ffa6b7..e7af504 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -1523,56 +1523,6 @@ record_full_stopped_by_watchpoint (void)
return record_full_beneath_to_stopped_by_watchpoint ();
}
-/* "to_disconnect" method for process record target. */
-
-static void
-record_full_disconnect (struct target_ops *target, char *args, int from_tty)
-{
- if (record_debug)
- fprintf_unfiltered (gdb_stdlog,
- "Process record: record_full_disconnect\n");
-
- unpush_target (&record_full_ops);
- target_disconnect (args, from_tty);
-}
-
-/* "to_detach" method for process record target. */
-
-static void
-record_full_detach (struct target_ops *ops, char *args, int from_tty)
-{
- if (record_debug)
- fprintf_unfiltered (gdb_stdlog, "Process record: record_full_detach\n");
-
- unpush_target (&record_full_ops);
- target_detach (args, from_tty);
-}
-
-/* "to_mourn_inferior" method for process record target. */
-
-static void
-record_full_mourn_inferior (struct target_ops *ops)
-{
- if (record_debug)
- fprintf_unfiltered (gdb_stdlog, "Process record: "
- "record_full_mourn_inferior\n");
-
- unpush_target (&record_full_ops);
- target_mourn_inferior ();
-}
-
-/* Close process record target before killing the inferior process. */
-
-static void
-record_full_kill (struct target_ops *ops)
-{
- if (record_debug)
- fprintf_unfiltered (gdb_stdlog, "Process record: record_full_kill\n");
-
- unpush_target (&record_full_ops);
- target_kill ();
-}
-
static int
record_full_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p)
{
@@ -2117,10 +2067,10 @@ init_record_full_ops (void)
record_full_ops.to_close = record_full_close;
record_full_ops.to_resume = record_full_resume;
record_full_ops.to_wait = record_full_wait;
- record_full_ops.to_disconnect = record_full_disconnect;
- record_full_ops.to_detach = record_full_detach;
- record_full_ops.to_mourn_inferior = record_full_mourn_inferior;
- record_full_ops.to_kill = record_full_kill;
+ record_full_ops.to_disconnect = record_disconnect;
+ record_full_ops.to_detach = record_detach;
+ record_full_ops.to_mourn_inferior = record_mourn_inferior;
+ record_full_ops.to_kill = record_kill;
record_full_ops.to_create_inferior = find_default_create_inferior;
record_full_ops.to_store_registers = record_full_store_registers;
record_full_ops.to_xfer_partial = record_full_xfer_partial;
diff --git a/gdb/record.c b/gdb/record.c
index 8b44717..abd8216 100644
--- a/gdb/record.c
+++ b/gdb/record.c
@@ -33,6 +33,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 *
@@ -71,13 +75,73 @@ record_read_memory (struct gdbarch *gdbarch,
{
int ret = target_read_memory (memaddr, myaddr, len);
- if (ret && record_debug)
- printf_unfiltered (_("Process record: error reading memory "
- "at addr %s len = %ld.\n"),
- paddress (gdbarch, memaddr), (long) len);
+ if (ret != 0)
+ DEBUG ("error reading memory at addr %s len = %ld.\n",
+ paddress (gdbarch, memaddr), (long) len);
+
return ret;
}
+/* 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 b428eaf..04d6b4a 100644
--- a/gdb/record.h
+++ b/gdb/record.h
@@ -41,4 +41,16 @@ extern int record_read_memory (struct gdbarch *gdbarch,
/* The "record goto" command. */
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 *);
+
#endif /* _RECORD_H_ */
--
1.7.1
next prev parent reply other threads:[~2013-03-04 17:07 UTC|newest]
Thread overview: 102+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-04 17:07 [patch v9 00/23] branch tracing support for Atom Markus Metzger
2013-03-04 17:07 ` [patch v9 07/23] gdbserver, btrace: add generic btrace support Markus Metzger
2013-03-05 20:08 ` Jan Kratochvil
2013-03-06 9:15 ` Metzger, Markus T
2013-03-06 13:22 ` Jan Kratochvil
2013-03-04 17:07 ` [patch v9 10/23] remote, btrace: add branch tracing protocol to Qbtrace packet Markus Metzger
2013-03-05 20:09 ` Jan Kratochvil
2013-03-06 9:19 ` Metzger, Markus T
2013-03-04 17:07 ` [patch v9 02/23] linux, btrace: perf_event based branch tracing Markus Metzger
2013-03-05 20:06 ` Jan Kratochvil
2013-03-06 10:11 ` Mark Kettenis
2013-03-06 10:29 ` Metzger, Markus T
2013-03-04 17:07 ` [patch v9 04/23] xml, btrace: define btrace xml document style Markus Metzger
2013-03-05 20:07 ` Jan Kratochvil
2013-03-04 17:07 ` [patch v9 01/23] thread, btrace: add generic branch trace support Markus Metzger
2013-03-05 20:06 ` Jan Kratochvil
2013-03-05 22:02 ` Tom Tromey
2013-03-06 21:11 ` Doug Evans
2013-03-07 7:50 ` Metzger, Markus T
2013-03-07 22:57 ` Doug Evans
2013-03-04 17:07 ` [patch v9 03/23] linux, i386, amd64: enable btrace for 32bit and 64bit linux native Markus Metzger
2013-03-05 20:06 ` Jan Kratochvil
2013-03-04 17:07 ` [patch v9 08/23] gdbserver, linux, btrace: add btrace support for linux-low Markus Metzger
2013-03-05 20:09 ` Jan Kratochvil
2013-03-06 9:17 ` Metzger, Markus T
2013-03-06 13:33 ` Jan Kratochvil
2013-03-04 17:07 ` [patch v9 05/23] remote, btrace: add branch trace remote ops Markus Metzger
2013-03-05 20:07 ` Jan Kratochvil
2013-03-06 9:00 ` Metzger, Markus T
2013-03-04 17:07 ` Markus Metzger [this message]
2013-03-05 20:10 ` [patch v9 16/23] record: default target methods Jan Kratochvil
2013-03-04 17:08 ` [patch v9 06/23] btrace, doc: document remote serial protocol Markus Metzger
2013-03-04 18:08 ` Eli Zaretskii
2013-03-05 20:08 ` Jan Kratochvil
2013-03-06 9:06 ` Metzger, Markus T
2013-03-06 9:50 ` Jan Kratochvil
2013-03-06 10:01 ` Metzger, Markus T
2013-03-06 12:07 ` Jan Kratochvil
2013-03-06 12:13 ` Metzger, Markus T
2013-03-06 12:17 ` Jan Kratochvil
2013-03-04 17:08 ` [patch v9 22/23] testsuite, gdb.btrace: add btrace tests Markus Metzger
2013-03-04 19:47 ` Jan Kratochvil
2013-03-05 6:39 ` Metzger, Markus T
2013-03-05 20:14 ` Jan Kratochvil
2013-03-06 15:32 ` christian.himpel
2013-03-06 16:35 ` Jan Kratochvil
2013-03-04 17:08 ` [patch v9 11/23] target: add add_deprecated_target_alias Markus Metzger
2013-03-05 20:09 ` Jan Kratochvil
2013-03-04 17:08 ` [patch v9 20/23] record-btrace, disas: omit pc prefix Markus Metzger
2013-03-05 20:13 ` Jan Kratochvil
2013-03-04 17:08 ` [patch v9 09/23] btrace, x86: disable on some processors Markus Metzger
2013-03-05 20:09 ` Jan Kratochvil
2013-03-04 17:08 ` [patch v9 19/23] record, btrace: add record-btrace target Markus Metzger
2013-03-05 20:13 ` Jan Kratochvil
2013-03-06 9:57 ` Metzger, Markus T
2013-03-06 13:35 ` Jan Kratochvil
2013-03-06 14:01 ` Metzger, Markus T
2013-03-06 16:28 ` Jan Kratochvil
2013-03-04 17:09 ` [patch v9 17/23] record: add "record instruction-history" command Markus Metzger
2013-03-04 18:14 ` Eli Zaretskii
2013-03-05 20:11 ` Jan Kratochvil
2013-03-04 17:09 ` [patch v9 14/23] record-full.c: rename record_ in record_full_ Markus Metzger
2013-03-05 20:10 ` Jan Kratochvil
2013-03-04 17:09 ` [patch v9 15/23] record-full.h: rename record_ into record_full_ Markus Metzger
2013-03-05 20:10 ` Jan Kratochvil
2013-03-04 17:09 ` [patch v9 13/23] record: make it build again Markus Metzger
2013-03-05 20:10 ` Jan Kratochvil
2013-03-04 17:09 ` [patch v9 21/23] doc, record: document record changes Markus Metzger
2013-03-04 18:13 ` Eli Zaretskii
2013-03-05 20:13 ` Jan Kratochvil
2013-03-04 17:09 ` [patch v9 18/23] record: add "record function-call-history" command Markus Metzger
2013-03-04 18:07 ` Eli Zaretskii
2013-03-05 20:12 ` Jan Kratochvil
2013-03-04 17:09 ` [patch v9 23/23] btrace, remote: drop qbtrace packet Markus Metzger
2013-03-04 18:15 ` Eli Zaretskii
2013-03-05 20:15 ` Jan Kratochvil
2013-03-04 17:10 ` [patch v9 12/23] record: split record Markus Metzger
2013-03-05 20:09 ` Jan Kratochvil
2013-03-06 12:43 ` Crash of GDB with gdbserver btrace enabled [Re: [patch v9 00/23] branch tracing support for Atom] Jan Kratochvil
2013-03-06 14:40 ` Metzger, Markus T
2013-03-06 15:31 ` Metzger, Markus T
2013-03-06 17:06 ` Jan Kratochvil
2013-03-06 18:08 ` Metzger, Markus T
2013-03-07 9:06 ` Jan Kratochvil
2013-03-07 9:41 ` Metzger, Markus T
2013-03-07 10:00 ` Metzger, Markus T
2013-03-07 10:14 ` Jan Kratochvil
2013-03-07 10:33 ` Metzger, Markus T
2013-03-07 12:07 ` Jan Kratochvil
2013-03-07 12:33 ` Metzger, Markus T
2013-03-07 14:45 ` Jan Kratochvil
2013-03-07 15:22 ` Metzger, Markus T
2013-03-07 15:46 ` Jan Kratochvil
2013-03-07 15:12 ` Pedro Alves
2013-03-07 15:33 ` Metzger, Markus T
2013-03-07 15:39 ` Jan Kratochvil
2013-03-07 15:41 ` Pedro Alves
[not found] ` <20130318170643.GA15625@host2.jankratochvil.net>
[not found] ` <514758DA.2060905@redhat.com>
2013-03-20 15:52 ` [commit] [patch] Code cleanup: Remove parameter quitting [Re: Crash of GDB with gdbserver btrace enabled] Jan Kratochvil
[not found] ` <20130318192604.GA2786@host2.jankratochvil.net>
[not found] ` <51477828.30000@redhat.com>
2013-03-26 0:15 ` Jan Kratochvil
2013-04-03 18:05 ` Pedro Alves
2013-03-07 10:08 ` Crash of GDB with gdbserver btrace enabled [Re: [patch v9 00/23] branch tracing support for Atom] Jan Kratochvil
2013-03-06 15:41 ` 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=1362416770-19750-17-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