* 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.
+2010-03-24 Vladimir Prus <vladimir@codesourcery.com>
+
+ 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.
+
2010-03-24 Vladimir Prus <vladimir@codesourcery.com>
-trace-define-variable and -trace-list-variables.
{ "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 },
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;
tvariables_info_1 ();
}
+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)
{
switch (*reply)
{
case 'F':
- if ((target_frameno = (int) strtol (++reply, &reply, 16)) == -1)
- error (_("Target failed to find requested trace frame."));
+ p = ++reply;
+ target_frameno = (int) strtol (p, &reply, 16);
+ if (reply == p)
+ error (_("Unable to parse trace frame number"));
+ if (target_frameno == -1)
+ return -1;
break;
case 'T':
- if ((target_tracept = (int) strtol (++reply, &reply, 16)) == -1)
- error (_("Target failed to find requested trace frame."));
+ p = ++reply;
+ target_tracept = (int) strtol (p, &reply, 16);
+ if (reply == p)
+ error (_("Unable to parse tracepoint number"));
break;
case 'O': /* "OK"? */
if (reply[1] == 'K' && reply[2] == '\0')
/* Ask the target to find a trace frame of the given type TYPE,
using NUM, ADDR1, and ADDR2 as search parameters. Returns the
number of the trace frame, and also the tracepoint number at
- TPP. */
+ TPP. If no trace frame matches, return -1. May throw if the
+ operation fails. */
int (*to_trace_find) (enum trace_find_type type, int num,
ULONGEST addr1, ULONGEST addr2, int *tpp);
}
/* Worker function for the various flavors of the tfind command. */
-static void
-finish_tfind_command (enum trace_find_type type, int num,
- ULONGEST addr1, ULONGEST addr2,
- int from_tty)
+void
+tfind_1 (enum trace_find_type type, int num,
+ ULONGEST addr1, ULONGEST addr2,
+ int from_tty)
{
int target_frameno = -1, target_tracept = -1;
struct frame_id old_frame_id;
else
set_traceframe_context (get_current_frame ());
+ if (traceframe_number >= 0)
+ {
+ /* Use different branches for MI and CLI to make CLI messages
+ i18n-eable. */
+ if (ui_out_is_mi_like_p (uiout))
+ {
+ ui_out_field_string (uiout, "found", "1");
+ ui_out_field_int (uiout, "tracepoint", tracepoint_number);
+ ui_out_field_int (uiout, "traceframe", traceframe_number);
+ }
+ else
+ {
+ printf_unfiltered (_("Found trace frame %d, tracepoint %d\n"),
+ traceframe_number, tracepoint_number);
+ }
+ }
+ else
+ {
+ if (ui_out_is_mi_like_p (uiout))
+ ui_out_field_string (uiout, "found", "0");
+ else
+ printf_unfiltered (_("No trace frame found"));
+ }
+
/* If we're in nonstop mode and getting out of looking at trace
frames, there won't be any current frame to go back to and
display. */
if (frameno < -1)
error (_("invalid input (%d is less than zero)"), frameno);
- finish_tfind_command (tfind_number, frameno, 0, 0, from_tty);
+ tfind_1 (tfind_number, frameno, 0, 0, from_tty);
}
/* tfind end */
else
pc = parse_and_eval_address (args);
- finish_tfind_command (tfind_pc, 0, pc, 0, from_tty);
+ tfind_1 (tfind_pc, 0, pc, 0, from_tty);
}
/* tfind tracepoint command */
if (tp)
tdp = tp->number_on_target;
- finish_tfind_command (tfind_tp, tdp, 0, 0, from_tty);
+ tfind_1 (tfind_tp, tdp, 0, 0, from_tty);
}
/* TFIND LINE command:
/* Find within range of stated line. */
if (args && *args)
- finish_tfind_command (tfind_range, 0, start_pc, end_pc - 1, from_tty);
+ tfind_1 (tfind_range, 0, start_pc, end_pc - 1, from_tty);
else
- finish_tfind_command (tfind_outside, 0, start_pc, end_pc - 1, from_tty);
+ tfind_1 (tfind_outside, 0, start_pc, end_pc - 1, from_tty);
do_cleanups (old_chain);
}
stop = start + 1; /* ??? */
}
- finish_tfind_command (tfind_range, 0, start, stop, from_tty);
+ tfind_1 (tfind_range, 0, start, stop, from_tty);
}
/* tfind outside command */
stop = start + 1; /* ??? */
}
- finish_tfind_command (tfind_outside, 0, start, stop, from_tty);
+ tfind_1 (tfind_outside, 0, start, stop, from_tty);
}
/* info scope command: list the locals for a scope. */
#if !defined (TRACEPOINT_H)
#define TRACEPOINT_H 1
+#include "breakpoint.h"
+#include "target.h"
+
enum actionline_type
{
BADLINE = -1,
extern void tvariables_info_1 (void);
+extern void tfind_1 (enum trace_find_type type, int num,
+ ULONGEST addr1, ULONGEST addr2,
+ int from_tty);
+
#endif /* TRACEPOINT_H */