+2014-01-14 Pedro Alves <palves@redhat.com>
+ Tom Tromey <tromey@redhat.com>
+
+ * infrun.c (use_displaced_stepping): Use find_record_target
+ instead of RECORD_IS_USED.
+ (adjust_pc_after_break): Use record_full_is_used instead of
+ RECORD_IS_USED.
+ * record-btrace.c (record_btrace_open): Call record_preopen
+ instead of checking RECORD_IS_USED.
+ * record-full.c (record_full_shortname)
+ (record_full_core_shortname): New globals.
+ (record_full_is_used): New function.
+ (find_full_open): Call record_preopen instead of checking
+ RECORD_IS_USED.
+ (init_record_full_ops): Set the target's shortname to
+ record_full_shortname.
+ (init_record_full_core_ops): Set the target's shortname to
+ record_full_core_shortname.
+ * record-full.h (record_full_is_used): Declare.
+ * record.c (find_record_target): Make extern.
+ (record_preopen): New function.
+ * record.h (RECORD_IS_USED): Delete macro.
+ (find_record_target, record_preopen): Declare functions.
+
2014-01-14 Yao Qi <yao@codesourcery.com>
* gdbarch.sh (core_xfer_shared_libraries): Change its argument
return (((can_use_displaced_stepping == AUTO_BOOLEAN_AUTO && non_stop)
|| can_use_displaced_stepping == AUTO_BOOLEAN_TRUE)
&& gdbarch_displaced_step_copy_insn_p (gdbarch)
- && !RECORD_IS_USED);
+ && find_record_target () == NULL);
}
/* Clean out any stray displaced stepping state. */
{
struct cleanup *old_cleanups = make_cleanup (null_cleanup, NULL);
- if (RECORD_IS_USED)
+ if (record_full_is_used ())
record_full_gdb_operation_disable_set ();
/* When using hardware single-step, a SIGTRAP is reported for both
DEBUG ("open");
- if (RECORD_IS_USED)
- error (_("The process is already being recorded."));
+ record_preopen ();
if (!target_has_execution)
error (_("The program is not being run."));
static struct target_ops record_full_ops;
static struct target_ops record_full_core_ops;
+/* See record-full.h. */
+
+int
+record_full_is_used (void)
+{
+ struct target_ops *t;
+
+ t = find_record_target ();
+ return (t == &record_full_ops
+ || t == &record_full_core_ops);
+}
+
+
/* Command lists for "set/show record full". */
static struct cmd_list_element *set_record_full_cmdlist;
static struct cmd_list_element *show_record_full_cmdlist;
if (record_debug)
fprintf_unfiltered (gdb_stdlog, "Process record: record_full_open\n");
- /* Check if record target is already running. */
- if (current_target.to_stratum == record_stratum)
- error (_("Process record target already running. Use \"record stop\" to "
- "stop record target first."));
+ record_preopen ();
/* Reset the tmp beneath pointers. */
tmp_to_resume_ops = NULL;
extern int record_full_arch_list_add_reg (struct regcache *regcache, int num);
extern int record_full_arch_list_add_mem (CORE_ADDR addr, int len);
extern int record_full_arch_list_add_end (void);
+
+/* Returns true if the process record target is open. */
+extern int record_full_is_used (void);
+
extern struct cleanup *record_full_gdb_operation_disable_set (void);
#endif /* RECORD_FULL_H */
if (record_debug) \
fprintf_unfiltered (gdb_stdlog, "record: " msg "\n", ##args)
-/* Find the record target in the target stack. */
+/* See record.h. */
-static struct target_ops *
+struct target_ops *
find_record_target (void)
{
struct target_ops *t;
/* See record.h. */
+void
+record_preopen (void)
+{
+ /* Check if a record target is already running. */
+ if (find_record_target () != NULL)
+ error (_("The process is already being recorded. Use \"record stop\" to "
+ "stop recording first."));
+}
+
+/* See record.h. */
+
int
record_read_memory (struct gdbarch *gdbarch,
CORE_ADDR memaddr, gdb_byte *myaddr,
struct cmd_list_element;
-#define RECORD_IS_USED (current_target.to_stratum == record_stratum)
-
extern unsigned int record_debug;
/* Allow record targets to add their own sub-commands. */
/* The default "to_kill" target method for record targets. */
extern void record_kill (struct target_ops *);
+/* Find the record_stratum target in the current target stack.
+ Returns NULL if none is found. */
+extern struct target_ops *find_record_target (void);
+
+/* This is to be called by record_stratum targets' open routine before
+ it does anything. */
+extern void record_preopen (void);
+
#endif /* _RECORD_H_ */