2010-05-17 Michael Snyder <msnyder@vmware.com>

* mi/mi-cmd-break.c: White space.
	* mi/mi-cmd-env.c: White space.
	* mi/mi-cmds.c: White space.
	* mi/mi-cmd-stack.c: White space.
	* mi/mi-cmd-var.c: White space.
	* mi/mi-console.c: White space.
	* mi/mi-getopt.c: White space.
	* mi/mi-interp.c: White space.
	* mi/mi-main.c: White space.
	* mi/mi-out.c: White space.
	* mi/mi-parse.c: White space.
This commit is contained in:
Michael Snyder 2010-05-17 20:49:39 +00:00
parent cdb27c12f3
commit 102040f0d0
12 changed files with 122 additions and 9 deletions

View file

@ -1,5 +1,17 @@
2010-05-17 Michael Snyder <msnyder@vmware.com> 2010-05-17 Michael Snyder <msnyder@vmware.com>
* mi/mi-cmd-break.c: White space.
* mi/mi-cmd-env.c: White space.
* mi/mi-cmds.c: White space.
* mi/mi-cmd-stack.c: White space.
* mi/mi-cmd-var.c: White space.
* mi/mi-console.c: White space.
* mi/mi-getopt.c: White space.
* mi/mi-interp.c: White space.
* mi/mi-main.c: White space.
* mi/mi-out.c: White space.
* mi/mi-parse.c: White space.
* cli/cli-cmds.c: White space. * cli/cli-cmds.c: White space.
* cli/cli-decode.c: White space. * cli/cli-decode.c: White space.
* cli/cli-dump.c: White space. * cli/cli-dump.c: White space.

View file

@ -99,6 +99,7 @@ mi_cmd_break_insert (char *command, char **argv, int argc)
to denote the end of the option list. */ to denote the end of the option list. */
int optind = 0; int optind = 0;
char *optarg; char *optarg;
while (1) while (1)
{ {
int opt = mi_getopt ("mi_cmd_break_insert", argc, argv, opts, &optind, &optarg); int opt = mi_getopt ("mi_cmd_break_insert", argc, argv, opts, &optind, &optarg);
@ -217,9 +218,12 @@ mi_cmd_break_watch (char *command, char **argv, int argc)
/* Parse arguments. */ /* Parse arguments. */
int optind = 0; int optind = 0;
char *optarg; char *optarg;
while (1) while (1)
{ {
int opt = mi_getopt ("mi_cmd_break_watch", argc, argv, opts, &optind, &optarg); int opt = mi_getopt ("mi_cmd_break_watch", argc, argv,
opts, &optind, &optarg);
if (opt < 0) if (opt < 0)
break; break;
switch ((enum opt) opt) switch ((enum opt) opt)

View file

@ -52,6 +52,7 @@ env_execute_cli_command (const char *cmd, const char *args)
{ {
struct cleanup *old_cleanups; struct cleanup *old_cleanups;
char *run; char *run;
if (args != NULL) if (args != NULL)
run = xstrprintf ("%s %s", cmd, args); run = xstrprintf ("%s %s", cmd, args);
else else
@ -141,6 +142,7 @@ mi_cmd_env_path (char *command, char **argv, int argc)
{ {
int opt = mi_getopt ("mi_cmd_env_path", argc, argv, opts, int opt = mi_getopt ("mi_cmd_env_path", argc, argv, opts,
&optind, &optarg); &optind, &optarg);
if (opt < 0) if (opt < 0)
break; break;
switch ((enum opt) opt) switch ((enum opt) opt)
@ -211,6 +213,7 @@ mi_cmd_env_dir (char *command, char **argv, int argc)
{ {
int opt = mi_getopt ("mi_cmd_env_dir", argc, argv, opts, int opt = mi_getopt ("mi_cmd_env_dir", argc, argv, opts,
&optind, &optarg); &optind, &optarg);
if (opt < 0) if (opt < 0)
break; break;
switch ((enum opt) opt) switch ((enum opt) opt)

View file

@ -204,6 +204,7 @@ mi_cmd_stack_list_args (char *command, char **argv, int argc)
i++, fi = get_prev_frame (fi)) i++, fi = get_prev_frame (fi))
{ {
struct cleanup *cleanup_frame; struct cleanup *cleanup_frame;
QUIT; QUIT;
cleanup_frame = make_cleanup_ui_out_tuple_begin_end (uiout, "frame"); cleanup_frame = make_cleanup_ui_out_tuple_begin_end (uiout, "frame");
ui_out_field_int (uiout, "level", i); ui_out_field_int (uiout, "level", i);
@ -309,6 +310,7 @@ list_args_or_locals (enum what_to_list what, int values, struct frame_info *fi)
struct cleanup *cleanup_tuple = NULL; struct cleanup *cleanup_tuple = NULL;
struct symbol *sym2; struct symbol *sym2;
struct value *val; struct value *val;
if (values != PRINT_NO_VALUES || what == all) if (values != PRINT_NO_VALUES || what == all)
cleanup_tuple = cleanup_tuple =
make_cleanup_ui_out_tuple_begin_end (uiout, NULL); make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
@ -333,6 +335,7 @@ list_args_or_locals (enum what_to_list what, int values, struct frame_info *fi)
&& TYPE_CODE (type) != TYPE_CODE_UNION) && TYPE_CODE (type) != TYPE_CODE_UNION)
{ {
struct value_print_options opts; struct value_print_options opts;
val = read_var_value (sym2, fi); val = read_var_value (sym2, fi);
get_raw_print_options (&opts); get_raw_print_options (&opts);
opts.deref_ref = 1; opts.deref_ref = 1;
@ -345,6 +348,7 @@ list_args_or_locals (enum what_to_list what, int values, struct frame_info *fi)
case PRINT_ALL_VALUES: case PRINT_ALL_VALUES:
{ {
struct value_print_options opts; struct value_print_options opts;
val = read_var_value (sym2, fi); val = read_var_value (sym2, fi);
get_raw_print_options (&opts); get_raw_print_options (&opts);
opts.deref_ref = 1; opts.deref_ref = 1;

View file

@ -62,6 +62,7 @@ print_varobj (struct varobj *var, enum print_values print_values,
if (mi_print_value_p (var, print_values)) if (mi_print_value_p (var, print_values))
{ {
char *val = varobj_get_value (var); char *val = varobj_get_value (var);
ui_out_field_string (uiout, "value", val); ui_out_field_string (uiout, "value", val);
xfree (val); xfree (val);
} }
@ -435,6 +436,7 @@ mi_cmd_var_list_children (char *command, char **argv, int argc)
if (from < to) if (from < to)
{ {
struct cleanup *cleanup_children; struct cleanup *cleanup_children;
if (mi_version (uiout) == 1) if (mi_version (uiout) == 1)
cleanup_children cleanup_children
= make_cleanup_ui_out_tuple_begin_end (uiout, "children"); = make_cleanup_ui_out_tuple_begin_end (uiout, "children");
@ -446,6 +448,7 @@ mi_cmd_var_list_children (char *command, char **argv, int argc)
++ix) ++ix)
{ {
struct cleanup *cleanup_child; struct cleanup *cleanup_child;
cleanup_child = make_cleanup_ui_out_tuple_begin_end (uiout, "child"); cleanup_child = make_cleanup_ui_out_tuple_begin_end (uiout, "child");
print_varobj (child, print_values, 1 /* print expression */); print_varobj (child, print_values, 1 /* print expression */);
do_cleanups (cleanup_child); do_cleanups (cleanup_child);
@ -554,7 +557,9 @@ mi_cmd_var_evaluate_expression (char *command, char **argv, int argc)
optind = 0; optind = 0;
while (1) while (1)
{ {
int opt = mi_getopt ("-var-evaluate-expression", argc, argv, opts, &optind, &optarg); int opt = mi_getopt ("-var-evaluate-expression", argc, argv,
opts, &optind, &optarg);
if (opt < 0) if (opt < 0)
break; break;
switch ((enum opt) opt) switch ((enum opt) opt)
@ -581,12 +586,14 @@ mi_cmd_var_evaluate_expression (char *command, char **argv, int argc)
if (formatFound) if (formatFound)
{ {
char *val = varobj_get_formatted_value (var, format); char *val = varobj_get_formatted_value (var, format);
ui_out_field_string (uiout, "value", val); ui_out_field_string (uiout, "value", val);
xfree (val); xfree (val);
} }
else else
{ {
char *val = varobj_get_value (var); char *val = varobj_get_value (var);
ui_out_field_string (uiout, "value", val); ui_out_field_string (uiout, "value", val);
xfree (val); xfree (val);
} }
@ -732,6 +739,7 @@ varobj_update_one (struct varobj *var, enum print_values print_values,
if (mi_print_value_p (r->varobj, print_values)) if (mi_print_value_p (r->varobj, print_values))
{ {
char *val = varobj_get_value (r->varobj); char *val = varobj_get_value (r->varobj);
ui_out_field_string (uiout, "value", val); ui_out_field_string (uiout, "value", val);
xfree (val); xfree (val);
} }
@ -784,6 +792,7 @@ varobj_update_one (struct varobj *var, enum print_values print_values,
for (j = 0; VEC_iterate (varobj_p, r->new, j, child); ++j) for (j = 0; VEC_iterate (varobj_p, r->new, j, child); ++j)
{ {
struct cleanup *cleanup_child; struct cleanup *cleanup_child;
cleanup_child = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); cleanup_child = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
print_varobj (child, print_values, 1 /* print_expression */); print_varobj (child, print_values, 1 /* print_expression */);
do_cleanups (cleanup_child); do_cleanups (cleanup_child);

View file

@ -164,6 +164,7 @@ lookup_table (const char *command)
{ {
const char *chp; const char *chp;
unsigned int index = 0; unsigned int index = 0;
/* compute our hash */ /* compute our hash */
for (chp = command; *chp; chp++) for (chp = command; *chp; chp++)
{ {
@ -203,6 +204,7 @@ build_table (struct mi_cmd *commands)
for (command = commands; command->name != 0; command++) for (command = commands; command->name != 0; command++)
{ {
struct mi_cmd **entry = lookup_table (command->name); struct mi_cmd **entry = lookup_table (command->name);
if (*entry) if (*entry)
internal_error (__FILE__, __LINE__, internal_error (__FILE__, __LINE__,
_("command `%s' appears to be duplicated"), _("command `%s' appears to be duplicated"),

View file

@ -47,6 +47,7 @@ mi_console_file_new (struct ui_file *raw,
{ {
struct ui_file *ui_file = ui_file_new (); struct ui_file *ui_file = ui_file_new ();
struct mi_console_file *mi_console = XMALLOC (struct mi_console_file); struct mi_console_file *mi_console = XMALLOC (struct mi_console_file);
mi_console->magic = &mi_console_file_magic; mi_console->magic = &mi_console_file_magic;
mi_console->raw = raw; mi_console->raw = raw;
mi_console->buffer = mem_fileopen (); mi_console->buffer = mem_fileopen ();
@ -62,6 +63,7 @@ static void
mi_console_file_delete (struct ui_file *file) mi_console_file_delete (struct ui_file *file)
{ {
struct mi_console_file *mi_console = ui_file_data (file); struct mi_console_file *mi_console = ui_file_data (file);
if (mi_console->magic != &mi_console_file_magic) if (mi_console->magic != &mi_console_file_magic)
internal_error (__FILE__, __LINE__, internal_error (__FILE__, __LINE__,
_("mi_console_file_delete: bad magic number")); _("mi_console_file_delete: bad magic number"));
@ -73,6 +75,7 @@ mi_console_file_fputs (const char *buf,
struct ui_file *file) struct ui_file *file)
{ {
struct mi_console_file *mi_console = ui_file_data (file); struct mi_console_file *mi_console = ui_file_data (file);
if (mi_console->magic != &mi_console_file_magic) if (mi_console->magic != &mi_console_file_magic)
internal_error (__FILE__, __LINE__, internal_error (__FILE__, __LINE__,
"mi_console_file_fputs: bad magic number"); "mi_console_file_fputs: bad magic number");
@ -90,6 +93,7 @@ mi_console_raw_packet (void *data,
long length_buf) long length_buf)
{ {
struct mi_console_file *mi_console = data; struct mi_console_file *mi_console = data;
if (mi_console->magic != &mi_console_file_magic) if (mi_console->magic != &mi_console_file_magic)
internal_error (__FILE__, __LINE__, internal_error (__FILE__, __LINE__,
_("mi_console_file_transform: bad magic number")); _("mi_console_file_transform: bad magic number"));
@ -116,6 +120,7 @@ static void
mi_console_file_flush (struct ui_file *file) mi_console_file_flush (struct ui_file *file)
{ {
struct mi_console_file *mi_console = ui_file_data (file); struct mi_console_file *mi_console = ui_file_data (file);
if (mi_console->magic != &mi_console_file_magic) if (mi_console->magic != &mi_console_file_magic)
internal_error (__FILE__, __LINE__, internal_error (__FILE__, __LINE__,
_("mi_console_file_flush: bad magic number")); _("mi_console_file_flush: bad magic number"));

View file

@ -30,6 +30,7 @@ mi_getopt (const char *prefix,
{ {
char *arg; char *arg;
struct mi_opt *opt; struct mi_opt *opt;
/* We assume that argv/argc are ok. */ /* We assume that argv/argc are ok. */
if (*optind > argc || *optind < 0) if (*optind > argc || *optind < 0)
internal_error (__FILE__, __LINE__, internal_error (__FILE__, __LINE__,

View file

@ -113,8 +113,8 @@ static int
mi_interpreter_resume (void *data) mi_interpreter_resume (void *data)
{ {
struct mi_interp *mi = data; struct mi_interp *mi = data;
/* As per hack note in mi_interpreter_init, swap in the output channels... */
/* As per hack note in mi_interpreter_init, swap in the output channels... */
gdb_setup_readline (); gdb_setup_readline ();
/* These overwrite some of the initialization done in /* These overwrite some of the initialization done in
@ -170,6 +170,7 @@ static struct gdb_exception
mi_interpreter_exec (void *data, const char *command) mi_interpreter_exec (void *data, const char *command)
{ {
char *tmp = alloca (strlen (command) + 1); char *tmp = alloca (strlen (command) + 1);
strcpy (tmp, command); strcpy (tmp, command);
mi_execute_command_wrapper (tmp); mi_execute_command_wrapper (tmp);
return exception_none; return exception_none;
@ -213,6 +214,7 @@ mi_cmd_interpreter_exec (char *command, char **argv, int argc)
for (i = 1; i < argc; i++) for (i = 1; i < argc; i++)
{ {
struct gdb_exception e = interp_exec (interp_to_use, argv[i]); struct gdb_exception e = interp_exec (interp_to_use, argv[i]);
if (e.reason < 0) if (e.reason < 0)
{ {
mi_error_message = xstrdup (e.message); mi_error_message = xstrdup (e.message);
@ -327,6 +329,7 @@ static void
mi_inferior_added (struct inferior *inf) mi_inferior_added (struct inferior *inf)
{ {
struct mi_interp *mi = top_level_interpreter_data (); struct mi_interp *mi = top_level_interpreter_data ();
target_terminal_ours (); target_terminal_ours ();
fprintf_unfiltered (mi->event_channel, fprintf_unfiltered (mi->event_channel,
"thread-group-added,id=\"i%d\"", "thread-group-added,id=\"i%d\"",
@ -338,6 +341,7 @@ static void
mi_inferior_appeared (struct inferior *inf) mi_inferior_appeared (struct inferior *inf)
{ {
struct mi_interp *mi = top_level_interpreter_data (); struct mi_interp *mi = top_level_interpreter_data ();
target_terminal_ours (); target_terminal_ours ();
fprintf_unfiltered (mi->event_channel, fprintf_unfiltered (mi->event_channel,
"thread-group-started,id=\"i%d\",pid=\"%d\"", "thread-group-started,id=\"i%d\",pid=\"%d\"",
@ -349,6 +353,7 @@ static void
mi_inferior_exit (struct inferior *inf) mi_inferior_exit (struct inferior *inf)
{ {
struct mi_interp *mi = top_level_interpreter_data (); struct mi_interp *mi = top_level_interpreter_data ();
target_terminal_ours (); target_terminal_ours ();
fprintf_unfiltered (mi->event_channel, "thread-group-exited,id=\"i%d\"", fprintf_unfiltered (mi->event_channel, "thread-group-exited,id=\"i%d\"",
inf->num); inf->num);
@ -359,6 +364,7 @@ static void
mi_inferior_removed (struct inferior *inf) mi_inferior_removed (struct inferior *inf)
{ {
struct mi_interp *mi = top_level_interpreter_data (); struct mi_interp *mi = top_level_interpreter_data ();
target_terminal_ours (); target_terminal_ours ();
fprintf_unfiltered (mi->event_channel, fprintf_unfiltered (mi->event_channel,
"thread-group-removed,id=\"i%d\"", "thread-group-removed,id=\"i%d\"",
@ -377,6 +383,7 @@ mi_on_normal_stop (struct bpstats *bs, int print_frame)
if (print_frame) if (print_frame)
{ {
int core; int core;
if (uiout != mi_uiout) if (uiout != mi_uiout)
{ {
/* The normal_stop function has printed frame information into /* The normal_stop function has printed frame information into
@ -385,6 +392,7 @@ mi_on_normal_stop (struct bpstats *bs, int print_frame)
the frame again. In practice, this can only happen when running the frame again. In practice, this can only happen when running
a CLI command in MI. */ a CLI command in MI. */
struct ui_out *saved_uiout = uiout; struct ui_out *saved_uiout = uiout;
uiout = mi_uiout; uiout = mi_uiout;
print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC); print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC);
uiout = saved_uiout; uiout = saved_uiout;
@ -396,6 +404,7 @@ mi_on_normal_stop (struct bpstats *bs, int print_frame)
{ {
struct cleanup *back_to = make_cleanup_ui_out_list_begin_end struct cleanup *back_to = make_cleanup_ui_out_list_begin_end
(mi_uiout, "stopped-threads"); (mi_uiout, "stopped-threads");
ui_out_field_int (mi_uiout, NULL, ui_out_field_int (mi_uiout, NULL,
pid_to_thread_id (inferior_ptid)); pid_to_thread_id (inferior_ptid));
do_cleanups (back_to); do_cleanups (back_to);
@ -424,6 +433,7 @@ mi_about_to_proceed (void)
if (!ptid_equal (inferior_ptid, null_ptid)) if (!ptid_equal (inferior_ptid, null_ptid))
{ {
struct thread_info *tp = inferior_thread (); struct thread_info *tp = inferior_thread ();
if (tp->in_infcall) if (tp->in_infcall)
return; return;
} }
@ -503,6 +513,7 @@ mi_on_resume (ptid_t ptid)
else else
{ {
struct thread_info *ti = find_thread_ptid (ptid); struct thread_info *ti = find_thread_ptid (ptid);
gdb_assert (ti); gdb_assert (ti);
fprintf_unfiltered (raw_stdout, "*running,thread-id=\"%d\"\n", ti->num); fprintf_unfiltered (raw_stdout, "*running,thread-id=\"%d\"\n", ti->num);
} }
@ -525,6 +536,7 @@ static void
mi_solib_loaded (struct so_list *solib) mi_solib_loaded (struct so_list *solib)
{ {
struct mi_interp *mi = top_level_interpreter_data (); struct mi_interp *mi = top_level_interpreter_data ();
target_terminal_ours (); target_terminal_ours ();
if (gdbarch_has_global_solist (target_gdbarch)) if (gdbarch_has_global_solist (target_gdbarch))
fprintf_unfiltered (mi->event_channel, fprintf_unfiltered (mi->event_channel,
@ -548,6 +560,7 @@ static void
mi_solib_unloaded (struct so_list *solib) mi_solib_unloaded (struct so_list *solib)
{ {
struct mi_interp *mi = top_level_interpreter_data (); struct mi_interp *mi = top_level_interpreter_data ();
target_terminal_ours (); target_terminal_ours ();
if (gdbarch_has_global_solist (target_gdbarch)) if (gdbarch_has_global_solist (target_gdbarch))
fprintf_unfiltered (mi->event_channel, fprintf_unfiltered (mi->event_channel,
@ -573,6 +586,7 @@ report_initial_inferior (struct inferior *inf, void *closure)
and top_level_interpreter_data is set, we cannot call and top_level_interpreter_data is set, we cannot call
it here. */ it here. */
struct mi_interp *mi = closure; struct mi_interp *mi = closure;
target_terminal_ours (); target_terminal_ours ();
fprintf_unfiltered (mi->event_channel, fprintf_unfiltered (mi->event_channel,
"thread-group-added,id=\"i%d\"", "thread-group-added,id=\"i%d\"",

View file

@ -218,6 +218,7 @@ static int
proceed_thread_callback (struct thread_info *thread, void *arg) proceed_thread_callback (struct thread_info *thread, void *arg)
{ {
int pid = *(int *)arg; int pid = *(int *)arg;
proceed_thread (thread, pid); proceed_thread (thread, pid);
return 0; return 0;
} }
@ -253,6 +254,7 @@ exec_continue (char **argv, int argc)
else else
{ {
struct cleanup *back_to = make_cleanup_restore_integer (&sched_multi); struct cleanup *back_to = make_cleanup_restore_integer (&sched_multi);
if (current_context->all) if (current_context->all)
{ {
sched_multi = 1; sched_multi = 1;
@ -344,6 +346,7 @@ mi_cmd_exec_interrupt (char *command, char **argv, int argc)
else if (current_context->thread_group != -1) else if (current_context->thread_group != -1)
{ {
struct inferior *inf = find_inferior_id (current_context->thread_group); struct inferior *inf = find_inferior_id (current_context->thread_group);
iterate_over_threads (interrupt_thread_callback, &inf->pid); iterate_over_threads (interrupt_thread_callback, &inf->pid);
} }
else else
@ -388,6 +391,7 @@ mi_cmd_exec_run (char *command, char **argv, int argc)
if (current_context->all) if (current_context->all)
{ {
struct cleanup *back_to = save_current_space_and_thread (); struct cleanup *back_to = save_current_space_and_thread ();
iterate_over_inferiors (run_one_inferior, NULL); iterate_over_inferiors (run_one_inferior, NULL);
do_cleanups (back_to); do_cleanups (back_to);
} }
@ -403,6 +407,7 @@ static int
find_thread_of_process (struct thread_info *ti, void *p) find_thread_of_process (struct thread_info *ti, void *p)
{ {
int pid = *(int *)p; int pid = *(int *)p;
if (PIDGET (ti->ptid) == pid && !is_exited (ti->ptid)) if (PIDGET (ti->ptid) == pid && !is_exited (ti->ptid))
return 1; return 1;
@ -420,6 +425,7 @@ mi_cmd_target_detach (char *command, char **argv, int argc)
struct thread_info *tp; struct thread_info *tp;
char *end = argv[0]; char *end = argv[0];
int pid = strtol (argv[0], &end, 10); int pid = strtol (argv[0], &end, 10);
if (*end != '\0') if (*end != '\0')
error (_("Cannot parse thread group id '%s'"), argv[0]); error (_("Cannot parse thread group id '%s'"), argv[0]);
@ -500,6 +506,7 @@ collect_cores (struct thread_info *ti, void *xdata)
if (ptid_get_pid (ti->ptid) == data->pid) if (ptid_get_pid (ti->ptid) == data->pid)
{ {
int core = target_core_of_thread (ti->ptid); int core = target_core_of_thread (ti->ptid);
if (core != -1) if (core != -1)
VEC_safe_push (int, data->cores, core); VEC_safe_push (int, data->cores, core);
} }
@ -511,6 +518,7 @@ static int *
unique (int *b, int *e) unique (int *b, int *e)
{ {
int *d = b; int *d = b;
while (++b != e) while (++b != e)
if (*d != *b) if (*d != *b)
*++d = *b; *++d = *b;
@ -607,6 +615,7 @@ static void
free_vector_of_ints (void *xvector) free_vector_of_ints (void *xvector)
{ {
VEC (int) **vector = xvector; VEC (int) **vector = xvector;
VEC_free (int, *vector); VEC_free (int, *vector);
} }
@ -619,6 +628,7 @@ static void
free_vector_of_osdata_items (splay_tree_value xvalue) free_vector_of_osdata_items (splay_tree_value xvalue)
{ {
VEC (osdata_item_s) *value = (VEC (osdata_item_s) *) xvalue; VEC (osdata_item_s) *value = (VEC (osdata_item_s) *) xvalue;
/* We don't free the items itself, it will be done separately. */ /* We don't free the items itself, it will be done separately. */
VEC_free (osdata_item_s, value); VEC_free (osdata_item_s, value);
} }
@ -628,6 +638,7 @@ splay_tree_int_comparator (splay_tree_key xa, splay_tree_key xb)
{ {
int a = xa; int a = xa;
int b = xb; int b = xb;
return a - b; return a - b;
} }
@ -644,6 +655,7 @@ list_available_thread_groups (VEC (int) *ids, int recurse)
struct osdata *data; struct osdata *data;
struct osdata_item *item; struct osdata_item *item;
int ix_items; int ix_items;
/* This keeps a map from integer (pid) to VEC (struct osdata_item *)* /* This keeps a map from integer (pid) to VEC (struct osdata_item *)*
The vector contains information about all threads for the given pid. The vector contains information about all threads for the given pid.
This is assigned an initial value to avoid "may be used uninitialized" This is assigned an initial value to avoid "may be used uninitialized"
@ -657,8 +669,8 @@ list_available_thread_groups (VEC (int) *ids, int recurse)
if (recurse) if (recurse)
{ {
struct osdata *threads = get_osdata ("threads"); struct osdata *threads = get_osdata ("threads");
make_cleanup_osdata_free (threads);
make_cleanup_osdata_free (threads);
tree = splay_tree_new (splay_tree_int_comparator, tree = splay_tree_new (splay_tree_int_comparator,
do_nothing, do_nothing,
free_vector_of_osdata_items); free_vector_of_osdata_items);
@ -741,9 +753,9 @@ list_available_thread_groups (VEC (int) *ids, int recurse)
{ {
struct cleanup *back_to_2 = struct cleanup *back_to_2 =
make_cleanup_ui_out_tuple_begin_end (uiout, NULL); make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
const char *tid = get_osdata_column (child, "tid"); const char *tid = get_osdata_column (child, "tid");
const char *tcore = get_osdata_column (child, "core"); const char *tcore = get_osdata_column (child, "core");
ui_out_field_string (uiout, "id", tid); ui_out_field_string (uiout, "id", tid);
if (tcore) if (tcore)
ui_out_field_string (uiout, "core", tcore); ui_out_field_string (uiout, "core", tcore);
@ -783,6 +795,7 @@ mi_cmd_list_thread_groups (char *command, char **argv, int argc)
{ {
int opt = mi_getopt ("-list-thread-groups", argc, argv, opts, int opt = mi_getopt ("-list-thread-groups", argc, argv, opts,
&optind, &optarg); &optind, &optarg);
if (opt < 0) if (opt < 0)
break; break;
switch ((enum opt) opt) switch ((enum opt) opt)
@ -805,6 +818,7 @@ mi_cmd_list_thread_groups (char *command, char **argv, int argc)
{ {
char *end; char *end;
int inf = strtoul (argv[optind], &end, 0); int inf = strtoul (argv[optind], &end, 0);
if (*end != '\0') if (*end != '\0')
error ("invalid group id '%s'", argv[optind]); error ("invalid group id '%s'", argv[optind]);
VEC_safe_push (int, ids, inf); VEC_safe_push (int, ids, inf);
@ -824,6 +838,7 @@ mi_cmd_list_thread_groups (char *command, char **argv, int argc)
{ {
/* Local thread groups, single id. */ /* Local thread groups, single id. */
int pid = *VEC_address (int, ids); int pid = *VEC_address (int, ids);
if (!in_inferior_list (pid)) if (!in_inferior_list (pid))
error ("Invalid thread group id '%d'", pid); error ("Invalid thread group id '%d'", pid);
print_thread_info (uiout, -1, pid); print_thread_info (uiout, -1, pid);
@ -831,6 +846,7 @@ mi_cmd_list_thread_groups (char *command, char **argv, int argc)
else else
{ {
struct print_one_inferior_data data; struct print_one_inferior_data data;
data.recurse = recurse; data.recurse = recurse;
data.inferiors = ids; data.inferiors = ids;
@ -1094,6 +1110,7 @@ get_register (struct frame_info *frame, int regnum, int format)
{ {
int idx = gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG ? int idx = gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG ?
j : register_size (gdbarch, regnum) - 1 - j; j : register_size (gdbarch, regnum) - 1 - j;
sprintf (ptr, "%02x", (unsigned char) buffer[idx]); sprintf (ptr, "%02x", (unsigned char) buffer[idx]);
ptr += 2; ptr += 2;
} }
@ -1103,6 +1120,7 @@ get_register (struct frame_info *frame, int regnum, int format)
else else
{ {
struct value_print_options opts; struct value_print_options opts;
get_formatted_print_options (&opts, format); get_formatted_print_options (&opts, format);
opts.deref_ref = 1; opts.deref_ref = 1;
val_print (register_type (gdbarch, regnum), buffer, 0, 0, val_print (register_type (gdbarch, regnum), buffer, 0, 0,
@ -1259,6 +1277,7 @@ mi_cmd_data_read_memory (char *command, char **argv, int argc)
{ {
int opt = mi_getopt ("mi_cmd_data_read_memory", argc, argv, opts, int opt = mi_getopt ("mi_cmd_data_read_memory", argc, argv, opts,
&optind, &optarg); &optind, &optarg);
if (opt < 0) if (opt < 0)
break; break;
switch ((enum opt) opt) switch ((enum opt) opt)
@ -1351,6 +1370,7 @@ mi_cmd_data_read_memory (char *command, char **argv, int argc)
struct cleanup *cleanup_list_memory; struct cleanup *cleanup_list_memory;
int row; int row;
int row_byte; int row_byte;
cleanup_list_memory = make_cleanup_ui_out_list_begin_end (uiout, "memory"); cleanup_list_memory = make_cleanup_ui_out_list_begin_end (uiout, "memory");
for (row = 0, row_byte = 0; for (row = 0, row_byte = 0;
row < nr_rows; row < nr_rows;
@ -1387,6 +1407,7 @@ mi_cmd_data_read_memory (char *command, char **argv, int argc)
if (aschar) if (aschar)
{ {
int byte; int byte;
ui_file_rewind (stream->stream); ui_file_rewind (stream->stream);
for (byte = row_byte; byte < row_byte + word_size * nr_cols; byte++) for (byte = row_byte; byte < row_byte + word_size * nr_cols; byte++)
{ {
@ -1457,6 +1478,7 @@ mi_cmd_data_write_memory (char *command, char **argv, int argc)
{ {
int opt = mi_getopt ("mi_cmd_data_write_memory", argc, argv, opts, int opt = mi_getopt ("mi_cmd_data_write_memory", argc, argv, opts,
&optind, &optarg); &optind, &optarg);
if (opt < 0) if (opt < 0)
break; break;
switch ((enum opt) opt) switch ((enum opt) opt)
@ -1525,8 +1547,8 @@ mi_cmd_list_features (char *command, char **argv, int argc)
if (argc == 0) if (argc == 0)
{ {
struct cleanup *cleanup = NULL; struct cleanup *cleanup = NULL;
cleanup = make_cleanup_ui_out_list_begin_end (uiout, "features");
cleanup = make_cleanup_ui_out_list_begin_end (uiout, "features");
ui_out_field_string (uiout, NULL, "frozen-varobjs"); ui_out_field_string (uiout, NULL, "frozen-varobjs");
ui_out_field_string (uiout, NULL, "pending-breakpoints"); ui_out_field_string (uiout, NULL, "pending-breakpoints");
ui_out_field_string (uiout, NULL, "thread-info"); ui_out_field_string (uiout, NULL, "thread-info");
@ -1548,8 +1570,8 @@ mi_cmd_list_target_features (char *command, char **argv, int argc)
if (argc == 0) if (argc == 0)
{ {
struct cleanup *cleanup = NULL; struct cleanup *cleanup = NULL;
cleanup = make_cleanup_ui_out_list_begin_end (uiout, "features");
cleanup = make_cleanup_ui_out_list_begin_end (uiout, "features");
if (target_can_async_p ()) if (target_can_async_p ())
ui_out_field_string (uiout, NULL, "async"); ui_out_field_string (uiout, NULL, "async");
@ -1655,6 +1677,7 @@ captured_mi_execute_command (struct ui_out *uiout, void *data)
case CLI_COMMAND: case CLI_COMMAND:
{ {
char *argv[2]; char *argv[2];
/* A CLI command was read from the input stream. */ /* A CLI command was read from the input stream. */
/* This "feature" will be removed as soon as we have a /* This "feature" will be removed as soon as we have a
complete set of mi commands. */ complete set of mi commands. */
@ -1761,12 +1784,14 @@ mi_execute_command (char *cmd, int from_tty)
else if (!ptid_equal (inferior_ptid, null_ptid)) else if (!ptid_equal (inferior_ptid, null_ptid))
{ {
struct thread_info *ti = inferior_thread (); struct thread_info *ti = inferior_thread ();
report_change = (ti->num != command->thread); report_change = (ti->num != command->thread);
} }
if (report_change) if (report_change)
{ {
struct thread_info *ti = inferior_thread (); struct thread_info *ti = inferior_thread ();
target_terminal_ours (); target_terminal_ours ();
fprintf_unfiltered (mi->event_channel, fprintf_unfiltered (mi->event_channel,
"thread-selected,id=\"%d\"", "thread-selected,id=\"%d\"",
@ -1827,6 +1852,7 @@ mi_cmd_execute (struct mi_parse *parse)
if (parse->thread != -1) if (parse->thread != -1)
{ {
struct thread_info *tp = find_thread_id (parse->thread); struct thread_info *tp = find_thread_id (parse->thread);
if (!tp) if (!tp)
error (_("Invalid thread id: %d"), parse->thread); error (_("Invalid thread id: %d"), parse->thread);
@ -1840,6 +1866,7 @@ mi_cmd_execute (struct mi_parse *parse)
{ {
struct frame_info *fid; struct frame_info *fid;
int frame = parse->frame; int frame = parse->frame;
fid = find_relative_frame (get_current_frame (), &frame); fid = find_relative_frame (get_current_frame (), &frame);
if (frame == 0) if (frame == 0)
/* find_relative_frame was successful */ /* find_relative_frame was successful */
@ -1888,6 +1915,7 @@ mi_execute_cli_command (const char *cmd, int args_p, const char *args)
{ {
struct cleanup *old_cleanups; struct cleanup *old_cleanups;
char *run; char *run;
if (args_p) if (args_p)
run = xstrprintf ("%s %s", cmd, args); run = xstrprintf ("%s %s", cmd, args);
else else
@ -1977,6 +2005,7 @@ mi_load_progress (const char *section_name,
if (new_section) if (new_section)
{ {
struct cleanup *cleanup_tuple; struct cleanup *cleanup_tuple;
xfree (previous_sect_name); xfree (previous_sect_name);
previous_sect_name = xstrdup (section_name); previous_sect_name = xstrdup (section_name);
@ -1997,6 +2026,7 @@ mi_load_progress (const char *section_name,
delta.tv_usec >= update_threshold.tv_usec) delta.tv_usec >= update_threshold.tv_usec)
{ {
struct cleanup *cleanup_tuple; struct cleanup *cleanup_tuple;
last_update.tv_sec = time_now.tv_sec; last_update.tv_sec = time_now.tv_sec;
last_update.tv_usec = time_now.tv_usec; last_update.tv_usec = time_now.tv_usec;
if (current_token) if (current_token)
@ -2044,6 +2074,7 @@ static void
print_diff_now (struct mi_timestamp *start) print_diff_now (struct mi_timestamp *start)
{ {
struct mi_timestamp now; struct mi_timestamp now;
timestamp (&now); timestamp (&now);
print_diff (start, &now); print_diff (start, &now);
} }
@ -2093,6 +2124,7 @@ mi_cmd_trace_define_variable (char *command, char **argv, int argc)
if (expr->nelts == 3 && expr->elts[0].opcode == OP_INTERNALVAR) if (expr->nelts == 3 && expr->elts[0].opcode == OP_INTERNALVAR)
{ {
struct internalvar *intvar = expr->elts[1].internalvar; struct internalvar *intvar = expr->elts[1].internalvar;
if (intvar) if (intvar)
name = internalvar_name (intvar); name = internalvar_name (intvar);
} }

View file

@ -120,6 +120,7 @@ void
mi_table_body (struct ui_out *uiout) mi_table_body (struct ui_out *uiout)
{ {
mi_out_data *data = ui_out_data (uiout); mi_out_data *data = ui_out_data (uiout);
if (data->suppress_output) if (data->suppress_output)
return; return;
/* close the table header line if there were any headers */ /* close the table header line if there were any headers */
@ -133,6 +134,7 @@ void
mi_table_end (struct ui_out *uiout) mi_table_end (struct ui_out *uiout)
{ {
mi_out_data *data = ui_out_data (uiout); mi_out_data *data = ui_out_data (uiout);
data->suppress_output = 0; data->suppress_output = 0;
mi_close (uiout, ui_out_type_list); /* body */ mi_close (uiout, ui_out_type_list); /* body */
mi_close (uiout, ui_out_type_tuple); mi_close (uiout, ui_out_type_tuple);
@ -146,6 +148,7 @@ mi_table_header (struct ui_out *uiout, int width, enum ui_align alignment,
const char *colhdr) const char *colhdr)
{ {
mi_out_data *data = ui_out_data (uiout); mi_out_data *data = ui_out_data (uiout);
if (data->suppress_output) if (data->suppress_output)
return; return;
mi_open (uiout, NULL, ui_out_type_tuple); mi_open (uiout, NULL, ui_out_type_tuple);
@ -165,6 +168,7 @@ mi_begin (struct ui_out *uiout,
const char *id) const char *id)
{ {
mi_out_data *data = ui_out_data (uiout); mi_out_data *data = ui_out_data (uiout);
if (data->suppress_output) if (data->suppress_output)
return; return;
mi_open (uiout, id, type); mi_open (uiout, id, type);
@ -178,6 +182,7 @@ mi_end (struct ui_out *uiout,
int level) int level)
{ {
mi_out_data *data = ui_out_data (uiout); mi_out_data *data = ui_out_data (uiout);
if (data->suppress_output) if (data->suppress_output)
return; return;
mi_close (uiout, type); mi_close (uiout, type);
@ -191,6 +196,7 @@ mi_field_int (struct ui_out *uiout, int fldno, int width,
{ {
char buffer[20]; /* FIXME: how many chars long a %d can become? */ char buffer[20]; /* FIXME: how many chars long a %d can become? */
mi_out_data *data = ui_out_data (uiout); mi_out_data *data = ui_out_data (uiout);
if (data->suppress_output) if (data->suppress_output)
return; return;
@ -205,6 +211,7 @@ mi_field_skip (struct ui_out *uiout, int fldno, int width,
enum ui_align alignment, const char *fldname) enum ui_align alignment, const char *fldname)
{ {
mi_out_data *data = ui_out_data (uiout); mi_out_data *data = ui_out_data (uiout);
if (data->suppress_output) if (data->suppress_output)
return; return;
mi_field_string (uiout, fldno, width, alignment, fldname, ""); mi_field_string (uiout, fldno, width, alignment, fldname, "");
@ -222,6 +229,7 @@ mi_field_string (struct ui_out *uiout,
const char *string) const char *string)
{ {
mi_out_data *data = ui_out_data (uiout); mi_out_data *data = ui_out_data (uiout);
if (data->suppress_output) if (data->suppress_output)
return; return;
field_separator (uiout); field_separator (uiout);
@ -243,6 +251,7 @@ mi_field_fmt (struct ui_out *uiout, int fldno,
va_list args) va_list args)
{ {
mi_out_data *data = ui_out_data (uiout); mi_out_data *data = ui_out_data (uiout);
if (data->suppress_output) if (data->suppress_output)
return; return;
field_separator (uiout); field_separator (uiout);
@ -281,6 +290,7 @@ void
mi_flush (struct ui_out *uiout) mi_flush (struct ui_out *uiout)
{ {
mi_out_data *data = ui_out_data (uiout); mi_out_data *data = ui_out_data (uiout);
gdb_flush (data->buffer); gdb_flush (data->buffer);
} }
@ -292,6 +302,7 @@ static void
field_separator (struct ui_out *uiout) field_separator (struct ui_out *uiout)
{ {
mi_out_data *data = ui_out_data (uiout); mi_out_data *data = ui_out_data (uiout);
if (data->suppress_field_separator) if (data->suppress_field_separator)
data->suppress_field_separator = 0; data->suppress_field_separator = 0;
else else
@ -304,6 +315,7 @@ mi_open (struct ui_out *uiout,
enum ui_out_type type) enum ui_out_type type)
{ {
mi_out_data *data = ui_out_data (uiout); mi_out_data *data = ui_out_data (uiout);
field_separator (uiout); field_separator (uiout);
data->suppress_field_separator = 1; data->suppress_field_separator = 1;
if (name) if (name)
@ -326,6 +338,7 @@ mi_close (struct ui_out *uiout,
enum ui_out_type type) enum ui_out_type type)
{ {
mi_out_data *data = ui_out_data (uiout); mi_out_data *data = ui_out_data (uiout);
switch (type) switch (type)
{ {
case ui_out_type_tuple: case ui_out_type_tuple:
@ -346,6 +359,7 @@ void
mi_out_buffered (struct ui_out *uiout, char *string) mi_out_buffered (struct ui_out *uiout, char *string)
{ {
mi_out_data *data = ui_out_data (uiout); mi_out_data *data = ui_out_data (uiout);
fprintf_unfiltered (data->buffer, "%s", string); fprintf_unfiltered (data->buffer, "%s", string);
} }
@ -355,6 +369,7 @@ void
mi_out_rewind (struct ui_out *uiout) mi_out_rewind (struct ui_out *uiout)
{ {
mi_out_data *data = ui_out_data (uiout); mi_out_data *data = ui_out_data (uiout);
ui_file_rewind (data->buffer); ui_file_rewind (data->buffer);
} }
@ -371,6 +386,7 @@ mi_out_put (struct ui_out *uiout,
struct ui_file *stream) struct ui_file *stream)
{ {
mi_out_data *data = ui_out_data (uiout); mi_out_data *data = ui_out_data (uiout);
ui_file_put (data->buffer, do_write, stream); ui_file_put (data->buffer, do_write, stream);
ui_file_rewind (data->buffer); ui_file_rewind (data->buffer);
} }
@ -381,6 +397,7 @@ int
mi_version (struct ui_out *uiout) mi_version (struct ui_out *uiout)
{ {
mi_out_data *data = ui_out_data (uiout); mi_out_data *data = ui_out_data (uiout);
return data->mi_version; return data->mi_version;
} }
@ -390,6 +407,7 @@ struct ui_out *
mi_out_new (int mi_version) mi_out_new (int mi_version)
{ {
int flags = 0; int flags = 0;
mi_out_data *data = XMALLOC (mi_out_data); mi_out_data *data = XMALLOC (mi_out_data);
data->suppress_field_separator = 0; data->suppress_field_separator = 0;
data->suppress_output = 0; data->suppress_output = 0;

View file

@ -35,6 +35,7 @@ static int
mi_parse_escape (char **string_ptr) mi_parse_escape (char **string_ptr)
{ {
int c = *(*string_ptr)++; int c = *(*string_ptr)++;
switch (c) switch (c)
{ {
case '\n': case '\n':
@ -54,6 +55,7 @@ mi_parse_escape (char **string_ptr)
{ {
int i = host_hex_value (c); int i = host_hex_value (c);
int count = 0; int count = 0;
while (++count < 3) while (++count < 3)
{ {
c = (**string_ptr); c = (**string_ptr);
@ -106,10 +108,12 @@ mi_parse_argv (char *args, struct mi_parse *parse)
char *chp = args; char *chp = args;
int argc = 0; int argc = 0;
char **argv = xmalloc ((argc + 1) * sizeof (char *)); char **argv = xmalloc ((argc + 1) * sizeof (char *));
argv[argc] = NULL; argv[argc] = NULL;
while (1) while (1)
{ {
char *arg; char *arg;
/* skip leading white space */ /* skip leading white space */
while (isspace (*chp)) while (isspace (*chp))
chp++; chp++;
@ -125,6 +129,7 @@ mi_parse_argv (char *args, struct mi_parse *parse)
/* A quoted string. */ /* A quoted string. */
int len; int len;
char *start = chp + 1; char *start = chp + 1;
/* Determine the buffer size. */ /* Determine the buffer size. */
chp = start; chp = start;
len = 0; len = 0;
@ -182,6 +187,7 @@ mi_parse_argv (char *args, struct mi_parse *parse)
characters into a buffer. */ characters into a buffer. */
int len; int len;
char *start = chp; char *start = chp;
while (*chp != '\0' && !isspace (*chp)) while (*chp != '\0' && !isspace (*chp))
{ {
chp++; chp++;
@ -223,6 +229,7 @@ mi_parse (char *cmd)
{ {
char *chp; char *chp;
struct mi_parse *parse = XMALLOC (struct mi_parse); struct mi_parse *parse = XMALLOC (struct mi_parse);
memset (parse, 0, sizeof (*parse)); memset (parse, 0, sizeof (*parse));
parse->all = 0; parse->all = 0;
parse->thread_group = -1; parse->thread_group = -1;
@ -253,6 +260,7 @@ mi_parse (char *cmd)
/* Extract the command. */ /* Extract the command. */
{ {
char *tmp = chp + 1; /* discard ``-'' */ char *tmp = chp + 1; /* discard ``-'' */
for (; *chp && !isspace (*chp); chp++) for (; *chp && !isspace (*chp); chp++)
; ;
parse->command = xmalloc ((chp - tmp + 1) * sizeof (char *)); parse->command = xmalloc ((chp - tmp + 1) * sizeof (char *));
@ -289,6 +297,7 @@ mi_parse (char *cmd)
size_t tgs = sizeof ("--thread-group ") - 1; size_t tgs = sizeof ("--thread-group ") - 1;
size_t ts = sizeof ("--thread ") - 1; size_t ts = sizeof ("--thread ") - 1;
size_t fs = sizeof ("--frame ") - 1; size_t fs = sizeof ("--frame ") - 1;
if (strncmp (chp, "--all ", as) == 0) if (strncmp (chp, "--all ", as) == 0)
{ {
parse->all = 1; parse->all = 1;