* 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.
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-decode.c: White space.
* cli/cli-dump.c: White space.
to denote the end of the option list. */
int optind = 0;
char *optarg;
+
while (1)
{
int opt = mi_getopt ("mi_cmd_break_insert", argc, argv, opts, &optind, &optarg);
/* Parse arguments. */
int optind = 0;
char *optarg;
+
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)
break;
switch ((enum opt) opt)
{
struct cleanup *old_cleanups;
char *run;
+
if (args != NULL)
run = xstrprintf ("%s %s", cmd, args);
else
{
int opt = mi_getopt ("mi_cmd_env_path", argc, argv, opts,
&optind, &optarg);
+
if (opt < 0)
break;
switch ((enum opt) opt)
{
int opt = mi_getopt ("mi_cmd_env_dir", argc, argv, opts,
&optind, &optarg);
+
if (opt < 0)
break;
switch ((enum opt) opt)
i++, fi = get_prev_frame (fi))
{
struct cleanup *cleanup_frame;
+
QUIT;
cleanup_frame = make_cleanup_ui_out_tuple_begin_end (uiout, "frame");
ui_out_field_int (uiout, "level", i);
struct cleanup *cleanup_tuple = NULL;
struct symbol *sym2;
struct value *val;
+
if (values != PRINT_NO_VALUES || what == all)
cleanup_tuple =
make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
&& TYPE_CODE (type) != TYPE_CODE_UNION)
{
struct value_print_options opts;
+
val = read_var_value (sym2, fi);
get_raw_print_options (&opts);
opts.deref_ref = 1;
case PRINT_ALL_VALUES:
{
struct value_print_options opts;
+
val = read_var_value (sym2, fi);
get_raw_print_options (&opts);
opts.deref_ref = 1;
if (mi_print_value_p (var, print_values))
{
char *val = varobj_get_value (var);
+
ui_out_field_string (uiout, "value", val);
xfree (val);
}
if (from < to)
{
struct cleanup *cleanup_children;
+
if (mi_version (uiout) == 1)
cleanup_children
= make_cleanup_ui_out_tuple_begin_end (uiout, "children");
++ix)
{
struct cleanup *cleanup_child;
+
cleanup_child = make_cleanup_ui_out_tuple_begin_end (uiout, "child");
print_varobj (child, print_values, 1 /* print expression */);
do_cleanups (cleanup_child);
optind = 0;
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)
break;
switch ((enum opt) opt)
if (formatFound)
{
char *val = varobj_get_formatted_value (var, format);
+
ui_out_field_string (uiout, "value", val);
xfree (val);
}
else
{
char *val = varobj_get_value (var);
+
ui_out_field_string (uiout, "value", val);
xfree (val);
}
if (mi_print_value_p (r->varobj, print_values))
{
char *val = varobj_get_value (r->varobj);
+
ui_out_field_string (uiout, "value", val);
xfree (val);
}
for (j = 0; VEC_iterate (varobj_p, r->new, j, child); ++j)
{
struct cleanup *cleanup_child;
+
cleanup_child = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
print_varobj (child, print_values, 1 /* print_expression */);
do_cleanups (cleanup_child);
{
const char *chp;
unsigned int index = 0;
+
/* compute our hash */
for (chp = command; *chp; chp++)
{
for (command = commands; command->name != 0; command++)
{
struct mi_cmd **entry = lookup_table (command->name);
+
if (*entry)
internal_error (__FILE__, __LINE__,
_("command `%s' appears to be duplicated"),
{
struct ui_file *ui_file = ui_file_new ();
struct mi_console_file *mi_console = XMALLOC (struct mi_console_file);
+
mi_console->magic = &mi_console_file_magic;
mi_console->raw = raw;
mi_console->buffer = mem_fileopen ();
mi_console_file_delete (struct ui_file *file)
{
struct mi_console_file *mi_console = ui_file_data (file);
+
if (mi_console->magic != &mi_console_file_magic)
internal_error (__FILE__, __LINE__,
_("mi_console_file_delete: bad magic number"));
struct ui_file *file)
{
struct mi_console_file *mi_console = ui_file_data (file);
+
if (mi_console->magic != &mi_console_file_magic)
internal_error (__FILE__, __LINE__,
"mi_console_file_fputs: bad magic number");
long length_buf)
{
struct mi_console_file *mi_console = data;
+
if (mi_console->magic != &mi_console_file_magic)
internal_error (__FILE__, __LINE__,
_("mi_console_file_transform: bad magic number"));
mi_console_file_flush (struct ui_file *file)
{
struct mi_console_file *mi_console = ui_file_data (file);
+
if (mi_console->magic != &mi_console_file_magic)
internal_error (__FILE__, __LINE__,
_("mi_console_file_flush: bad magic number"));
{
char *arg;
struct mi_opt *opt;
+
/* We assume that argv/argc are ok. */
if (*optind > argc || *optind < 0)
internal_error (__FILE__, __LINE__,
mi_interpreter_resume (void *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 ();
/* These overwrite some of the initialization done in
mi_interpreter_exec (void *data, const char *command)
{
char *tmp = alloca (strlen (command) + 1);
+
strcpy (tmp, command);
mi_execute_command_wrapper (tmp);
return exception_none;
for (i = 1; i < argc; i++)
{
struct gdb_exception e = interp_exec (interp_to_use, argv[i]);
+
if (e.reason < 0)
{
mi_error_message = xstrdup (e.message);
mi_inferior_added (struct inferior *inf)
{
struct mi_interp *mi = top_level_interpreter_data ();
+
target_terminal_ours ();
fprintf_unfiltered (mi->event_channel,
"thread-group-added,id=\"i%d\"",
mi_inferior_appeared (struct inferior *inf)
{
struct mi_interp *mi = top_level_interpreter_data ();
+
target_terminal_ours ();
fprintf_unfiltered (mi->event_channel,
"thread-group-started,id=\"i%d\",pid=\"%d\"",
mi_inferior_exit (struct inferior *inf)
{
struct mi_interp *mi = top_level_interpreter_data ();
+
target_terminal_ours ();
fprintf_unfiltered (mi->event_channel, "thread-group-exited,id=\"i%d\"",
inf->num);
mi_inferior_removed (struct inferior *inf)
{
struct mi_interp *mi = top_level_interpreter_data ();
+
target_terminal_ours ();
fprintf_unfiltered (mi->event_channel,
"thread-group-removed,id=\"i%d\"",
if (print_frame)
{
int core;
+
if (uiout != mi_uiout)
{
/* The normal_stop function has printed frame information into
the frame again. In practice, this can only happen when running
a CLI command in MI. */
struct ui_out *saved_uiout = uiout;
+
uiout = mi_uiout;
print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC);
uiout = saved_uiout;
{
struct cleanup *back_to = make_cleanup_ui_out_list_begin_end
(mi_uiout, "stopped-threads");
+
ui_out_field_int (mi_uiout, NULL,
- pid_to_thread_id (inferior_ptid));
+ pid_to_thread_id (inferior_ptid));
do_cleanups (back_to);
}
else
if (!ptid_equal (inferior_ptid, null_ptid))
{
struct thread_info *tp = inferior_thread ();
+
if (tp->in_infcall)
return;
}
else
{
struct thread_info *ti = find_thread_ptid (ptid);
+
gdb_assert (ti);
fprintf_unfiltered (raw_stdout, "*running,thread-id=\"%d\"\n", ti->num);
}
mi_solib_loaded (struct so_list *solib)
{
struct mi_interp *mi = top_level_interpreter_data ();
+
target_terminal_ours ();
if (gdbarch_has_global_solist (target_gdbarch))
fprintf_unfiltered (mi->event_channel,
mi_solib_unloaded (struct so_list *solib)
{
struct mi_interp *mi = top_level_interpreter_data ();
+
target_terminal_ours ();
if (gdbarch_has_global_solist (target_gdbarch))
fprintf_unfiltered (mi->event_channel,
and top_level_interpreter_data is set, we cannot call
it here. */
struct mi_interp *mi = closure;
+
target_terminal_ours ();
fprintf_unfiltered (mi->event_channel,
"thread-group-added,id=\"i%d\"",
proceed_thread_callback (struct thread_info *thread, void *arg)
{
int pid = *(int *)arg;
+
proceed_thread (thread, pid);
return 0;
}
else
{
struct cleanup *back_to = make_cleanup_restore_integer (&sched_multi);
+
if (current_context->all)
{
sched_multi = 1;
else if (current_context->thread_group != -1)
{
struct inferior *inf = find_inferior_id (current_context->thread_group);
+
iterate_over_threads (interrupt_thread_callback, &inf->pid);
}
else
if (current_context->all)
{
struct cleanup *back_to = save_current_space_and_thread ();
+
iterate_over_inferiors (run_one_inferior, NULL);
do_cleanups (back_to);
}
find_thread_of_process (struct thread_info *ti, void *p)
{
int pid = *(int *)p;
+
if (PIDGET (ti->ptid) == pid && !is_exited (ti->ptid))
return 1;
struct thread_info *tp;
char *end = argv[0];
int pid = strtol (argv[0], &end, 10);
+
if (*end != '\0')
error (_("Cannot parse thread group id '%s'"), argv[0]);
if (ptid_get_pid (ti->ptid) == data->pid)
{
int core = target_core_of_thread (ti->ptid);
+
if (core != -1)
VEC_safe_push (int, data->cores, core);
}
unique (int *b, int *e)
{
int *d = b;
+
while (++b != e)
if (*d != *b)
*++d = *b;
free_vector_of_ints (void *xvector)
{
VEC (int) **vector = xvector;
+
VEC_free (int, *vector);
}
free_vector_of_osdata_items (splay_tree_value xvalue)
{
VEC (osdata_item_s) *value = (VEC (osdata_item_s) *) xvalue;
+
/* We don't free the items itself, it will be done separately. */
VEC_free (osdata_item_s, value);
}
{
int a = xa;
int b = xb;
+
return a - b;
}
struct osdata *data;
struct osdata_item *item;
int ix_items;
+
/* This keeps a map from integer (pid) to VEC (struct osdata_item *)*
The vector contains information about all threads for the given pid.
This is assigned an initial value to avoid "may be used uninitialized"
if (recurse)
{
struct osdata *threads = get_osdata ("threads");
- make_cleanup_osdata_free (threads);
+ make_cleanup_osdata_free (threads);
tree = splay_tree_new (splay_tree_int_comparator,
do_nothing,
free_vector_of_osdata_items);
{
struct cleanup *back_to_2 =
make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
-
const char *tid = get_osdata_column (child, "tid");
const char *tcore = get_osdata_column (child, "core");
+
ui_out_field_string (uiout, "id", tid);
if (tcore)
ui_out_field_string (uiout, "core", tcore);
{
int opt = mi_getopt ("-list-thread-groups", argc, argv, opts,
&optind, &optarg);
+
if (opt < 0)
break;
switch ((enum opt) opt)
{
char *end;
int inf = strtoul (argv[optind], &end, 0);
+
if (*end != '\0')
error ("invalid group id '%s'", argv[optind]);
VEC_safe_push (int, ids, inf);
{
/* Local thread groups, single id. */
int pid = *VEC_address (int, ids);
+
if (!in_inferior_list (pid))
error ("Invalid thread group id '%d'", pid);
print_thread_info (uiout, -1, pid);
else
{
struct print_one_inferior_data data;
+
data.recurse = recurse;
data.inferiors = ids;
{
int idx = gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG ?
j : register_size (gdbarch, regnum) - 1 - j;
+
sprintf (ptr, "%02x", (unsigned char) buffer[idx]);
ptr += 2;
}
else
{
struct value_print_options opts;
+
get_formatted_print_options (&opts, format);
opts.deref_ref = 1;
val_print (register_type (gdbarch, regnum), buffer, 0, 0,
{
int opt = mi_getopt ("mi_cmd_data_read_memory", argc, argv, opts,
&optind, &optarg);
+
if (opt < 0)
break;
switch ((enum opt) opt)
struct cleanup *cleanup_list_memory;
int row;
int row_byte;
+
cleanup_list_memory = make_cleanup_ui_out_list_begin_end (uiout, "memory");
for (row = 0, row_byte = 0;
row < nr_rows;
if (aschar)
{
int byte;
+
ui_file_rewind (stream->stream);
for (byte = row_byte; byte < row_byte + word_size * nr_cols; byte++)
{
{
int opt = mi_getopt ("mi_cmd_data_write_memory", argc, argv, opts,
&optind, &optarg);
+
if (opt < 0)
break;
switch ((enum opt) opt)
if (argc == 0)
{
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, "pending-breakpoints");
ui_out_field_string (uiout, NULL, "thread-info");
if (argc == 0)
{
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 ())
ui_out_field_string (uiout, NULL, "async");
case CLI_COMMAND:
{
char *argv[2];
+
/* A CLI command was read from the input stream. */
/* This "feature" will be removed as soon as we have a
complete set of mi commands. */
else if (!ptid_equal (inferior_ptid, null_ptid))
{
struct thread_info *ti = inferior_thread ();
+
report_change = (ti->num != command->thread);
}
if (report_change)
{
struct thread_info *ti = inferior_thread ();
+
target_terminal_ours ();
fprintf_unfiltered (mi->event_channel,
"thread-selected,id=\"%d\"",
if (parse->thread != -1)
{
struct thread_info *tp = find_thread_id (parse->thread);
+
if (!tp)
error (_("Invalid thread id: %d"), parse->thread);
{
struct frame_info *fid;
int frame = parse->frame;
+
fid = find_relative_frame (get_current_frame (), &frame);
if (frame == 0)
/* find_relative_frame was successful */
{
struct cleanup *old_cleanups;
char *run;
+
if (args_p)
run = xstrprintf ("%s %s", cmd, args);
else
if (new_section)
{
struct cleanup *cleanup_tuple;
+
xfree (previous_sect_name);
previous_sect_name = xstrdup (section_name);
delta.tv_usec >= update_threshold.tv_usec)
{
struct cleanup *cleanup_tuple;
+
last_update.tv_sec = time_now.tv_sec;
last_update.tv_usec = time_now.tv_usec;
if (current_token)
print_diff_now (struct mi_timestamp *start)
{
struct mi_timestamp now;
+
timestamp (&now);
print_diff (start, &now);
}
if (expr->nelts == 3 && expr->elts[0].opcode == OP_INTERNALVAR)
{
struct internalvar *intvar = expr->elts[1].internalvar;
+
if (intvar)
name = internalvar_name (intvar);
}
mi_table_body (struct ui_out *uiout)
{
mi_out_data *data = ui_out_data (uiout);
+
if (data->suppress_output)
return;
/* close the table header line if there were any headers */
mi_table_end (struct ui_out *uiout)
{
mi_out_data *data = ui_out_data (uiout);
+
data->suppress_output = 0;
mi_close (uiout, ui_out_type_list); /* body */
mi_close (uiout, ui_out_type_tuple);
const char *colhdr)
{
mi_out_data *data = ui_out_data (uiout);
+
if (data->suppress_output)
return;
mi_open (uiout, NULL, ui_out_type_tuple);
const char *id)
{
mi_out_data *data = ui_out_data (uiout);
+
if (data->suppress_output)
return;
mi_open (uiout, id, type);
int level)
{
mi_out_data *data = ui_out_data (uiout);
+
if (data->suppress_output)
return;
mi_close (uiout, type);
mi_field_int (struct ui_out *uiout, int fldno, int width,
enum ui_align alignment, const char *fldname, int value)
{
- 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);
+
if (data->suppress_output)
return;
enum ui_align alignment, const char *fldname)
{
mi_out_data *data = ui_out_data (uiout);
+
if (data->suppress_output)
return;
mi_field_string (uiout, fldno, width, alignment, fldname, "");
const char *string)
{
mi_out_data *data = ui_out_data (uiout);
+
if (data->suppress_output)
return;
field_separator (uiout);
va_list args)
{
mi_out_data *data = ui_out_data (uiout);
+
if (data->suppress_output)
return;
field_separator (uiout);
mi_flush (struct ui_out *uiout)
{
mi_out_data *data = ui_out_data (uiout);
+
gdb_flush (data->buffer);
}
field_separator (struct ui_out *uiout)
{
mi_out_data *data = ui_out_data (uiout);
+
if (data->suppress_field_separator)
data->suppress_field_separator = 0;
else
enum ui_out_type type)
{
mi_out_data *data = ui_out_data (uiout);
+
field_separator (uiout);
data->suppress_field_separator = 1;
if (name)
enum ui_out_type type)
{
mi_out_data *data = ui_out_data (uiout);
+
switch (type)
{
case ui_out_type_tuple:
mi_out_buffered (struct ui_out *uiout, char *string)
{
mi_out_data *data = ui_out_data (uiout);
+
fprintf_unfiltered (data->buffer, "%s", string);
}
mi_out_rewind (struct ui_out *uiout)
{
mi_out_data *data = ui_out_data (uiout);
+
ui_file_rewind (data->buffer);
}
struct ui_file *stream)
{
mi_out_data *data = ui_out_data (uiout);
+
ui_file_put (data->buffer, do_write, stream);
ui_file_rewind (data->buffer);
}
mi_version (struct ui_out *uiout)
{
mi_out_data *data = ui_out_data (uiout);
+
return data->mi_version;
}
mi_out_new (int mi_version)
{
int flags = 0;
+
mi_out_data *data = XMALLOC (mi_out_data);
data->suppress_field_separator = 0;
data->suppress_output = 0;
mi_parse_escape (char **string_ptr)
{
int c = *(*string_ptr)++;
+
switch (c)
{
case '\n':
{
int i = host_hex_value (c);
int count = 0;
+
while (++count < 3)
{
c = (**string_ptr);
char *chp = args;
int argc = 0;
char **argv = xmalloc ((argc + 1) * sizeof (char *));
+
argv[argc] = NULL;
while (1)
{
char *arg;
+
/* skip leading white space */
while (isspace (*chp))
chp++;
/* A quoted string. */
int len;
char *start = chp + 1;
+
/* Determine the buffer size. */
chp = start;
len = 0;
characters into a buffer. */
int len;
char *start = chp;
+
while (*chp != '\0' && !isspace (*chp))
{
chp++;
{
char *chp;
struct mi_parse *parse = XMALLOC (struct mi_parse);
+
memset (parse, 0, sizeof (*parse));
parse->all = 0;
parse->thread_group = -1;
/* Extract the command. */
{
char *tmp = chp + 1; /* discard ``-'' */
+
for (; *chp && !isspace (*chp); chp++)
;
parse->command = xmalloc ((chp - tmp + 1) * sizeof (char *));
size_t tgs = sizeof ("--thread-group ") - 1;
size_t ts = sizeof ("--thread ") - 1;
size_t fs = sizeof ("--frame ") - 1;
+
if (strncmp (chp, "--all ", as) == 0)
{
parse->all = 1;