mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-28 23:39:35 +08:00
Implement -trace-save.
* mi-cmds.h (mi_cmds_trace_save): Declare. * mi-cmds.c (mi_cmds): Register -trace-save. * mi/mi-main.c (mi_cmd_trace_save): New. * remote.c (remote_save_trace_data): Take const parameter. * target.h (struct target_ops::to_save_trace_data): Take const parameter. * target.c (update_current_target): Adjust to the above. * tracepoint.c (trave_save): New, extracted from (trace_save_command): ...this. (tfile_trace_find): Remove message that is unnecessary now that 'tfind' reports found frame. * tracepoint.h (trace_save): Declare.
This commit is contained in:
@ -1,3 +1,20 @@
|
|||||||
|
2010-03-24 Vladimir Prus <vladimir@codesourcery.com>
|
||||||
|
|
||||||
|
Implement -trace-save.
|
||||||
|
|
||||||
|
* mi-cmds.h (mi_cmds_trace_save): Declare.
|
||||||
|
* mi-cmds.c (mi_cmds): Register -trace-save.
|
||||||
|
* mi/mi-main.c (mi_cmd_trace_save): New.
|
||||||
|
* remote.c (remote_save_trace_data): Take const parameter.
|
||||||
|
* target.h (struct target_ops::to_save_trace_data): Take
|
||||||
|
const parameter.
|
||||||
|
* target.c (update_current_target): Adjust to the above.
|
||||||
|
* tracepoint.c (trave_save): New, extracted from
|
||||||
|
(trace_save_command): ...this.
|
||||||
|
(tfile_trace_find): Remove message that is unnecessary now
|
||||||
|
that 'tfind' reports found frame.
|
||||||
|
* tracepoint.h (trace_save): Declare.
|
||||||
|
|
||||||
2010-03-24 Vladimir Prus <vladimir@codesourcery.com>
|
2010-03-24 Vladimir Prus <vladimir@codesourcery.com>
|
||||||
|
|
||||||
Implement -trace-find.
|
Implement -trace-find.
|
||||||
|
@ -109,6 +109,7 @@ struct mi_cmd mi_cmds[] =
|
|||||||
{ "trace-define-variable", { NULL, 0 }, mi_cmd_trace_define_variable },
|
{ "trace-define-variable", { NULL, 0 }, mi_cmd_trace_define_variable },
|
||||||
{ "trace-find", { NULL, 0 }, mi_cmd_trace_find },
|
{ "trace-find", { NULL, 0 }, mi_cmd_trace_find },
|
||||||
{ "trace-list-variables", { NULL, 0 }, mi_cmd_trace_list_variables },
|
{ "trace-list-variables", { NULL, 0 }, mi_cmd_trace_list_variables },
|
||||||
|
{ "trace-save", { NULL, 0 }, mi_cmd_trace_save },
|
||||||
{ "trace-start", { NULL, 0 }, mi_cmd_trace_start },
|
{ "trace-start", { NULL, 0 }, mi_cmd_trace_start },
|
||||||
{ "trace-status", { NULL, 0 }, mi_cmd_trace_status },
|
{ "trace-status", { NULL, 0 }, mi_cmd_trace_status },
|
||||||
{ "trace-stop", { NULL, 0 }, mi_cmd_trace_stop },
|
{ "trace-stop", { NULL, 0 }, mi_cmd_trace_stop },
|
||||||
|
@ -92,6 +92,7 @@ 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_define_variable;
|
||||||
extern mi_cmd_argv_ftype mi_cmd_trace_find;
|
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_list_variables;
|
||||||
|
extern mi_cmd_argv_ftype mi_cmd_trace_save;
|
||||||
extern mi_cmd_argv_ftype mi_cmd_trace_start;
|
extern mi_cmd_argv_ftype mi_cmd_trace_start;
|
||||||
extern mi_cmd_argv_ftype mi_cmd_trace_status;
|
extern mi_cmd_argv_ftype mi_cmd_trace_status;
|
||||||
extern mi_cmd_argv_ftype mi_cmd_trace_stop;
|
extern mi_cmd_argv_ftype mi_cmd_trace_stop;
|
||||||
|
@ -2210,6 +2210,32 @@ mi_cmd_trace_find (char *command, char **argv, int argc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
mi_cmd_trace_save (char *command, char **argv, int argc)
|
||||||
|
{
|
||||||
|
int target_saves = 0;
|
||||||
|
char *filename;
|
||||||
|
|
||||||
|
if (argc != 1 && argc != 2)
|
||||||
|
error (_("Usage: -trace-save [-r] filename"));
|
||||||
|
|
||||||
|
if (argc == 2)
|
||||||
|
{
|
||||||
|
filename = argv[1];
|
||||||
|
if (strcmp (argv[0], "-r") == 0)
|
||||||
|
target_saves = 1;
|
||||||
|
else
|
||||||
|
error (_("Invalid option: %s"), argv[0]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
filename = argv[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
trace_save (filename, target_saves);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
mi_cmd_trace_start (char *command, char **argv, int argc)
|
mi_cmd_trace_start (char *command, char **argv, int argc)
|
||||||
{
|
{
|
||||||
|
@ -9583,7 +9583,7 @@ remote_get_trace_state_variable_value (int tsvnum, LONGEST *val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
remote_save_trace_data (char *filename)
|
remote_save_trace_data (const char *filename)
|
||||||
{
|
{
|
||||||
struct remote_state *rs = get_remote_state ();
|
struct remote_state *rs = get_remote_state ();
|
||||||
char *p, *reply;
|
char *p, *reply;
|
||||||
|
@ -836,7 +836,7 @@ update_current_target (void)
|
|||||||
(int (*) (int, LONGEST *))
|
(int (*) (int, LONGEST *))
|
||||||
return_zero);
|
return_zero);
|
||||||
de_fault (to_save_trace_data,
|
de_fault (to_save_trace_data,
|
||||||
(int (*) (char *))
|
(int (*) (const char *))
|
||||||
tcomplain);
|
tcomplain);
|
||||||
de_fault (to_upload_tracepoints,
|
de_fault (to_upload_tracepoints,
|
||||||
(int (*) (struct uploaded_tp **))
|
(int (*) (struct uploaded_tp **))
|
||||||
|
@ -653,7 +653,7 @@ struct target_ops
|
|||||||
location pointed to by VAL, else returning 0. */
|
location pointed to by VAL, else returning 0. */
|
||||||
int (*to_get_trace_state_variable_value) (int tsv, LONGEST *val);
|
int (*to_get_trace_state_variable_value) (int tsv, LONGEST *val);
|
||||||
|
|
||||||
int (*to_save_trace_data) (char *filename);
|
int (*to_save_trace_data) (const char *filename);
|
||||||
|
|
||||||
int (*to_upload_tracepoints) (struct uploaded_tp **utpp);
|
int (*to_upload_tracepoints) (struct uploaded_tp **utpp);
|
||||||
|
|
||||||
|
@ -2405,13 +2405,15 @@ trace_dump_command (char *args, int from_tty)
|
|||||||
|
|
||||||
extern int trace_regblock_size;
|
extern int trace_regblock_size;
|
||||||
|
|
||||||
static void
|
/* Save tracepoint data to file named FILENAME. If TARGET_DOES_SAVE is
|
||||||
trace_save_command (char *args, int from_tty)
|
non-zero, the save is performed on the target, otherwise GDB obtains all
|
||||||
|
trace data and saves it locally. */
|
||||||
|
|
||||||
|
void
|
||||||
|
trace_save (const char *filename, int target_does_save)
|
||||||
{
|
{
|
||||||
char **argv;
|
|
||||||
char *filename = NULL, *pathname;
|
|
||||||
int target_does_save = 0;
|
|
||||||
struct cleanup *cleanup;
|
struct cleanup *cleanup;
|
||||||
|
char *pathname;
|
||||||
struct trace_status *ts = current_trace_status ();
|
struct trace_status *ts = current_trace_status ();
|
||||||
int err, status;
|
int err, status;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
@ -2424,25 +2426,6 @@ trace_save_command (char *args, int from_tty)
|
|||||||
gdb_byte buf[MAX_TRACE_UPLOAD];
|
gdb_byte buf[MAX_TRACE_UPLOAD];
|
||||||
int written;
|
int written;
|
||||||
|
|
||||||
if (args == NULL)
|
|
||||||
error_no_arg (_("file in which to save trace data"));
|
|
||||||
|
|
||||||
argv = gdb_buildargv (args);
|
|
||||||
make_cleanup_freeargv (argv);
|
|
||||||
|
|
||||||
for (; *argv; ++argv)
|
|
||||||
{
|
|
||||||
if (strcmp (*argv, "-r") == 0)
|
|
||||||
target_does_save = 1;
|
|
||||||
else if (**argv == '-')
|
|
||||||
error (_("unknown option `%s'"), *argv);
|
|
||||||
else
|
|
||||||
filename = *argv;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!filename)
|
|
||||||
error_no_arg (_("file in which to save trace data"));
|
|
||||||
|
|
||||||
/* If the target is to save the data to a file on its own, then just
|
/* If the target is to save the data to a file on its own, then just
|
||||||
send the command and be done with it. */
|
send the command and be done with it. */
|
||||||
if (target_does_save)
|
if (target_does_save)
|
||||||
@ -2458,13 +2441,13 @@ trace_save_command (char *args, int from_tty)
|
|||||||
target is losing, we can get out without touching files. */
|
target is losing, we can get out without touching files. */
|
||||||
status = target_get_trace_status (ts);
|
status = target_get_trace_status (ts);
|
||||||
|
|
||||||
pathname = tilde_expand (args);
|
pathname = tilde_expand (filename);
|
||||||
cleanup = make_cleanup (xfree, pathname);
|
cleanup = make_cleanup (xfree, pathname);
|
||||||
|
|
||||||
fp = fopen (pathname, "w");
|
fp = fopen (pathname, "w");
|
||||||
if (!fp)
|
if (!fp)
|
||||||
error (_("Unable to open file '%s' for saving trace data (%s)"),
|
error (_("Unable to open file '%s' for saving trace data (%s)"),
|
||||||
args, safe_strerror (errno));
|
filename, safe_strerror (errno));
|
||||||
make_cleanup_fclose (fp);
|
make_cleanup_fclose (fp);
|
||||||
|
|
||||||
/* Write a file header, with a high-bit-set char to indicate a
|
/* Write a file header, with a high-bit-set char to indicate a
|
||||||
@ -2576,8 +2559,41 @@ trace_save_command (char *args, int from_tty)
|
|||||||
perror_with_name (pathname);
|
perror_with_name (pathname);
|
||||||
|
|
||||||
do_cleanups (cleanup);
|
do_cleanups (cleanup);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
trace_save_command (char *args, int from_tty)
|
||||||
|
{
|
||||||
|
int target_does_save = 0;
|
||||||
|
char **argv;
|
||||||
|
char *filename = NULL;
|
||||||
|
struct cleanup *back_to;
|
||||||
|
|
||||||
|
if (args == NULL)
|
||||||
|
error_no_arg (_("file in which to save trace data"));
|
||||||
|
|
||||||
|
argv = gdb_buildargv (args);
|
||||||
|
back_to = make_cleanup_freeargv (argv);
|
||||||
|
|
||||||
|
for (; *argv; ++argv)
|
||||||
|
{
|
||||||
|
if (strcmp (*argv, "-r") == 0)
|
||||||
|
target_does_save = 1;
|
||||||
|
else if (**argv == '-')
|
||||||
|
error (_("unknown option `%s'"), *argv);
|
||||||
|
else
|
||||||
|
filename = *argv;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!filename)
|
||||||
|
error_no_arg (_("file in which to save trace data"));
|
||||||
|
|
||||||
|
trace_save (filename, target_does_save);
|
||||||
|
|
||||||
if (from_tty)
|
if (from_tty)
|
||||||
printf_filtered (_("Trace data saved to file '%s'.\n"), args);
|
printf_filtered (_("Trace data saved to file '%s'.\n"), args);
|
||||||
|
|
||||||
|
do_cleanups (back_to);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tell the target what to do with an ongoing tracing run if GDB
|
/* Tell the target what to do with an ongoing tracing run if GDB
|
||||||
@ -3426,7 +3442,6 @@ tfile_trace_find (enum trace_find_type type, int num,
|
|||||||
}
|
}
|
||||||
if (found)
|
if (found)
|
||||||
{
|
{
|
||||||
printf_filtered ("Found traceframe %d.\n", tfnum);
|
|
||||||
if (tpp)
|
if (tpp)
|
||||||
*tpp = tpnum;
|
*tpp = tpnum;
|
||||||
cur_offset = offset;
|
cur_offset = offset;
|
||||||
|
@ -184,4 +184,6 @@ extern void tfind_1 (enum trace_find_type type, int num,
|
|||||||
ULONGEST addr1, ULONGEST addr2,
|
ULONGEST addr1, ULONGEST addr2,
|
||||||
int from_tty);
|
int from_tty);
|
||||||
|
|
||||||
|
extern void trace_save (const char *filename, int target_does_save);
|
||||||
|
|
||||||
#endif /* TRACEPOINT_H */
|
#endif /* TRACEPOINT_H */
|
||||||
|
Reference in New Issue
Block a user