aboutsummaryrefslogtreecommitdiff
path: root/gdb/mi
diff options
context:
space:
mode:
authorVladimir Prus <vladimir@codesourcery.com>2010-03-23 21:50:11 +0000
committerVladimir Prus <vladimir@codesourcery.com>2010-03-23 21:50:11 +0000
commit40e1c229a2dd402eb050b1025c4b1b7667a7e83e (patch)
treee8fa1df36bc7f26c586864858edfca5915448df9 /gdb/mi
parent9b4c786c6c9f2599873343b935a46a446ba1c029 (diff)
downloadgdb-40e1c229a2dd402eb050b1025c4b1b7667a7e83e.zip
gdb-40e1c229a2dd402eb050b1025c4b1b7667a7e83e.tar.gz
gdb-40e1c229a2dd402eb050b1025c4b1b7667a7e83e.tar.bz2
-trace-define-variable and -trace-list-variables.
* tracepoint.c (create_trace_state_variable): Make private copy of name, as opposed to assuming the pointer lives forever. (tvariables_info_1): New. (tvariables_info): Use the above. * tracepoint.h (create_trace_state_variable, tvariables_info_1): Declare. * mi/mi-cmds.c (mi_cmds): Register -trace-define-variable and -trace-list-variables. * mi/mi-cmds.h (mi_cmd_trace_define_variable) (mi_cmd_trace_list_variables): New. * mi/mi-main.c (mi_cmd_trace_define_variable) (mi_cmd_trace_list_variables): New.
Diffstat (limited to 'gdb/mi')
-rw-r--r--gdb/mi/mi-cmds.c2
-rw-r--r--gdb/mi/mi-cmds.h2
-rw-r--r--gdb/mi/mi-main.c46
3 files changed, 50 insertions, 0 deletions
diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c
index 6b260fc..a07ee3b 100644
--- a/gdb/mi/mi-cmds.c
+++ b/gdb/mi/mi-cmds.c
@@ -106,6 +106,8 @@ struct mi_cmd mi_cmds[] =
{ "thread-info", { NULL, 0 }, mi_cmd_thread_info },
{ "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-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 },
{ "trace-stop", { NULL, 0 }, mi_cmd_trace_stop },
diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h
index b5ff61f..dc2b2c6 100644
--- a/gdb/mi/mi-cmds.h
+++ b/gdb/mi/mi-cmds.h
@@ -89,6 +89,8 @@ extern mi_cmd_argv_ftype mi_cmd_target_file_delete;
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_list_variables;
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_stop;
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index c30e0e5..031c006 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -2080,6 +2080,52 @@ print_diff (struct mi_timestamp *start, struct mi_timestamp *end)
}
void
+mi_cmd_trace_define_variable (char *command, char **argv, int argc)
+{
+ struct expression *expr;
+ struct cleanup *back_to;
+ LONGEST initval = 0;
+ struct trace_state_variable *tsv;
+ char *name = 0;
+
+ if (argc != 1 && argc != 2)
+ error (_("Usage: -trace-define-variable VARIABLE [VALUE]"));
+
+ expr = parse_expression (argv[0]);
+ back_to = make_cleanup (xfree, expr);
+
+ if (expr->nelts == 3 && expr->elts[0].opcode == OP_INTERNALVAR)
+ {
+ struct internalvar *intvar = expr->elts[1].internalvar;
+ if (intvar)
+ name = internalvar_name (intvar);
+ }
+
+ if (!name || *name == '\0')
+ error (_("Invalid name of trace variable"));
+
+ tsv = find_trace_state_variable (name);
+ if (!tsv)
+ tsv = create_trace_state_variable (name);
+
+ if (argc == 2)
+ initval = value_as_long (parse_and_eval (argv[1]));
+
+ tsv->initial_value = initval;
+
+ do_cleanups (back_to);
+}
+
+void
+mi_cmd_trace_list_variables (char *command, char **argv, int argc)
+{
+ if (argc != 0)
+ error (_("-trace-list-variables: no arguments are allowed"));
+
+ tvariables_info_1 ();
+}
+
+void
mi_cmd_trace_start (char *command, char **argv, int argc)
{
start_tracing ();