between different record targets.
gdb/
* 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_stop): New.
(record_unpush): New.
(cmd_record_stop): Call record_stop. Replace unpush_target
call with record_unpush call.
(record_disconnect, record_detach): Assert that the target
is of record stratum. Call record_unpush, record_stop, and
DEBUG.
(record_mourn_inferior, record_kill): Assert that the target
is of record stratum. Call record_unpush and DEBUG.
+2013-03-11 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_stop): New.
+ (record_unpush): New.
+ (cmd_record_stop): Call record_stop. Replace unpush_target
+ call with record_unpush call.
+ (record_disconnect, record_detach): Assert that the target
+ is of record stratum. Call record_unpush, record_stop, and
+ DEBUG.
+ (record_mourn_inferior, record_kill): Assert that the target
+ is of record stratum. Call record_unpush and DEBUG.
+
2013-03-11 Markus Metzger <markus.t.metzger@intel.com>
* record-full.h, record-full.c (record_memory_query): Rename
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)
{
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;
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 *
{
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;
}
+/* Stop recording. */
+
+static void
+record_stop (struct target_ops *t)
+{
+ DEBUG ("stop %s", t->to_shortname);
+
+ if (t->to_stop_recording != NULL)
+ t->to_stop_recording ();
+}
+
+/* Unpush the record target. */
+
+static void
+record_unpush (struct target_ops *t)
+{
+ DEBUG ("unpush %s", t->to_shortname);
+
+ unpush_target (t);
+}
+
+/* See record.h. */
+
+void
+record_disconnect (struct target_ops *t, char *args, int from_tty)
+{
+ gdb_assert (t->to_stratum == record_stratum);
+
+ DEBUG ("disconnect %s", t->to_shortname);
+
+ record_stop (t);
+ record_unpush (t);
+
+ target_disconnect (args, from_tty);
+}
+
+/* See record.h. */
+
+void
+record_detach (struct target_ops *t, char *args, int from_tty)
+{
+ gdb_assert (t->to_stratum == record_stratum);
+
+ DEBUG ("detach %s", t->to_shortname);
+
+ record_stop (t);
+ record_unpush (t);
+
+ target_detach (args, from_tty);
+}
+
+/* See record.h. */
+
+void
+record_mourn_inferior (struct target_ops *t)
+{
+ gdb_assert (t->to_stratum == record_stratum);
+
+ DEBUG ("mourn inferior %s", t->to_shortname);
+
+ /* It is safer to not stop recording. Resources will be freed when
+ threads are discarded. */
+ record_unpush (t);
+
+ target_mourn_inferior ();
+}
+
+/* See record.h. */
+
+void
+record_kill (struct target_ops *t)
+{
+ gdb_assert (t->to_stratum == record_stratum);
+
+ DEBUG ("kill %s", t->to_shortname);
+
+ /* It is safer to not stop recording. Resources will be freed when
+ threads are discarded. */
+ record_unpush (t);
+
+ target_kill ();
+}
+
/* Implement "show record debug" command. */
static void
struct target_ops *t;
t = require_record_target ();
- unpush_target (t);
+
+ record_stop (t);
+ record_unpush (t);
printf_unfiltered (_("Process record is stopped and all execution "
"logs are deleted.\n"));
/* 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_ */
/* See target.h. */
+void
+target_stop_recording (void)
+{
+ struct target_ops *t;
+
+ for (t = current_target.beneath; t != NULL; t = t->beneath)
+ if (t->to_stop_recording != NULL)
+ {
+ t->to_stop_recording ();
+ return;
+ }
+
+ /* This is optional. */
+}
+
+/* See target.h. */
+
void
target_info_record (void)
{
VEC (btrace_block_s) *(*to_read_btrace) (struct btrace_target_info *,
enum btrace_read_type);
+ /* Stop trace recording. */
+ void (*to_stop_recording) (void);
+
/* Print information about the recording. */
void (*to_info_record) (void);
extern VEC (btrace_block_s) *target_read_btrace (struct btrace_target_info *,
enum btrace_read_type);
+/* See to_stop_recording in struct target_ops. */
+extern void target_stop_recording (void);
+
/* See to_info_record in struct target_ops. */
extern void target_info_record (void);