* mi/mi-cmd-disas.c: Ditto.
* mi/mi-cmd-env.c: Ditto.
* mi/mi-cmd-file.c: Ditto.
* mi/mi-cmd-stack.c: Ditto.
* mi/mi-cmd-target.c: Ditto.
* mi/mi-cmd-var.c: Ditto.
* mi/mi-cmds.c: Ditto.
* mi/mi-cmds.h: Ditto.
* mi/mi-console.c: Ditto.
* mi/mi-getopt.c: Ditto.
* mi/mi-getopt.h: Ditto.
* mi/mi-interp.c: Ditto.
* mi/mi-main.c: Ditto.
* mi/mi-out.c: Ditto.
* mi/mi-parse.c: Ditto.
* mi/mi-parse.h: Ditto.
* mi/mi-symbol-cmds.c: Ditto.
* mi/mi-getopt.h: Move mi_opt struct up.
* mi/mi-main.c (captured_mi_execute_command): Remove redundant
return.
* mi/mi-out.c (_initialize_mi_out): Remove empty initialize.
+2012-03-06 Stan Shebs <stan@codesourcery.com>
+
+ * mi/mi-cmd-break.c: Enforce coding standards, fix comments.
+ * mi/mi-cmd-disas.c: Ditto.
+ * mi/mi-cmd-env.c: Ditto.
+ * mi/mi-cmd-file.c: Ditto.
+ * mi/mi-cmd-stack.c: Ditto.
+ * mi/mi-cmd-target.c: Ditto.
+ * mi/mi-cmd-var.c: Ditto.
+ * mi/mi-cmds.c: Ditto.
+ * mi/mi-cmds.h: Ditto.
+ * mi/mi-console.c: Ditto.
+ * mi/mi-getopt.c: Ditto.
+ * mi/mi-getopt.h: Ditto.
+ * mi/mi-interp.c: Ditto.
+ * mi/mi-main.c: Ditto.
+ * mi/mi-out.c: Ditto.
+ * mi/mi-parse.c: Ditto.
+ * mi/mi-parse.h: Ditto.
+ * mi/mi-symbol-cmds.c: Ditto.
+
+ * mi/mi-getopt.h: Move mi_opt struct up.
+ * mi/mi-main.c (captured_mi_execute_command): Remove redundant
+ return.
+ * mi/mi-out.c (_initialize_mi_out): Remove empty initialize.
+
2012-03-06 Tom Tromey <tromey@redhat.com>
* proc-service.c (ps_pglobal_lookup): Set the current program
static int mi_can_breakpoint_notify;
-/* Output a single breakpoint, when allowed. */
+/* Output a single breakpoint, when allowed. */
static void
breakpoint_notify (struct breakpoint *b)
error (_("-break-insert: Garbage following <location>"));
address = argv[oind];
- /* Now we have what we need, let's insert the breakpoint! */
+ /* Now we have what we need, let's insert the breakpoint! */
if (! mi_breakpoint_observers_installed)
{
observer_attach_breakpoint_created (breakpoint_notify);
first argument:
-break-watch <expr> --> insert a regular wp.
-break-watch -r <expr> --> insert a read watchpoint.
- -break-watch -a <expr> --> insert an access wp. */
+ -break-watch -a <expr> --> insert an access wp. */
void
mi_cmd_break_watch (char *command, char **argv, int argc)
error (_("-break-watch: Garbage following <expression>"));
expr = argv[oind];
- /* Now we have what we need, let's insert the watchpoint! */
+ /* Now we have what we need, let's insert the watchpoint! */
switch (type)
{
case REG_WP:
#include "ui-out.h"
#include "disasm.h"
-/* The arguments to be passed on the command line and parsed here are:
-
+/* The arguments to be passed on the command line and parsed here are
either:
START-ADDRESS: address to start the disassembly at.
2 -- disassembly and opcodes.
3 -- disassembly, source and opcodes.
*/
+
void
mi_cmd_disassemble (char *command, char **argv, int argc)
{
CORE_ADDR high = 0;
struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
- /* Options processing stuff. */
+ /* Options processing stuff. */
int oind = 0;
char *oarg;
enum opt
{
FILE_OPT, LINE_OPT, NUM_OPT, START_OPT, END_OPT
};
- static const struct mi_opt opts[] = {
- {"f", FILE_OPT, 1},
- {"l", LINE_OPT, 1},
- {"n", NUM_OPT, 1},
- {"s", START_OPT, 1},
- {"e", END_OPT, 1},
- { 0, 0, 0 }
- };
+ static const struct mi_opt opts[] =
+ {
+ {"f", FILE_OPT, 1},
+ {"l", LINE_OPT, 1},
+ {"n", NUM_OPT, 1},
+ {"s", START_OPT, 1},
+ {"e", END_OPT, 1},
+ { 0, 0, 0 }
+ };
/* Get the options with their arguments. Keep track of what we
- encountered. */
+ encountered. */
while (1)
{
int opt = mi_getopt ("-data-disassemble", argc, argv, opts,
argc -= oind;
/* Allow only filename + linenum (with how_many which is not
- required) OR start_addr + and_addr */
+ required) OR start_addr + end_addr. */
if (!((line_seen && file_seen && num_seen && !start_seen && !end_seen)
|| (line_seen && file_seen && !num_seen && !start_seen && !end_seen)
if (mode < 0 || mode > 3)
error (_("-data-disassemble: Mode argument must be 0, 1, 2, or 3."));
- /* Convert the mode into a set of disassembly flags */
+ /* Convert the mode into a set of disassembly flags. */
disasm_flags = 0;
if (mode & 0x1)
disasm_flags |= DISASSEMBLY_RAW_INSN;
/* We must get the function beginning and end where line_num is
- contained. */
+ contained. */
if (line_seen && file_seen)
{
/* MI Command Set - environment commands.
-
Copyright (C) 2002-2004, 2007-2012 Free Software Foundation, Inc.
Contributed by Red Hat Inc.
#include "gdb_stat.h"
static void env_mod_path (char *dirname, char **which_path);
+
extern void _initialize_mi_cmd_env (void);
static const char path_var_name[] = "PATH";
/* The following is copied from mi-main.c so for m1 and below we can
perform old behavior and use cli commands. If ARGS is non-null,
append it to the CMD. */
+
static void
env_execute_cli_command (const char *cmd, const char *args)
{
}
}
-
/* Print working directory. */
+
void
mi_cmd_env_pwd (char *command, char **argv, int argc)
{
struct ui_out *uiout = current_uiout;
if (argc > 0)
- error (_("-environment-pwd: No arguments required"));
+ error (_("-environment-pwd: No arguments allowed"));
if (mi_version (uiout) < 2)
{
}
/* Change working directory. */
+
void
mi_cmd_env_cd (char *command, char **argv, int argc)
{
}
/* Add one or more directories to start of executable search path. */
+
void
mi_cmd_env_path (char *command, char **argv, int argc)
{
}
/* Add zero or more directories to the front of the source path. */
+
void
mi_cmd_env_dir (char *command, char **argv, int argc)
{
}
/* Set the inferior terminal device name. */
+
void
mi_cmd_inferior_tty_set (char *command, char **argv, int argc)
{
set_inferior_io_terminal (argv[0]);
}
-/* Print the inferior terminal device name */
+/* Print the inferior terminal device name. */
+
void
mi_cmd_inferior_tty_show (char *command, char **argv, int argc)
{
/* We want original execution path to reset to, if desired later.
At this point, current inferior is not created, so cannot use
current_inferior ()->environment. Also, there's no obvious
- place where this code can be moved suchs that it surely run
+ place where this code can be moved such that it surely run
before any code possibly mangles original PATH. */
environment = make_environ ();
init_environ (environment);
-/* MI Command Set - breakpoint and watchpoint commands.
+/* MI Command Set - file commands.
Copyright (C) 2000-2002, 2007-2012 Free Software Foundation, Inc.
Contributed by Cygnus Solutions (a Red Hat company).
#include "psymtab.h"
/* Return to the client the absolute path and line number of the
- current file being executed. */
+ current file being executed. */
void
mi_cmd_file_list_exec_source_file (char *command, char **argv, int argc)
if (!mi_valid_noargs ("-file-list-exec-source-file", argc, argv))
error (_("-file-list-exec-source-file: Usage: No args"));
- /* Set the default file and line, also get them */
+ /* Set the default file and line, also get them. */
set_default_source_symtab_and_line ();
st = get_current_source_symtab_and_line ();
- /* We should always get a symtab.
- Apparently, filename does not need to be tested for NULL.
- The documentation in symtab.h suggests it will always be correct */
+ /* We should always get a symtab. Apparently, filename does not
+ need to be tested for NULL. The documentation in symtab.h
+ suggests it will always be correct. */
if (!st.symtab)
error (_("-file-list-exec-source-file: No symtab"));
- /* Extract the fullname if it is not known yet */
+ /* Extract the fullname if it is not known yet. */
symtab_to_fullname (st.symtab);
- /* Print to the user the line, filename and fullname */
+ /* Print to the user the line, filename and fullname. */
ui_out_field_int (uiout, "line", st.line);
ui_out_field_string (uiout, "file", st.symtab->filename);
}
/* A callback for map_partial_symbol_filenames. */
+
static void
print_partial_file_name (const char *filename, const char *fullname,
void *ignore)
if (!mi_valid_noargs ("-file-list-exec-source-files", argc, argv))
error (_("-file-list-exec-source-files: Usage: No args"));
- /* Print the table header */
+ /* Print the table header. */
ui_out_begin (uiout, ui_out_type_list, "files");
- /* Look at all of the symtabs */
+ /* Look at all of the symtabs. */
ALL_SYMTABS (objfile, s)
{
ui_out_begin (uiout, ui_out_type_tuple, NULL);
ui_out_field_string (uiout, "file", s->filename);
- /* Extract the fullname if it is not known yet */
+ /* Extract the fullname if it is not known yet. */
symtab_to_fullname (s);
if (s->fullname)
enum print_values values,
struct frame_info *fi);
-/* Print a list of the stack frames. Args can be none, in which case
+/* Print a list of the stack frames. Args can be none, in which case
we want to print the whole backtrace, or a pair of numbers
specifying the frame numbers at which to start and stop the
- display. If the two numbers are equal, a single frame will be
- displayed. */
+ display. If the two numbers are equal, a single frame will be
+ displayed. */
+
void
mi_cmd_stack_list_frames (char *command, char **argv, int argc)
{
else
{
/* Called with no arguments, it means we want the whole
- backtrace. */
+ backtrace. */
frame_low = -1;
frame_high = -1;
}
/* Let's position fi on the frame at which to start the
display. Could be the innermost frame if the whole stack needs
- displaying, or if frame_low is 0. */
+ displaying, or if frame_low is 0. */
for (i = 0, fi = get_current_frame ();
fi && i < frame_low;
i++, fi = get_prev_frame (fi));
cleanup_stack = make_cleanup_ui_out_list_begin_end (current_uiout, "stack");
- /* Now let;s print the frames up to frame_high, or until there are
- frames in the stack. */
+ /* Now let's print the frames up to frame_high, or until there are
+ frames in the stack. */
for (;
fi && (i <= frame_high || frame_high == -1);
i++, fi = get_prev_frame (fi))
{
QUIT;
/* Print the location and the address always, even for level 0.
- args == 0: don't print the arguments. */
+ If args is 0, don't print the arguments. */
print_frame_info (fi, 1, LOC_AND_ADDRESS, 0 /* args */ );
}
frame_high = atoi (argv[0]);
else
/* Called with no arguments, it means we want the real depth of
- the stack. */
+ the stack. */
frame_high = -1;
for (i = 0, fi = get_current_frame ();
/* Print a list of the locals for the current frame. With argument of
0, print only the names, with argument of 1 print also the
- values. */
+ values. */
+
void
mi_cmd_stack_list_locals (char *command, char **argv, int argc)
{
/* Print a list of the arguments for the current frame. With argument
of 0, print only the names, with argument of 1 print also the
- values. */
+ values. */
+
void
mi_cmd_stack_list_args (char *command, char **argv, int argc)
{
else
{
/* Called with no arguments, it means we want args for the whole
- backtrace. */
+ backtrace. */
frame_low = -1;
frame_high = -1;
}
/* Let's position fi on the frame at which to start the
display. Could be the innermost frame if the whole stack needs
- displaying, or if frame_low is 0. */
+ displaying, or if frame_low is 0. */
for (i = 0, fi = get_current_frame ();
fi && i < frame_low;
i++, fi = get_prev_frame (fi));
= make_cleanup_ui_out_list_begin_end (uiout, "stack-args");
/* Now let's print the frames up to frame_high, or until there are
- frames in the stack. */
+ frames in the stack. */
for (;
fi && (i <= frame_high || frame_high == -1);
i++, fi = get_prev_frame (fi))
current frame. ARGC must be 1 and ARGV[0] specify if only the names,
or both names and values of the variables must be printed. See
parse_print_value for possible values. */
+
void
mi_cmd_stack_list_variables (char *command, char **argv, int argc)
{
list_args_or_locals (all, parse_print_values (argv[0]), frame);
}
-/* Print single local or argument. ARG must be already read in. For WHAT and
- VALUES see list_args_or_locals.
+/* Print single local or argument. ARG must be already read in. For
+ WHAT and VALUES see list_args_or_locals.
- Errors are printed as if they would be the parameter value. Use zeroed ARG
- iff it should not be printed accoring to VALUES. */
+ Errors are printed as if they would be the parameter value. Use
+ zeroed ARG iff it should not be printed according to VALUES. */
static void
list_arg_or_local (const struct frame_arg *arg, enum what_to_list what,
/* Print a list of the locals or the arguments for the currently
selected frame. If the argument passed is 0, printonly the names
of the variables, if an argument of 1 is passed, print the values
- as well. */
+ as well. */
+
static void
list_args_or_locals (enum what_to_list what, enum print_values values,
struct frame_info *fi)
xfree (entryarg.error);
}
}
+
if (BLOCK_FUNCTION (block))
break;
else
mi_cmd_stack_info_frame (char *command, char **argv, int argc)
{
if (argc > 0)
- error (_("-stack-info-frame: No arguments required"));
+ error (_("-stack-info-frame: No arguments allowed"));
print_frame_info (get_selected_frame (NULL), 1, LOC_AND_ADDRESS, 0);
}
char *oarg;
const char *remote_file, *local_file;
static const struct mi_opt opts[] =
- {
- { 0, 0, 0 }
- };
+ {
+ { 0, 0, 0 }
+ };
static const char prefix[] = "-target-file-get";
if (mi_getopt (prefix, argc, argv, opts, &oind, &oarg) != -1
char *oarg;
const char *remote_file, *local_file;
static const struct mi_opt opts[] =
- {
- { 0, 0, 0 }
- };
+ {
+ { 0, 0, 0 }
+ };
static const char prefix[] = "-target-file-put";
if (mi_getopt (prefix, argc, argv, opts, &oind, &oarg) != -1
char *oarg;
const char *remote_file;
static const struct mi_opt opts[] =
- {
- { 0, 0, 0 }
- };
+ {
+ { 0, 0, 0 }
+ };
static const char prefix[] = "-target-file-delete";
if (mi_getopt (prefix, argc, argv, opts, &oind, &oarg) != -1
/* MI Command Set - varobj commands.
-
Copyright (C) 2000, 2002, 2004-2005, 2007-2012 Free Software
Foundation, Inc.
extern int varobjdebug; /* defined in varobj.c. */
static void varobj_update_one (struct varobj *var,
- enum print_values print_values,
- int explicit);
+ enum print_values print_values,
+ int explicit);
static int mi_print_value_p (struct varobj *var,
enum print_values print_values);
/* Print variable object VAR. The PRINT_VALUES parameter controls
if the value should be printed. The PRINT_EXPRESSION parameter
controls if the expression should be printed. */
+
static void
print_varobj (struct varobj *var, enum print_values print_values,
int print_expression)
enum varobj_type var_type;
if (argc != 3)
- {
- /* mi_error_message = xstrprintf ("-var-create: Usage:
- ...."); return MI_CMD_ERROR; */
- error (_("-var-create: Usage: NAME FRAME EXPRESSION."));
- }
+ error (_("-var-create: Usage: NAME FRAME EXPRESSION."));
name = xstrdup (argv[0]);
- /* Add cleanup for name. Must be free_current_contents as
- name can be reallocated */
+ /* Add cleanup for name. Must be free_current_contents as name can
+ be reallocated. */
old_cleanups = make_cleanup (free_current_contents, &name);
frame = xstrdup (argv[1]);
error (_("-var-delete: Usage: [-c] EXPRESSION."));
name = xstrdup (argv[0]);
- /* Add cleanup for name. Must be free_current_contents as
- name can be reallocated */
+ /* Add cleanup for name. Must be free_current_contents as name can
+ be reallocated. */
old_cleanups = make_cleanup (free_current_contents, &name);
/* If we have one single argument it cannot be '-c' or any string
- starting with '-'. */
+ starting with '-'. */
if (argc == 1)
{
if (strcmp (name, "-c") == 0)
}
/* If we have 2 arguments they must be '-c' followed by a string
- which would be the variable name. */
+ which would be the variable name. */
if (argc == 2)
{
if (strcmp (name, "-c") != 0)
}
/* If we didn't error out, now NAME contains the name of the
- variable. */
+ variable. */
var = varobj_get_handle (name);
if (argc != 2)
error (_("-var-set-format: Usage: NAME FORMAT."));
- /* Get varobj handle, if a valid var obj name was specified */
+ /* Get varobj handle, if a valid var obj name was specified. */
var = varobj_get_handle (argv[0]);
format = mi_parse_format (argv[1]);
- /* Set the format of VAR to given format */
+ /* Set the format of VAR to the given format. */
varobj_set_display_format (var, format);
- /* Report the new current format */
+ /* Report the new current format. */
ui_out_field_string (uiout, "format", varobj_format_string[(int) format]);
- /* Report the value in the new format */
+ /* Report the value in the new format. */
val = varobj_get_value (var);
ui_out_field_string (uiout, "value", val);
xfree (val);
varobj_set_frozen (var, frozen);
- /* We don't automatically return the new value, or what varobjs got new
- values during unfreezing. If this information is required, client
- should call -var-update explicitly. */
+ /* We don't automatically return the new value, or what varobjs got
+ new values during unfreezing. If this information is required,
+ client should call -var-update explicitly. */
}
-
void
mi_cmd_var_show_format (char *command, char **argv, int argc)
{
if (argc != 1)
error (_("-var-show-format: Usage: NAME."));
- /* Get varobj handle, if a valid var obj name was specified */
+ /* Get varobj handle, if a valid var obj name was specified. */
var = varobj_get_handle (argv[0]);
format = varobj_get_display_format (var);
- /* Report the current format */
+ /* Report the current format. */
ui_out_field_string (uiout, "format", varobj_format_string[(int) format]);
}
if (argc != 1)
error (_("-var-info-num-children: Usage: NAME."));
- /* Get varobj handle, if a valid var obj name was specified */
+ /* Get varobj handle, if a valid var obj name was specified. */
var = varobj_get_handle (argv[0]);
ui_out_field_int (uiout, "numchild", varobj_get_num_children (var));
error (_("-var-list-children: Usage: "
"[PRINT_VALUES] NAME [FROM TO]"));
- /* Get varobj handle, if a valid var obj name was specified */
+ /* Get varobj handle, if a valid var obj name was specified. */
if (argc == 1 || argc == 3)
var = varobj_get_handle (argv[0]);
else
if (argc != 1)
error (_("-var-info-type: Usage: NAME."));
- /* Get varobj handle, if a valid var obj name was specified */
+ /* Get varobj handle, if a valid var obj name was specified. */
var = varobj_get_handle (argv[0]);
ui_out_field_string (uiout, "type", varobj_get_type (var));
if (argc != 1)
error (_("-var-info-expression: Usage: NAME."));
- /* Get varobj handle, if a valid var obj name was specified */
+ /* Get varobj handle, if a valid var obj name was specified. */
var = varobj_get_handle (argv[0]);
lang = varobj_get_language (var);
char *oarg;
enum opt
- {
- OP_FORMAT
- };
- static const struct mi_opt opts[] =
{
- {"f", OP_FORMAT, 1},
- { 0, 0, 0 }
+ OP_FORMAT
};
+ static const struct mi_opt opts[] =
+ {
+ {"f", OP_FORMAT, 1},
+ { 0, 0, 0 }
+ };
- /* Parse arguments */
+ /* Parse arguments. */
format = FORMAT_NATURAL;
formatFound = 0;
oind = 0;
if (opt < 0)
break;
switch ((enum opt) opt)
- {
+ {
case OP_FORMAT:
if (formatFound)
error (_("Cannot specify format more than once"));
format = mi_parse_format (oarg);
formatFound = 1;
break;
- }
+ }
}
if (oind >= argc)
if (oind < argc - 1)
error (_("Garbage at end of command"));
- /* Get varobj handle, if a valid var obj name was specified */
+ /* Get varobj handle, if a valid var obj name was specified. */
var = varobj_get_handle (argv[oind]);
if (formatFound)
if (argc != 2)
error (_("-var-assign: Usage: NAME EXPRESSION."));
- /* Get varobj handle, if a valid var obj name was specified */
+ /* Get varobj handle, if a valid var obj name was specified. */
var = varobj_get_handle (argv[0]);
if (!varobj_editable_p (var))
thread_stopped = 1;
}
- if (thread_stopped)
- if (!data->only_floating || varobj_floating_p (var))
- varobj_update_one (var, data->print_values, 0 /* implicit */);
+ if (thread_stopped
+ && (!data->only_floating || varobj_floating_p (var)))
+ varobj_update_one (var, data->print_values, 0 /* implicit */);
}
void
if (argc == 1)
name = argv[0];
else
- name = (argv[1]);
+ name = argv[1];
if (argc == 2)
print_values = mi_parse_values_option (argv[0]);
else
cleanup = make_cleanup_ui_out_list_begin_end (uiout, "changelist");
- /* Check if the parameter is a "*" which means that we want
- to update all variables */
+ /* Check if the parameter is a "*", which means that we want to
+ update all variables. */
if ((*name == '*' || *name == '@') && (*(name + 1) == '\0'))
{
struct mi_cmd_var_update data;
- data.only_floating = *name == '@';
+ data.only_floating = (*name == '@');
data.print_values = print_values;
- /* varobj_update_one automatically updates all the children of VAROBJ.
- Therefore update each VAROBJ only once by iterating only the root
- VAROBJs. */
+ /* varobj_update_one automatically updates all the children of
+ VAROBJ. Therefore update each VAROBJ only once by iterating
+ only the root VAROBJs. */
all_root_varobjs (mi_cmd_var_update_iter, &data);
}
else
{
- /* Get varobj handle, if a valid var obj name was specified */
+ /* Get varobj handle, if a valid var obj name was specified. */
struct varobj *var = varobj_get_handle (name);
varobj_update_one (var, print_values, 1 /* explicit */);
{
if (argc != 0)
error (_("-enable-pretty-printing: no arguments allowed"));
+
varobj_enable_pretty_printing ();
}
/* MI Command Set for GDB, the GNU debugger.
-
Copyright (C) 2000-2001, 2003, 2007-2012 Free Software Foundation,
Inc.
#include "gdb_string.h"
extern void _initialize_mi_cmds (void);
+
struct mi_cmd;
static struct mi_cmd **lookup_table (const char *command);
static void build_table (struct mi_cmd *commands);
-
struct mi_cmd mi_cmds[] =
{
{ "ada-task-info", { NULL, 0 }, mi_cmd_ada_task_info },
{ NULL, }
};
-/* Pointer to the mi command table (built at run time) */
+/* Pointer to the mi command table (built at run time). */
static struct mi_cmd **mi_table;
-/* A prime large enough to accomodate the entire command table */
+/* A prime large enough to accomodate the entire command table. */
enum
{
MI_TABLE_SIZE = 227
};
-/* Exported function used to obtain info from the table */
+/* Exported function used to obtain info from the table. */
struct mi_cmd *
mi_lookup (const char *command)
{
return *lookup_table (command);
}
-/* stat collecting */
+/* Used for collecting hash hit/miss statistics. */
+
struct mi_cmd_stats
{
int hit;
};
struct mi_cmd_stats stats;
-/* our lookup function */
+/* Look up a command. */
+
static struct mi_cmd **
lookup_table (const char *command)
{
const char *chp;
unsigned int index = 0;
- /* compute our hash */
+ /* Compute our hash. */
for (chp = command; *chp; chp++)
{
- /* some what arbitrary */
+ /* We use a somewhat arbitrary formula. */
index = ((index << 6) + (unsigned int) *chp) % MI_TABLE_SIZE;
}
- /* look it up */
+
while (1)
{
struct mi_cmd **entry = &mi_table[index];
_("command `%s' appears to be duplicated"),
command->name);
*entry = command;
+ /* FIXME lose these prints */
if (0)
{
fprintf_unfiltered (gdb_stdlog, "%-30s %2d\n",
typedef void (mi_cmd_argv_ftype) (char *command, char **argv, int argc);
-/* Function implementing each command */
+/* Declarations of the functions implementing each command. */
+
extern mi_cmd_argv_ftype mi_cmd_ada_task_info;
extern mi_cmd_argv_ftype mi_cmd_add_inferior;
extern mi_cmd_argv_ftype mi_cmd_break_insert;
extern mi_cmd_argv_ftype mi_cmd_enable_pretty_printing;
extern mi_cmd_argv_ftype mi_cmd_var_set_update_range;
-/* Description of a single command. */
+/* Description of a single command. */
struct mi_cli
{
struct mi_cmd
{
- /* official name of the command. */
+ /* Official name of the command. */
const char *name;
/* The corresponding CLI command that can be used to implement this
MI command (if cli.lhs is non NULL). */
mi_cmd_argv_ftype *argv_func;
};
-/* Lookup a command in the mi comand table */
+/* Lookup a command in the MI command table. */
extern struct mi_cmd *mi_lookup (const char *command);
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+/* An MI console is a kind of ui_file stream that sends output to
+ stdout, but encapsulated and prefixed with a distinctive string;
+ for instance, error output is normally identified by a leading
+ "&". */
+
#include "defs.h"
#include "mi-console.h"
#include "gdb_string.h"
-/* MI-console: send output to std-out but correcty encapsulated */
-
static ui_file_fputs_ftype mi_console_file_fputs;
static ui_file_flush_ftype mi_console_file_flush;
static ui_file_delete_ftype mi_console_file_delete;
char quote;
};
-int mi_console_file_magic;
+/* Use the address of this otherwise-unused global as a magic number
+ identifying this class of ui_file objects. */
+static int mi_console_file_magic;
+
+/* Create a console that wraps the given output stream RAW with the
+ string PREFIX and quoting it with QUOTE. */
struct ui_file *
-mi_console_file_new (struct ui_file *raw,
- const char *prefix, char quote)
+mi_console_file_new (struct ui_file *raw, const char *prefix, char quote)
{
struct ui_file *ui_file = ui_file_new ();
struct mi_console_file *mi_console = XMALLOC (struct mi_console_file);
set_ui_file_fputs (ui_file, mi_console_file_fputs);
set_ui_file_flush (ui_file, mi_console_file_flush);
set_ui_file_data (ui_file, mi_console, mi_console_file_delete);
+
return ui_file;
}
if (mi_console->magic != &mi_console_file_magic)
internal_error (__FILE__, __LINE__,
_("mi_console_file_delete: bad magic number"));
+
xfree (mi_console);
}
static void
-mi_console_file_fputs (const char *buf,
- struct ui_file *file)
+mi_console_file_fputs (const char *buf, 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");
- /* Append the text to our internal buffer */
+
+ /* Append the text to our internal buffer. */
fputs_unfiltered (buf, mi_console->buffer);
- /* Flush when an embedded \n */
+ /* Flush when an embedded newline is present anywhere in the buffer. */
if (strchr (buf, '\n') != NULL)
gdb_flush (file);
}
-/* Transform a byte sequence into a console output packet. */
+/* Transform a byte sequence into a console output packet. */
+
static void
-mi_console_raw_packet (void *data,
- const char *buf,
- long length_buf)
+mi_console_raw_packet (void *data, const char *buf, 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_raw_packet: bad magic number"));
if (length_buf > 0)
{
if (mi_console->magic != &mi_console_file_magic)
internal_error (__FILE__, __LINE__,
_("mi_console_file_flush: bad magic number"));
+
ui_file_put (mi_console->buffer, mi_console_raw_packet, mi_console);
ui_file_rewind (mi_console->buffer);
}
char *arg;
const struct mi_opt *opt;
- /* We assume that argv/argc are ok. */
+ /* We assume that argv/argc are ok. */
if (*oind > argc || *oind < 0)
internal_error (__FILE__, __LINE__,
_("mi_getopt_long: oind out of bounds"));
*oarg = NULL;
return -1;
}
- /* End of option list. */
+ /* End of option list. */
if (arg[0] != '-')
{
*oarg = NULL;
return -1;
}
- /* Look the option up. */
+ /* Look the option up. */
for (opt = opts; opt->name != NULL; opt++)
{
if (strcmp (opt->name, arg + 1) != 0)
continue;
if (opt->arg_p)
{
- /* A non-simple oarg option. */
+ /* A non-simple oarg option. */
if (argc < *oind + 2)
error (_("%s: Option %s requires an argument"), prefix, arg);
*oarg = argv[(*oind) + 1];
int oind = 0;
char *oarg;
static const struct mi_opt opts[] =
- {
- { 0, 0, 0 }
- };
+ {
+ { 0, 0, 0 }
+ };
if (mi_getopt (prefix, argc, argv, opts, &oind, &oarg) == -1)
return 1;
#ifndef MI_GETOPT_H
#define MI_GETOPT_H
+/* The option list. Terminated by NAME==NULL. ARG_P that the option
+ requires an argument. INDEX is returned to identify the option. */
+
+struct mi_opt
+ {
+ const char *name;
+ int index;
+ int arg_p;
+ };
+
/* Like getopt() but with simpler semantics.
An option has the form ``-<name>''. The special option ``--''
to specify the non-option argument. OPTARG is set to NULL.
mi_getopt() calls ``error("%s: Unknown option %c", prefix,
- option)'' if an unknown option is encountered. */
+ option)'' if an unknown option is encountered. */
-struct mi_opt;
extern int mi_getopt (const char *prefix, int argc, char **argv,
const struct mi_opt *opt, int *optind, char **optarg);
-/* The option list. Terminated by NAME==NULL. ARG_P that the option
- requires an argument. INDEX is returned to identify th option. */
-
-struct mi_opt
- {
- const char *name;
- int index;
- int arg_p;
- };
-
-struct mi_opt;
-
-/* mi_valid_noargs
-
- Determines if ARGC/ARGV are a valid set of parameters to satisfy
- an MI function that is not supposed to recieve any arguments.
+/* mi_valid_noargs determines if ARGC/ARGV are a valid set of
+ parameters to satisfy an MI function that is not supposed to
+ recieve any arguments.
- An MI function that should not recieve arguments can still be
+ An MI function that should not receive arguments can still be
passed parameters after the special option '--' such as below.
Example: The MI function -exec-run takes no args.
#include "solist.h"
#include "gdb.h"
-/* These are the interpreter setup, etc. functions for the MI interpreter */
+/* These are the interpreter setup, etc. functions for the MI
+ interpreter. */
+
static void mi_execute_command_wrapper (char *cmd);
static void mi_command_loop (int mi_version);
/* These are hooks that we put in place while doing interpreter_exec
- so we can report interesting things that happened "behind the mi's
- back" in this command */
+ so we can report interesting things that happened "behind the MI's
+ back" in this command. */
+
static int mi_interp_query_hook (const char *ctlstr, va_list ap)
- ATTRIBUTE_PRINTF (1, 0);
+ ATTRIBUTE_PRINTF (1, 0);
static void mi3_command_loop (void);
static void mi2_command_loop (void);
const char *name;
int mi_version;
- /* HACK: We need to force stdout/stderr to point at the console. This avoids
- any potential side effects caused by legacy code that is still
- using the TUI / fputs_unfiltered_hook. So we set up output channels for
- this now, and swap them in when we are run. */
+ /* HACK: We need to force stdout/stderr to point at the console.
+ This avoids any potential side effects caused by legacy code that
+ is still using the TUI / fputs_unfiltered_hook. So we set up
+ output channels for this now, and swap them in when we are
+ run. */
raw_stdout = stdio_fileopen (stdout);
- /* Create MI channels */
+ /* Create MI console channels, each with a different prefix so they
+ can be distinguished. */
mi->out = mi_console_file_new (raw_stdout, "~", '"');
mi->err = mi_console_file_new (raw_stdout, "&", '"');
mi->log = mi->err;
observer_attach_breakpoint_deleted (mi_breakpoint_deleted);
observer_attach_breakpoint_modified (mi_breakpoint_modified);
- /* The initial inferior is created before this function is called, so we
- need to report it explicitly. Use iteration in case future version
- of GDB creates more than one inferior up-front. */
+ /* The initial inferior is created before this function is
+ called, so we need to report it explicitly. Use iteration in
+ case future version of GDB creates more than one inferior
+ up-front. */
iterate_over_inferiors (report_initial_inferior, mi);
}
{
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
sync_execution = 0;
gdb_stdout = mi->out;
- /* Route error and log output through the MI */
+ /* Route error and log output through the MI. */
gdb_stderr = mi->err;
gdb_stdlog = mi->log;
- /* Route target output through the MI. */
+ /* Route target output through the MI. */
gdb_stdtarg = mi->targ;
- /* Route target error through the MI as well. */
+ /* Route target error through the MI as well. */
gdb_stdtargerr = mi->targ;
/* Replace all the hooks that we know about. There really needs to
deprecated_show_load_progress = mi_load_progress;
- /* If we're _the_ interpreter, take control. */
+ /* If we're _the_ interpreter, take control. */
if (current_interp_named_p (INTERP_MI1))
deprecated_command_loop_hook = mi1_command_loop;
else if (current_interp_named_p (INTERP_MI2))
return exception_none;
}
-/* Never display the default gdb prompt in mi case. */
+/* Never display the default GDB prompt in MI case. */
+
static int
mi_interpreter_prompt_p (void *data)
{
"does not support command execution"),
argv[0]);
- /* Insert the MI out hooks, making sure to also call the interpreter's hooks
- if it has any. */
- /* KRS: We shouldn't need this... Events should be installed and they should
- just ALWAYS fire something out down the MI channel... */
+ /* Insert the MI out hooks, making sure to also call the
+ interpreter's hooks if it has any. */
+ /* KRS: We shouldn't need this... Events should be installed and
+ they should just ALWAYS fire something out down the MI
+ channel. */
mi_insert_notify_hooks ();
- /* Now run the code... */
+ /* Now run the code. */
old_chain = make_cleanup (null_cleanup, 0);
for (i = 1; i < argc; i++)
do_cleanups (old_chain);
}
-/*
- * mi_insert_notify_hooks - This inserts a number of hooks that are
- * meant to produce async-notify ("=") MI messages while running
- * commands in another interpreter using mi_interpreter_exec. The
- * canonical use for this is to allow access to the gdb CLI
- * interpreter from within the MI, while still producing MI style
- * output when actions in the CLI command change gdb's state.
-*/
+/* This inserts a number of hooks that are meant to produce
+ async-notify ("=") MI messages while running commands in another
+ interpreter using mi_interpreter_exec. The canonical use for this
+ is to allow access to the gdb CLI interpreter from within the MI,
+ while still producing MI style output when actions in the CLI
+ command change GDB's state. */
static void
mi_insert_notify_hooks (void)
mi_command_loop (int mi_version)
{
/* Turn off 8 bit strings in quoted output. Any character with the
- high bit set is printed using C's octal format. */
+ high bit set is printed using C's octal format. */
sevenbit_strings = 1;
- /* Tell the world that we're alive */
+
+ /* Tell the world that we're alive. */
fputs_unfiltered ("(gdb) \n", raw_stdout);
gdb_flush (raw_stdout);
+
start_event_loop ();
}
if (current_uiout != mi_uiout)
{
- /* The normal_stop function has printed frame information into
- CLI uiout, or some other non-MI uiout. There's no way we
- can extract proper fields from random uiout object, so we print
- the frame again. In practice, this can only happen when running
- a CLI command in MI. */
+ /* The normal_stop function has printed frame information
+ into CLI uiout, or some other non-MI uiout. There's no
+ way we can extract proper fields from random uiout
+ object, so we print the frame again. In practice, this
+ can only happen when running a CLI command in MI. */
struct ui_out *saved_uiout = current_uiout;
struct target_waitstatus last;
ptid_t last_ptid;
/* When non-zero, no MI notifications will be emitted in
response to breakpoint change observers. */
+
int mi_suppress_breakpoint_notifications = 0;
/* Emit notification about a created breakpoint. */
+
static void
mi_breakpoint_created (struct breakpoint *b)
{
fprintf_unfiltered (mi->event_channel,
"breakpoint-created");
/* We want the output from gdb_breakpoint_query to go to
- mi->event_channel. One approach would be to just
- call gdb_breakpoint_query, and then use mi_out_put to
- send the current content of mi_outout into mi->event_channel.
- However, that will break if anything is output to mi_uiout
- prior the calling the breakpoint_created notifications.
- So, we use ui_out_redirect. */
+ mi->event_channel. One approach would be to just call
+ gdb_breakpoint_query, and then use mi_out_put to send the current
+ content of mi_outout into mi->event_channel. However, that will
+ break if anything is output to mi_uiout prior to calling the
+ breakpoint_created notifications. So, we use
+ ui_out_redirect. */
ui_out_redirect (mi_uiout, mi->event_channel);
TRY_CATCH (e, RETURN_MASK_ERROR)
gdb_breakpoint_query (mi_uiout, b->number, NULL);
}
/* Emit notification about deleted breakpoint. */
+
static void
mi_breakpoint_deleted (struct breakpoint *b)
{
}
/* Emit notification about modified breakpoint. */
+
static void
mi_breakpoint_modified (struct breakpoint *b)
{
fprintf_unfiltered (mi->event_channel,
"breakpoint-modified");
/* We want the output from gdb_breakpoint_query to go to
- mi->event_channel. One approach would be to just
- call gdb_breakpoint_query, and then use mi_out_put to
- send the current content of mi_outout into mi->event_channel.
- However, that will break if anything is output to mi_uiout
- prior the calling the breakpoint_created notifications.
- So, we use ui_out_redirect. */
+ mi->event_channel. One approach would be to just call
+ gdb_breakpoint_query, and then use mi_out_put to send the current
+ content of mi_outout into mi->event_channel. However, that will
+ break if anything is output to mi_uiout prior to calling the
+ breakpoint_created notifications. So, we use
+ ui_out_redirect. */
ui_out_redirect (mi_uiout, mi->event_channel);
TRY_CATCH (e, RETURN_MASK_ERROR)
gdb_breakpoint_query (mi_uiout, b->number, NULL);
gdb_flush (mi->event_channel);
}
-
static int
mi_output_running_pid (struct thread_info *info, void *arg)
{
_initialize_mi_interp (void)
{
static const struct interp_procs procs =
- {
- mi_interpreter_init, /* init_proc */
- mi_interpreter_resume, /* resume_proc */
- mi_interpreter_suspend, /* suspend_proc */
- mi_interpreter_exec, /* exec_proc */
- mi_interpreter_prompt_p, /* prompt_proc_p */
- mi_ui_out /* ui_out_proc */
- };
+ {
+ mi_interpreter_init, /* init_proc */
+ mi_interpreter_resume, /* resume_proc */
+ mi_interpreter_suspend, /* suspend_proc */
+ mi_interpreter_exec, /* exec_proc */
+ mi_interpreter_prompt_p, /* prompt_proc_p */
+ mi_ui_out /* ui_out_proc */
+ };
/* The various interpreter levels. */
interp_add (interp_new (INTERP_MI1, &procs));
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-/* Work in progress. */
-
#include "defs.h"
#include "arch-utils.h"
#include "target.h"
};
int mi_debug_p;
+
struct ui_file *raw_stdout;
-/* This is used to pass the current command timestamp
- down to continuation routines. */
+/* This is used to pass the current command timestamp down to
+ continuation routines. */
static struct mi_timestamp *current_command_ts;
static int do_timings = 0;
char *current_token;
-/* Few commands would like to know if options like --thread-group
- were explicitly specified. This variable keeps the current
- parsed command including all option, and make it possible. */
+/* Few commands would like to know if options like --thread-group were
+ explicitly specified. This variable keeps the current parsed
+ command including all option, and make it possible. */
static struct mi_parse *current_context;
int running_result_record_printed = 1;
mi_cmd_exec_return (char *command, char **argv, int argc)
{
/* This command doesn't really execute the target, it just pops the
- specified number of frames. */
+ specified number of frames. */
if (argc)
/* Call return_command with from_tty argument equal to 0 so as to
avoid being queried. */
proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
}
-
static int
proceed_thread_callback (struct thread_info *thread, void *arg)
{
{
if (non_stop)
{
- /* In non-stop mode, 'resume' always resumes a single thread. Therefore,
- to resume all threads of the current inferior, or all threads in all
- inferiors, we need to iterate over threads.
+ /* In non-stop mode, 'resume' always resumes a single thread.
+ Therefore, to resume all threads of the current inferior, or
+ all threads in all inferiors, we need to iterate over
+ threads.
See comment on infcmd.c:proceed_thread_callback for rationale. */
if (current_context->all || current_context->thread_group != -1)
}
else
{
- /* In all-stop mode, -exec-continue traditionally resumed either
- all threads, or one thread, depending on the 'scheduler-locking'
- variable. Let's continue to do the same. */
+ /* In all-stop mode, -exec-continue traditionally resumed
+ either all threads, or one thread, depending on the
+ 'scheduler-locking' variable. Let's continue to do the
+ same. */
continue_1 (1);
}
do_cleanups (back_to);
return 0;
}
-/* Interrupt the execution of the target. Note how we must play around
- with the token variables, in order to display the current token in
- the result of the interrupt command, and the previous execution
- token when the target finally stops. See comments in
+/* Interrupt the execution of the target. Note how we must play
+ around with the token variables, in order to display the current
+ token in the result of the interrupt command, and the previous
+ execution token when the target finally stops. See comments in
mi_cmd_execute. */
+
void
mi_cmd_exec_interrupt (char *command, char **argv, int argc)
{
return 0;
}
-/* Output a field named 'cores' with a list as the value. The elements of
- the list are obtained by splitting 'cores' on comma. */
+/* Output a field named 'cores' with a list as the value. The
+ elements of the list are obtained by splitting 'cores' on
+ comma. */
static void
output_cores (struct ui_out *uiout, const char *field_name, const char *xcores)
VEC (int) *ids = 0;
enum opt
- {
- AVAILABLE_OPT, RECURSE_OPT
- };
- static const struct mi_opt opts[] =
{
- {"-available", AVAILABLE_OPT, 0},
- {"-recurse", RECURSE_OPT, 1},
- { 0, 0, 0 }
+ AVAILABLE_OPT, RECURSE_OPT
};
+ static const struct mi_opt opts[] =
+ {
+ {"-available", AVAILABLE_OPT, 0},
+ {"-recurse", RECURSE_OPT, 1},
+ { 0, 0, 0 }
+ };
int oind = 0;
char *oarg;
}
else if (VEC_length (int, ids) == 1)
{
- /* Local thread groups, single id. */
+ /* Local thread groups, single id. */
int id = *VEC_address (int, ids);
struct inferior *inf = find_inferior_id (id);
struct cleanup *cleanup;
/* Note that the test for a valid register must include checking the
- gdbarch_register_name because gdbarch_num_regs may be allocated for
- the union of the register sets within a family of related processors.
- In this case, some entries of gdbarch_register_name will change depending
- upon the particular processor being debugged. */
+ gdbarch_register_name because gdbarch_num_regs may be allocated
+ for the union of the register sets within a family of related
+ processors. In this case, some entries of gdbarch_register_name
+ will change depending upon the particular processor being
+ debugged. */
gdbarch = get_current_arch ();
numregs = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch);
int i;
struct cleanup *cleanup;
- /* The last time we visited this function, the current frame's register
- contents were saved in THIS_REGS. Move THIS_REGS over to PREV_REGS,
- and refresh THIS_REGS with the now-current register contents. */
+ /* The last time we visited this function, the current frame's
+ register contents were saved in THIS_REGS. Move THIS_REGS over
+ to PREV_REGS, and refresh THIS_REGS with the now-current register
+ contents. */
prev_regs = this_regs;
this_regs = frame_save_as_regcache (get_selected_frame (NULL));
cleanup = make_cleanup_regcache_xfree (prev_regs);
/* Note that the test for a valid register must include checking the
- gdbarch_register_name because gdbarch_num_regs may be allocated for
- the union of the register sets within a family of related processors.
- In this case, some entries of gdbarch_register_name will change depending
- upon the particular processor being debugged. */
+ gdbarch_register_name because gdbarch_num_regs may be allocated
+ for the union of the register sets within a family of related
+ processors. In this case, some entries of gdbarch_register_name
+ will change depending upon the particular processor being
+ debugged. */
gdbarch = get_regcache_arch (this_regs);
numregs = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch);
make_cleanup_ui_out_list_begin_end (uiout, "changed-registers");
- if (argc == 0) /* No args, just do all the regs. */
+ if (argc == 0)
{
+ /* No args, just do all the regs. */
for (regnum = 0;
regnum < numregs;
regnum++)
/* Return a list of register number and value pairs. The valid
arguments expected are: a letter indicating the format in which to
- display the registers contents. This can be one of: x (hexadecimal), d
- (decimal), N (natural), t (binary), o (octal), r (raw). After the
- format argumetn there can be a sequence of numbers, indicating which
- registers to fetch the content of. If the format is the only argument,
- a list of all the registers with their values is returned. */
+ display the registers contents. This can be one of: x
+ (hexadecimal), d (decimal), N (natural), t (binary), o (octal), r
+ (raw). After the format argument there can be a sequence of
+ numbers, indicating which registers to fetch the content of. If
+ the format is the only argument, a list of all the registers with
+ their values is returned. */
+
void
mi_cmd_data_list_register_values (char *command, char **argv, int argc)
{
struct cleanup *list_cleanup, *tuple_cleanup;
/* Note that the test for a valid register must include checking the
- gdbarch_register_name because gdbarch_num_regs may be allocated for
- the union of the register sets within a family of related processors.
- In this case, some entries of gdbarch_register_name will change depending
- upon the particular processor being debugged. */
+ gdbarch_register_name because gdbarch_num_regs may be allocated
+ for the union of the register sets within a family of related
+ processors. In this case, some entries of gdbarch_register_name
+ will change depending upon the particular processor being
+ debugged. */
if (argc == 0)
error (_("-data-list-register-values: Usage: "
list_cleanup = make_cleanup_ui_out_list_begin_end (uiout, "register-values");
- if (argc == 1) /* No args, beside the format: do all the regs. */
+ if (argc == 1)
{
+ /* No args, beside the format: do all the regs. */
for (regnum = 0;
regnum < numregs;
regnum++)
}
/* Output one register's contents in the desired format. */
+
static void
get_register (struct frame_info *frame, int regnum, int format)
{
ptr += 2;
}
ui_out_field_string (uiout, "value", buf);
- /*fputs_filtered (buf, gdb_stdout); */
}
else
{
char format;
/* Note that the test for a valid register must include checking the
- gdbarch_register_name because gdbarch_num_regs may be allocated for
- the union of the register sets within a family of related processors.
- In this case, some entries of gdbarch_register_name will change depending
- upon the particular processor being debugged. */
+ gdbarch_register_name because gdbarch_num_regs may be allocated
+ for the union of the register sets within a family of related
+ processors. In this case, some entries of gdbarch_register_name
+ will change depending upon the particular processor being
+ debugged. */
regcache = get_current_regcache ();
gdbarch = get_regcache_arch (regcache);
/* Evaluate the value of the argument. The argument is an
expression. If the expression contains spaces it needs to be
included in double quotes. */
+
void
mi_cmd_data_evaluate_expression (char *command, char **argv, int argc)
{
do_cleanups (old_chain);
}
-/* DATA-MEMORY-READ:
+/* This is the -data-read-memory command.
ADDR: start address of data to be dumped.
WORD-FORMAT: a char indicating format for the ``word''. See
{addr="...",rowN={wordN="..." ,... [,ascii="..."]}, ...}
Returns:
- The number of bytes read is SIZE*ROW*COL. */
+ The number of bytes read is SIZE*ROW*COL. */
void
mi_cmd_data_read_memory (char *command, char **argv, int argc)
struct ui_out *uiout = current_uiout;
struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
CORE_ADDR addr;
- long total_bytes;
- long nr_cols;
- long nr_rows;
+ long total_bytes, nr_cols, nr_rows;
char word_format;
struct type *word_type;
long word_size;
int oind = 0;
char *oarg;
enum opt
- {
- OFFSET_OPT
- };
- static const struct mi_opt opts[] =
{
- {"o", OFFSET_OPT, 1},
- { 0, 0, 0 }
+ OFFSET_OPT
};
+ static const struct mi_opt opts[] =
+ {
+ {"o", OFFSET_OPT, 1},
+ { 0, 0, 0 }
+ };
while (1)
{
/* Start address of the memory dump. */
addr = parse_and_eval_address (argv[0]) + offset;
/* The format character to use when displaying a memory word. See
- the ``x'' command. */
+ the ``x'' command. */
word_format = argv[1][0];
/* The size of the memory word. */
word_size = atol (argv[2]);
byte < row_byte + word_size * nr_cols; byte++)
{
if (byte >= nr_bytes)
- {
- fputc_unfiltered ('X', stream->stream);
- }
+ fputc_unfiltered ('X', stream->stream);
else if (mbuf[byte] < 32 || mbuf[byte] > 126)
- {
- fputc_unfiltered (aschar, stream->stream);
- }
+ fputc_unfiltered (aschar, stream->stream);
else
fputc_unfiltered (mbuf[byte], stream->stream);
}
int oind = 0;
char *oarg;
enum opt
- {
- OFFSET_OPT
- };
- static const struct mi_opt opts[] =
{
- {"o", OFFSET_OPT, 1},
- { 0, 0, 0 }
+ OFFSET_OPT
};
+ static const struct mi_opt opts[] =
+ {
+ {"o", OFFSET_OPT, 1},
+ { 0, 0, 0 }
+ };
while (1)
{
do_cleanups (cleanups);
}
-
-/* DATA-MEMORY-WRITE:
+/* Implementation of the -data-write_memory command.
COLUMN_OFFSET: optional argument. Must be preceded by '-o'. The
offset from the beginning of the memory grid row where the cell to
Writes VALUE into ADDR + (COLUMN_OFFSET * WORD_SIZE).
Prints nothing. */
+
void
mi_cmd_data_write_memory (char *command, char **argv, int argc)
{
int oind = 0;
char *oarg;
enum opt
- {
- OFFSET_OPT
- };
- static const struct mi_opt opts[] =
{
- {"o", OFFSET_OPT, 1},
- { 0, 0, 0 }
+ OFFSET_OPT
};
+ static const struct mi_opt opts[] =
+ {
+ {"o", OFFSET_OPT, 1},
+ { 0, 0, 0 }
+ };
while (1)
{
/* The format character to use when displaying a memory word. See
the ``x'' command. */
word_format = argv[1][0];
- /* The size of the memory word. */
+ /* The size of the memory word. */
word_size = atol (argv[2]);
/* Calculate the real address of the write destination. */
do_cleanups (old_chain);
}
-/* DATA-MEMORY-WRITE-RAW:
+/* Implementation of the -data-write-memory-bytes command.
ADDR: start address
- DATA: string of bytes to write at that address. */
+ DATA: string of bytes to write at that address. */
+
void
mi_cmd_data_write_memory_bytes (char *command, char **argv, int argc)
{
{
int x;
sscanf (cdata + i * 2, "%02x", &x);
- data[i] = (gdb_byte)x;
+ data[i] = (gdb_byte) x;
}
r = target_write_memory (addr, data, len);
do_cleanups (back_to);
}
-
void
mi_cmd_enable_timings (char *command, char **argv, int argc)
{
ui_out_field_fmt (current_uiout, "inferior", "i%d", inf->num);
}
-/* Callback used to find the first inferior other than the
- current one. */
+/* Callback used to find the first inferior other than the current
+ one. */
static int
get_other_inferior (struct inferior *inf, void *arg)
args->action will tell mi_execute_command what action
to perfrom after the given command has executed (display/suppress
- prompt, display error). */
+ prompt, display error). */
static void
captured_mi_execute_command (struct ui_out *uiout, struct mi_parse *context)
fprintf_unfiltered (raw_stdout, " token=`%s' command=`%s' args=`%s'\n",
context->token, context->command, context->args);
-
mi_cmd_execute (context);
/* Print the result if there were no errors.
Remember that on the way out of executing a command, you have
- to directly use the mi_interp's uiout, since the command could
- have reset the interpreter, in which case the current uiout
- will most likely crash in the mi_out_* routines. */
+ to directly use the mi_interp's uiout, since the command
+ could have reset the interpreter, in which case the current
+ uiout will most likely crash in the mi_out_* routines. */
if (!running_result_record_printed)
{
fputs_unfiltered (context->token, raw_stdout);
fputs_unfiltered ("\n", raw_stdout);
}
else
- /* The command does not want anything to be printed. In that
- case, the command probably should not have written anything
- to uiout, but in case it has written something, discard it. */
+ /* The command does not want anything to be printed. In that
+ case, the command probably should not have written anything
+ to uiout, but in case it has written something, discard it. */
mi_out_rewind (uiout);
break;
}
break;
}
-
}
do_cleanups (cleanup);
-
- return;
}
/* Print a gdb exception to the MI output stream. */
fputs_unfiltered ("(gdb) \n", raw_stdout);
gdb_flush (raw_stdout);
- /* Print any buffered hook code. */
- /* ..... */
}
static void
set_current_inferior (inf);
/* This behaviour means that if --thread-group option identifies
- an inferior with multiple threads, then a random one will be picked.
- This is not a problem -- frontend should always provide --thread if
- it wishes to operate on a specific thread. */
+ an inferior with multiple threads, then a random one will be
+ picked. This is not a problem -- frontend should always
+ provide --thread if it wishes to operate on a specific
+ thread. */
if (inf->pid != 0)
tp = any_thread_of_process (inf->pid);
switch_to_thread (tp ? tp->ptid : null_ptid);
fprintf_unfiltered (gdb_stdout, "cli=%s run=%s\n",
cmd, run);
old_cleanups = make_cleanup (xfree, run);
- execute_command ( /*ui */ run, 0 /*from_tty */ );
+ execute_command (run, 0 /* from_tty */ );
do_cleanups (old_cleanups);
return;
}
run = xstrprintf ("%s %s", cli_command, argc ? *argv : "");
old_cleanups = make_cleanup (xfree, run);
- execute_command ( /*ui */ run, 0 /*from_tty */ );
+ execute_command (run, 0 /* from_tty */ );
/* Do this before doing any printing. It would appear that some
print code leaves garbage around in the buffer. */
static void
timestamp (struct mi_timestamp *tv)
- {
- gettimeofday (&tv->wallclock, NULL);
+{
+ gettimeofday (&tv->wallclock, NULL);
#ifdef HAVE_GETRUSAGE
- getrusage (RUSAGE_SELF, &rusage);
- tv->utime.tv_sec = rusage.ru_utime.tv_sec;
- tv->utime.tv_usec = rusage.ru_utime.tv_usec;
- tv->stime.tv_sec = rusage.ru_stime.tv_sec;
- tv->stime.tv_usec = rusage.ru_stime.tv_usec;
+ getrusage (RUSAGE_SELF, &rusage);
+ tv->utime.tv_sec = rusage.ru_utime.tv_sec;
+ tv->utime.tv_usec = rusage.ru_utime.tv_usec;
+ tv->stime.tv_sec = rusage.ru_stime.tv_sec;
+ tv->stime.tv_usec = rusage.ru_stime.tv_usec;
#else
- {
- long usec = get_run_time ();
+ {
+ long usec = get_run_time ();
- tv->utime.tv_sec = usec/1000000L;
- tv->utime.tv_usec = usec - 1000000L*tv->utime.tv_sec;
- tv->stime.tv_sec = 0;
- tv->stime.tv_usec = 0;
- }
-#endif
+ tv->utime.tv_sec = usec/1000000L;
+ tv->utime.tv_usec = usec - 1000000L*tv->utime.tv_sec;
+ tv->stime.tv_sec = 0;
+ tv->stime.tv_usec = 0;
}
+#endif
+}
static void
print_diff_now (struct mi_timestamp *start)
- {
- struct mi_timestamp now;
+{
+ struct mi_timestamp now;
- timestamp (&now);
- print_diff (start, &now);
- }
+ timestamp (&now);
+ print_diff (start, &now);
+}
void
mi_print_timing_maybe (void)
{
- /* If the command is -enable-timing then do_timings may be
- true whilst current_command_ts is not initialized. */
+ /* If the command is -enable-timing then do_timings may be true
+ whilst current_command_ts is not initialized. */
if (do_timings && current_command_ts)
print_diff_now (current_command_ts);
}
static long
timeval_diff (struct timeval start, struct timeval end)
- {
- return ((end.tv_sec - start.tv_sec) * 1000000L)
- + (end.tv_usec - start.tv_usec);
- }
+{
+ return ((end.tv_sec - start.tv_sec) * 1000000L)
+ + (end.tv_usec - start.tv_usec);
+}
static void
print_diff (struct mi_timestamp *start, struct mi_timestamp *end)
- {
- fprintf_unfiltered
- (raw_stdout,
- ",time={wallclock=\"%0.5f\",user=\"%0.5f\",system=\"%0.5f\"}",
- timeval_diff (start->wallclock, end->wallclock) / 1000000.0,
- timeval_diff (start->utime, end->utime) / 1000000.0,
- timeval_diff (start->stime, end->stime) / 1000000.0);
- }
+{
+ fprintf_unfiltered
+ (raw_stdout,
+ ",time={wallclock=\"%0.5f\",user=\"%0.5f\",system=\"%0.5f\"}",
+ timeval_diff (start->wallclock, end->wallclock) / 1000000.0,
+ timeval_diff (start->utime, end->utime) / 1000000.0,
+ timeval_diff (start->stime, end->stime) / 1000000.0);
+}
void
mi_cmd_trace_define_variable (char *command, char **argv, int argc)
mi_cmd_trace_list_variables (char *command, char **argv, int argc)
{
if (argc != 0)
- error (_("-trace-list-variables: no arguments are allowed"));
+ error (_("-trace-list-variables: no arguments allowed"));
tvariables_info_1 ();
}
error (_("Invalid mode '%s'"), mode);
if (has_stack_frames () || get_traceframe_number () >= 0)
- {
- print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC);
- }
+ print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC);
}
void
trace_save (filename, target_saves);
}
-
void
mi_cmd_trace_start (char *command, char **argv, int argc)
{
trace_status_mi (1);
}
-/* Implement the "-ada-task-info" GDB/MI command. */
+/* Implement the "-ada-task-info" command. */
void
mi_cmd_ada_task_info (char *command, char **argv, int argc)
enum ui_out_type type);
static void mi_close (struct ui_out *uiout, enum ui_out_type type);
-/* Mark beginning of a table */
+/* Mark beginning of a table. */
void
mi_table_begin (struct ui_out *uiout,
const char *tblid)
{
mi_open (uiout, tblid, ui_out_type_tuple);
- mi_field_int (uiout, -1/*fldno*/, -1/*width*/, -1/*alin*/,
- "nr_rows", nr_rows);
- mi_field_int (uiout, -1/*fldno*/, -1/*width*/, -1/*alin*/,
- "nr_cols", nr_cols);
+ mi_field_int (uiout, -1, -1, -1, "nr_rows", nr_rows);
+ mi_field_int (uiout, -1, -1, -1, "nr_cols", nr_cols);
mi_open (uiout, "hdr", ui_out_type_list);
}
-/* Mark beginning of a table body */
+/* Mark beginning of a table body. */
void
mi_table_body (struct ui_out *uiout)
mi_open (uiout, "body", ui_out_type_list);
}
-/* Mark end of a table */
+/* Mark end of a table. */
void
mi_table_end (struct ui_out *uiout)
mi_close (uiout, ui_out_type_tuple);
}
-/* Specify table header */
+/* Specify table header. */
void
mi_table_header (struct ui_out *uiout, int width, enum ui_align alignment,
- const char *col_name,
- const char *colhdr)
+ const char *col_name, const char *colhdr)
{
mi_out_data *data = ui_out_data (uiout);
if (data->suppress_output)
return;
+
mi_open (uiout, NULL, ui_out_type_tuple);
mi_field_int (uiout, 0, 0, 0, "width", width);
mi_field_int (uiout, 0, 0, 0, "alignment", alignment);
mi_close (uiout, ui_out_type_tuple);
}
-/* Mark beginning of a list */
+/* Mark beginning of a list. */
void
-mi_begin (struct ui_out *uiout,
- enum ui_out_type type,
- int level,
+mi_begin (struct ui_out *uiout, enum ui_out_type type, int level,
const char *id)
{
mi_out_data *data = ui_out_data (uiout);
if (data->suppress_output)
return;
+
mi_open (uiout, id, type);
}
-/* Mark end of a list */
+/* Mark end of a list. */
void
-mi_end (struct ui_out *uiout,
- enum ui_out_type type,
- int level)
+mi_end (struct ui_out *uiout, enum ui_out_type type, int level)
{
mi_out_data *data = ui_out_data (uiout);
if (data->suppress_output)
return;
+
mi_close (uiout, type);
}
-/* output an int field */
+/* Output an int field. */
-void
+static void
mi_field_int (struct ui_out *uiout, int fldno, int width,
enum ui_align alignment, const char *fldname, int value)
{
mi_field_string (uiout, fldno, width, alignment, fldname, buffer);
}
-/* used to ommit a field */
+/* Used to omit a field. */
void
mi_field_skip (struct ui_out *uiout, int fldno, int width,
{
}
-/* other specific mi_field_* end up here so alignment and field
- separators are both handled by mi_field_string */
+/* Other specific mi_field_* end up here so alignment and field
+ separators are both handled by mi_field_string. */
void
-mi_field_string (struct ui_out *uiout,
- int fldno,
- int width,
- enum ui_align align,
- const char *fldname,
- const char *string)
+mi_field_string (struct ui_out *uiout, int fldno, int width,
+ enum ui_align align, const char *fldname, const char *string)
{
mi_out_data *data = ui_out_data (uiout);
if (data->suppress_output)
return;
+
field_separator (uiout);
if (fldname)
fprintf_unfiltered (data->buffer, "%s=", fldname);
fprintf_unfiltered (data->buffer, "\"");
}
-/* This is the only field function that does not align */
+/* This is the only field function that does not align. */
void
-mi_field_fmt (struct ui_out *uiout, int fldno,
- int width, enum ui_align align,
- const char *fldname,
- const char *format,
- va_list args)
+mi_field_fmt (struct ui_out *uiout, int fldno, int width,
+ enum ui_align align, const char *fldname,
+ const char *format, va_list args)
{
mi_out_data *data = ui_out_data (uiout);
if (data->suppress_output)
return;
+
field_separator (uiout);
if (fldname)
fprintf_unfiltered (data->buffer, "%s=\"", fldname);
void
mi_message (struct ui_out *uiout, int verbosity,
- const char *format,
- va_list args)
+ const char *format, va_list args)
{
}
}
static void
-mi_open (struct ui_out *uiout,
- const char *name,
- enum ui_out_type type)
+mi_open (struct ui_out *uiout, const char *name, enum ui_out_type type)
{
mi_out_data *data = ui_out_data (uiout);
}
static void
-mi_close (struct ui_out *uiout,
- enum ui_out_type type)
+mi_close (struct ui_out *uiout, enum ui_out_type type)
{
mi_out_data *data = ui_out_data (uiout);
data->suppress_field_separator = 0;
}
-/* add a string to the buffer */
+/* Add a string to the buffer. */
void
mi_out_buffered (struct ui_out *uiout, char *string)
fprintf_unfiltered (data->buffer, "%s", string);
}
-/* clear the buffer */
+/* Clear the buffer. */
void
mi_out_rewind (struct ui_out *uiout)
ui_file_rewind (data->buffer);
}
-/* dump the buffer onto the specified stream */
+/* Dump the buffer onto the specified stream. */
static void
do_write (void *data, const char *buffer, long length_buffer)
}
void
-mi_out_put (struct ui_out *uiout,
- struct ui_file *stream)
+mi_out_put (struct ui_out *uiout, struct ui_file *stream)
{
mi_out_data *data = ui_out_data (uiout);
ui_file_rewind (data->buffer);
}
-/* Current MI version. */
+/* Return the current MI version. */
int
mi_version (struct ui_out *uiout)
return data->mi_version;
}
-/* initalize private members at startup */
+/* Initialize private members at startup. */
struct ui_out *
mi_out_new (int mi_version)
data->buffer = mem_fileopen ();
return ui_out_new (&mi_ui_out_impl, data, flags);
}
-
-/* standard gdb initialization hook */
-void
-_initialize_mi_out (void)
-{
- /* nothing happens here */
-}
{
char *arg;
- /* skip leading white space */
+ /* Skip leading white space. */
while (isspace (*chp))
chp++;
/* Three possibilities: EOF, quoted string, or other text. */
return;
case '"':
{
- /* A quoted string. */
+ /* A quoted string. */
int len;
char *start = chp + 1;
- /* Determine the buffer size. */
+ /* Determine the buffer size. */
chp = start;
len = 0;
while (*chp != '\0' && *chp != '"')
chp++;
if (mi_parse_escape (&chp) <= 0)
{
- /* Do not allow split lines or "\000" */
+ /* Do not allow split lines or "\000". */
freeargv (argv);
return;
}
chp++;
len++;
}
- /* Insist on a closing quote. */
+ /* Insist on a closing quote. */
if (*chp != '"')
{
freeargv (argv);
return;
}
- /* Insist on trailing white space. */
+ /* Insist on trailing white space. */
if (chp[1] != '\0' && !isspace (chp[1]))
{
freeargv (argv);
return;
}
- /* create the buffer. */
+ /* Create the buffer and copy characters in. */
arg = xmalloc ((len + 1) * sizeof (char));
- /* And copy the characters in. */
chp = start;
len = 0;
while (*chp != '\0' && *chp != '"')
len++;
}
arg[len] = '\0';
- chp++; /* that closing quote. */
+ chp++; /* That closing quote. */
break;
}
default:
{
- /* An unquoted string. Accumulate all non blank
- characters into a buffer. */
+ /* An unquoted string. Accumulate all non-blank
+ characters into a buffer. */
int len;
char *start = chp;
break;
}
}
- /* Append arg to argv. */
+ /* Append arg to argv. */
argv = xrealloc (argv, (argc + 2) * sizeof (char *));
argv[argc++] = arg;
argv[argc] = NULL;
}
}
-
void
mi_parse_free (struct mi_parse *parse)
{
cleanup = make_cleanup (mi_parse_cleanup, parse);
- /* Before starting, skip leading white space. */
+ /* Before starting, skip leading white space. */
while (isspace (*cmd))
cmd++;
- /* Find/skip any token and then extract it. */
+ /* Find/skip any token and then extract it. */
for (chp = cmd; *chp >= '0' && *chp <= '9'; chp++)
;
*token = xmalloc (chp - cmd + 1);
memcpy (*token, cmd, (chp - cmd));
(*token)[chp - cmd] = '\0';
- /* This wasn't a real MI command. Return it as a CLI_COMMAND. */
+ /* This wasn't a real MI command. Return it as a CLI_COMMAND. */
if (*chp != '-')
{
while (isspace (*chp))
return parse;
}
- /* Extract the command. */
+ /* Extract the command. */
{
char *tmp = chp + 1; /* discard ``-'' */
parse->command[chp - tmp] = '\0';
}
- /* Find the command in the MI table. */
+ /* Find the command in the MI table. */
parse->cmd = mi_lookup (parse->command);
if (parse->cmd == NULL)
error (_("Undefined MI command: %s"), parse->command);
- /* Skip white space following the command. */
+ /* Skip white space following the command. */
while (isspace (*chp))
chp++;
/* Parse the --thread and --frame options, if present. At present,
- some important commands, like '-break-*' are implemented by forwarding
- to the CLI layer directly. We want to parse --thread and --frame
- here, so as not to leave those option in the string that will be passed
- to CLI. */
+ some important commands, like '-break-*' are implemented by
+ forwarding to the CLI layer directly. We want to parse --thread
+ and --frame here, so as not to leave those option in the string
+ that will be passed to CLI. */
for (;;)
{
const char *option;
}
/* For new argv commands, attempt to return the parsed argument
- list. */
+ list. */
if (parse->cmd->argv_func != NULL)
{
mi_parse_argv (chp, parse);
discard_cleanups (cleanup);
- /* Fully parsed. */
+ /* Fully parsed, flag as an MI command. */
parse->op = MI_COMMAND;
return parse;
}
extern struct mi_parse *mi_parse (char *cmd, char **token);
-/* Free a command returned by mi_parse_command. */
+/* Free a command returned by mi_parse_command. */
extern void mi_parse_free (struct mi_parse *cmd);
#include "objfiles.h"
#include "ui-out.h"
-/* SYMBOL-LIST-LINES:
-
- Print the list of all pc addresses and lines of code for
- the provided (full or base) source file name. The entries
- are sorted in ascending PC order. */
+/* Print the list of all pc addresses and lines of code for the
+ provided (full or base) source file name. The entries are sorted
+ in ascending PC order. */
void
mi_cmd_symbol_list_lines (char *command, char **argv, int argc)
if (s == NULL)
error (_("-symbol-list-lines: Unknown source file name."));
- /* Now, dump the associated line table. The pc addresses are already
- sorted by increasing values in the symbol table, so no need to
- perform any other sorting. */
+ /* Now, dump the associated line table. The pc addresses are
+ already sorted by increasing values in the symbol table, so no
+ need to perform any other sorting. */
gdbarch = get_objfile_arch (s->objfile);
cleanup_stack = make_cleanup_ui_out_list_begin_end (uiout, "lines");