diff options
author | Markus Metzger <mmetzger@sourceware.org> | 2013-03-11 08:47:10 +0000 |
---|---|---|
committer | Markus Metzger <mmetzger@sourceware.org> | 2013-03-11 08:47:10 +0000 |
commit | 7c1687a9661c460fac39e57a451a90c5f48213d9 (patch) | |
tree | 35ee2e97db0ea8485c239d209c625aa80eaad35e /gdb/record.c | |
parent | 25ea693b87da84e449d731c609b0fd744092e70d (diff) | |
download | fsf-binutils-gdb-7c1687a9661c460fac39e57a451a90c5f48213d9.zip fsf-binutils-gdb-7c1687a9661c460fac39e57a451a90c5f48213d9.tar.gz fsf-binutils-gdb-7c1687a9661c460fac39e57a451a90c5f48213d9.tar.bz2 |
Provide default target methods for record targets that are likely to be shared
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.
Diffstat (limited to 'gdb/record.c')
-rw-r--r-- | gdb/record.c | 99 |
1 files changed, 94 insertions, 5 deletions
diff --git a/gdb/record.c b/gdb/record.c index 8b44717..36150f7 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,96 @@ 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; } +/* 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 @@ -131,7 +218,9 @@ cmd_record_stop (char *args, int from_tty) 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")); |