aboutsummaryrefslogtreecommitdiff
path: root/gdb/mi
diff options
context:
space:
mode:
authorVladimir Prus <vladimir@codesourcery.com>2010-03-23 22:01:47 +0000
committerVladimir Prus <vladimir@codesourcery.com>2010-03-23 22:01:47 +0000
commitf197e0f1b1c70895aae1395b96d780379ec695ab (patch)
treed311581ba37d0b40fa82e8abce8cd2a28a1b8359 /gdb/mi
parent40e1c229a2dd402eb050b1025c4b1b7667a7e83e (diff)
downloadgdb-f197e0f1b1c70895aae1395b96d780379ec695ab.zip
gdb-f197e0f1b1c70895aae1395b96d780379ec695ab.tar.gz
gdb-f197e0f1b1c70895aae1395b96d780379ec695ab.tar.bz2
Implement -trace-find.
* mi/mi-cmds.c (mi_cmds): Register -trace-find. * mi/mi-cmds.h (mi_cmd_trace_find): Declare. * mi/mi-main.c (mi_cmd_trace_find): New. * target.h (struct target_ops): Document to_trace_find. * tracepoint.h (tfind_1): Declare. * tracepoint.c (finish_tfind_command): Rename to... (tfind_1): ...this. * remote.c (remote_trace_find): Return -1 if target say there's no frame. Improve error diagnostics.
Diffstat (limited to 'gdb/mi')
-rw-r--r--gdb/mi/mi-cmds.c1
-rw-r--r--gdb/mi/mi-cmds.h1
-rw-r--r--gdb/mi/mi-main.c85
3 files changed, 87 insertions, 0 deletions
diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c
index a07ee3b..f430698 100644
--- a/gdb/mi/mi-cmds.c
+++ b/gdb/mi/mi-cmds.c
@@ -107,6 +107,7 @@ struct mi_cmd mi_cmds[] =
{ "thread-list-ids", { NULL, 0 }, mi_cmd_thread_list_ids},
{ "thread-select", { NULL, 0 }, mi_cmd_thread_select},
{ "trace-define-variable", { NULL, 0 }, mi_cmd_trace_define_variable },
+ { "trace-find", { NULL, 0 }, mi_cmd_trace_find },
{ "trace-list-variables", { NULL, 0 }, mi_cmd_trace_list_variables },
{ "trace-start", { NULL, 0 }, mi_cmd_trace_start },
{ "trace-status", { NULL, 0 }, mi_cmd_trace_status },
diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h
index dc2b2c6..32e0ec4 100644
--- a/gdb/mi/mi-cmds.h
+++ b/gdb/mi/mi-cmds.h
@@ -90,6 +90,7 @@ extern mi_cmd_argv_ftype mi_cmd_thread_info;
extern mi_cmd_argv_ftype mi_cmd_thread_list_ids;
extern mi_cmd_argv_ftype mi_cmd_thread_select;
extern mi_cmd_argv_ftype mi_cmd_trace_define_variable;
+extern mi_cmd_argv_ftype mi_cmd_trace_find;
extern mi_cmd_argv_ftype mi_cmd_trace_list_variables;
extern mi_cmd_argv_ftype mi_cmd_trace_start;
extern mi_cmd_argv_ftype mi_cmd_trace_status;
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 031c006..b016436 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -2126,6 +2126,91 @@ mi_cmd_trace_list_variables (char *command, char **argv, int argc)
}
void
+mi_cmd_trace_find (char *command, char **argv, int argc)
+{
+ char *mode;
+
+ if (argc == 0)
+ error (_("trace selection mode is required"));
+
+ mode = argv[0];
+
+ if (strcmp (mode, "none") == 0)
+ {
+ tfind_1 (tfind_number, -1, 0, 0, 0);
+ return;
+ }
+
+ if (current_trace_status ()->running)
+ error (_("May not look at trace frames while trace is running."));
+
+ if (strcmp (mode, "frame-number") == 0)
+ {
+ if (argc != 2)
+ error (_("frame number is required"));
+ tfind_1 (tfind_number, atoi (argv[1]), 0, 0, 0);
+ }
+ else if (strcmp (mode, "tracepoint-number") == 0)
+ {
+ if (argc != 2)
+ error (_("tracepoint number is required"));
+ tfind_1 (tfind_tp, atoi (argv[1]), 0, 0, 0);
+ }
+ else if (strcmp (mode, "pc") == 0)
+ {
+ if (argc != 2)
+ error (_("PC is required"));
+ tfind_1 (tfind_pc, 0, parse_and_eval_address (argv[1]), 0, 0);
+ }
+ else if (strcmp (mode, "pc-inside-range") == 0)
+ {
+ if (argc != 3)
+ error (_("Start and end PC are required"));
+ tfind_1 (tfind_range, 0, parse_and_eval_address (argv[1]),
+ parse_and_eval_address (argv[2]), 0);
+ }
+ else if (strcmp (mode, "pc-outside-range") == 0)
+ {
+ if (argc != 3)
+ error (_("Start and end PC are required"));
+ tfind_1 (tfind_outside, 0, parse_and_eval_address (argv[1]),
+ parse_and_eval_address (argv[2]), 0);
+ }
+ else if (strcmp (mode, "line") == 0)
+ {
+ struct symtabs_and_lines sals;
+ struct symtab_and_line sal;
+ static CORE_ADDR start_pc, end_pc;
+ struct cleanup *back_to;
+
+ if (argc != 2)
+ error (_("Line is required"));
+
+ sals = decode_line_spec (argv[1], 1);
+ back_to = make_cleanup (xfree, sals.sals);
+
+ sal = sals.sals[0];
+
+ if (sal.symtab == 0)
+ error (_("Could not find the specified line"));
+
+ if (sal.line > 0 && find_line_pc_range (sal, &start_pc, &end_pc))
+ tfind_1 (tfind_range, 0, start_pc, end_pc - 1, 0);
+ else
+ error (_("Could not find the specified line"));
+
+ do_cleanups (back_to);
+ }
+ else
+ error (_("Invalid mode '%s'"), mode);
+
+ if (has_stack_frames () || get_traceframe_number () >= 0)
+ {
+ print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC);
+ }
+}
+
+void
mi_cmd_trace_start (char *command, char **argv, int argc)
{
start_tracing ();