[PATCH v3 4/8] Add record_start function.

Tim Wiederhake
2016-11-21T15:49:08Z

2016-11-21 Tim Wiederhake <tim.wiederhake@intel.com>

gdb/ChangeLog

* record.h (record_start): New export.
* record.c (record_start): New function.

---
gdb/record.c | 28 ++++++++++++++++++++++++++++
gdb/record.h | 5 +++++
2 files changed, 33 insertions(+)

diff --git a/gdb/record.c b/gdb/record.c
index 34ebd1b..6df8ba1 100644
--- a/gdb/record.c
+++ b/gdb/record.c
@@ -93,6 +93,34 @@ record_preopen (void)

/* See record.h. */

+void
+record_start (const char *method, const char *format, int from_tty)
+{
+ if (method == NULL)
+ {
+ if (format == NULL)
+ return execute_command ("record", from_tty);
+ }
+ else if (strcmp (method, "full") == 0)
+ {
+ if (format == NULL)
+ return execute_command ("record full", from_tty);
+ }
+ else if (strcmp (method, "btrace") == 0)
+ {
+ if (format == NULL)
+ return execute_command ("record btrace", from_tty);
+ if (strcmp (format, "bts") == 0)
+ return execute_command ("record btrace bts", from_tty);
+ if (strcmp (format, "pt") == 0)
+ return execute_command ("record btrace pt", from_tty);
+ }
+
+ error (_("Invalid argument."));
+}
+
+/* See record.h. */
+
int
record_read_memory (struct gdbarch *gdbarch,
CORE_ADDR memaddr, gdb_byte *myaddr,
diff --git a/gdb/record.h b/gdb/record.h
index 84440c64..eb091ce 100644
--- a/gdb/record.h
+++ b/gdb/record.h
@@ -91,4 +91,9 @@ extern struct target_ops *find_record_target (void);
it does anything. */
extern void record_preopen (void);

+/* Internal function that starts recording with the given METHOD and FORMAT.
+ NULL means default method or format. */
+extern void record_start (const char *method, const char *format,
+ int from_tty);
+
#endif /* _RECORD_H_ */
--
2.7.4