OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /openrisc/trunk/gnu-old/gdb-6.8/gdb/mi
    from Rev 157 to Rev 816
    Reverse comparison

Rev 157 → Rev 816

/mi-cmd-env.c
0,0 → 1,285
/* MI Command Set - environment commands.
 
Copyright (C) 2002, 2003, 2004, 2007, 2008 Free Software Foundation, Inc.
 
Contributed by Red Hat Inc.
 
This file is part of GDB.
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
 
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
 
#include "defs.h"
#include "inferior.h"
#include "value.h"
#include "mi-out.h"
#include "mi-cmds.h"
#include "mi-getopt.h"
#include "symtab.h"
#include "target.h"
#include "environ.h"
#include "command.h"
#include "ui-out.h"
#include "top.h"
 
#include "gdb_string.h"
#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";
static char *orig_path = NULL;
 
/* 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)
{
if (cmd != 0)
{
struct cleanup *old_cleanups;
char *run;
if (args != NULL)
run = xstrprintf ("%s %s", cmd, args);
else
run = xstrdup (cmd);
old_cleanups = make_cleanup (xfree, run);
execute_command ( /*ui */ run, 0 /*from_tty */ );
do_cleanups (old_cleanups);
return;
}
}
 
 
/* Print working directory. */
/* JPB: Some picky Ubuntu GCC compilers don't like the result of getcwd being
ignored (even if you cast it to void). So capture the value and ignore
THAT. */
enum mi_cmd_result
mi_cmd_env_pwd (char *command, char **argv, int argc)
{
char *res; /* For getcwd result */
if (argc > 0)
error (_("mi_cmd_env_pwd: No arguments required"));
if (mi_version (uiout) < 2)
{
env_execute_cli_command ("pwd", NULL);
return MI_CMD_DONE;
}
/* Otherwise the mi level is 2 or higher. */
 
res = getcwd (gdb_dirbuf, sizeof (gdb_dirbuf)); /* JPB */
ui_out_field_string (uiout, "cwd", gdb_dirbuf);
 
return MI_CMD_DONE;
}
 
/* Change working directory. */
enum mi_cmd_result
mi_cmd_env_cd (char *command, char **argv, int argc)
{
if (argc == 0 || argc > 1)
error (_("mi_cmd_env_cd: Usage DIRECTORY"));
env_execute_cli_command ("cd", argv[0]);
 
return MI_CMD_DONE;
}
 
static void
env_mod_path (char *dirname, char **which_path)
{
if (dirname == 0 || dirname[0] == '\0')
return;
 
/* Call add_path with last arg 0 to indicate not to parse for
separator characters. */
add_path (dirname, which_path, 0);
}
 
/* Add one or more directories to start of executable search path. */
enum mi_cmd_result
mi_cmd_env_path (char *command, char **argv, int argc)
{
char *exec_path;
char *env;
int reset = 0;
int optind = 0;
int i;
char *optarg;
enum opt
{
RESET_OPT
};
static struct mi_opt opts[] =
{
{"r", RESET_OPT, 0},
{ 0, 0, 0 }
};
 
dont_repeat ();
 
if (mi_version (uiout) < 2)
{
for (i = argc - 1; i >= 0; --i)
env_execute_cli_command ("path", argv[i]);
return MI_CMD_DONE;
}
 
/* Otherwise the mi level is 2 or higher. */
while (1)
{
int opt = mi_getopt ("mi_cmd_env_path", argc, argv, opts,
&optind, &optarg);
if (opt < 0)
break;
switch ((enum opt) opt)
{
case RESET_OPT:
reset = 1;
break;
}
}
argv += optind;
argc -= optind;
 
 
if (reset)
{
/* Reset implies resetting to original path first. */
exec_path = xstrdup (orig_path);
}
else
{
/* Otherwise, get current path to modify. */
env = get_in_environ (inferior_environ, path_var_name);
 
/* Can be null if path is not set. */
if (!env)
env = "";
exec_path = xstrdup (env);
}
 
for (i = argc - 1; i >= 0; --i)
env_mod_path (argv[i], &exec_path);
 
set_in_environ (inferior_environ, path_var_name, exec_path);
xfree (exec_path);
env = get_in_environ (inferior_environ, path_var_name);
ui_out_field_string (uiout, "path", env);
 
return MI_CMD_DONE;
}
 
/* Add zero or more directories to the front of the source path. */
enum mi_cmd_result
mi_cmd_env_dir (char *command, char **argv, int argc)
{
int i;
int optind = 0;
int reset = 0;
char *optarg;
enum opt
{
RESET_OPT
};
static struct mi_opt opts[] =
{
{"r", RESET_OPT, 0},
{ 0, 0, 0 }
};
 
dont_repeat ();
 
if (mi_version (uiout) < 2)
{
for (i = argc - 1; i >= 0; --i)
env_execute_cli_command ("dir", argv[i]);
return MI_CMD_DONE;
}
 
/* Otherwise mi level is 2 or higher. */
while (1)
{
int opt = mi_getopt ("mi_cmd_env_dir", argc, argv, opts,
&optind, &optarg);
if (opt < 0)
break;
switch ((enum opt) opt)
{
case RESET_OPT:
reset = 1;
break;
}
}
argv += optind;
argc -= optind;
 
if (reset)
{
/* Reset means setting to default path first. */
xfree (source_path);
init_source_path ();
}
 
for (i = argc - 1; i >= 0; --i)
env_mod_path (argv[i], &source_path);
init_last_source_visited ();
 
ui_out_field_string (uiout, "source-path", source_path);
forget_cached_source_info ();
 
return MI_CMD_DONE;
}
 
/* Set the inferior terminal device name. */
enum mi_cmd_result
mi_cmd_inferior_tty_set (char *command, char **argv, int argc)
{
set_inferior_io_terminal (argv[0]);
 
return MI_CMD_DONE;
}
 
/* Print the inferior terminal device name */
enum mi_cmd_result
mi_cmd_inferior_tty_show (char *command, char **argv, int argc)
{
const char *inferior_io_terminal = get_inferior_io_terminal ();
if ( !mi_valid_noargs ("mi_cmd_inferior_tty_show", argc, argv))
error (_("mi_cmd_inferior_tty_show: Usage: No args"));
 
if (inferior_io_terminal)
ui_out_field_string (uiout, "inferior_tty_terminal", inferior_io_terminal);
 
return MI_CMD_DONE;
}
 
void
_initialize_mi_cmd_env (void)
{
char *env;
 
/* We want original execution path to reset to, if desired later. */
env = get_in_environ (inferior_environ, path_var_name);
 
/* Can be null if path is not set. */
if (!env)
env = "";
orig_path = xstrdup (env);
}
mi-cmd-env.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mi-cmds.h =================================================================== --- mi-cmds.h (nonexistent) +++ mi-cmds.h (revision 816) @@ -0,0 +1,161 @@ +/* MI Command Set for GDB, the GNU debugger. + + Copyright (C) 2000, 2003, 2004, 2005, 2007, 2008 + Free Software Foundation, Inc. + + Contributed by Cygnus Solutions (a Red Hat company). + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef MI_CMDS_H +#define MI_CMDS_H + +/* An MI command can return any of the following. */ + +enum mi_cmd_result + { + /* Report the command as ``done''. Display both the ``NNN^done'' + message and the completion prompt. */ + MI_CMD_DONE = 0, + /* The command is still running in the forground. Main loop should + display the completion prompt. */ + MI_CMD_FORGROUND, + /* An error condition was detected and an error message was + asprintf'd into the mi_error_message buffer. The main loop will + display the error message and the completion prompt. */ + MI_CMD_ERROR, + /* The MI command has already displayed its completion message. + Main loop will not display a completion message but will display + the completion prompt. */ + MI_CMD_QUIET + }; + +enum print_values { + PRINT_NO_VALUES, + PRINT_ALL_VALUES, + PRINT_SIMPLE_VALUES +}; + +extern const char mi_no_values[]; +extern const char mi_simple_values[]; +extern const char mi_all_values[]; + +typedef enum mi_cmd_result (mi_cmd_argv_ftype) (char *command, char **argv, int argc); + +/* Older MI commands have this interface. Retained until all old + commands are flushed. */ + +typedef enum mi_cmd_result (mi_cmd_args_ftype) ( /*ui */ char *args, int from_tty); + +/* Function implementing each command */ +extern mi_cmd_argv_ftype mi_cmd_break_insert; +extern mi_cmd_argv_ftype mi_cmd_break_watch; +extern mi_cmd_argv_ftype mi_cmd_disassemble; +extern mi_cmd_argv_ftype mi_cmd_data_evaluate_expression; +extern mi_cmd_argv_ftype mi_cmd_data_list_register_names; +extern mi_cmd_argv_ftype mi_cmd_data_list_register_values; +extern mi_cmd_argv_ftype mi_cmd_data_list_changed_registers; +extern mi_cmd_argv_ftype mi_cmd_data_read_memory; +extern mi_cmd_argv_ftype mi_cmd_data_write_memory; +extern mi_cmd_argv_ftype mi_cmd_data_write_register_values; +extern mi_cmd_argv_ftype mi_cmd_enable_timings; +extern mi_cmd_argv_ftype mi_cmd_env_cd; +extern mi_cmd_argv_ftype mi_cmd_env_dir; +extern mi_cmd_argv_ftype mi_cmd_env_path; +extern mi_cmd_argv_ftype mi_cmd_env_pwd; +extern mi_cmd_args_ftype mi_cmd_exec_continue; +extern mi_cmd_args_ftype mi_cmd_exec_finish; +extern mi_cmd_args_ftype mi_cmd_exec_next; +extern mi_cmd_args_ftype mi_cmd_exec_next_instruction; +extern mi_cmd_args_ftype mi_cmd_exec_return; +extern mi_cmd_args_ftype mi_cmd_exec_run; +extern mi_cmd_args_ftype mi_cmd_exec_step; +extern mi_cmd_args_ftype mi_cmd_exec_step_instruction; +extern mi_cmd_args_ftype mi_cmd_exec_until; +extern mi_cmd_args_ftype mi_cmd_exec_interrupt; +extern mi_cmd_argv_ftype mi_cmd_file_list_exec_source_file; +extern mi_cmd_argv_ftype mi_cmd_file_list_exec_source_files; +extern mi_cmd_argv_ftype mi_cmd_gdb_exit; +extern mi_cmd_argv_ftype mi_cmd_inferior_tty_set; +extern mi_cmd_argv_ftype mi_cmd_inferior_tty_show; +extern mi_cmd_argv_ftype mi_cmd_interpreter_exec; +extern mi_cmd_argv_ftype mi_cmd_list_features; +extern mi_cmd_argv_ftype mi_cmd_stack_info_depth; +extern mi_cmd_argv_ftype mi_cmd_stack_info_frame; +extern mi_cmd_argv_ftype mi_cmd_stack_list_args; +extern mi_cmd_argv_ftype mi_cmd_stack_list_frames; +extern mi_cmd_argv_ftype mi_cmd_stack_list_locals; +extern mi_cmd_argv_ftype mi_cmd_stack_select_frame; +extern mi_cmd_argv_ftype mi_cmd_symbol_list_lines; +extern mi_cmd_args_ftype mi_cmd_target_download; +extern mi_cmd_argv_ftype mi_cmd_target_file_get; +extern mi_cmd_argv_ftype mi_cmd_target_file_put; +extern mi_cmd_argv_ftype mi_cmd_target_file_delete; +extern mi_cmd_args_ftype mi_cmd_target_select; +extern mi_cmd_argv_ftype mi_cmd_thread_list_ids; +extern mi_cmd_argv_ftype mi_cmd_thread_select; +extern mi_cmd_argv_ftype mi_cmd_var_assign; +extern mi_cmd_argv_ftype mi_cmd_var_create; +extern mi_cmd_argv_ftype mi_cmd_var_delete; +extern mi_cmd_argv_ftype mi_cmd_var_evaluate_expression; +extern mi_cmd_argv_ftype mi_cmd_var_info_expression; +extern mi_cmd_argv_ftype mi_cmd_var_info_path_expression; +extern mi_cmd_argv_ftype mi_cmd_var_info_num_children; +extern mi_cmd_argv_ftype mi_cmd_var_info_type; +extern mi_cmd_argv_ftype mi_cmd_var_list_children; +extern mi_cmd_argv_ftype mi_cmd_var_set_format; +extern mi_cmd_argv_ftype mi_cmd_var_set_frozen; +extern mi_cmd_argv_ftype mi_cmd_var_show_attributes; +extern mi_cmd_argv_ftype mi_cmd_var_show_format; +extern mi_cmd_argv_ftype mi_cmd_var_update; + +/* Description of a single command. */ + +struct mi_cli +{ + /* Corresponding CLI command. If ARGS_P is non-zero, the MI + command's argument list is appended to the CLI command. */ + const char *cmd; + int args_p; +}; + +struct mi_cmd +{ + /* 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). */ + struct mi_cli cli; + /* If non-null, the function implementing the MI command. */ + mi_cmd_args_ftype *args_func; + /* If non-null, the function implementing the MI command. */ + mi_cmd_argv_ftype *argv_func; +}; + +/* Lookup a command in the mi comand table */ + +extern struct mi_cmd *mi_lookup (const char *command); + +/* Debug flag */ +extern int mi_debug_p; + +/* Raw console output - FIXME: should this be a parameter? */ +extern struct ui_file *raw_stdout; + +extern char *mi_error_message; +extern void mi_execute_command (char *cmd, int from_tty); + +#endif
mi-cmds.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mi-common.h =================================================================== --- mi-common.h (nonexistent) +++ mi-common.h (revision 816) @@ -0,0 +1,44 @@ +/* Interface for common GDB/MI data + Copyright (C) 2005, 2007, 2008 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef MI_COMMON_H +#define MI_COMMON_H + +/* Represents the reason why GDB is sending an asynchronous command to the + front end. NOTE: When modifing this, don't forget to update gdb.texinfo! */ +enum async_reply_reason +{ + EXEC_ASYNC_BREAKPOINT_HIT = 0, + EXEC_ASYNC_WATCHPOINT_TRIGGER, + EXEC_ASYNC_READ_WATCHPOINT_TRIGGER, + EXEC_ASYNC_ACCESS_WATCHPOINT_TRIGGER, + EXEC_ASYNC_FUNCTION_FINISHED, + EXEC_ASYNC_LOCATION_REACHED, + EXEC_ASYNC_WATCHPOINT_SCOPE, + EXEC_ASYNC_END_STEPPING_RANGE, + EXEC_ASYNC_EXITED_SIGNALLED, + EXEC_ASYNC_EXITED, + EXEC_ASYNC_EXITED_NORMALLY, + EXEC_ASYNC_SIGNAL_RECEIVED, + /* This is here only to represent the number of enums. */ + EXEC_ASYNC_LAST +}; + +const char *async_reason_lookup (enum async_reply_reason reason); + +#endif
mi-common.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: ChangeLog-1999-2003 =================================================================== --- ChangeLog-1999-2003 (nonexistent) +++ ChangeLog-1999-2003 (revision 816) @@ -0,0 +1,2180 @@ +2003-11-06 Andrew Cagney + + * mi-cmd-var.c (mi_cmd_var_set_format): Replace STREQN with + strncmp. + +2003-10-24 Andrew Cagney + + * tui-out.c: Fix "fortunatly"[sic]. + +2003-10-02 Andrew Cagney + + * mi-main.c: Rename REGISTER_RAW_SIZE to + DEPRECATED_REGISTER_RAW_SIZE. + +2003-09-30 Andrew Cagney + + * mi-main.c: Rename REGISTER_VIRTUAL_SIZE to + DEPRECATED_REGISTER_VIRTUAL_SIZE. + +2003-09-17 Andrew Cagney + + * mi-main.c: Rename REGISTER_BYTE to DEPRECATED_REGISTER_BYTE. + +2003-09-10 Elena Zannoni + + * mi-main.c (mi_setup_architecture_data): Don't use + DEPRECATED_REGISTER_BYTES because some architecture don't set it + and its default is 0. + +2003-08-08 Andrew Cagney + + * mi-main.c (captured_mi_execute_command): Add "mi2" and "mi3" to + interpreters that hack around CLI. + * mi-interp.c (mi3_command_loop): New function. + (mi_interpreter_resume): Check for "mi3", default to "mi2". + +2003-08-07 Andrew Cagney + + * mi-interp.c (_initialize_mi_interp): Register "mi2" and "mi3". + Make "mi" select "mi2". + +2003-08-05 Andrew Cagney + + * mi-cmd-env.c (env_execute_cli_command): Use an explicit "%s %s" + when constructing the run command. + (mi_cmd_env_cd, mi_cmd_env_path, mi_cmd_env_dir): Simplify command + string removing the "%s". + +2003-08-04 Andrew Cagney + + * mi-cmds.h (struct mi_cli): Define. + (struct mi_cmd): Change type of "cli" to "struct mi_cli". + * mi-cmds.c (mi_cmds): Update table. + * mi-parse.c (mi_parse): Update. + * mi-main.c (mi_execute_cli_command): Add "args_p" parameter, make + others constant. + (mi_cmd_execute): Update call. + (captured_mi_execute_command): Ditto. + +2003-08-04 David Carlton + + * mi-main.c (mi_error_last_message): Add "%s" second argument to + xasprintf call. + +2003-06-28 Daniel Jacobowitz + + * mi-out.c (mi_ui_out_impl): Add NULL for redirect member. + +2003-06-17 Daniel Jacobowitz + + * mi-cmds.c (mi_cmds): Add "-target-disconnect". + +2003-06-11 David Carlton + + * mi-cmd-stack.c: Include dictionary.h. + (list_args_or_locals): Update use of ALL_BLOCK_SYMBOLS. + +2003-06-11 Andrew Cagney + + * mi-main.c (get_register): Replace REGISTER_CONVERTIBLE with + DEPRECATED_REGISTER_CONVERTIBLE. + +2003-06-08 Andrew Cagney + + * mi-parse.c (_initialize_mi_parse): Delete function. + * mi-main.c: Include "mi-main.h". + * mi-interp.c (_initialize_mi_interp): Add declaration. + * mi-cmd-stack.c: Include "stack.h". + (select_frame_command_wrapper): Delete extern declaration. + (mi_cmd_stack_select_frame): Replace select_frame_command_wrapper + with select_frame_command. + +2003-05-16 Andrew Cagney + + * mi-main.c (mi_setup_architecture_data): + +2003-05-12 Elena Zannoni + + * mi-mi-cmd-stack.c (list_args_or_locals): Rename VAR_NAMESPACE to + VAR_DOMAIN. + +2003-05-11 Andrew Cagney + + * mi-symbol-cmds.c: Rename "mi-cmd-symbol.c", avoid 8.3 problem. + +2003-05-08 Andrew Cagney + + * mi-main.c (register_changed_p): Use MAX_REGISTER_SIZE instead of + MAX_REGISTER_RAW_SIZE. + +2003-05-08 Andrew Cagney + + * mi-main.c (get_register): Use MAX_REGISTER_SIZE. + +2003-05-05 Andrew Cagney + + * mi-main.c (mi_cmd_data_write_register_values): Replace + REGISTER_SIZE with DEPRECATED_REGISTER_SIZE. + +2003-05-03 J. Brobecker + + From Thierry Schneider : + * mi-cmds.h (mi_cmd_symbol_list_lines): Add declaration. + * mi-cmds.c (mi_cmds): Add entry for new MI command. + * mi-cmd-symbol.c (mi_cmd_symbol_list_lines): New source file + for all symbol-related commands. + +2003-04-02 Bob Rossi + + * mi-cmd-file.c: New file to implement mi file commands. + * mi-getopt.c (mi_valid_noargs): Added mi_valid_noargs to verify + if a set of parameters passed to an MI function has no arguments + * mi-getopt.h (mi_valid_noargs): Declare. + * mi-cmds.c (mi_cmds): Added -file-list-exec-source-file command. + * mi-cmds.h (mi_cmd_file_list_exec_source_file): Declare. + +2003-03-27 Andrew Cagney + + * gdbmi.texinfo: Delete file. Contents moved to + ../doc/gdb.texinfo. + +2003-03-12 Andrew Cagney + + * mi-main.c (get_register): Use frame_register instead of + get_saved_register. + +2003-03-08 Andrew Cagney + + * mi-out.c: Update copyright. + (mi_out_data): Define typedef. Use instead of ui_out_data. + +2003-03-01 Andrew Cagney + + * mi-main.c (get_register): Use register_type instead of + REGISTER_VIRTUAL_TYPE. + +2003-02-25 David Carlton + + * mi-cmd-stack.c: Replace all instances of SYMBOL_NAME with + DEPRECATED_SYMBOL_NAME. Update copyright. + +2003-02-21 Daniel Jacobowitz + + * mi-cmd-stack.c (list_args_or_locals): Handle LOC_COMPUTED and + LOC_COMPUTED_ARG. + +2003-02-19 David Carlton + + * mi-cmd-stack.c: #include "block.h" + +2003-02-09 Andrew Cagney + + * mi-interp.c (mi_remove_notify_hooks): Convert function + definition to ISO C. + +2003-02-06 Andrew Cagney + + * mi-cmd-env.c: Include "gdb_stat.h" instead of . + +2003-02-04 Jim Ingham + Keith Seitz + Elena Zannoni + Andrew Cagney + + * mi-main.h: New file. + * mi-interp.c: New file. + * mi-main.c: Include "interps.h". + (mi_error_message): Make global. + (mi_input): Delete static function, moved to "mi-interp.c". + (mi_execute_command, mi_execute_command_wrapper): Ditto. + (mi_command_loop, mi1_command_loop, mi2_command_loop): Ditto. + (mi_load_progress): Make non-static. + (mi_error_last_message): New function. + (captured_mi_execute_command): If the interpreter changed, don't + print anything. + (mi_load_progress): Use current_interp_named_p. + (mi_init_ui): Delete function. + (_initialize_mi_main): Don't install the mi interpreter, handled + by "mi-interp.c". + (mi_exec_async_cli_cmd_continuation): Make static. + * mi-console.h (mi_console_file_new): Add `quote' parameter. + * mi-console.c (struct mi_console_file): Add `quote'. + (mi_console_file_new): Add `quote' parameter. Initialize `quote'. + (mi_console_raw_packet): Only quote the output when `quote'. + * mi-cmds.h (mi_cmd_interpreter_exec): Declare. + (mi_error_message, mi_error_last_message): Declare. + (mi_execute_command): Declare. + * mi-cmds.c: Add `interpreter-exec' command. + +2003-02-04 Andrew Cagney + + From Keith Seitz : + * gdbmi.texinfo (GDB/MI Miscellaneous Commands): Document the + interpreter-exec command. + +2003-02-02 Andrew Cagney + + From 2002-11-10 Jason Molenda (jason-cl@molenda.com): + * mi-cmd-var.c (mi_cmd_var_list_children): CHILDREN field is + now a list; still a tuple when in mi1. + * gdbmi.texinfo: Update var-list-children example. + +2003-01-13 Andrew Cagney + + * mi-cmd-env.c: Update copyright. + +2003-01-13 Elena Zannoni + + * mi-main.c (mi_cmd_exec_return): Use print_stack_frame instead of + show_and_print_stack_frame. + +2003-01-09 Andrew Cagney + + * mi-cmd-env.c: Include "gdb_string.h" instead of . + Move all includes to after "defs.h". + +2002-12-13 Jeff Johnston + + * mi-cmds.c (-environment-directory) Change to use mi_cmd_env_dir, + (-environment-cd): Change to use mi_cmd_env_cd,. + (-environment-pwd): Change to use mi_cmd_env_pwd. + (-environment-path): Change to use mi_cmd_env_path. + * mi-cmds.h (mi_cmd_env_cd, mi_cmd_env_dir): New prototypes. + (mi_cmd_env_path, mi_cmd_env_pwd): Ditto. + * mi-cmd-env.c: New file. Part of fix for PR gdb/741. + * gdbmi.texinfo (environment-cd): Update output and example. + (environment-pwd): Ditto. + (environment-dir): Update output, description, and examples. + (environment-path): Ditto. + +2002-11-29 Andrew Cagney + + * mi/mi-cmd-stack.c, mi/mi-main.c: Update to use + deprecated_selected_frame. + +2002-11-13 Andrew Cagney + + * mi-main.c (mi_cmd_data_write_register_values): Use + deprecated_write_register_bytes instead of write_register_bytes. + +2002-11-11 Jeff Johnston + + * gdbmi.texinfo (-var-assign): Add comments about interaction + with -var-update and add an example. Part of fix for gdb/702. + +2002-11-08 Jeff Johnston + + * mi-main.c (mi_command_loop): Initialize raw_stdout and gdb_stdout + only if mi version is <= 1. + (mi_init_ui): Initialize raw_stdout and gdb_stdout if mi version + is > 1 so startup message is treated as console output. This is + part of fix for PR gdb/604. + +2002-11-06 Jeff Johnston + + * mi-cmd-var.c (mi_cmd_var_create): Change the function used to + parse the frame addr from parse_and_eval_address() to + string_to_core_addr(). This is a fix for PR gdb/494. + +2002-10-23 Jeff Johnston + + * mi-cmd-var.c: Change all remaining occurrences of ui_out_tuple_begin + to make_cleanup_ui_out_tuple_begin_end. Change all remaining + occurrences of ui_out_list_begin to make_cleanup_ui_out_list_begin_end. + Use do_cleanups instead of ui_out_list_end or ui_out_tuple_end. This + is a fix for PR gdb/680. + * mi-cmd-stack.c: Ditto. + * mi-main.c: Ditto. + +2002-10-22 Keith Seitz + + * mi-main.c (mi_cmd_thread_select): Only return MI_CMD_CAUGHT_ERROR + when we really did catch an error(). If we got GDB_RC_FAIL, return + MI_CMD_ERROR instead. + +2002-10-03 Jeff Johnston + + * gdbmi.texinfo: Fix examples that show frames to remove + extraneous blank in level field. Part of fix for PR gdb/192. + +2002-10-03 Jeff Johnston + + * mi-cmd-var.c (mi_cmd_var_update): Fix for PR gdb/672. For m2, + output list begin and end for "changelist" rather than tuple begin/end. + (varobj_update_one): For m2, add tuple begin and end for varobj + update output. + +2002-10-02 Elena Zannoni + + * mi-main.c (mi_cmd_exec_return): Don't use + return_command_wrapper, use return_command instead. + (mi_cmd_exec_interrupt): Don't use + interrupt_target_command_wrapper, use interrupt_target_command + instead. + (return_command_wrapper, interrupt_target_command_wrapper): + Delete. + Include frame.h. + +2002-10-01 Andrew Cagney + + * mi-main.c (mi2_command_loop): New function. + (mi0_command_loop): Delete function. + (_initialize_mi_main): Recognize, and default to, "mi2". Do not + recognize "mi0". + * mi-out.c (mi_table_begin): Remove mi0 code. + (mi_table_body, mi_table_end): Ditto. + (mi_table_header, mi_open, mi_close): Ditto. + +2002-09-29 Andrew Cagney + + * mi-out.c (mi_version): New function. + * mi-out.h (mi_version): Declare. + +2002-09-27 Andrew Cagney + + From 2002-07-12 Mo DeJong + * gdbmi.texinfo (var-evaluate-expression): Note that + var-list-children must be invoked before child variable + values can be evaluated. + +2002-09-26 Elena Zannoni + + * mi-cmd-disas.c (dump_insns): Add text only output for CLI. + (do_mixed_source_and_assembly): Ditto. + +2002-09-11 Keith Seitz + + * mi-main.c (mi_cmd_data_list_register_names): Use cleanups + for the uiout list. Do the cleanups when returning an error. + (mi_cmd_data_list_changed_registers): Ditto. + (mi_cmd_data_list_register_values): Use cleanups for the uiout list + and tuples. Do the cleanups when returning errors. + +2002-07-29 Andrew Cagney + + * mi-cmd-var.c: Include "gdb_string.h". + * mi-cmd-disas.c: Ditto. + +2002-06-17 Keith Seitz + + * gdbmi.texinfo: Update command examples with real MI behavior. + +2002-05-20 Keith Seitz + + * mi-main.c (captured_mi_execute_command): Add uiout parameter. + "data" is now a structure which is used to pass data to/from this + function to mi_execute_command. + Modify function to comply with requirements from catch_exceptions. + Store real return result and command's return result in data. + (mi_execute_command): Use catch_exceptions. + Use enum to handle actions to be performed instead of overloading + catch_errors return result and the mi return result. + +2002-04-14 Andrew Cagney + + * mi-main.c (mi_cmd_exec_return): + +2002-04-09 Andrew Cagney + + * mi-main.c (register_changed_p): Use frame_register_read instead + of read_relative_register_raw_bytes. + (get_register): Delete out-of-date comment. + +2002-04-07 Elena Zannoni + + * mi-cmd-disas.c: Run through indent. + +2002-04-07 Elena Zannoni + + * mi-cmd-disas.c (dump_insns): New function. + (do_mixed_source_and_assembly): New function. + (do_assembly_only): New function. + (do_disassembly): New function. + (mi_cmd_disassemble): Rewrite using smaller, more modular + functions. + +2002-04-05 Jim Blandy + + * mi-cmd-stack.c (list_args_or_locals): Pass new arg to + get_frame_block. (See entry in gdb/ChangeLog.) + +2002-04-05 Elena Zannoni + + * mi-cmd-disas.c (mi_cmd_disassemble): Use TARGET_PRINT_INSN + instead of tm_print_insn. + Update copyright year. + +2002-04-04 Daniel Jacobowitz + + * mi-cmd-disas.c (mi_cmd_disassemble): Skip end-of-function + markers in the line table. + +2002-03-15 Andrew Cagney + + * mi-main.c (XMALLOC): Delete macro. + * mi-out.c (XMALLOC): Ditto. + * mi-parse.c (XMALLOC): Ditto. + * mi-console.c (XMALLOC): Ditto. + * mi-cmd-var.c (XMALLOC): Ditto. + * mi-cmd-break.c (XMALLOC): Ditto. + + * mi/mi-cmd-var.c, mi/mi-console.c, mi/mi-out.c: Update copyright + * mi/mi-parse.c: Ditto. + +2002-02-24 Andrew Cagney + + From wiz at danbala: + * gdbmi.texinfo: Fix grammar and typos. + Fix PR gdb/287. + +2002-02-03 Jim Blandy + + * mi-cmd-stack.c (list_args_or_locals): Move declaration of + print_me inside the loop body, so it gets re-initialized every + iteration. The cases for the different symbol kinds leave + print_me unchanged if they don't want the symbol printed. + +2002-01-22 Andrew Cagney + + * gdbmi.texinfo: Remove makeinfo 3.12 hacks. + +2002-01-21 Andrew Cagney + + * mi-cmd-stack.c: Remove #else clause of #ifdef UI_OUT. + * mi-cmd-break.c: Ditto. + * mi-main.c: Ditto. + +2001-12-30 Eli Zaretskii + + * gdbmi.texinfo: Fix the application of GFDL in the Copyright notice. + +2001-10-12 Daniel Jacobowitz + + * mi-cmd-stack.c (list_args_or_locals): Use ALL_BLOCK_SYMBOLS. + +2001-09-18 Andrew Cagney + + * mi-main.c (mi_cmd_thread_select): Pass uiout to + gdb_thread_select. + (mi_cmd_thread_list_ids): Pass uiout to gdb_list_thread_ids. + + * mi-cmd-break.c (breakpoint_notify): Pass uiout to + gdb_breakpoint_query. + +2001-08-17 Keith Seitz + + * mi-cmd-var.c (varobj_update_one): Update call to + varobj_update to reflect recent api change. + +2001-07-26 Andrew Cagney + + * mi-main.c: Include "gdb.h". + * mi-cmd-break.c: Include "gdb.h". + +2001-07-12 Andrew Cagney + + * mi-main.c (mi_execute_command): Flush output after ``(gdb)'' + prompt. Bug reported by David Whedon. + (mi_execute_async_cli_command): Ditto. + (mi_exec_async_cli_cmd_continuation): Ditto. + (mi_command_loop): Ditto. + +2001-07-10 Mark Kettenis + + * mi-out.c (mi_out_new): Initialize suppress_ouput field of newly + created `struct ui_out_data'. + +2001-07-09 Kevin Buettner + + * mi-main.c (register_changed_p, get_register): Use alloca() + to allocate space previously allocated via gcc's + variable-length array extension. + (mi_cmd_data_write_register_values, mi_cmd_data_write_memory): + Change type of ``buffer'' to ``void *''. Don't cast return value + from xmalloc(). Add a cleanup to free the xmalloc'd buffer. + +2001-07-07 Andrew Cagney + + * mi-main.c (mi_cmd_data_evaluate_expression): Replace value_ptr + with `struct value *'. + +2001-07-08 Kevin Buettner + + * mi-out.c (mi_table_header, mi_field_int, mi_field_skip) + (mi_field_string) Make function declarators match earlier + declarations. + +2001-07-04 Andrew Cagney + + * mi-out.c (mi_ui_out_impl): Initialize is_mi_like_p to one. + +2001-06-27 Andrew Cagney + + * mi-out.c (mi_table_begin): Include nr_cols and nr_rows in mi1 + table output. + * mi-out.c (mi_table_begin): Only suppress output when mi0. Change + the header to a list. + (mi_table_body): For mi1, close the header list and open a table + body list. + (mi_table_end): For mi1, close the body list. + (mi_table_header): For mi1, output a tuple containing all the + header information. + (mi_open, mi_close): Reverse logic of mi_version test. + * gdbmi.texinfo (GDB/MI Breakpoint Table Commands): Update. + +2001-06-26 Andrew Cagney + + * gdbmi.texinfo (GDB/MI Output Syntax): Delete reference to query + packet. + +2001-06-26 Andrew Cagney + + * mi-cmd-stack.c (list_args_or_locals): Output a list of "args" or + "locals" entries. + * gdbmi.texinfo (stack-list-locals, stack-list-arguments) + (exec-interrupt, target-select, thread-select): Update + documentation. + +2001-06-26 Andrew Cagney + + * mi-cmd-stack.c (mi_cmd_stack_list_frames): Output a list of + "stack" entries. + (mi_cmd_stack_list_args): Ditto for "stack-args". + * gdbmi.texinfo (stack-list-frames, stack-list-arguments): Update + documentation. + (GDB/MI Stack Manipulation Commands): Fix section title. Was + Stack Manipulation Commands in GDB/MI. + +2001-06-25 Andrew Cagney + + * gdbmi.texinfo: Update output examples that contain stop reason + output, change the args=.... to a list. + (exec-return): Ditto. + +2001-06-25 Andrew Cagney + + * mi-main.c (mi_cmd_data_read_memory): Output the memory contents + - memory and data - as a list. + * gdbmi.texinfo (data-read-memory): Update documentation. + +2001-06-25 Andrew Cagney + + * mi-main.c (mi_cmd_data_list_register_values): Output a list of + register values. + * gdbmi.texinfo (data-list-register-values): Update documentation. + +2001-06-25 Andrew Cagney + + * mi-main.c (mi_cmd_data_list_register_names): Output a list of + register names. + (mi_cmd_data_list_register_names): Include the pseudo registers. + (mi_cmd_data_list_register_names): Don't leave holes in the list, + output "" for NULL registers. + * gdbmi.texinfo (data-list-register-names): Update documentation. + +2001-06-23 Andrew Cagney + + * mi-main.c (mi_cmd_data_list_changed_registers): Output a list of + register numbers. + * gdbmi.texinfo (data-list-changed-registers): Update + documentation. + +2001-06-23 Andrew Cagney + + * gdbmi.texinfo (data-disassemble): Update documentation of + output. Produces a list of instructions and a list of source + lines. + +2001-06-22 Andrew Cagney + + * mi-cmd-disas.c (mi_cmd_disassemble): For "-data-disassemble", + output a list instead of a tupple. + +2001-06-21 Andrew Cagney + + * mi-out.c (struct ui_out_data): Replace field first_header with + suppress_output. + (mi_begin, mi_end): Check suppress_header. + (mi_field_int, mi_field_skip): Ditto. + (mi_field_string, mi_field_fmt): Ditto. + (mi_table_begin): When nr_rows is zero, set suppress_header else, + output the start of the header. + (mi_table_body): Clear suppress header. + +2001-06-21 Andrew Cagney + + * mi-out.c (mi_open): For lists, when mi_version > 0, use ``[''. + (mi_close): Ditto for ``]''. + +2001-06-20 Andrew Cagney + + * mi-out.c (mi_table_header): Add parameter ``col_name''. + +2001-06-18 Andrew Cagney + + * mi-out.c: Include "gdb_assert.h". + (mi_table_begin): Add parameter ``nr_rows''. + +2001-06-18 Andrew Cagney + + * mi-main.c: Use strncmp as the "mi" test. Allow "mi", "mi0" and + "mi1". + (mi_command_loop): Add parameter mi_version, pass to mi_out_new. + (mi1_command_loop, mi0_command_loop): New functions. + (_initialize_mi_main): Recognize "mi", "mi0" and "mi1". + * mi-out.c (mi_out_new): Add parameter mi_version. + (struct ui_out_data): Add field mi_version. + * mi-out.h (mi_out_new): Update. + +2001-06-07 Andrew Cagney + + * gdbmi.texinfo (GDB/MI Output Syntax): Add tuples and lists to + syntax. + (GDB/MI Draft Changes to Output Syntax): Delete section. + +Mon Jun 11 17:22:25 2001 Andrew Cagney + + * mi-out.c: Fix typo. s/supress/suppress/. + +2001-06-09 Andrew Cagney + + * mi-out.c (mi_table_end, mi_table_begin, mi_begin, mi_end): Move + supress_field_separator updates from here. + (mi_open, mi_close): To here. + (mi_open): Add parameter name. Output a field_separator. + (mi_table_begin): Update. + (mi_table_header): Update. + (mi_begin): Update. + +2001-06-09 Andrew Cagney + + * mi-out.c (mi_table_begin): Make char* parameters constant. + (mi_table_header): Ditto. + (mi_field_int): Ditto. + (mi_field_skip): Ditto. + (mi_field_string): Ditto. + (mi_field_fmt): Ditto. + (mi_text): Ditto. + (mi_message): Ditto. + +2001-05-12 Andrew Cagney + + * mi-out.c (mi_close, mi_open): Output ``[]'' when a list. + +Fri May 11 13:55:07 2001 Andrew Cagney + + * mi-cmd-var.c: Replace ui_out_list_begin, ui_out_list_end and + make_cleanup_ui_out_list_end with ui_out_tupple_begin, + ui_out_tupple_end and make_cleanup_ui_out_tupple_begin_end. + * mi-cmd-stack.c: Ditto. + * mi-cmd-disas.c: Ditto. + * mi-main.c: Ditto. + +2001-05-10 Andrew Cagney + + * mi-out.c (mi_open, mi_close): Replace list_open and list_close. + (mi_table_begin): Update. + (mi_table_header): Update. + (mi_begin): Update. + (mi_table_body): Update. + (mi_table_end): Update. + (mi_end): Update. + +Thu May 10 16:28:13 2001 Andrew Cagney + + * mi-main.c (mi_execute_async_cli_command): Always initialize + old_cleanups. + +2001-05-08 Andrew Cagney + + * mi-out.c (mi_begin, mi_end): Replace mi_list_begin and + mi_list_end. + (mi_ui_out_impl): Update. + +2001-03-28 Andrew Cagney + + * mi-main.c (mi_cmd_data_read_memory): Use xcalloc. + +2001-03-26 Eli Zaretskii + + * gdbmi.texinfo: Update copyright. Change Permissions to GFDL. + +2001-03-20 Andrew Cagney + + * mi-cmd-disas.c (mi_cmd_disassemble): Initialize ``file_string'' + and ``line_num''. Consolidate declaration of argument variables. + +2001-03-19 Andrew Cagney + + * mi-out.h: Remove #ifdef __STDC__. + +2001-03-08 Andrew Cagney + + * mi-main.c (mi_cmd_data_list_register_names): Use NUM_REGS, not + ARCH_NUM_REGS. + (mi_cmd_data_list_changed_registers): Ditto. + (mi_cmd_data_list_register_values): Ditto. + (mi_cmd_data_write_register_values): Ditto. + +2001-03-06 Kevin Buettner + + * gdbmi.texinfo, mi-cmd-disas.c, mi-cmd-stack.c, mi-cmd-var.c, + mi-cmds.c, mi-cmds.h, mi-console.c, mi-console.h, mi-getopt.c, + mi-getopt.h, mi-out.c, mi-out.h, mi-parse.c, mi-parse.h: + Update/correct copyright notices. + +Wed Feb 7 19:50:37 2001 Andrew Cagney + + * mi-getopt.c: Add __FILE__ and __LINE__ parameter to calls to + internal_error. + * mi-console.c: Ditto. + * mi-cmds.c: Ditto. + * mi-cmd-break.c: Ditto. + +2001-01-27 Fernando Nasser + + From Momchil Velikov + * mi-cmd-disas.c (gdb_dis_asm_read_memory): Add missing memory + attributes argument in the call to `xfer_memory'. + +2000-12-14 Kevin Buettner + + * mi-cmd-disas.c, mi-cmd-var.c, mi-console.c, mi-main.c, + mi-parse.c: Replace occurrences of free() with xfree(). + +Fri Nov 17 16:07:23 2000 Andrew Cagney + + * mi-main.c: Replace asprintf with xasprintf. + * mi-cmd-var.c (mi_cmd_var_create): Ditto. + +2000-10-16 Eli Zaretskii + + * gdbmi.texinfo (GDB/MI Variable Objects): Dimensions of + multitable changed to "@columnfractions .4 .6". Suggested by + Dmitry Sivachenko . + +2000-08-23 Eli Zaretskii + + * gdbmi.texinfo: Change flathead -> @sc{gdb/mi}. + Fix typos and markup mistakes (from Dmitry S. + Sivachenko ). + +2000-07-24 Eli Zaretskii + + * gdbmi.texinfo: Change GDB -> @value{GDBN}, and + (gdb) -> (@value{GDBP}). Fix a few typos and some markup. From + Dmitry S. Sivachenko . + +Tue May 16 14:13:41 2000 Andrew Cagney + + * mi-main.c (mi_cmd_execute): Use free_current_contents. + (free_and_reset): Delete. + +Mon May 15 16:17:56 2000 Andrew Cagney + + * mi-main.c (mi_cmd_data_assign, mi_cmd_data_evaluate_expression), + mi-cmd-var.c (mi_cmd_var_create, mi_cmd_var_delete): Delete + make_cleanup_func casts. Not needed. + +2000-05-07 Eli Zaretskii + + * gdbmi.texinfo: Lots of typos and grammar fixes from Brian + Youmans <3diff@flib.gnu.ai.mit.edu>. + +Wed Apr 26 18:35:19 2000 Andrew Cagney + + * gdbmi.texinfo (GDB/MI Output Syntax v2.0): Convert Draft 2.0 + Output Syntax into a new section. Cross reference. + (menu): Fix tipo. GDB/MI Compatibility with CLI. + +2000-04-23 Eli Zaretskii + + * gdbmi.texinfo: Lots of changes, to include this document as part + of the GDB manual. + +2000-03-13 James Ingham + + * mi-cmd-var.c (mi_cmd_var_create): Add special frame cookie "@" + to indicate an "USE_CURRENT_FRAME" variable. + (varobj_update_one): Add "in_scope" and "type_changed" to the + result. + +2000-03-06 Elena Zannoni + + * mi-cmds.h: Export mi_cmd_data_write_register_values. + + * mi-cmds.c (mi_cmds): Implement data-write-register-values with + mi_cmd_data_write_register_values. + + * mi-main.c (mi_cmd_data_write_register_values): New + function. Write a value into a register. + +2000-03-06 Elena Zannoni + + * gdbmi.texinfo: Update data-disassemble documentation. + +2000-03-01 Elena Zannoni + + * mi-cmd-disas.c (mi_cmd_disassemble): Use + ui_out_field_core_addr() instead of print_address_numeric(), to + maintain consistency throughout MI. + +Wed Feb 23 17:09:39 2000 Andrew Cagney + + * mi-cmd-break.c, mi-cmd-disas.c, mi-cmd-stack.c, mi-cmd-var.c, + mi-cmds.c, mi-cmds.h, mi-console.c, mi-console.h, mi-getopt.c, + mi-getopt.h, mi-main.c, mi-out.c, mi-out.h, mi-parse.c, + mi-parse.h: Update copyright information. + +Wed Feb 23 13:31:16 2000 Andrew Cagney + + * mi-cmd-disas.c (gdb_dis_asm_read_memory): Change LEN to unsigned + long. Match ../include/dis-asm.h change. + +Wed Feb 23 10:30:55 2000 Andrew Cagney + + * gdbmi.texinfo: Update copyright - FSF. Update version + information. + + mi-cmd-break.c, mi-cmd-disas.c, mi-cmd-stack.c, mi-cmd-var.c, + mi-cmds.h, mi-main.c, mi-parse.c, mi-parse.h: Re-format using GNU + indent. + +2000-02-21 Elena Zannoni + + * mi-main.c: Add include of gdbcore.h for write_memory() + prototype. + +2000-02-18 Elena Zannoni + + * mi-cmd-disas.c (mi_cmd_disassemble): Change syntax of + command. Now use options. + Instead of printing the symbolic address of instructions via + print_address_symbolic(), use build_address_symbolic() and format + properly for output. + (gdb_do_disassmble): Delete. + +2000-02-18 Elena Zannoni + + * mi-cmd-disas.c (mi_cmd_disassemble): + +2000-02-17 Elena Zannoni + + * mi-main.c (mi_cmd_data_write_memory): New function. Write a + value into target memory. + + * mi-cmds.h (mi_cmd_data_write_memory): Export. + + * mi-cmds.c (mi_cmds): Hook up data-write-memory to + mi_cmd_data_write_memory(). + +2000-02-17 Elena Zannoni + + * mi-main.c (mi_cmd_target_download): Correct error message to + report right function name. + (mi_cmd_target_select): Add doing exec cleanups at end. + (mi_cmd_data_read_memory): Correct typo. + (mi_cmd_execute): Do not simply free last_async_command, but reset + it to NULL as well. + (free_and_reset): New function, free the argument and set it to + NULL. + (mi_cmd_target_select_continuation): Delete prototype. + +Tue Feb 1 00:17:12 2000 Andrew Cagney + + * mi-cmd-disas.c, mi-cmds.h, mi-console.c, mi-console.h, + mi-main.c, mi-out.c, mi-out.h: Update to reflect rename of + gdb-file / GDB_FILE to ui-file / ``struct ui_file''. + +Mon Jan 31 18:33:28 2000 Andrew Cagney + + * mi-main.c (mi_command_loop): Delete reference to + fputs_unfiltered_hook. + +2000-01-27 Elena Zannoni + + * mi-cmds.c (mi_cmds): Update entries for + mi_cmd_data_list_register_names, + mi_cmd_data_list_changed_registers, + mi_cmd_data_list_register_values. + + * mi-cmds.h (mi_cmd_data_list_register_names, + mi_cmd_data_list_changed_registers, + mi_cmd_data_list_register_values): Update to mi_cmd_argv_ftype. + + * mi-main.c (mi_cmd_data_list_register_names, + mi_cmd_data_list_changed_registers, + mi_cmd_data_list_register_values): Update to use argc, argv + parameters. + +2000-01-27 Elena Zannoni + + * mi-main.c (mi_cmd_data_read_memory): Correct the computation of + next-row. + +2000-01-27 Fernando Nasser + + * mi-cmd-var.c (mi_cmd_var_create): Test for NULL type. + (mi_cmd_var_set_format, mi_cmd_var_show_format, + mi_cmd_var_info_num_children, mi_cmd_var_list_children, + mi_cmd_var_info_type, mi_cmd_var_info_expression, + mi_cmd_var_show_attributes, mi_cmd_var_evaluate_expression, + mi_cmd_var_assign, mi_cmd_var_update): Prevent possibility of memory + leak on error. + +2000-01-27 Fernando Nasser + + * mi-out.c (mi_field_string): Test for NULL string pointer. + +2000-01-17 Elena Zannoni + + * mi-cmd-stack.c (mi_cmd_stack_list_frames): Call + print_frmae_info() with the correct arguments. + + * mi-main.c (mi_cmd_exec_return): Call + show_and_print_stack_frame() with LOC_AND_ADDRESS, so it does the + right thing. Update Copyright. + +2000-01-13 Elena Zannoni + + * mi-main.c: Move disassemble commands from here. + + * mi-cmd-disas.c: To here. New file. + +2000-01-13 Elena Zannoni + + * mi-cmd-stack.c: Remove include of mi-out.h. + + * mi-main.c (mi_cmd_disassemble): Update function to use argc/argv + interface. + + * mi-cmds.h: Ditto. + + * mi-cmds.c: Ditto. + +2000-01-12 Elena Zannoni + + * gdbmi.texinfo: Update stack commands descriptions. + Add thread commands descriptions and examples. + + * mi-main.c (mi_cmd_thread_list_ids): Fix typo. + +2000-01-12 Elena Zannoni + + * mi-main.c (mi_cmd_thread_list_ids): New function, print a list + of currently known threads ids, and the total number of threads. + (mi_cmd_thread_select): New function. Switch current thread. + + * mi-cmds.c (mi_cmds): Implement thread-list-ids by + mi_cmd_thread_list_ids, and thread-select by mi_cmd_thread_select. + + * mi-cmds.h (mi_cmd_thread_select, mi_cmd_thread_list_ids): Export. + +2000-01-11 Elena Zannoni + + * mi-main.c: Move stack commands from here. + + * mi-cmd-stack.c: To here. New file. + +2000-01-07 Elena Zannoni + + * mi-main.c (list_args_or_locals): Add a new paramter, the frame + for which to display args or locals. Don't use selected_frame + anymore, use the new parameter instead. Return void instead of + mi_cmd_result, let callers do so. + (mi_cmd_stack_list_args): Change interface. Now accept low and + high frame numbers to display args for a range of frames. Without + these two, display args for the whole stack. + (mi_cmd_stack_list_locals): Adapt to new interface for + list_args_or_locals. + +2000-01-06 Elena Zannoni + + * mi-main.c (mi_cmd_stack_info_depth, mi_cmd_stack_list_args, + mi_cmd_stack_list_frames, mi_cmd_stack_list_locals, + mi_cmd_stack_select_frame): Change to use argv type of parameters. + + * mi-cmds.c (mi_cmds): Change stack-info-depth, + stack-list-arguments, stack-list-frames, stack-list-locals, + stack-select-frame to use argv parameters. + + * mi-cmds.h (mi_cmd_stack_info_depth, mi_cmd_stack_list_args, + mi_cmd_stack_list_frames, mi_cmd_stack_list_locals, + mi_cmd_stack_select_frame): Update definitions. + +Tue Jan 4 12:38:54 2000 Andrew Cagney + + * mi-main.c (mi_command_loop): Force the MI interface to use seven + bit strings. + * gdbmi.texinfo: Make it clear that a quoted C string is seven + bit. + +Thu Dec 30 14:15:22 1999 Andrew Cagney + + * mi-getopt.c (mi_getopt): Rewrite. Allow long options. + * mi-getopt.h (struct mi_opt): Declare. + (mi_getopt): Update. + + * mi-main.c (mi_cmd_data_read_memory), mi-cmd-break.c + (mi_cmd_break_insert, mi_cmd_break_watch): Update. + +Wed Dec 29 23:38:35 1999 Andrew Cagney + + * mi-cmd-break.c (mi_cmd_break_insert): Add support for -c + , -i and -p . + (breakpoint_notify): New function. + (mi_cmd_break_insert): Wrap GDB call with callback hooks so that + MI is notified when ever a breakpoint is created. + + * gdbmi.texinfo: Update. + +Fri Dec 24 11:23:22 1999 Andrew Cagney + + * mi-main.c (gdb_do_disassemble): Strip out more useless #ifdef + UI_OUTs. + +1999-12-23 Elena Zannoni + + * mi-main.c (gdb_do_disassemble): Fix output. Lines that have no + assembly instructions must still be outputted, to keep the source + line numbering correct. + Remove #ifdef UI_OUT's, they are useless. + +1999-12-17 Elena Zannoni + + * mi-main.c (gdb_do_disassemble): Don't print a new list in mixed + mode, every time. Just do it when we actually encounter a new + source line. + +1999-12-17 Fernando Nasser + + * mi-cmd-var.c (mi_cmd_var_list_children): Add test for C++ pseudo + variable objects (private, public, protected) as these do not have + a type and the -var-list-children operation was dumping core. + +Fri Dec 17 20:23:33 1999 Andrew Cagney + + * gdbmi.texinfo: Document recommended syntax for options. + + * mi-main.c (mi_cmd_data_read_memory): Add support for ``-o + ''. + * gdbmi.texinfo: Document. + +Wed Dec 15 17:43:08 1999 Andrew Cagney + + * mi-getopt.h (mi_getopt): Change optarg to a char pointer. Check + optind. + * mi-cmd-break.c (mi_cmd_break_insert): Update. + + * mi-main.c (mi_cmd_data_read_memory): Add fields "next-row-addr", + "prev-row-addr", "next-page-addr", "prev-page-addr" and a per row + "addr". + * gdbmi.texinfo: Update. + +Wed Dec 15 01:05:40 1999 Andrew Cagney + + * mi-cmds.h (mi_cmd_result): Add MI_CMD_CAUGHT_ERROR for when the + error is caught. + + * mi-main.c (captured_mi_execute_command): When + MI_CMD_CAUGHT_ERROR return 0 rethrowing the eror. + +1999-12-13 Elena Zannoni + + * mi-cmd-break.c (mi_cmd_break_insert): Remove unused var. + + * mi-cmd-var.c (mi_cmd_var_update): Remove unused variables. + +Mon Dec 13 18:43:36 1999 Andrew Cagney + + * mi-parse.c (mi_parse): Quote the command when printing it. + (mi_parse_argv): Fix handling of quoted strings. Was not + de-quoting them. + (mi_parse_argv): Make static. + +Mon Dec 13 18:30:03 1999 Andrew Cagney + + * mi-cmds.h (mi_cmd_break_insert, mi_cmd_break_watch): Change type + to mi_cmd_argv_ftype. + * mi-cmds.c (mi_cmds): Update. + * mi-cmd-break.c (mi_cmd_break_insert, mi_cmd_break_watch): Change + to new style of arguments with argc and argv. Parse arguments + using mi_getopt. + + * mi-cmd-break.c (mi_cmd_break_insert): Wrap body in #ifdef UI_OUT + to avoid non-ui compile problems. + +Mon Dec 13 15:08:36 1999 Andrew Cagney + + * mi-getopt.h, mi-getopt.c: New files. Similar to getopt but with + well defined semantics. + +Mon Dec 13 14:22:21 1999 Andrew Cagney + + * mi-main.c (mi_cmd_break_insert, mi_cmd_break_watch, enum + wp_type, enum bp_type): Move from here. + * mi-cmd-break.c: To here. New file. + (mi_cmd_break_insert, mi_cmd_break_insert, mi_cmd_break_watch): + Use error to report problems. + +1999-12-09 Elena Zannoni + + * gdbmi.texinfo: Update description of exec-interrupt. + + * mi-main.c (mi_cmd_exec_interrupt): If the program is not + executing, don't try to interrupt it, but error out instead. Make + sure previous_async_command is not null before duplicating it into + last_async_command. + + * gdbmi.texinfo: Add examples for data-evaluate-expression. + +1999-12-08 Elena Zannoni + + * mi-cmd-var.c (mi_cmd_var_assign, mi_cmd_var_create, + mi_cmd_var_delete, mi_cmd_var_evaluate_expression, + mi_cmd_var_info_expression, mi_cmd_var_info_num_children, + mi_cmd_var_info_type, mi_cmd_var_list_children, + mi_cmd_var_set_format, mi_cmd_var_show_attributes, + mi_cmd_var_show_format, mi_cmd_var_update): Change to use new + style of arguments with argc and argv. + (next_arg): Delete. + (which_var): Delete. + + * mi-cmds.c (mi_cmds): Update entries for mi_cmd_var_assign, + mi_cmd_var_create, mi_cmd_var_delete, + mi_cmd_var_evaluate_expression, mi_cmd_var_info_expression, + mi_cmd_var_info_num_children, mi_cmd_var_info_type, + mi_cmd_var_list_children, mi_cmd_var_set_format, + mi_cmd_var_show_attributes, mi_cmd_var_show_format, + mi_cmd_var_update. + + * mi-cmds.h (mi_cmd_var_assign, mi_cmd_var_create, + mi_cmd_var_delete, mi_cmd_var_evaluate_expression, + mi_cmd_var_info_expression, mi_cmd_var_info_num_children, + mi_cmd_var_info_type, mi_cmd_var_list_children, + mi_cmd_var_set_format, mi_cmd_var_show_attributes, + mi_cmd_var_show_format, mi_cmd_var_update): Update declarations. + +1999-12-08 Elena Zannoni + + * gdbmi.texinfo: Comment out -data-assign command. * mi-main.c + (mi_cmd_data_assign): Do not use, comment out. * mi-cmds.h + (mi_cmd_data_assign): Remove. * mi-cmds.c: Remove -data-assign + command from MI interface. + +1999-12-07 Elena Zannoni + + * mi-parse.c (mi_parse): Add '\n' at end of error messages, so + that prompt comes out on new line. + + * gdbmi.texinfo: Update disassembly command output. + +1999-12-06 Elena Zannoni + + * mi-main.c (gdb_do_disassemble): Update output for UI_OUT case. + +1999-12-02 Elena Zannoni + + * gdbmi.texinfo: Update exec-until output, including the reason + for stopping. + +Thu Dec 2 17:17:22 1999 Andrew Cagney + + * mi-cmds.c: Include for memset. + +1999-12-01 Elena Zannoni + + * mi-main.c (mi_cmd_exec_return): ifdef the references to + return_command_wrapper(). + +1999-12-01 Elena Zannoni + + * mi-main.c (mi_cmd_gdb_exit, mi_cmd_exec_interrupt, + mi_cmd_target_select, mi_execute_async_cli_command, + mi_exec_async_cli_cmd_continuation, mi_load_progress): Don't print + last_async_command if it is NULL. + (mi_cmd_exec_return): + +1999-12-01 Elena Zannoni + + * mi-main.c (mi_cmd_exec_return): Reimplement using + return_command() instead of mi_execute_async_cli_command(). + +1999-12-01 Elena Zannoni + + * mi-cmds.h: Export mi_cmd_data_assign and + mi_cmd_data_evaluate_expression. + + * mi-cmds.c (mi_cmds): Hook data-assign to mi_cmd_data_assign and + data-evaluate-expression to mi_cmd_data_evaluate_expression. + + * mi-main.c (mi_cmd_data_assign): New function. Implement + data-assign command. + (mi_cmd_data_evaluate_expression): New function. Implement + data-evaluate-expression command. + +1999-12-01 Elena Zannoni + + * gdbmi.texinfo: Fix some texinfo formatting errors. + +1999-12-01 Elena Zannoni + + * gdbmi.texinfo: Update data-list-register-values description. + + * mi-cmds.h: Export mi_cmd_data_list_register_values. + + * mi-cmds.c (mi_cmds): Hook data-list-register-values to + mi_cmd_data_list_register_values. + + * mi-main.c (mi_cmd_data_list_register_values): New + function. Implements the -data-list-register-values command. + (get_register): New function. Output the contents of a given + register. + +Wed Dec 1 20:27:22 1999 Andrew Cagney + + * mi-main.c (mi_execute_async_cli_command): Append missing "\n" + for synchronous stopped message. + +1999-11-30 James Ingham + + * gdbmi.texinfo: Fix obvious typo in @end statement. + +Wed Dec 1 12:36:27 1999 Andrew Cagney + + * mi-cmd-var.c: Include "value.h". + * mi-console.c: Include . + +Wed Dec 1 00:21:03 1999 Andrew Cagney + + * mi-main.c (captured_mi_execute_command): For a CLI command, pass + "%s" to mi_execute_cli_command to stop core dumps. + (captured_mi_execute_command): Echo CLI commands on gdb_stdlog. + +Wed Dec 1 00:10:07 1999 Andrew Cagney + + * gdbmi.texinfo: Explain NR-BYTES and ADDR. + +Tue Nov 30 23:31:57 1999 Andrew Cagney + + * mi-cmd-var.c (mi_cmd_var_create, mi_cmd_var_delete, + mi_cmd_var_set_format, mi_cmd_var_show_format, + mi_cmd_var_info_num_children, mi_cmd_var_list_children, + mi_cmd_var_info_type, mi_cmd_var_info_expression, + mi_cmd_var_show_attributes, mi_cmd_var_evaluate_expression, + mi_cmd_var_assign, mi_cmd_var_update, varobj_update_one, next_arg, + which_var): New file. Move varobj commands to here from + mi-main.c. + + * mi-console.h, mi-console.c (mi_console_file_new, + mi_console_file_delete, mi_console_file_fputs, + mi_console_raw_packet, mi_console_file_flush): New files. Move + mi_console_file to here from mi-main.c. + +Tue Nov 30 19:37:25 1999 Andrew Cagney + + * mi-main.c (captured_mi_execute_command): Use fputstr_unfiltered + when printing error messages. + (mi_cmd_execute): Ditto. + +1999-11-29 Elena Zannoni + + * gdbmi.texinfo: Describe -data-list-changed-registers, + -data-list-register-names. Add examples for + -exec-next-instruction, exec-step-instruction, -exec-run, + -exec-until. Format examples for -data-read-memory. + update example for -target-download. + +1999-11-29 Elena Zannoni + + * gdbmi.texinfo: Remove mentioning of inaccurate watchpoint hit + count. + +Mon Nov 29 19:28:55 1999 Andrew Cagney + + * mi-main.c (mi_execute_async_cli_command): Return ``enum + mi_cmd_cmd_result''. mi_cmd_exec_run, mi_cmd_exec_next, + mi_cmd_exec_step, mi_cmd_exec_step_instruction, + mi_cmd_exec_finish, mi_cmd_exec_until, mi_cmd_exec_return, + mi_cmd_exec_continue): Update call. + (mi_execute_async_cli_command): When target is synchronous, fake + asynchronous behavour (ulgh). Allows tests to be run on built-in + simulator and native targets. + +Mon Nov 29 15:15:16 1999 Andrew Cagney + + * mi-cmds.h (mi_cmd_gdb_exit), mi-cmds.c (mi_cmds), mi-main.c + (mi_cmd_gdb_exit): Change function signature to mi_cmd_argv_ftype. + +1999-11-28 Andew Cagney + + * mi-parse.c: Include and + +1999-11-26 Elena Zannoni + + * gdbmi.texinfo: Added watchpoint command descriptions and + examples. + + * mi-main.c (mi_load_progress): Add parameter for total sent so far. + Print it as well. + +Fri Nov 26 10:17:49 1999 Andrew Cagney + + * gdbmi.texinfo (section Output Syntax): For lists, the + part of a is optional. Clarify syntax. + (appendix Proposed v2.0 Output Syntax): New section. Provide + record of discussion of possible changes to syntax. + +Wed Nov 24 19:41:35 1999 Andrew Cagney + + * mi-main.c (mi_cmd_data_read_memory): Simplify. Fix coredump + when arguments were bad. + (mi_cmd_execute): Change parameter to ``struct mi_parse''. Handle + case of argv_func as well as args_func. + (captured_mi_execute_command): Update. + + * mi-cmds.c (struct mi_cmd): Add field for mi_cmd_argv_ftype. + (mi_cmds): Update mi_cmd_data_read_memory. + (mi_lookup): Return + + * mi-cmds.h (mi_cmd_args_ftype): Rename mi_cmd_ftype. Make all + functions of type this type. + (mi_cmd_argv_ftype): Declare. + (mi_cmd_data_read_memory): Change type to mi_cmd_argv_fytpe. + (struct mi_cmd): Move declaration to here from mi-cmds.c. + (mi_lookup): Return a pointer to ``struct mi_cmd''. + +Wed Nov 24 15:03:34 1999 Andrew Cagney + + * mi-parse.c (mi_parse): Initialize TOKEN when a CLI command. + + * gdbmi.texinfo: Allow a before a CLI command. + + * mi-parse.h (struct mi_parse): Declare. + (mi_parse): Change to return a ``struct mi_parse''. + (enum mi_command_type): Delete PARSE_ERROR. + + * mi-main.c (struct mi_execute_command_context): Delete. + (captured_mi_execute_command): Update + (mi_execute_command): Update. Check for mi_parse returning NULL. + +Wed Nov 24 12:57:14 1999 Andrew Cagney + + * mi-parse.h: Remove const, from cmd parameter. Causes cascading + warnings. + +Wed Nov 24 15:03:34 1999 Andrew Cagney + + * mi-parse.c (mi_parse): New function. Move parse code to here. + * mi-main.c (parse): From here. Delete. + +Wed Nov 24 12:57:14 1999 Andrew Cagney + + * mi-parse.c, mi-parse.h: New files. Implement mi_parse_env. + +Wed Nov 24 11:24:05 1999 Andrew Cagney + + * mi-out.c (mi_field_string): Make string parameter constant. + +1999-11-23 Elena Zannoni + + * mi-cmds.h (mi_cmd_target_download): Export. + + * mi-cmds.c (mi_cmds): Add mi_cmd_target_download. + + * mi-main.c: Include . + (mi_cmd_target_download): New function, implement the + target-download command. + (mi_load_progress): New function. Called via the + show_load_progress hook. Prints updates every 0.5 secs. + (mi_command_loop): Initialize the show_load_progress hook. + +1999-11-22 Elena Zannoni + + * mi-main.c (mi_cmd_exec_until): New function. Implement until + command. + (mi_cmd_exec_step_instruction): New function. Implement stepi + command. + (mi_cmd_exec_next_instruction): New function. Implement nexti + command. + + * mi-cmds.c (mi_cmds): Add mi_cmd_exec_step_instruction, + mi_cmd_exec_next_instruction, mi_cmd_exec_until. + + * mi-cmds.h (mi_cmd_exec_step_instruction, + mi_cmd_exec_next_instruction, mi_cmd_exec_until): Export. + +Tue Nov 23 00:30:37 1999 Andrew Cagney + + * mi/gdbmi.texinfo: Document -data-read-memory. + + * mi-main.c (mi_cmd_data_read_memory): Fix off-by-one check of + argc. + (mi_cmd_data_read_memory): Label the output table with "memory". + +Thu Nov 18 18:15:53 1999 Andrew Cagney + + * mi-main.c (mi_cmd_exec_interrupt, mi_cmd_break_insert, + mi_cmd_break_watch, mi_cmd_disassemble, mi_cmd_execute): Replace + strdup with xstrdup. + +Thu Nov 18 20:50:09 1999 Andrew Cagney + + * mi-main.c (mi_cmd_data_read_memory): New function. Implement + data-read-memory. + + * mi-cmds.h, mi-cmds.c: Add mi_cmd_data_read_memory. + * mi-cmds.c (mi_cmds): Ditto. + +1999-11-11 Elena Zannoni + + * mi-cmds.h (mi_cmd_break_watch): Export. + + * mi-cmds.c (mi_cmds): Hook up break-watch to function + mi_cmd_break_watch. + + * mi-main.c (wp_type): New enumeration for the possible types of + watchpoints. + (mi_cmd_break_watch): New function, implements the break-watch + command. + +1999-11-11 Elena Zannoni + + * mi-main.c (mi_cmd_break_insert): Handle case in which the command is + just a -break-insert w/o args. + +Fri Nov 12 00:01:52 1999 Andrew Cagney + + * mi-out.c (mi_field_string): Always quote the string. + +1999-11-10 Elena Zannoni + + * mi-cmds.h(mi_cmd_data_list_changed_registers, + mi_cmd_data_list_register_names): Export. + + * mi-cmds.c (mi_cmds): Hook up data-list-changed-registers to + mi_cmd_data_list_changed_registers and data-list-register-names to + mi_cmd_data_list_register_names. + + * mi-main.c (mi_cmd_data_list_changed_registers): New function, + implements the data-list-changed-registers command. + (mi_cmd_data_list_register_names): New function, implements the + data-list-register-names command. + (register_changed_p): New function. Decide whether the register + contents have changed. + (setup_architecture_data): New function. Initialize registers + memory. + (_initialize_mi_main): Call setup_architecture_data(), and + register_gdbarch_swap(). + +Wed Nov 10 18:35:08 1999 Andrew Cagney + + * mi-main.c (mi_execute_command): Correctly quote error messages. + +Wed Nov 10 11:05:14 1999 Andrew Cagney + + * mi/gdbmi.texinfo: Delete . Replaced by + . + + * mi-main.c (mi_console_raw_packet): Always quote console output. + +Tue Nov 9 17:53:05 1999 Andrew Cagney + + * mi-main.c (mi_console_file_new), mi-out.c (mi_out_new): Replace + the tui_file with a mem_file. Ya! + + * mi-out.c (do_write): New function, wrapper to gdb_file_write. + (mi_out_put): Pass do_write to gdb_file_put. + + * mi-main.c (mi_console_file_flush): Rewrite. Use + mi_console_raw_packet to send data to the console. + (mi_console_raw_packet): New function. Correctly + create quoted C string packets. + +1999-11-08 Elena Zannoni + + * mi-cmds.c (mi_cmds): Break-insert is now implemented by + mi_cmd_break_insert. + * mi-cmds.h (mi_cmd_break_insert): Export. + * mi-main.c (bp_type): New enumeration. + (mi_cmd_break_insert): New function. Implements all flavors of + breakpoint insertion. + +Mon Nov 8 17:49:17 1999 Andrew Cagney + + * mi-main.c (mi_console_file_flush): Replace gdb_file_get_strbuf + with tui_file_get_strbuf. + +Fri Nov 5 17:06:07 1999 Andrew Cagney + + * mi-main.c (mi_console_file_delete, mi_console_file_fputs, + mi_console_file_flush): Call internal_error instead of error. + +Thu Nov 4 19:53:32 1999 Andrew Cagney + + * mi-main.c (captured_mi_execute_command): New function. + (mi_execute_command): Rewrite. Replace SET_TOP_LEVEL() with call + to captured_mi_execute_command via catch_errors. + +Thu Nov 4 20:33:58 1999 Andrew Cagney + + * mi-main.c (clean): Delete. + (mi_command_loop): Delete extern declaration of + mi_execute_command. + +1999-10-28 Elena Zannoni + + * mi-main.c (mi_cmd_stack_select_frame): Conditionalize the body + on UI_OUT, because select_frame_command_wrapper is only defined if + UI_OUT is. + (mi_cmd_exec_interrupt): Conditionalize the body on UI_OUT, + because interrupt_target_command_wrapper is only defined if UI_OUT is. + + * mi-cmds.c (mi_cmds): Implement command exec-interrupt by + mi_cmd_exec_interrupt. + + * mi-main.c (mi_cmd_exec_interrupt): New function. Implements + exec-interrupt command. + (mi_cmd_execute): If the target is running save execution command + token in previous_async_command. If the command is not 'interrupt' + and the target is running, reject it. + (clean): New function. Free the arg and reset it to NULL. + + * mi-cmds.h (mi_cmd_exec_interrupt):Export. + +1999-10-28 Elena Zannoni + + * mi-cmds.c (mi_cmds): Implement command stack-select-frame by + mi_cmd_stack_select_frame. + + * mi-main.c (mi_cmd_stack_select_frame): New function. Implements + stack-select-frame command. + + * mi-cmds.h (mi_cmd_select_frame):Export. + +1999-10-26 Elena Zannoni + + * mi-cmds.c (mi_cmds): Implement commands stack-list-locals and + stack-list-arguments by mi_cmd_stack_list_locals and + mi_cmd_stack_list_args. + + * mi-main.c (mi_cmd_stack_list_locals): New function. Implements + stack-list-locals command. + (mi_cmd_stack_list_args): New function. Implements + stack-list-arguments command. + (list_args_or_locals): New function. Do all the work for the + listing of locals or arguments. + + * mi-cmds.h (mi_cmd_stack_list_args,mi_cmd_stack_list_locals) : + Export. + +1999-10-25 Elena Zannoni + + * mi-cmds.c (mi_cmds): Add new command stack-info-depth. + + * mi-main.c (mi_cmd_stack_info_depth): New function. Implements + the stack-info-depth command. + * mi-cmds.h (mi_cmd_stack_info_depth): Export. + + +1999-10-22 Elena Zannoni + + * mi-main.c (mi_execute_command): Handle MI_CMD_ERROR case + properly, for command that return error code and don't set + mi_error_message. + + * mi-cmds.c (mi_cmds): Hook stack-list-frames command to + mi_cmd_stack_list_frames function. + * mi-cmds.h (mi_cmd_stack_list_frames): Export. + + * mi-main.c (mi_execute_command): Deal with a return code of + MI_CMD_ERROR from the execution of mi commands. + (mi_error_message): Static string variable, to contain the error + message from mi commands. + (mi_cmd_stack_list_frames): New function. Prints a backtrace. + +1999-10-18 Elena Zannoni + + * mi-main.c (mi_cmd_disassemble): Handle the new command line + parameter that specifies the number of disassembly lines to be + displayed. + (gdb_do_disassemble): Add new parameter. Count the number of lines + that have been displayed, and stop when limit is reached. + +Wed Oct 13 18:04:13 1999 Andrew Cagney + + * mi-main.c (mi_command_loop): Don't initialize ``flush_hook''. + +1999-10-13 Elena Zannoni + + * mi/gdbmi.texinfo: More reformatting of the grammars. + +1999-10-12 Elena Zannoni + + * mi/gdbmi.texinfo: More TeX formatting. + +1999-10-11 Elena Zannoni + + * mi/gdbmi.texinfo: First pass completed. All commands should have + some comments/info. + Escape '@' output special char. + Reformat for TeX. + +1999-10-08 Elena Zannoni + + * mi/gdbmi.texinfo: Filled in part of file command section, and + stack section. + +1999-10-07 Elena Zannoni + + * mi/gdbmi.texinfo: Filled in some sections about execution + commands. + +Tue Oct 5 15:27:28 1999 Andrew Cagney + + * mi-cmds.h: Sort table + * mi-cmds.c: Ditto. + (MI_TABLE_SIZE): Increase to 251. + +1999-10-04 Fernando Nasser + + * mi-main.c (mi_cmd_var_create, mi_cmd_var_delete): Add missing + cleanups. + +1999-10-04 Fernando Nasser + + * mi-main.c (next_arg): Returns lenght as well. + (which_var, mi_cmd_var_create, mi_cmd_var_delete, + mi_cmd_var_set_format, mi_cmd_var_update): Do not modify the input + string, use allocated storage instead. + (mi_cmd_var_assign): Adjust call to next_arg() to include new + argument. + +1999-10-04 Fernando Nasser + + * mi-main.c (mi_execute_command): Fix handling of errors. + +1999-10-04 Fernando Nasser + + * mi-out.c (mi_out_new): Call tui_sfileopen() instead of + deprecated gdb_file_init_astream(). + * mi-main.c (mi_console_file_new): Ditto. + +Mon Oct 4 15:17:29 1999 Andrew Cagney + + * mi-cmds.h: Sort function declarations. + (mi_lookup): Add extern. + + * mi-cmds.c (mi_lookup): Delete dead code. + (build_table): Call internal_error instead of error. + (build_table): Send trace output to gdb_stdlog. + +1999-10-01 Elena Zannoni + + * mi-main.c (mi_execute_async_cli_command): Don't do the cleanups + if target_executing is null. + +1999-09-28 Elena Zannoni + + * mi-main.c (async_p): Change var name to event_loop_p. + +Mon Sep 27 15:11:00 1999 Andrew Cagney + + * mi-main.c (mi_execute_async_cli_command, mi_execute_command): + Replace target_has_async with function target_can_async_p. + +Sun Sep 26 00:12:52 1999 Andrew Cagney + + * mi-main.c (mi_cmd_target_select_continuation): Delete function. + (mi_cmd_target_select): Simplify. target-connect is guarenteed to + be synchronous. + +Sun Sep 26 00:12:52 1999 Andrew Cagney + + * mi-cmds.h (mi_cmd_ftype): Replace mi_impl_ftype. + (enum mi_cmd_result): Define. + * mi-cmds.c (struct mi_cmd): Update. + (mi_lookup): Update. + * mi-main.c (mi_cmd_execute): Update. + + * mi-main.c (mi_cmd_gdb_exit, mi_cmd_exec_run, mi_cmd_exec_next, + mi_cmd_exec_step, mi_cmd_target_select, mi_cmd_exec_continue, + mi_cmd_exec_return, mi_cmd_exec_finish, mi_cmd_disassemble, + mi_cmd_var_create, mi_cmd_var_delete, mi_cmd_var_set_format, + mi_cmd_var_show_format, mi_cmd_var_info_num_children, + mi_cmd_var_list_children, mi_cmd_var_info_type, + mi_cmd_var_info_expression, mi_cmd_var_show_attributes, + mi_cmd_var_evaluate_expression, mi_cmd_var_update): Update. + Return MI_CMD_DONE. + +1999-09-22 Fernando Nasser + + * mi-main.c (mi_cmd_var_create): Use paddr() to format address + on trace output. + +1999-09-21 Fernando Nasser + + * mi-main.c (mi_cmd_var_create): Test for varobjdebug before + printing trace and send it to gdb_stdlog. + +Mon Sep 20 13:41:04 1999 Andrew Cagney + + * Makefile.in (mi-out.o): Add dependency list. + * mi-out.c: Include "mi-out.h". + +1999-09-18 Elena Zannoni + + * mi-main.c (_initialize_mi_main): Events on stadin are now + handled by stdin_event_handler. + +1999-09-17 Fernando Nasser + + * mi-cmds.c (mi_cmds): Add var-* commands. + +1999-09-17 Fernando Nasser + + * mi-main.c (mi_cmd_var_create, mi_cmd_var_delete, + mi_cmd_var_set_format, mi_cmd_var_show_format, + mi_cmd_var_info_num_children, mi_cmd_var_list_children, + mi_cmd_var_info_type, mi_cmd_var_info_expression, + mi_cmd_var_show_attributes, mi_cmd_var_evaluate_expression, + mi_cmd_var_assign, mi_cmd_var_update, varobj_update_one, + which_var, next_arg): New functions. Implement the -var-* + commands. + * mi-cmds.h: Add prototypes for the above. + +1999-09-14 Fernando Nasser + + * mi-cmds.c (mi_cmds): Add detach command. + +1999-09-09 Fernando Nasser + + * mi-cmds.c (lookup_table): Fix typo. + +1999-09-09 Fernando Nasser + + * mi-cmds.c (mi_cmds): Fix typo and missing command. + +1999-09-09 Fernando Nasser + + * mi-main.c: Properly align function prototypes. + (mi_cmd_target_select): Proper check for NULL value. + +1999-09-09 Fernando Nasser + + * mi-main.c (mi_execute_async_cli_command): Fix for native targets + that do not have async yet. + +1999-09-01 Elena Zannoni + + * mi-main.c (mi_cmd_disassemble): Remove unused var. + (gdb_do_disassemble): Ditto. + +1999-08-30 Elena Zannoni + + * mi-main.c: Replace all the occurrences of 'asynch' in variable + or function names with 'async' to make it consistent with the rest + of gdb. + +Mon Aug 30 18:16:39 1999 Andrew Cagney + + * mi-main.c: #include for isspace(). + +1999-08-27 Elena Zannoni + + * mi-main.c (gdb_do_disassemble): This function returns void, not + int. + +1999-08-26 Elena Zannoni + + * mi-main.c (mi_cmd_disassemble): Don't use atoi() on the high + address string, just treat it same as address low. + (gdb_do_disassemble): Parse high_address string before seeing if + it is zero. + +1999-08-25 Elena Zannoni + + * mi-main.c (mi_cmd_disassemble): New function to produce + disassembly output for mi. + (gdb_dis_asm_read_memory): New function. Read the disassembly from + the executable file, instead of target memory. + (compare_lines): New function. Compare order of disassembly lines. + (gdb_do_disassemble): New function. Do the real job of getting the + assembly code out. + + * mi-cmds.c (mi_cmds): Do data-disassemble mi command via the + mi_cmd_disassemble function. + + * mi-cmds.h: Export new function mi_cmd_disassemble. + +Wed Aug 25 15:58:31 1999 Andrew Cagney + + * mi-main.c (mi_command_loop): Remove references to ui-hooks. + +1999-08-21 Elena Zannoni + + * mi-main.c (mi_execute_asynch_cli_command): Fix the incorrect + usage of strcat(): allocate enough space for the string. + +1999-08-13 Elena Zannoni + + From Christopher Faylor + * mi-main.c (mi_execute_command): Make sure we flush all the + output after each command. + +1999-08-10 Elena Zannoni + + * mi-main.c (_initialize_mi_main): Remove casting in call to + add_file_handler. + +Sun Aug 8 17:20:57 1999 Andrew Cagney + + * mi-main.c (mi_cmd_target_select, mi_execute_asynch_cli_command): + Replace call to fatal with call to internal_error. + +1999-07-26 Fernando Nasser + + * mi-main.c (mi_cmd_execute): Add return code. + (mi_execute_command): Make appropriate changes when calling the + function mentioned above. + (mi_cmd_gdb_exit, mi_cmd_target_select, + mi_cmd_target_select_continuation, mi_execute_command, + mi_exec_asynch_cli_cmd, mi_exec_asynch_cli_cmd_continuation): + Print token, prefix, class and output (if any) in one single group + of statements. + (mi_execute_command, mi_cmd_execute): Fix error prefix. + (mi_cmd_execute): Use exec cleanup for token. + * mi-out.c (mi_out_rewind): New function. + * mi-out.h: Prototype for the above. + +1999-07-16 Fernando Nasser + + * mi-main.c (mi_cmd_gdb_exit): Use buffer for exit message. + (mi_cmd_execute): Route error messages to correct file. + (mi_execute_asynch_cli_command): Insert line feed after running + message. + +1999-07-16 Fernando Nasser + + * mi-out.h (mi_out_buffered): Add extern declaration. + * mi-out.c (mi_out_buffered): New function. Insert a string at the + current buffer position. + * mi-main.c (mi_cmd_target_select, mi_execute_command, + mi_cmd_execute, mi_execute_asynch_cli_command): Use the above + function instead of printing to raw_stdout. + (mi_cmd_target_select, mi_cmd_target_select_continuation, + mi_execute_command, mi_cmd_execute, mi_execute_cli_command, + mi_exec_asynch_cli_cmd_continuation): Fix handling of token and + prefix. + (mi_execute_cli_command): Remove parameter no longer needed. + +1999-07-15 Elena Zannoni + + * mi-main.c (mi_cmd_target_select_continuation): Print the numeric + token when we are connected. + (mi_execute_command): Don't print the token now, do it later. + (mi_execute_cli_command): Add a new parameter for the numeric + token. Print the token, the prefix and the class after the + command has executed, not before. + (mi_execute_asynch_cli_command): Don't print an extra blank line. + +1999-07-15 Fernando Nasser + + * mi-main.c (mi_gdb_exit): Add \n at the end. + +1999-07-15 Fernando Nasser + + * mi-main.c (mi_cmd_execute): New function. Dispatch a mi operation. + (mi_execute_command): Use the above. + +1999-07-15 Fernando Nasser + + * mi-main.c: Fix identation. + +1999-07-15 Elena Zannoni + + * mi-main.c: Include target.h and inferior.h. + (mi_cmd_target_select): New function to execute the target-select + mi operation. + (mi_cmd_target_select_continuation): New function. Continuation + for the target-select operation. + (mi_execute_command): In case of an MI command which requires + asynchronous execution, do not try to display the result now. If + the execution has to look synchronous don't display the "(gdb)" + prompt. + (mi_execute_asynch_cli_command): Invoke real asynchronous + commands, set up exec_cleanups, and continuations. + (mi_exec_asynch_cli_cmd_continuation): New function. Continuation + for all the MI execution commands except 'target-select'. + (mi_execute_command): Handle null commands by exiting gdb, instead + of core dumping. + + * mi-cmds.c (mi_cmds): Hook up -target-select operation to new mi + function. + + * mi-cmds.h (mi_cmd_target_select): Add extern declaration. + +Thu Jul 15 10:31:39 1999 Andrew Cagney + + * mi-main.c (struct mi_console_file): Add field ``prefix''. + (mi_console_file_new): Add argument prefix. Initialize prefix + field. + (mi_console_file_flush): Use ``prefix'' instead of "~" as the + prefix string. + (mi_command_loop): Update stream output prefixes. gdb_stdout == + "~", gdb_stderr / gdb_stdlog == "&", gdb_stdtarg == "@". + +1999-07-13 Fernando Nasser + + * mi-main.c (ui_out_data): New field first_header. Fix output when + no breakpoints are found. + (mi_table_begin, mi_table_body, mi_table_header): Test for + first_header. + (mi_table_end): Test for supress_field_separator. + (mi_message): Remove messages from MI output. + +1999-06-30 Fernando Nasser + + * mi-cmds.c (mi_cmds[]): Delete gdb-cli operation. + * mi-main.c (parse): Remove ifdefs for cli commands parsing. + (mi-execute-command): Ditto. + +Mon Jun 28 13:06:52 1999 Andrew Cagney + + * mi-out.h: New file. + (mi_out_new, mi_out_put): Move mi specific delcarations to here. + * ui-out.h: From here. + + * mi-main.c: Include "mi-out.h". + +1999-06-25 Fernando Nasser + + * top.c (print_gdb_version): Add the word HEADLESS when output + follows headless format. + (print_command_lines): Fix typo. + +1999-06-25 Elena Zannoni + + * event-loop.h: Export input_fd. + * mi-main.c (mi_command_loop): Use the event loop if running + asynchronously. + (mi_execute_command_wrapper): New function. + (_initialize_mi-main): Set things up for running asynchronously. + +1999-06-18 Fernando Nasser + + * mi-cmds.c (mi_lookup): Deleted. + (lookup_table): New function. Replaces old mi_lookup() for local + use. + (mi_lookup): New function. External interface for command table + searchs. + (build_table): New definition. + (mi_cmds[]): Add several command implementations and the gdb-cli + special operation. + (mi_cmd_execute): Deleted. + * mi-cmds.h: Add type definition for command implementation + function pointers, add declaration for new implementation + functions and a declaration for mi_lookup(). + * mi-main.c (mi_execute_asynch_cli_command): New + function. Captures code that was repeated for all asynch + operations. + (mi_cmd_exec_*): Use the above new function. + (mi_gdb_cmd_exit): Fix the output, printing something appropriate. + (mi_cmd_exec_finish): New operation implementation function. + (mi_cmd_exec_return): Ditto. + (parse): Prepare to remove cli commands. + (mi_execute_command): Fix the output and change the way mi-cmds is + used. + +1999-06-18 Fernando Nasser + + * mi-out.c (mi_table_begin): Add missing field separator call. + +Thu Jun 17 21:05:40 1999 Fernando Nasser + + * breakpoint.c (breakpoint_1): Remove space in breakpoint table + id. + (mention): Use ui_out for last new line (forgotten). + +1999-06-16 Fernando Nasser + + * mi-main.c (mi_console_file_flush): Prevent prefix printing when + buffer empty; change prefix to '~'. + (mi_cmd_exec_*): Prefix normal output with '^' instead of + ','; remove unwanted new lines before "stopped". + +1999-06-16 Fernando Nasser + + * mi-cmds.c (struct mi_cmds): Updated entries for -exec-continue + and exec-next operations. + (mi_cmd_execute): New text for error messages. + * mi-cmds.h: Add declaration for mi_cmd_exec_next and + mi_cmd_exec_continue. + * mi-main.c (mi_cmd_exec_next): New function. Implements exec-next + operation. + (mi_cmd_exec_continue): New function. Implements exec-continue + operation. + (mi_execute_comand): Add missing space to prompt. + (mi_cmd_exec_run): Ditto. + (mi_cmd_exec_step): Ditto. + * mi-out.c (mi_out_new): Add flags argument to ui_out_new call. + (ui_list_end): Reset supress_field_separator flag. + +Sat Jun 12 11:49:10 1999 Andrew Cagney + + * mi-cmds.h. mi-cmds.c (exec step): Command implemented by + mi_cmd_exec_step instead of cli call. + * mi-main.c (mi_cmd_exec_step): New function. + + * mi-cmds.h. mi-cmds.c (exec run): Command implemented by + mi_cmd_exec_run instead of cli call. + * mi-main.c (mi_cmd_exec_run): New function. + + * mi-cmds.h. mi-cmds.c (gdb exit): Command implemented by + mi_cmd_gdb_exit instead of quit_force. + * mi-main.c (mi_cmd_gdb_exit): New function. + +Sat Jun 12 11:33:23 1999 Andrew Cagney + + * mi-main.c (mi_command_loop): Pass mi_input to + simplified_command_loop. + (mi_input): New function. Calls gdb_readline with no prompt. + +Sat Jun 12 11:19:02 1999 Andrew Cagney + + * mi-main.c (mi_console_file_fputs): Re-implement. Use a buffer + to accumulate output. + + * mi-main.c (struct mi_console_file): Add a buffer. + (mi_console_file_new): Create a buffer. + (mi_console_file_flush): New function. + +Sat Jun 12 10:59:39 1999 Andrew Cagney + + * mi-cmds.h (raw_stdout): Declare. Will be moved later. + * mi-cmds.c (mi_cmd_execute): Send error messages to RAW stdout. + (mi_cmds): Sort by class. + + * mi-main.c (raw_stdout): Make global. + * mi-main.c: Remove #ifdef UI_OUT. File assumes UI_OUT is + present. + * mi-main.c: Include "gdb_string.h". + (mi_out_put): Delete declaration. + +1999-06-11 Fernando Nasser + + * mi-main.c: Add pre-processor test for UI_OUT. + (mi_execute_command): Add pre-processor test for UI_OUT. + +Fri Jun 11 23:11:41 1999 Andrew Cagney + + * mi-main.c (raw_stdout): New variable. + (mi_execute_command): Write mi-out direct to raw_stdout. + (mi_command_loop): Create raw_stdout. Attach gdb_stdout to the + console. + (mi_console_file_fputs, mi_console_file_delete, + mi_console_file_new): New functions. + (struct mi_console_file): Declare. + +Fri Jun 11 18:34:33 1999 Andrew Cagney + + * mi-main.c (mi_execute_command): Call mi_out_put to display the + result. + * mi-out.c (mi_out_put): New function. + * ui-out.h (mi_out_put): Add declare. Will move later. + * Makefile.in (mi-cmds.o, mi-main.o): Add dependency on ui-out.h. + + * mi-out.c (mi_field_string, mi_field_fmt, mi_message, mi_flush, + out_field_fmt, list_open, list_close): Replace gdb_stdout with + data->buffer. + (field_separator, list_open, list_close): Add uiout parameter. + (mi_table_begin, mi_table_body, mi_table_end, mi_list_begin, + mi_list_end, mi_field_string, mi_field_fmt, out_field_fmt, + out_field_fmt): Update. + + * mi-out.c (mi_out_new): Initialize supress_field_separator. + (supress_field_separator): Move into mi-out local data object. + (mi_table_begin, mi_list_begin, field_separator): Update. + +Fri Jun 11 16:08:37 1999 Andrew Cagney + + * mi-out.c (mi_out_new): New function, replace init_mi_out. + * mi-main.c (mi_command_loop): Call mi_out_new(). + + * ui-out.h (mi_out_new): Add declaration. Will move later. + (mi_ui_out_impl): Delete. + +Wed Jun 9 16:42:16 1999 Andrew Cagney + + * mi-main.c: Include "ui-hooks.h". + (mi_init_ui, mi_command_loop): New functions. + (_initialize_mi_main): Install ``mi'' as the interpreter when + selected. + +Mon Jun 7 18:43:43 1999 Andrew Cagney + + From Fernando Nasser + * mi-cmds.c (build_table): Clean up error message. + * mi-cmds.c (mi_cmd_execute), mi-main.c (mi_execute_command): Only + print debug information when mi_debug_p. + * mi-cmds.h (mi_debug_p), mi-main.c: Global, control debug messages. + +Thu Jun 3 00:44:52 1999 Andrew Cagney + + From Fernando Nasser : + * mi-cmds.c: Add CLI definitions for "exec-arguments", + "exec-next", "gdb-exit", "break-list", "break-info", "exec-step" + and "stack-list-frames" to mi_cmds. + (struct mi_command): Add ``from_tty'' argument to func. + * mi-cmds.h (quit_force): Declare. + +1999-05-31 Fernando Nasser + + * mi-out.c (mi_table_end): Remove unwanted "\n". + +Thu May 27 14:59:06 1999 Andrew Cagney + + * top.c: Include "ui-hooks.h". + (call_interp_loop): Tempoary. Pass mi_execute_command to + simplified_command_loop. Initialize gdb_stdout & gdb_stderr to + stdio gdb_file streams. Force all hooks to null. + + * mi-cmds.h, mi-main.c, mi-cmds.c: New files. + * Makefile.in (SFILES): Add mi-main.c, mi-cmds.c + (COMMON_OBS): Add mi-main.o, mi-cmds.o. + (mi_cmds_h): Define. + +Wed May 26 12:39:49 1999 Andrew Cagney + + * top.c (call_interp_loop): Hack. Add extern declaration for + mi_ui_out_impl. + +1999-05-25 Fernando Nasser + + * mi-out.c: New table syntax. + +Mon May 24 16:16:29 1999 Andrew Cagney + + mi-out.c (_initialize_mi_out): Add external declaration. + +1999-05-21 Fernando Nasser + + * mi-out.c (mi_table_begin): Added missing parameter. + +1999-05-21 Fernando Nasser + + * mi-out.c: Changed table markers and added table id. + +1999-05-21 Fernando Nasser + + * mi-out.c: New file. Implements low-level ui-out primitives for + CLI-based interaction. + + +Local Variables: +mode: change-log +left-margin: 8 +fill-column: 74 +version-control: never +End: Index: mi-interp.c =================================================================== --- mi-interp.c (nonexistent) +++ mi-interp.c (revision 816) @@ -0,0 +1,377 @@ +/* MI Interpreter Definitions and Commands for GDB, the GNU debugger. + + Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008 + Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include "defs.h" +#include "gdb_string.h" +#include "interps.h" +#include "event-top.h" +#include "event-loop.h" +#include "inferior.h" +#include "ui-out.h" +#include "top.h" +#include "exceptions.h" +#include "mi-main.h" +#include "mi-cmds.h" +#include "mi-out.h" +#include "mi-console.h" + +struct mi_interp +{ + /* MI's output channels */ + struct ui_file *out; + struct ui_file *err; + struct ui_file *log; + struct ui_file *targ; + struct ui_file *event_channel; + + /* This is the interpreter for the mi... */ + struct interp *mi2_interp; + struct interp *mi1_interp; + struct interp *mi_interp; +}; + +/* 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 */ +static int mi_interp_query_hook (const char *ctlstr, va_list ap) + ATTR_FORMAT (printf, 1, 0); + +static void mi3_command_loop (void); +static void mi2_command_loop (void); +static void mi1_command_loop (void); + +static void mi_insert_notify_hooks (void); +static void mi_remove_notify_hooks (void); + +static void * +mi_interpreter_init (void) +{ + struct mi_interp *mi = XMALLOC (struct mi_interp); + + /* 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 */ + mi->out = mi_console_file_new (raw_stdout, "~", '"'); + mi->err = mi_console_file_new (raw_stdout, "&", '"'); + mi->log = mi->err; + mi->targ = mi_console_file_new (raw_stdout, "@", '"'); + mi->event_channel = mi_console_file_new (raw_stdout, "=", 0); + + return mi; +} + +static int +mi_interpreter_resume (void *data) +{ + struct mi_interp *mi = data; + /* As per hack note in mi_interpreter_init, swap in the output channels... */ + + gdb_setup_readline (); + + /* These overwrite some of the initialization done in + _intialize_event_loop. */ + call_readline = gdb_readline2; + input_handler = mi_execute_command_wrapper; + add_file_handler (input_fd, stdin_event_handler, 0); + async_command_editing_p = 0; + /* FIXME: This is a total hack for now. PB's use of the MI + implicitly relies on a bug in the async support which allows + asynchronous commands to leak through the commmand loop. The bug + involves (but is not limited to) the fact that sync_execution was + erroneously initialized to 0. Duplicate by initializing it thus + here... */ + sync_execution = 0; + + gdb_stdout = mi->out; + /* Route error and log output through the MI */ + gdb_stderr = mi->err; + gdb_stdlog = mi->log; + /* Route target output through the MI. */ + gdb_stdtarg = mi->targ; + /* Route target error through the MI as well. */ + gdb_stdtargerr = mi->targ; + + /* Replace all the hooks that we know about. There really needs to + be a better way of doing this... */ + clear_interpreter_hooks (); + + deprecated_show_load_progress = mi_load_progress; + + /* 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)) + deprecated_command_loop_hook = mi2_command_loop; + else if (current_interp_named_p (INTERP_MI3)) + deprecated_command_loop_hook = mi3_command_loop; + else + deprecated_command_loop_hook = mi2_command_loop; + + return 1; +} + +static int +mi_interpreter_suspend (void *data) +{ + gdb_disable_readline (); + return 1; +} + +static struct gdb_exception +mi_interpreter_exec (void *data, const char *command) +{ + static struct gdb_exception ok; + char *tmp = alloca (strlen (command) + 1); + strcpy (tmp, command); + mi_execute_command_wrapper (tmp); + return exception_none; +} + +/* Never display the default gdb prompt in mi case. */ +static int +mi_interpreter_prompt_p (void *data) +{ + return 0; +} + +static void +mi_interpreter_exec_continuation (struct continuation_arg *arg) +{ + bpstat_do_actions (&stop_bpstat); + if (!target_executing) + { + fputs_unfiltered ("*stopped", raw_stdout); + mi_out_put (uiout, raw_stdout); + fputs_unfiltered ("\n", raw_stdout); + fputs_unfiltered ("(gdb) \n", raw_stdout); + gdb_flush (raw_stdout); + do_exec_cleanups (ALL_CLEANUPS); + } + else if (target_can_async_p ()) + { + add_continuation (mi_interpreter_exec_continuation, NULL); + } +} + +enum mi_cmd_result +mi_cmd_interpreter_exec (char *command, char **argv, int argc) +{ + struct interp *interp_to_use; + enum mi_cmd_result result = MI_CMD_DONE; + int i; + struct interp_procs *procs; + + if (argc < 2) + { + mi_error_message = xstrprintf ("mi_cmd_interpreter_exec: Usage: -interpreter-exec interp command"); + return MI_CMD_ERROR; + } + + interp_to_use = interp_lookup (argv[0]); + if (interp_to_use == NULL) + { + mi_error_message = xstrprintf ("mi_cmd_interpreter_exec: could not find interpreter \"%s\"", argv[0]); + return MI_CMD_ERROR; + } + + if (!interp_exec_p (interp_to_use)) + { + mi_error_message = xstrprintf ("mi_cmd_interpreter_exec: interpreter \"%s\" does not support command execution", + argv[0]); + return MI_CMD_ERROR; + } + + /* 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... */ + + for (i = 1; i < argc; i++) + { + /* We had to set sync_execution = 0 for the mi (well really for Project + Builder's use of the mi - particularly so interrupting would work. + But for console commands to work, we need to initialize it to 1 - + since that is what the cli expects - before running the command, + and then set it back to 0 when we are done. */ + sync_execution = 1; + { + struct gdb_exception e = interp_exec (interp_to_use, argv[i]); + if (e.reason < 0) + { + mi_error_message = xstrdup (e.message); + result = MI_CMD_ERROR; + break; + } + } + do_exec_error_cleanups (ALL_CLEANUPS); + sync_execution = 0; + } + + mi_remove_notify_hooks (); + + /* Okay, now let's see if the command set the inferior going... + Tricky point - have to do this AFTER resetting the interpreter, since + changing the interpreter will clear out all the continuations for + that interpreter... */ + + if (target_can_async_p () && target_executing) + { + fputs_unfiltered ("^running\n", raw_stdout); + add_continuation (mi_interpreter_exec_continuation, NULL); + } + + return result; +} + +/* + * 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. +*/ + +static void +mi_insert_notify_hooks (void) +{ + deprecated_query_hook = mi_interp_query_hook; +} + +static void +mi_remove_notify_hooks (void) +{ + deprecated_query_hook = NULL; +} + +static int +mi_interp_query_hook (const char *ctlstr, va_list ap) +{ + return 1; +} + +static void +mi_execute_command_wrapper (char *cmd) +{ + mi_execute_command (cmd, stdin == instream); +} + +static void +mi1_command_loop (void) +{ + mi_command_loop (1); +} + +static void +mi2_command_loop (void) +{ + mi_command_loop (2); +} + +static void +mi3_command_loop (void) +{ + mi_command_loop (3); +} + +static void +mi_command_loop (int mi_version) +{ +#if 0 + /* HACK: 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 */ + raw_stdout = stdio_fileopen (stdout); + /* Route normal output through the MIx */ + gdb_stdout = mi_console_file_new (raw_stdout, "~", '"'); + /* Route error and log output through the MI */ + gdb_stderr = mi_console_file_new (raw_stdout, "&", '"'); + gdb_stdlog = gdb_stderr; + /* Route target output through the MI. */ + gdb_stdtarg = mi_console_file_new (raw_stdout, "@", '"'); + /* HACK: Poke the ui_out table directly. Should we be creating a + mi_out object wired up to the above gdb_stdout / gdb_stderr? */ + uiout = mi_out_new (mi_version); + /* HACK: Override any other interpreter hooks. We need to create a + real event table and pass in that. */ + deprecated_init_ui_hook = 0; + /* deprecated_command_loop_hook = 0; */ + deprecated_print_frame_info_listing_hook = 0; + deprecated_query_hook = 0; + deprecated_warning_hook = 0; + deprecated_create_breakpoint_hook = 0; + deprecated_delete_breakpoint_hook = 0; + deprecated_modify_breakpoint_hook = 0; + deprecated_interactive_hook = 0; + deprecated_readline_begin_hook = 0; + deprecated_readline_hook = 0; + deprecated_readline_end_hook = 0; + deprecated_register_changed_hook = 0; + deprecated_memory_changed_hook = 0; + deprecated_context_hook = 0; + deprecated_target_wait_hook = 0; + deprecated_call_command_hook = 0; + deprecated_error_hook = 0; + deprecated_error_begin_hook = 0; + deprecated_show_load_progress = mi_load_progress; +#endif + /* Turn off 8 bit strings in quoted output. Any character with the + high bit set is printed using C's octal format. */ + sevenbit_strings = 1; + /* Tell the world that we're alive */ + fputs_unfiltered ("(gdb) \n", raw_stdout); + gdb_flush (raw_stdout); + start_event_loop (); +} + +extern initialize_file_ftype _initialize_mi_interp; /* -Wmissing-prototypes */ + +void +_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 */ + }; + + /* The various interpreter levels. */ + interp_add (interp_new (INTERP_MI1, NULL, mi_out_new (1), &procs)); + interp_add (interp_new (INTERP_MI2, NULL, mi_out_new (2), &procs)); + interp_add (interp_new (INTERP_MI3, NULL, mi_out_new (3), &procs)); + + /* "mi" selects the most recent released version. "mi2" was + released as part of GDB 6.0. */ + interp_add (interp_new (INTERP_MI, NULL, mi_out_new (2), &procs)); +}
mi-interp.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mi-console.c =================================================================== --- mi-console.c (nonexistent) +++ mi-console.c (revision 816) @@ -0,0 +1,123 @@ +/* MI Console code. + + Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. + + Contributed by Cygnus Solutions (a Red Hat company). + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#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; + +struct mi_console_file + { + int *magic; + struct ui_file *raw; + struct ui_file *buffer; + const char *prefix; + char quote; + }; + +int mi_console_file_magic; + +struct ui_file * +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); + mi_console->magic = &mi_console_file_magic; + mi_console->raw = raw; + mi_console->buffer = mem_fileopen (); + mi_console->prefix = prefix; + mi_console->quote = quote; + 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; +} + +static void +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")); + xfree (mi_console); +} + +static void +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 */ + fputs_unfiltered (buf, mi_console->buffer); + /* Flush when an embedded \n */ + if (strchr (buf, '\n') != NULL) + gdb_flush (file); +} + +/* Transform a byte sequence into a console output packet. */ +static void +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")); + + if (length_buf > 0) + { + fputs_unfiltered (mi_console->prefix, mi_console->raw); + if (mi_console->quote) + { + fputs_unfiltered ("\"", mi_console->raw); + fputstrn_unfiltered (buf, length_buf, mi_console->quote, mi_console->raw); + fputs_unfiltered ("\"\n", mi_console->raw); + } + else + { + fputstrn_unfiltered (buf, length_buf, 0, mi_console->raw); + fputs_unfiltered ("\n", mi_console->raw); + } + gdb_flush (mi_console->raw); + } +} + +static void +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")); + ui_file_put (mi_console->buffer, mi_console_raw_packet, mi_console); + ui_file_rewind (mi_console->buffer); +}
mi-console.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mi-getopt.c =================================================================== --- mi-getopt.c (nonexistent) +++ mi-getopt.c (revision 816) @@ -0,0 +1,90 @@ +/* MI Command Set - MI Option Parser. + Copyright (C) 2000, 2001, 2007, 2008 Free Software Foundation, Inc. + Contributed by Cygnus Solutions (a Red Hat company). + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include "defs.h" +#include "mi-getopt.h" +#include "gdb_string.h" + +int +mi_getopt (const char *prefix, + int argc, char **argv, + struct mi_opt *opts, + int *optind, char **optarg) +{ + char *arg; + struct mi_opt *opt; + /* We assume that argv/argc are ok. */ + if (*optind > argc || *optind < 0) + internal_error (__FILE__, __LINE__, + _("mi_getopt_long: optind out of bounds")); + if (*optind == argc) + return -1; + arg = argv[*optind]; + /* ``--''? */ + if (strcmp (arg, "--") == 0) + { + *optind += 1; + *optarg = NULL; + return -1; + } + /* End of option list. */ + if (arg[0] != '-') + { + *optarg = NULL; + return -1; + } + /* 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 optarg option. */ + if (argc < *optind + 2) + error (_("%s: Option %s requires an argument"), prefix, arg); + *optarg = argv[(*optind) + 1]; + *optind = (*optind) + 2; + return opt->index; + } + else + { + *optarg = NULL; + *optind = (*optind) + 1; + return opt->index; + } + } + error (_("%s: Unknown option ``%s''"), prefix, arg + 1); +} + +int +mi_valid_noargs (const char *prefix, int argc, char **argv) +{ + int optind = 0; + char *optarg; + static struct mi_opt opts[] = + { + { 0, 0, 0 } + }; + + if (mi_getopt (prefix, argc, argv, opts, &optind, &optarg) == -1) + return 1; + else + return 0; +}
mi-getopt.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mi-cmd-disas.c =================================================================== --- mi-cmd-disas.c (nonexistent) +++ mi-cmd-disas.c (revision 816) @@ -0,0 +1,161 @@ +/* MI Command Set - disassemble commands. + Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. + Contributed by Cygnus Solutions (a Red Hat company). + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include "defs.h" +#include "target.h" +#include "value.h" +#include "mi-cmds.h" +#include "mi-getopt.h" +#include "gdb_string.h" +#include "ui-out.h" +#include "disasm.h" + +/* The arguments to be passed on the command line and parsed here are: + + either: + + START-ADDRESS: address to start the disassembly at. + END-ADDRESS: address to end the disassembly at. + + or: + + FILENAME: The name of the file where we want disassemble from. + LINE: The line around which we want to disassemble. It will + disassemble the function that contins that line. + HOW_MANY: Number of disassembly lines to display. In mixed mode, it + is the number of disassembly lines only, not counting the source + lines. + + always required: + + MODE: 0 or 1 for disassembly only, or mixed source and disassembly, + respectively. */ +enum mi_cmd_result +mi_cmd_disassemble (char *command, char **argv, int argc) +{ + enum mi_cmd_result retval; + CORE_ADDR start; + + int mixed_source_and_assembly; + struct symtab *s; + + /* Which options have we processed ... */ + int file_seen = 0; + int line_seen = 0; + int num_seen = 0; + int start_seen = 0; + int end_seen = 0; + + /* ... and their corresponding value. */ + char *file_string = NULL; + int line_num = -1; + int how_many = -1; + CORE_ADDR low = 0; + CORE_ADDR high = 0; + + /* Options processing stuff. */ + int optind = 0; + char *optarg; + enum opt + { + FILE_OPT, LINE_OPT, NUM_OPT, START_OPT, END_OPT + }; + static 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. */ + while (1) + { + int opt = mi_getopt ("mi_cmd_disassemble", argc, argv, opts, + &optind, &optarg); + if (opt < 0) + break; + switch ((enum opt) opt) + { + case FILE_OPT: + file_string = xstrdup (optarg); + file_seen = 1; + break; + case LINE_OPT: + line_num = atoi (optarg); + line_seen = 1; + break; + case NUM_OPT: + how_many = atoi (optarg); + num_seen = 1; + break; + case START_OPT: + low = parse_and_eval_address (optarg); + start_seen = 1; + break; + case END_OPT: + high = parse_and_eval_address (optarg); + end_seen = 1; + break; + } + } + argv += optind; + argc -= optind; + + /* Allow only filename + linenum (with how_many which is not + required) OR start_addr + and_addr */ + + if (!((line_seen && file_seen && num_seen && !start_seen && !end_seen) + || (line_seen && file_seen && !num_seen && !start_seen && !end_seen) + || (!line_seen && !file_seen && !num_seen && start_seen && end_seen))) + error + ("mi_cmd_disassemble: Usage: ( [-f filename -l linenum [-n howmany]] | [-s startaddr -e endaddr]) [--] mixed_mode."); + + if (argc != 1) + error + ("mi_cmd_disassemble: Usage: [-f filename -l linenum [-n howmany]] [-s startaddr -e endaddr] [--] mixed_mode."); + + mixed_source_and_assembly = atoi (argv[0]); + if ((mixed_source_and_assembly != 0) && (mixed_source_and_assembly != 1)) + error (_("mi_cmd_disassemble: Mixed_mode argument must be 0 or 1.")); + + + /* We must get the function beginning and end where line_num is + contained. */ + + if (line_seen && file_seen) + { + s = lookup_symtab (file_string); + if (s == NULL) + error (_("mi_cmd_disassemble: Invalid filename.")); + if (!find_line_pc (s, line_num, &start)) + error (_("mi_cmd_disassemble: Invalid line number")); + if (find_pc_partial_function (start, NULL, &low, &high) == 0) + error (_("mi_cmd_disassemble: No function contains specified address")); + } + + gdb_disassembly (uiout, + file_string, + line_num, + mixed_source_and_assembly, how_many, low, high); + + return MI_CMD_DONE; +}
mi-cmd-disas.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mi-cmd-stack.c =================================================================== --- mi-cmd-stack.c (nonexistent) +++ mi-cmd-stack.c (revision 816) @@ -0,0 +1,343 @@ +/* MI Command Set - stack commands. + Copyright (C) 2000, 2002, 2003, 2004, 2005, 2007, 2008 + Free Software Foundation, Inc. + Contributed by Cygnus Solutions (a Red Hat company). + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include "defs.h" +#include "target.h" +#include "frame.h" +#include "value.h" +#include "mi-cmds.h" +#include "ui-out.h" +#include "symtab.h" +#include "block.h" +#include "stack.h" +#include "dictionary.h" +#include "gdb_string.h" + +static void list_args_or_locals (int locals, int values, struct frame_info *fi); + +/* 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. */ +enum mi_cmd_result +mi_cmd_stack_list_frames (char *command, char **argv, int argc) +{ + int frame_low; + int frame_high; + int i; + struct cleanup *cleanup_stack; + struct frame_info *fi; + + if (argc > 2 || argc == 1) + error (_("mi_cmd_stack_list_frames: Usage: [FRAME_LOW FRAME_HIGH]")); + + if (argc == 2) + { + frame_low = atoi (argv[0]); + frame_high = atoi (argv[1]); + } + else + { + /* Called with no arguments, it means we want the whole + 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. */ + for (i = 0, fi = get_current_frame (); + fi && i < frame_low; + i++, fi = get_prev_frame (fi)); + + if (fi == NULL) + error (_("mi_cmd_stack_list_frames: Not enough frames in stack.")); + + cleanup_stack = make_cleanup_ui_out_list_begin_end (uiout, "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. */ + print_frame_info (fi, 1, LOC_AND_ADDRESS, 0 /* args */ ); + } + + do_cleanups (cleanup_stack); + + return MI_CMD_DONE; +} + +enum mi_cmd_result +mi_cmd_stack_info_depth (char *command, char **argv, int argc) +{ + int frame_high; + int i; + struct frame_info *fi; + + if (argc > 1) + error (_("mi_cmd_stack_info_depth: Usage: [MAX_DEPTH]")); + + if (argc == 1) + frame_high = atoi (argv[0]); + else + /* Called with no arguments, it means we want the real depth of + the stack. */ + frame_high = -1; + + for (i = 0, fi = get_current_frame (); + fi && (i < frame_high || frame_high == -1); + i++, fi = get_prev_frame (fi)) + QUIT; + + ui_out_field_int (uiout, "depth", i); + + return MI_CMD_DONE; +} + +/* 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. */ +enum mi_cmd_result +mi_cmd_stack_list_locals (char *command, char **argv, int argc) +{ + struct frame_info *frame; + enum print_values print_values; + + if (argc != 1) + error (_("mi_cmd_stack_list_locals: Usage: PRINT_VALUES")); + + frame = get_selected_frame (NULL); + + if (strcmp (argv[0], "0") == 0 + || strcmp (argv[0], mi_no_values) == 0) + print_values = PRINT_NO_VALUES; + else if (strcmp (argv[0], "1") == 0 + || strcmp (argv[0], mi_all_values) == 0) + print_values = PRINT_ALL_VALUES; + else if (strcmp (argv[0], "2") == 0 + || strcmp (argv[0], mi_simple_values) == 0) + print_values = PRINT_SIMPLE_VALUES; + else + error (_("Unknown value for PRINT_VALUES: must be: \ +0 or \"%s\", 1 or \"%s\", 2 or \"%s\""), + mi_no_values, mi_all_values, mi_simple_values); + list_args_or_locals (1, print_values, frame); + return MI_CMD_DONE; +} + +/* 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. */ +enum mi_cmd_result +mi_cmd_stack_list_args (char *command, char **argv, int argc) +{ + int frame_low; + int frame_high; + int i; + struct frame_info *fi; + struct cleanup *cleanup_stack_args; + + if (argc < 1 || argc > 3 || argc == 2) + error (_("mi_cmd_stack_list_args: Usage: PRINT_VALUES [FRAME_LOW FRAME_HIGH]")); + + if (argc == 3) + { + frame_low = atoi (argv[1]); + frame_high = atoi (argv[2]); + } + else + { + /* Called with no arguments, it means we want args for the whole + 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. */ + for (i = 0, fi = get_current_frame (); + fi && i < frame_low; + i++, fi = get_prev_frame (fi)); + + if (fi == NULL) + error (_("mi_cmd_stack_list_args: Not enough frames in stack.")); + + cleanup_stack_args = 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. */ + for (; + fi && (i <= frame_high || frame_high == -1); + 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); + list_args_or_locals (0, atoi (argv[0]), fi); + do_cleanups (cleanup_frame); + } + + do_cleanups (cleanup_stack_args); + + return MI_CMD_DONE; +} + +/* 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. */ +static void +list_args_or_locals (int locals, int values, struct frame_info *fi) +{ + struct block *block; + struct symbol *sym; + struct dict_iterator iter; + int nsyms; + struct cleanup *cleanup_list; + static struct ui_stream *stb = NULL; + struct type *type; + + stb = ui_out_stream_new (uiout); + + block = get_frame_block (fi, 0); + + cleanup_list = make_cleanup_ui_out_list_begin_end (uiout, locals ? "locals" : "args"); + + while (block != 0) + { + ALL_BLOCK_SYMBOLS (block, iter, sym) + { + int print_me = 0; + + switch (SYMBOL_CLASS (sym)) + { + default: + case LOC_UNDEF: /* catches errors */ + case LOC_CONST: /* constant */ + case LOC_TYPEDEF: /* local typedef */ + case LOC_LABEL: /* local label */ + case LOC_BLOCK: /* local function */ + case LOC_CONST_BYTES: /* loc. byte seq. */ + case LOC_UNRESOLVED: /* unresolved static */ + case LOC_OPTIMIZED_OUT: /* optimized out */ + print_me = 0; + break; + + case LOC_ARG: /* argument */ + case LOC_REF_ARG: /* reference arg */ + case LOC_REGPARM: /* register arg */ + case LOC_REGPARM_ADDR: /* indirect register arg */ + case LOC_LOCAL_ARG: /* stack arg */ + case LOC_BASEREG_ARG: /* basereg arg */ + case LOC_COMPUTED_ARG: /* arg with computed location */ + if (!locals) + print_me = 1; + break; + + case LOC_LOCAL: /* stack local */ + case LOC_BASEREG: /* basereg local */ + case LOC_STATIC: /* static */ + case LOC_REGISTER: /* register */ + case LOC_COMPUTED: /* computed location */ + if (locals) + print_me = 1; + break; + } + if (print_me) + { + struct cleanup *cleanup_tuple = NULL; + struct symbol *sym2; + struct value *val; + if (values != PRINT_NO_VALUES) + cleanup_tuple = + make_cleanup_ui_out_tuple_begin_end (uiout, NULL); + ui_out_field_string (uiout, "name", SYMBOL_PRINT_NAME (sym)); + + if (!locals) + sym2 = lookup_symbol (SYMBOL_NATURAL_NAME (sym), + block, VAR_DOMAIN, + (int *) NULL, + (struct symtab **) NULL); + else + sym2 = sym; + switch (values) + { + case PRINT_SIMPLE_VALUES: + type = check_typedef (sym2->type); + type_print (sym2->type, "", stb->stream, -1); + ui_out_field_stream (uiout, "type", stb); + if (TYPE_CODE (type) != TYPE_CODE_ARRAY + && TYPE_CODE (type) != TYPE_CODE_STRUCT + && TYPE_CODE (type) != TYPE_CODE_UNION) + { + val = read_var_value (sym2, fi); + common_val_print + (val, stb->stream, 0, 1, 0, Val_no_prettyprint); + ui_out_field_stream (uiout, "value", stb); + } + do_cleanups (cleanup_tuple); + break; + case PRINT_ALL_VALUES: + val = read_var_value (sym2, fi); + common_val_print + (val, stb->stream, 0, 1, 0, Val_no_prettyprint); + ui_out_field_stream (uiout, "value", stb); + do_cleanups (cleanup_tuple); + break; + } + } + } + if (BLOCK_FUNCTION (block)) + break; + else + block = BLOCK_SUPERBLOCK (block); + } + do_cleanups (cleanup_list); + ui_out_stream_delete (stb); +} + +enum mi_cmd_result +mi_cmd_stack_select_frame (char *command, char **argv, int argc) +{ + if (argc == 0 || argc > 1) + error (_("mi_cmd_stack_select_frame: Usage: FRAME_SPEC")); + + select_frame_command (argv[0], 1 /* not used */ ); + return MI_CMD_DONE; +} + +enum mi_cmd_result +mi_cmd_stack_info_frame (char *command, char **argv, int argc) +{ + if (argc > 0) + error (_("mi_cmd_stack_info_frame: No arguments required")); + + print_frame_info (get_selected_frame (NULL), 1, LOC_AND_ADDRESS, 0); + return MI_CMD_DONE; +}
mi-cmd-stack.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mi-out.c =================================================================== --- mi-out.c (nonexistent) +++ mi-out.c (revision 816) @@ -0,0 +1,409 @@ +/* MI Command Set - output generating routines. + + Copyright (C) 2000, 2002, 2003, 2004, 2005, 2007, 2008 + Free Software Foundation, Inc. + + Contributed by Cygnus Solutions (a Red Hat company). + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include "defs.h" +#include "ui-out.h" +#include "mi-out.h" + +struct ui_out_data + { + int suppress_field_separator; + int suppress_output; + int mi_version; + struct ui_file *buffer; + }; +typedef struct ui_out_data mi_out_data; + +/* These are the MI output functions */ + +static void mi_table_begin (struct ui_out *uiout, int nbrofcols, + int nr_rows, const char *tblid); +static void mi_table_body (struct ui_out *uiout); +static void mi_table_end (struct ui_out *uiout); +static void mi_table_header (struct ui_out *uiout, int width, + enum ui_align alig, const char *col_name, + const char *colhdr); +static void mi_begin (struct ui_out *uiout, enum ui_out_type type, + int level, const char *id); +static void mi_end (struct ui_out *uiout, enum ui_out_type type, int level); +static void mi_field_int (struct ui_out *uiout, int fldno, int width, + enum ui_align alig, const char *fldname, int value); +static void mi_field_skip (struct ui_out *uiout, int fldno, int width, + enum ui_align alig, const char *fldname); +static void mi_field_string (struct ui_out *uiout, int fldno, int width, + enum ui_align alig, const char *fldname, + const char *string); +static 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) ATTR_FORMAT (printf, 6, 0); +static void mi_spaces (struct ui_out *uiout, int numspaces); +static void mi_text (struct ui_out *uiout, const char *string); +static void mi_message (struct ui_out *uiout, int verbosity, + const char *format, va_list args) + ATTR_FORMAT (printf, 3, 0); +static void mi_wrap_hint (struct ui_out *uiout, char *identstring); +static void mi_flush (struct ui_out *uiout); + +/* This is the MI ui-out implementation functions vector */ + +/* FIXME: This can be initialized dynamically after default is set to + handle initial output in main.c */ + +struct ui_out_impl mi_ui_out_impl = +{ + mi_table_begin, + mi_table_body, + mi_table_end, + mi_table_header, + mi_begin, + mi_end, + mi_field_int, + mi_field_skip, + mi_field_string, + mi_field_fmt, + mi_spaces, + mi_text, + mi_message, + mi_wrap_hint, + mi_flush, + NULL, + 1, /* Needs MI hacks. */ +}; + +/* Prototypes for local functions */ + +extern void _initialize_mi_out (void); +static void field_separator (struct ui_out *uiout); +static void mi_open (struct ui_out *uiout, const char *name, + enum ui_out_type type); +static void mi_close (struct ui_out *uiout, enum ui_out_type type); + +/* Mark beginning of a table */ + +void +mi_table_begin (struct ui_out *uiout, + int nr_cols, + int nr_rows, + const char *tblid) +{ + mi_out_data *data = ui_out_data (uiout); + 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_open (uiout, "hdr", ui_out_type_list); +} + +/* Mark beginning of a table body */ + +void +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_close (uiout, ui_out_type_list); + mi_open (uiout, "body", ui_out_type_list); +} + +/* Mark end of a table */ + +void +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); +} + +/* Specify table header */ + +void +mi_table_header (struct ui_out *uiout, int width, enum ui_align alignment, + 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_field_string (uiout, 0, 0, 0, "col_name", col_name); + mi_field_string (uiout, 0, width, alignment, "colhdr", colhdr); + mi_close (uiout, ui_out_type_tuple); +} + +/* Mark beginning of a list */ + +void +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 */ + +void +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 */ + +void +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? */ + mi_out_data *data = ui_out_data (uiout); + if (data->suppress_output) + return; + + sprintf (buffer, "%d", value); + mi_field_string (uiout, fldno, width, alignment, fldname, buffer); +} + +/* used to ommit a field */ + +void +mi_field_skip (struct ui_out *uiout, int fldno, int width, + 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, ""); +} + +/* 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_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, "\""); + if (string) + fputstr_unfiltered (string, '"', data->buffer); + fprintf_unfiltered (data->buffer, "\""); +} + +/* 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_out_data *data = ui_out_data (uiout); + if (data->suppress_output) + return; + field_separator (uiout); + if (fldname) + fprintf_unfiltered (data->buffer, "%s=\"", fldname); + else + fputs_unfiltered ("\"", data->buffer); + vfprintf_unfiltered (data->buffer, format, args); + fputs_unfiltered ("\"", data->buffer); +} + +void +mi_spaces (struct ui_out *uiout, int numspaces) +{ +} + +void +mi_text (struct ui_out *uiout, const char *string) +{ +} + +void +mi_message (struct ui_out *uiout, int verbosity, + const char *format, + va_list args) +{ +} + +void +mi_wrap_hint (struct ui_out *uiout, char *identstring) +{ + wrap_here (identstring); +} + +void +mi_flush (struct ui_out *uiout) +{ + mi_out_data *data = ui_out_data (uiout); + gdb_flush (data->buffer); +} + +/* local functions */ + +/* access to ui_out format private members */ + +static void +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 + fputc_unfiltered (',', data->buffer); +} + +static void +mi_open (struct ui_out *uiout, + const char *name, + enum ui_out_type type) +{ + mi_out_data *data = ui_out_data (uiout); + field_separator (uiout); + data->suppress_field_separator = 1; + if (name) + fprintf_unfiltered (data->buffer, "%s=", name); + switch (type) + { + case ui_out_type_tuple: + fputc_unfiltered ('{', data->buffer); + break; + case ui_out_type_list: + fputc_unfiltered ('[', data->buffer); + break; + default: + internal_error (__FILE__, __LINE__, _("bad switch")); + } +} + +static void +mi_close (struct ui_out *uiout, + enum ui_out_type type) +{ + mi_out_data *data = ui_out_data (uiout); + switch (type) + { + case ui_out_type_tuple: + fputc_unfiltered ('}', data->buffer); + break; + case ui_out_type_list: + fputc_unfiltered (']', data->buffer); + break; + default: + internal_error (__FILE__, __LINE__, _("bad switch")); + } + data->suppress_field_separator = 0; +} + +/* add a string to the buffer */ + +void +mi_out_buffered (struct ui_out *uiout, char *string) +{ + mi_out_data *data = ui_out_data (uiout); + fprintf_unfiltered (data->buffer, "%s", string); +} + +/* clear the buffer */ + +void +mi_out_rewind (struct ui_out *uiout) +{ + mi_out_data *data = ui_out_data (uiout); + ui_file_rewind (data->buffer); +} + +/* dump the buffer onto the specified stream */ + +static void +do_write (void *data, const char *buffer, long length_buffer) +{ + ui_file_write (data, buffer, length_buffer); +} + +void +mi_out_put (struct ui_out *uiout, + 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); +} + +/* Current MI version. */ + +int +mi_version (struct ui_out *uiout) +{ + mi_out_data *data = ui_out_data (uiout); + return data->mi_version; +} + +/* initalize private members at startup */ + +struct ui_out * +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; + data->mi_version = mi_version; + /* FIXME: This code should be using a ``string_file'' and not the + TUI buffer hack. */ + 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 */ +}
mi-out.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mi-getopt.h =================================================================== --- mi-getopt.h (nonexistent) +++ mi-getopt.h (revision 816) @@ -0,0 +1,78 @@ +/* MI Option Parser. + Copyright (C) 2000, 2007, 2008 Free Software Foundation, Inc. + Contributed by Cygnus Solutions (a Red Hat company). + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef MI_GETOPT_H +#define MI_GETOPT_H + +/* Like getopt() but with simpler semantics. + + An option has the form ``-''. The special option ``--'' + denotes the end of the option list. An option can be followed by a + separate argument (on a per option basis). + + On entry OPTIND contains the index of the next element of ARGV that + needs parsing. OPTIND is updated to indicate the index of the next + argument before mi_getopt() returns. + + If ARGV[OPTIND] is an option, that options INDEX is returned. + OPTARG is set to the options argument or NULL. OPTIND is updated. + + If ARGV[OPTIND] is not an option, -1 is returned and OPTIND updated + 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. */ + +struct mi_opt; +extern int mi_getopt (const char *prefix, int argc, char **argv, + 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. + + An MI function that should not recieve arguments can still be + passed parameters after the special option '--' such as below. + + Example: The MI function -exec-run takes no args. + However, the client may pass '-exec-run -- -a ...' + See PR-783 + + PREFIX is passed to mi_getopt for an error message. + + This function Returns 1 if the parameter pair ARGC/ARGV are valid + for an MI function that takes no arguments. Otherwise, it returns 0 + and the appropriate error message is displayed by mi_getopt. */ + +extern int mi_valid_noargs (const char *prefix, int argc, char **argv); + +#endif
mi-getopt.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mi-console.h =================================================================== --- mi-console.h (nonexistent) +++ mi-console.h (revision 816) @@ -0,0 +1,27 @@ +/* MI Command Set - MI Console. + Copyright (C) 2000, 2007, 2008 Free Software Foundation, Inc. + Contributed by Cygnus Solutions (a Red Hat company). + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef MI_CONSOLE_H +#define MI_CONSOLE_H + +extern struct ui_file *mi_console_file_new (struct ui_file *raw, + const char *prefix, + char quote); + +#endif
mi-console.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mi-parse.c =================================================================== --- mi-parse.c (nonexistent) +++ mi-parse.c (revision 816) @@ -0,0 +1,231 @@ +/* MI Command Set - MI parser. + + Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. + + Contributed by Cygnus Solutions (a Red Hat company). + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include "defs.h" +#include "mi-cmds.h" +#include "mi-parse.h" + +#include +#include "gdb_string.h" + +static void +mi_parse_argv (char *args, struct mi_parse *parse) +{ + 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++; + /* Three possibilities: EOF, quoted string, or other text. */ + switch (*chp) + { + case '\0': + parse->argv = argv; + parse->argc = argc; + return; + case '"': + { + /* A quoted string. */ + int len; + char *start = chp + 1; + /* Determine the buffer size. */ + chp = start; + len = 0; + while (*chp != '\0' && *chp != '"') + { + if (*chp == '\\') + { + chp++; + if (parse_escape (&chp) <= 0) + { + /* Do not allow split lines or "\000" */ + freeargv (argv); + return; + } + } + else + chp++; + len++; + } + /* Insist on a closing quote. */ + if (*chp != '"') + { + freeargv (argv); + return; + } + /* Insist on trailing white space. */ + if (chp[1] != '\0' && !isspace (chp[1])) + { + freeargv (argv); + return; + } + /* create the buffer. */ + arg = xmalloc ((len + 1) * sizeof (char)); + /* And copy the characters in. */ + chp = start; + len = 0; + while (*chp != '\0' && *chp != '"') + { + if (*chp == '\\') + { + chp++; + arg[len] = parse_escape (&chp); + } + else + arg[len] = *chp++; + len++; + } + arg[len] = '\0'; + chp++; /* that closing quote. */ + break; + } + default: + { + /* An unquoted string. Accumulate all non blank + characters into a buffer. */ + int len; + char *start = chp; + while (*chp != '\0' && !isspace (*chp)) + { + chp++; + } + len = chp - start; + arg = xmalloc ((len + 1) * sizeof (char)); + strncpy (arg, start, len); + arg[len] = '\0'; + break; + } + } + /* 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) +{ + if (parse == NULL) + return; + if (parse->command != NULL) + xfree (parse->command); + if (parse->token != NULL) + xfree (parse->token); + if (parse->args != NULL) + xfree (parse->args); + if (parse->argv != NULL) + freeargv (parse->argv); + xfree (parse); +} + + +struct mi_parse * +mi_parse (char *cmd) +{ + char *chp; + struct mi_parse *parse = XMALLOC (struct mi_parse); + memset (parse, 0, sizeof (*parse)); + + /* Before starting, skip leading white space. */ + while (isspace (*cmd)) + cmd++; + + /* Find/skip any token and then extract it. */ + for (chp = cmd; *chp >= '0' && *chp <= '9'; chp++) + ; + parse->token = xmalloc ((chp - cmd + 1) * sizeof (char *)); + memcpy (parse->token, cmd, (chp - cmd)); + parse->token[chp - cmd] = '\0'; + + /* This wasn't a real MI command. Return it as a CLI_COMMAND. */ + if (*chp != '-') + { + while (isspace (*chp)) + chp++; + parse->command = xstrdup (chp); + parse->op = CLI_COMMAND; + return parse; + } + + /* Extract the command. */ + { + char *tmp = chp + 1; /* discard ``-'' */ + for (; *chp && !isspace (*chp); chp++) + ; + parse->command = xmalloc ((chp - tmp + 1) * sizeof (char *)); + memcpy (parse->command, tmp, chp - tmp); + parse->command[chp - tmp] = '\0'; + } + + /* Find the command in the MI table. */ + parse->cmd = mi_lookup (parse->command); + if (parse->cmd == NULL) + { + /* FIXME: This should be a function call. */ + fprintf_unfiltered + (raw_stdout, + "%s^error,msg=\"Undefined MI command: %s\"\n", + parse->token, parse->command); + mi_parse_free (parse); + return NULL; + } + + /* Skip white space following the command. */ + while (isspace (*chp)) + chp++; + + /* For new argv commands, attempt to return the parsed argument + list. */ + if (parse->cmd->argv_func != NULL) + { + mi_parse_argv (chp, parse); + if (parse->argv == NULL) + { + /* FIXME: This should be a function call. */ + fprintf_unfiltered + (raw_stdout, + "%s^error,msg=\"Problem parsing arguments: %s %s\"\n", + parse->token, parse->command, chp); + mi_parse_free (parse); + return NULL; + } + } + + /* FIXME: DELETE THIS */ + /* For CLI and old ARGS commands, also return the remainder of the + command line as a single string. */ + if (parse->cmd->args_func != NULL + || parse->cmd->cli.cmd != NULL) + { + parse->args = xstrdup (chp); + } + + /* Fully parsed. */ + parse->op = MI_COMMAND; + return parse; +}
mi-parse.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: gdb-mi.el =================================================================== --- gdb-mi.el (nonexistent) +++ gdb-mi.el (revision 816) @@ -0,0 +1,608 @@ +;;; gdb-mi.el + +;; Author: Nick Roberts +;; Maintainer: Nick Roberts +;; Keywords: unix, tools + +;; Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. + +;; This file is part of GNU GDB. + +;; GNU GDB is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;;; Commentary: + +;; This mode acts as a graphical user interface to GDB and works with Emacs +;; 22.x and the version of GDB with which it is distributed. You can interact +;; with GDB through the GUD buffer in the usual way, but there are also +;; buffers which control the execution and describe the state of your program. +;; It separates the input/output of your program from that of GDB and displays +;; expressions and their current values in their own buffers. It also uses +;; features of Emacs 21 such as the fringe/display margin for breakpoints, and +;; the toolbar (see the GDB Graphical Interface section in the Emacs info +;; manual). + +;; Start the debugger with M-x gdbmi. + +;; This file uses GDB/MI as the primary interface to GDB. It is still under +;; development and is part of a process to migrate Emacs from annotations (as +;; used in gdb-ui.el) to GDB/MI. It runs gdb with GDB/MI (-interp=mi) and +;; access CLI using "-interpreter-exec console cli-command". + +;; This mode acts on top of gdb-ui.el. After the release of 22.1, +;; mainline Emacs in the CVS repository will have a file also called gdb-mi.el +;; which will *replace* gdb-ui.el. If you are interested in developing +;; this mode you should get this version. +;; +;; Known Bugs: +;; +;; 1) To handle program input, if required, and to avoid extra output in the +;; GUD buffer you must not use run, step, next or continue etc but their MI +;; counterparts through gud-run, gud-step etc, e.g clicking on the appropriate +;; icon in the toolbar. +;; 2) Some commands send extra prompts to the GUD buffer. +;; 3) Doesn't list catchpoints in breakpoints buffer. +;; +;; TODO: +;; 1) Prefix MI commands with a token instead of queueing commands. +;; 2) Use MI command -data-read-memory for memory window. +;; 3) Use MI command -data-disassemble for disassembly window. +;; 4) Allow separate buffers for Inferior IO and GDB IO. +;; 5) Watch windows to work with threads. +;; +;;; Code: + +(require 'gud) +(require 'gdb-ui) + +(defvar gdb-last-command nil) +(defvar gdb-prompt-name nil) + +;;;###autoload +(defun gdbmi (command-line) + "Run gdb on program FILE in buffer *gud-FILE*. +The directory containing FILE becomes the initial working directory +and source-file directory for your debugger. + +If `gdb-many-windows' is nil (the default value) then gdb just +pops up the GUD buffer unless `gdb-show-main' is t. In this case +it starts with two windows: one displaying the GUD buffer and the +other with the source file with the main routine of the inferior. + +If `gdb-many-windows' is t, regardless of the value of +`gdb-show-main', the layout below will appear. Keybindings are +given in relevant buffer. + +Watch expressions appear in the speedbar/slowbar. + +The following commands help control operation : + +`gdb-many-windows' - Toggle the number of windows gdb uses. +`gdb-restore-windows' - To restore the window layout. + +See Info node `(emacs)GDB Graphical Interface' for a more +detailed description of this mode. + + ++--------------------------------------------------------------+ +| GDB Toolbar | ++-------------------------------+------------------------------+ +| GUD buffer (I/O of GDB) | Locals buffer | +| | | +| | | +| | | ++-------------------------------+------------------------------+ +| Source buffer | +| | +| | +| | +| | +| | +| | +| | ++-------------------------------+------------------------------+ +| Stack buffer | Breakpoints buffer | +| RET gdb-frames-select | SPC gdb-toggle-breakpoint | +| | RET gdb-goto-breakpoint | +| | d gdb-delete-breakpoint | ++-------------------------------+------------------------------+" + ;; + (interactive (list (gud-query-cmdline 'gdbmi))) + ;; + ;; Let's start with a basic gud-gdb buffer and then modify it a bit. + (gdb command-line) + ;; + (setq gdb-debug-ring nil) + (set (make-local-variable 'gud-minor-mode) 'gdbmi) + (set (make-local-variable 'gud-marker-filter) 'gud-gdbmi-marker-filter) + ;; + (gud-def gud-step "-exec-step %p" "\C-s" + "Step one source line with display.") + (gud-def gud-stepi "-exec-step-instruction %p" "\C-i" + "Step one instruction with display.") + (gud-def gud-next "-exec-next %p" "\C-n" + "Step one line (skip functions).") + (gud-def gud-cont "-exec-continue" "\C-r" + "Continue with display.") + (gud-def gud-finish "-exec-finish" "\C-f" + "Finish executing current function.") + (gud-def gud-run "-exec-run" nil "Run the program.") + (gud-def gud-break (if (not (string-equal mode-name "Machine")) + (gud-call "break %f:%l" arg) + (save-excursion + (beginning-of-line) + (forward-char 2) + (gud-call "break *%a" arg))) + "\C-b" "Set breakpoint at current line or address.") + ;; + (gud-def gud-remove (if (not (string-equal mode-name "Machine")) + (gud-call "clear %f:%l" arg) + (save-excursion + (beginning-of-line) + (forward-char 2) + (gud-call "clear *%a" arg))) + "\C-d" "Remove breakpoint at current line or address.") + ;; + (gud-def gud-until (if (not (string-equal mode-name "Machine")) + (gud-call "-exec-until %f:%l" arg) + (save-excursion + (beginning-of-line) + (forward-char 2) + (gud-call "-exec-until *%a" arg))) + "\C-u" "Continue to current line or address.") + + (define-key gud-minor-mode-map [left-margin mouse-1] + 'gdb-mouse-set-clear-breakpoint) + (define-key gud-minor-mode-map [left-fringe mouse-1] + 'gdb-mouse-set-clear-breakpoint) + (define-key gud-minor-mode-map [left-fringe mouse-2] + 'gdb-mouse-until) + (define-key gud-minor-mode-map [left-fringe drag-mouse-1] + 'gdb-mouse-until) + (define-key gud-minor-mode-map [left-margin mouse-3] + 'gdb-mouse-toggle-breakpoint-margin) + (define-key gud-minor-mode-map [left-fringe mouse-3] + 'gdb-mouse-toggle-breakpoint-fringe) + + (setq comint-input-sender 'gdbmi-send) + ;; + ;; (re-)initialise + (setq gdb-pc-address (if gdb-show-main "main" nil) + gdb-previous-frame-address nil + gdb-memory-address "main" + gdb-previous-frame nil + gdb-selected-frame nil + gdb-frame-number nil + gdb-var-list nil + gdb-prompting nil + gdb-input-queue nil + gdb-current-item nil + gdb-pending-triggers nil + gdb-output-sink 'user + gdb-server-prefix nil + gdb-flush-pending-output nil + gdb-location-alist nil + gdb-source-file-list nil + gdb-last-command nil + gdb-prompt-name nil + gdb-buffer-fringe-width (car (window-fringes))) + gdb-debug-ring nil + gdb-source-window nil + gdb-inferior-status nil + gdb-continuation nil + ;; + (setq gdb-buffer-type 'gdbmi) + ;; + ;; FIXME: use tty command to separate io. + ;;(gdb-clear-inferior-io) + ;; + (if (eq window-system 'w32) + (gdb-enqueue-input (list "-gdb-set new-console off\n" 'ignore))) + (gdb-enqueue-input (list "-gdb-set height 0\n" 'ignore)) + ;; find source file and compilation directory here + (gdb-enqueue-input + ; Needs GDB 6.2 onwards. + (list "-file-list-exec-source-files\n" + 'gdb-set-gud-minor-mode-existing-buffers-1)) + (gdb-enqueue-input + ; Needs GDB 6.0 onwards. + (list "-file-list-exec-source-file\n" 'gdb-get-source-file)) + (gdb-enqueue-input + (list "-data-list-register-names\n" 'gdb-get-register-names)) + (gdb-enqueue-input + (list "-gdb-show prompt\n" 'gdb-get-prompt)) + ;; + (setq gdb-locals-font-lock-keywords gdb-locals-font-lock-keywords-2) + (run-hooks 'gdbmi-mode-hook)) + + +(defun gdbmi-send (proc string) + "A comint send filter for gdb." + (if gud-running + (process-send-string proc (concat string "\n")) + (with-current-buffer gud-comint-buffer + (let ((inhibit-read-only t)) + (remove-text-properties (point-min) (point-max) '(face)))) + (setq gdb-output-sink 'user) + (setq gdb-prompting nil) + ;; mimic key to repeat previous command in GDB + (if (not (string-match "^\\s+$" string)) + (setq gdb-last-command string) + (if gdb-last-command (setq string gdb-last-command))) + (if gdb-enable-debug + (push (cons 'mi-send (concat string "\n")) gdb-debug-ring)) + (if (string-match "^-" string) + ;; MI command + (process-send-string proc (concat string "\n")) + ;; CLI command + (if (string-match "\\\\$" string) + (setq gdb-continuation (concat gdb-continuation string "\n")) + (process-send-string proc + (concat "-interpreter-exec console \"" + gdb-continuation string "\"\n")) + (setq gdb-continuation nil))))) + +(defcustom gud-gdbmi-command-name "gdb -interp=mi" + "Default command to execute an executable under the GDB-UI debugger." + :type 'string + :group 'gud) + +(defconst gdb-gdb-regexp "(gdb) \n") + +(defconst gdb-running-regexp (concat "\\^running\n" gdb-gdb-regexp)) + +;; fullname added GDB 6.4+. +;; Probably not needed. -stack-info-frame computes filename and line. +(defconst gdb-stopped-regexp + "\\*stopped,reason=.*?,file=\".*?\"\ +,fullname=\"\\(.*?\\)\",line=\"\\(.*?\\)\"}\n") + +(defconst gdb-error-regexp "\\^error,msg=\\(\".+\"\\)\n") + +(defconst gdb-done-regexp "\\^done,*\n*") + +(defconst gdb-console-regexp "~\\(\".*?[^\\]\"\\)\n") + +(defconst gdb-internals-regexp "&\\(\".*?\\n\"\\)\n") + +(defun gdbmi-prompt1 () + "Queue any GDB commands that the user interface needs." + (unless gdb-pending-triggers + (gdbmi-get-selected-frame) + (gdbmi-invalidate-frames) + (gdbmi-invalidate-breakpoints) + (gdb-get-changed-registers) + (gdb-invalidate-registers-1) + (gdb-invalidate-locals-1) + (if (and (boundp 'speedbar-frame) (frame-live-p speedbar-frame)) + (gdb-var-update-1)))) + +(defun gdbmi-prompt2 () + "Handle any output and send next GDB command." + (let ((sink gdb-output-sink)) + (when (eq sink 'emacs) + (let ((handler + (car (cdr gdb-current-item)))) + (with-current-buffer (gdb-get-buffer-create 'gdb-partial-output-buffer) + (funcall handler))))) + (let ((input (gdb-dequeue-input))) + (if input + (gdb-send-item input) + (progn + (setq gud-running nil) + (setq gdb-prompting t) + (gud-display-frame))))) + +(defun gud-gdbmi-marker-filter (string) + "Filter GDB/MI output." + (if gdb-flush-pending-output + nil + (if gdb-enable-debug (push (cons 'recv (list string gdb-output-sink)) + gdb-debug-ring)) + ;; Recall the left over gud-marker-acc from last time + (setq gud-marker-acc (concat gud-marker-acc string)) + ;; Start accumulating output for the GUD buffer + (let ((output "") running) + + (if (string-match gdb-running-regexp gud-marker-acc) + (setq + gud-marker-acc + (concat (substring gud-marker-acc 0 (match-beginning 0)) + (substring gud-marker-acc (match-end 0))) + running t)) + + (if (string-match gdb-stopped-regexp gud-marker-acc) + (setq + + ;; Extract the frame position from the marker. + gud-last-frame (cons (match-string 1 gud-marker-acc) + (string-to-number + (match-string 2 gud-marker-acc))) + + gud-marker-acc + (concat (substring gud-marker-acc 0 (match-beginning 0)) + (substring gud-marker-acc (match-end 0))))) + + ;; Filter error messages going to GUD buffer and + ;; display in minibuffer. + (when (eq gdb-output-sink 'user) + (while (string-match gdb-error-regexp gud-marker-acc) + (message (read (match-string 1 gud-marker-acc))) + (setq + gud-marker-acc + (concat (substring gud-marker-acc 0 (match-beginning 0)) + (substring gud-marker-acc (match-end 0))))) + + (if (string-match gdb-done-regexp gud-marker-acc) + (setq + gud-marker-acc + (concat (substring gud-marker-acc 0 (match-beginning 0)) + (substring gud-marker-acc (match-end 0)))))) + + (when (string-match gdb-gdb-regexp gud-marker-acc) + (setq + gud-marker-acc + (concat (substring gud-marker-acc 0 (match-beginning 0)) + (substring gud-marker-acc (match-end 0)))) + + ;; Remove the trimmings from the console stream. + (while (string-match gdb-console-regexp gud-marker-acc) + (setq + gud-marker-acc (concat + (substring gud-marker-acc 0 (match-beginning 0)) + (read (match-string 1 gud-marker-acc)) + (substring gud-marker-acc (match-end 0))))) + + ;; Remove the trimmings from log stream containing debugging messages + ;; being produced by GDB's internals and use warning face. + (while (string-match gdb-internals-regexp gud-marker-acc) + (setq + gud-marker-acc + (concat (substring gud-marker-acc 0 (match-beginning 0)) + (let ((error-message + (read (match-string 1 gud-marker-acc)))) + (put-text-property + 0 (length error-message) + 'face font-lock-warning-face + error-message) + error-message) + (substring gud-marker-acc (match-end 0))))) + + (setq output (gdbmi-concat-output output gud-marker-acc)) + (setq gud-marker-acc "") + (gdbmi-prompt1) + (unless gdb-input-queue + (setq output (concat output gdb-prompt-name))) + (gdbmi-prompt2) + (setq gud-running running)) + + (when gud-running + (setq output (gdbmi-concat-output output gud-marker-acc)) + (setq gud-marker-acc "")) + + output))) + +(defun gdbmi-concat-output (so-far new) + (let ((sink gdb-output-sink)) + (cond + ((eq sink 'user) (concat so-far new)) + ((eq sink 'emacs) + (gdb-append-to-partial-output new) + so-far) + ((eq sink 'inferior) + (gdb-append-to-inferior-io new) + so-far)))) + + +;; Breakpoint buffer : This displays the output of `-break-list'. +;; +(def-gdb-auto-update-trigger gdbmi-invalidate-breakpoints + (gdb-get-buffer 'gdb-breakpoints-buffer) + "-break-list\n" + gdb-break-list-handler) + +(defconst gdb-break-list-regexp +"bkpt={.*?number=\"\\(.*?\\)\",.*?type=\"\\(.*?\\)\",.*?disp=\"\\(.*?\\)\",.*?\ +enabled=\"\\(.\\)\",.*?addr=\"\\(.*?\\)\",\\(?:.*?func=\"\\(.*?\\)\",.*?\ +file=\"\\(.*?\\)\",.*?fullname=\".*?\",.*?line=\"\\(.*?\\)\",\ +\\|\\(?:.*?what=\"\\(.*?\\)\",\\)*\\).*?times=\"\\(.*?\\)\".*?}") + +(defun gdb-break-list-handler () + (setq gdb-pending-triggers (delq 'gdbmi-invalidate-breakpoints + gdb-pending-triggers)) + (let ((breakpoint) (breakpoints-list)) + (with-current-buffer (gdb-get-buffer-create 'gdb-partial-output-buffer) + (goto-char (point-min)) + (while (re-search-forward gdb-break-list-regexp nil t) + (let ((breakpoint (list (match-string 1) + (match-string 2) + (match-string 3) + (match-string 4) + (match-string 5) + (match-string 6) + (match-string 7) + (match-string 8) + (match-string 9) + (match-string 10)))) + (push breakpoint breakpoints-list)))) + (let ((buf (gdb-get-buffer 'gdb-breakpoints-buffer))) + (and buf (with-current-buffer buf + (let ((p (point)) + (buffer-read-only nil)) + (erase-buffer) + (insert "Num Type Disp Enb Hits Addr What\n") + (dolist (breakpoint breakpoints-list) + (insert + (concat + (nth 0 breakpoint) " " + (nth 1 breakpoint) " " + (nth 2 breakpoint) " " + (nth 3 breakpoint) " " + (nth 9 breakpoint) " " + (nth 4 breakpoint) " " + (if (nth 5 breakpoint) + (concat "in " (nth 5 breakpoint) " at " (nth 6 breakpoint) ":" (nth 7 breakpoint) "\n") + (concat (nth 8 breakpoint) "\n"))))) + (goto-char p)))))) + (gdb-info-breakpoints-custom)) + +(defun gdbmi-get-location (bptno line flag) + "Find the directory containing the relevant source file. +Put in buffer and place breakpoint icon." + (goto-char (point-min)) + (catch 'file-not-found + (if (re-search-forward gdb-source-file-regexp-1 nil t) + (delete (cons bptno "File not found") gdb-location-alist) + (push (cons bptno (match-string 1)) gdb-location-alist) + (gdb-resync) + (unless (assoc bptno gdb-location-alist) + (push (cons bptno "File not found") gdb-location-alist) + (message-box "Cannot find source file for breakpoint location. +Add directory to search path for source files using the GDB command, dir.")) + (throw 'file-not-found nil)) + (with-current-buffer + (find-file-noselect (match-string 1)) + (save-current-buffer + (set (make-local-variable 'gud-minor-mode) 'gdbmi) + (set (make-local-variable 'tool-bar-map) gud-tool-bar-map)) + ;; only want one breakpoint icon at each location + (save-excursion + (goto-line (string-to-number line)) + (gdb-put-breakpoint-icon (eq flag ?y) bptno))))) + +;; Frames buffer. This displays a perpetually correct bactrack trace. +;; +(def-gdb-auto-update-trigger gdbmi-invalidate-frames + (gdb-get-buffer 'gdb-stack-buffer) + "-stack-list-frames\n" + gdb-stack-list-frames-handler) + +(defconst gdb-stack-list-frames-regexp +"{.*?level=\"\\(.*?\\)\",.*?addr=\"\\(.*?\\)\",.*?func=\"\\(.*?\\)\",\ +\\(?:.*?file=\".*?\",.*?fullname=\"\\(.*?\\)\",.*?line=\"\\(.*?\\)\".*?}\\|\ +from=\"\\(.*?\\)\"\\)") + +(defun gdb-stack-list-frames-handler () + (setq gdb-pending-triggers (delq 'gdbmi-invalidate-frames + gdb-pending-triggers)) + (let ((frame nil) + (call-stack nil)) + (with-current-buffer (gdb-get-buffer-create 'gdb-partial-output-buffer) + (goto-char (point-min)) + (while (re-search-forward gdb-stack-list-frames-regexp nil t) + (let ((frame (list (match-string 1) + (match-string 2) + (match-string 3) + (match-string 4) + (match-string 5) + (match-string 6)))) + (push frame call-stack)))) + (let ((buf (gdb-get-buffer 'gdb-stack-buffer))) + (and buf (with-current-buffer buf + (let ((p (point)) + (buffer-read-only nil)) + (erase-buffer) + (insert "Level\tAddr\tFunc\tFile:Line\n") + (dolist (frame (nreverse call-stack)) + (insert + (concat + (nth 0 frame) "\t" + (nth 1 frame) "\t" + (propertize (nth 2 frame) + 'face font-lock-function-name-face) "\t" + (if (nth 3 frame) + (concat "at "(nth 3 frame) ":" (nth 4 frame) "\n") + (concat "from " (nth 5 frame) "\n"))))) + (goto-char p)))))) + (gdb-stack-list-frames-custom)) + +(defun gdb-stack-list-frames-custom () + (with-current-buffer (gdb-get-buffer 'gdb-stack-buffer) + (save-excursion + (let ((buffer-read-only nil)) + (goto-char (point-min)) + (forward-line 1) + (while (< (point) (point-max)) + (add-text-properties (point-at-bol) (point-at-eol) + '(mouse-face highlight + help-echo "mouse-2, RET: Select frame")) + (beginning-of-line) + (when (and (looking-at "^[0-9]+\\s-+\\(\\S-+\\)") + (equal (match-string 1) gdb-selected-frame)) + (put-text-property (point-at-bol) (point-at-eol) + 'face '(:inverse-video t))) + (forward-line 1)))))) + + +;; gdb-ui.el uses "info source" to find out if macro information is present. +(defun gdb-get-source-file () + "Find the source file where the program starts and display it with related +buffers, if required." + (goto-char (point-min)) + (if (re-search-forward gdb-source-file-regexp-1 nil t) + (setq gdb-main-file (match-string 1))) + (if gdb-many-windows + (gdb-setup-windows) + (gdb-get-buffer-create 'gdb-breakpoints-buffer) + (if gdb-show-main + (let ((pop-up-windows t)) + (display-buffer (gud-find-file gdb-main-file)))))) + +(defun gdbmi-get-selected-frame () + (if (not (member 'gdbmi-get-selected-frame gdb-pending-triggers)) + (progn + (gdb-enqueue-input + (list "-stack-info-frame\n" 'gdbmi-frame-handler)) + (push 'gdbmi-get-selected-frame + gdb-pending-triggers)))) + +(defun gdbmi-frame-handler () + (setq gdb-pending-triggers + (delq 'gdbmi-get-selected-frame gdb-pending-triggers)) + (with-current-buffer (gdb-get-buffer-create 'gdb-partial-output-buffer) + (goto-char (point-min)) + (when (re-search-forward gdb-stack-list-frames-regexp nil t) + (setq gdb-frame-number (match-string 1)) + (setq gdb-pc-address (match-string 2)) + (setq gdb-selected-frame (match-string 3)) + (when (match-string 4) + (setq gud-last-frame + (cons (match-string 4) (string-to-number (match-string 5)))) + (gud-display-frame) + (if gud-overlay-arrow-position + (let ((buffer (marker-buffer gud-overlay-arrow-position)) + (position (marker-position gud-overlay-arrow-position))) + (when buffer + (with-current-buffer buffer + (setq fringe-indicator-alist + (if (string-equal gdb-frame-number "0") + nil + '((overlay-arrow . hollow-right-triangle)))) + (setq gud-overlay-arrow-position (make-marker)) + (set-marker gud-overlay-arrow-position position)))))) + (if (gdb-get-buffer 'gdb-locals-buffer) + (with-current-buffer (gdb-get-buffer 'gdb-locals-buffer) + (setq mode-name (concat "Locals:" gdb-selected-frame)))) + (if (gdb-get-buffer 'gdb-assembler-buffer) + (with-current-buffer (gdb-get-buffer 'gdb-assembler-buffer) + (setq mode-name (concat "Machine:" gdb-selected-frame))))))) + +(defvar gdb-prompt-name-regexp "value=\"\\(.*?\\)\"") + +(defun gdb-get-prompt () + "Find prompt for GDB session." + (goto-char (point-min)) + (setq gdb-prompt-name nil) + (re-search-forward gdb-prompt-name-regexp nil t) + (setq gdb-prompt-name (match-string 1))) + +(provide 'gdb-mi) +;;; gdbmi.el ends here Index: mi-out.h =================================================================== --- mi-out.h (nonexistent) +++ mi-out.h (revision 816) @@ -0,0 +1,34 @@ +/* MI Command Set - MI output generating routines for GDB. + Copyright (C) 2000, 2007, 2008 Free Software Foundation, Inc. + Contributed by Cygnus Solutions (a Red Hat company). + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef MI_OUT_H +#define MI_OUT_H 1 + +struct ui_out; +struct ui_file; + +extern struct ui_out *mi_out_new (int mi_version); +extern void mi_out_put (struct ui_out *uiout, struct ui_file *stream); +extern void mi_out_rewind (struct ui_out *uiout); +extern void mi_out_buffered (struct ui_out *uiout, char *string); + +/* Return the version number of the current MI. */ +extern int mi_version (struct ui_out *uiout); + +#endif /* MI_OUT_H */
mi-out.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mi-parse.h =================================================================== --- mi-parse.h (nonexistent) +++ mi-parse.h (revision 816) @@ -0,0 +1,63 @@ +/* MI Command Set - MI Command Parser. + Copyright (C) 2000, 2007, 2008 Free Software Foundation, Inc. + Contributed by Cygnus Solutions (a Red Hat company). + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef MI_PARSE_H +#define MI_PARSE_H + +#include + +/* MI parser */ + +/* Timestamps for current command and last asynchronous command. */ +struct mi_timestamp { + struct timeval wallclock; + struct timeval utime; + struct timeval stime; +}; + +enum mi_command_type + { + MI_COMMAND, CLI_COMMAND + }; + +struct mi_parse + { + enum mi_command_type op; + char *command; + char *token; + const struct mi_cmd *cmd; + struct mi_timestamp *cmd_start; + char *args; + char **argv; + int argc; + }; + +/* Attempts to parse CMD returning a ``struct mi_command''. If CMD is + invalid, an error mesage is reported (MI format) and NULL is + returned. For a CLI_COMMAND, COMMAND, TOKEN and OP are initialized. + For an MI_COMMAND COMMAND, TOKEN, ARGS and OP are + initialized. Un-initialized fields are zero. */ + +extern struct mi_parse *mi_parse (char *cmd); + +/* Free a command returned by mi_parse_command. */ + +extern void mi_parse_free (struct mi_parse *cmd); + +#endif
mi-parse.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mi-cmd-file.c =================================================================== --- mi-cmd-file.c (nonexistent) +++ mi-cmd-file.c (revision 816) @@ -0,0 +1,118 @@ +/* MI Command Set - breakpoint and watchpoint commands. + Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. + Contributed by Cygnus Solutions (a Red Hat company). + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include "defs.h" +#include "mi-cmds.h" +#include "mi-getopt.h" +#include "ui-out.h" +#include "symtab.h" +#include "source.h" +#include "objfiles.h" + +/* Return to the client the absolute path and line number of the + current file being executed. */ + +enum mi_cmd_result +mi_cmd_file_list_exec_source_file (char *command, char **argv, int argc) +{ + struct symtab_and_line st; + int optind = 0; + char *optarg; + + if (!mi_valid_noargs ("mi_cmd_file_list_exec_source_file", argc, argv)) + error (_("mi_cmd_file_list_exec_source_file: Usage: No args")); + + /* 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 */ + if (!st.symtab) + error (_("mi_cmd_file_list_exec_source_file: No symtab")); + + /* Extract the fullname if it is not known yet */ + symtab_to_fullname (st.symtab); + + /* 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); + + /* We may not be able to open the file (not available). */ + if (st.symtab->fullname) + ui_out_field_string (uiout, "fullname", st.symtab->fullname); + + ui_out_field_int (uiout, "macro-info", st.symtab->macro_table ? 1 : 0); + + return MI_CMD_DONE; +} + +enum mi_cmd_result +mi_cmd_file_list_exec_source_files (char *command, char **argv, int argc) +{ + struct symtab *s; + struct partial_symtab *ps; + struct objfile *objfile; + + if (!mi_valid_noargs ("mi_cmd_file_list_exec_source_files", argc, argv)) + error (_("mi_cmd_file_list_exec_source_files: Usage: No args")); + + /* Print the table header */ + ui_out_begin (uiout, ui_out_type_list, "files"); + + /* 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 */ + symtab_to_fullname (s); + + if (s->fullname) + ui_out_field_string (uiout, "fullname", s->fullname); + + ui_out_end (uiout, ui_out_type_tuple); + } + + /* Look at all of the psymtabs */ + ALL_PSYMTABS (objfile, ps) + { + if (!ps->readin) + { + ui_out_begin (uiout, ui_out_type_tuple, NULL); + + ui_out_field_string (uiout, "file", ps->filename); + + /* Extract the fullname if it is not known yet */ + psymtab_to_fullname (ps); + + if (ps->fullname) + ui_out_field_string (uiout, "fullname", ps->fullname); + + ui_out_end (uiout, ui_out_type_tuple); + } + } + + ui_out_end (uiout, ui_out_type_list); + + return MI_CMD_DONE; +}
mi-cmd-file.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mi-main.c =================================================================== --- mi-main.c (nonexistent) +++ mi-main.c (revision 816) @@ -0,0 +1,1571 @@ +/* MI Command Set. + + Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008 + Free Software Foundation, Inc. + + Contributed by Cygnus Solutions (a Red Hat company). + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Work in progress. */ + +#include "defs.h" +#include "target.h" +#include "inferior.h" +#include "gdb_string.h" +#include "exceptions.h" +#include "top.h" +#include "gdbthread.h" +#include "mi-cmds.h" +#include "mi-parse.h" +#include "mi-getopt.h" +#include "mi-console.h" +#include "ui-out.h" +#include "mi-out.h" +#include "interps.h" +#include "event-loop.h" +#include "event-top.h" +#include "gdbcore.h" /* For write_memory(). */ +#include "value.h" +#include "regcache.h" +#include "gdb.h" +#include "frame.h" +#include "mi-main.h" + +#include +#include + +#if defined HAVE_SYS_RESOURCE_H +#include +#endif + +#ifdef HAVE_GETRUSAGE +struct rusage rusage; +#endif + +enum + { + FROM_TTY = 0 + }; + +/* Enumerations of the actions that may result from calling + captured_mi_execute_command. */ + +enum captured_mi_execute_command_actions + { + EXECUTE_COMMAND_DISPLAY_PROMPT, + EXECUTE_COMMAND_SUPRESS_PROMPT + }; + +/* This structure is used to pass information from captured_mi_execute_command + to mi_execute_command. */ +struct captured_mi_execute_command_args +{ + /* This return result of the MI command (output). */ + enum mi_cmd_result rc; + + /* What action to perform when the call is finished (output). */ + enum captured_mi_execute_command_actions action; + + /* The command context to be executed (input). */ + struct mi_parse *command; +}; + +int mi_debug_p; +struct ui_file *raw_stdout; + +/* 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; + +/* The token of the last asynchronous command. */ +static char *last_async_command; +static char *previous_async_command; +char *mi_error_message; + +extern void _initialize_mi_main (void); +static enum mi_cmd_result mi_cmd_execute (struct mi_parse *parse); + +static void mi_execute_cli_command (const char *cmd, int args_p, + const char *args); +static enum mi_cmd_result mi_execute_async_cli_command (char *mi, char *args, int from_tty); + +static void mi_exec_async_cli_cmd_continuation (struct continuation_arg *arg); + +static int register_changed_p (int regnum, struct regcache *, + struct regcache *); +static int get_register (int regnum, int format); + +/* Command implementations. FIXME: Is this libgdb? No. This is the MI + layer that calls libgdb. Any operation used in the below should be + formalized. */ + +static void timestamp (struct mi_timestamp *tv); + +static void print_diff_now (struct mi_timestamp *start); +static void print_diff (struct mi_timestamp *start, struct mi_timestamp *end); + +enum mi_cmd_result +mi_cmd_gdb_exit (char *command, char **argv, int argc) +{ + /* We have to print everything right here because we never return. */ + if (last_async_command) + fputs_unfiltered (last_async_command, raw_stdout); + fputs_unfiltered ("^exit\n", raw_stdout); + mi_out_put (uiout, raw_stdout); + /* FIXME: The function called is not yet a formal libgdb function. */ + quit_force (NULL, FROM_TTY); + return MI_CMD_DONE; +} + +enum mi_cmd_result +mi_cmd_exec_run (char *args, int from_tty) +{ + /* FIXME: Should call a libgdb function, not a cli wrapper. */ + return mi_execute_async_cli_command ("run", args, from_tty); +} + +enum mi_cmd_result +mi_cmd_exec_next (char *args, int from_tty) +{ + /* FIXME: Should call a libgdb function, not a cli wrapper. */ + return mi_execute_async_cli_command ("next", args, from_tty); +} + +enum mi_cmd_result +mi_cmd_exec_next_instruction (char *args, int from_tty) +{ + /* FIXME: Should call a libgdb function, not a cli wrapper. */ + return mi_execute_async_cli_command ("nexti", args, from_tty); +} + +enum mi_cmd_result +mi_cmd_exec_step (char *args, int from_tty) +{ + /* FIXME: Should call a libgdb function, not a cli wrapper. */ + return mi_execute_async_cli_command ("step", args, from_tty); +} + +enum mi_cmd_result +mi_cmd_exec_step_instruction (char *args, int from_tty) +{ + /* FIXME: Should call a libgdb function, not a cli wrapper. */ + return mi_execute_async_cli_command ("stepi", args, from_tty); +} + +enum mi_cmd_result +mi_cmd_exec_finish (char *args, int from_tty) +{ + /* FIXME: Should call a libgdb function, not a cli wrapper. */ + return mi_execute_async_cli_command ("finish", args, from_tty); +} + +enum mi_cmd_result +mi_cmd_exec_until (char *args, int from_tty) +{ + /* FIXME: Should call a libgdb function, not a cli wrapper. */ + return mi_execute_async_cli_command ("until", args, from_tty); +} + +enum mi_cmd_result +mi_cmd_exec_return (char *args, int from_tty) +{ + /* This command doesn't really execute the target, it just pops the + specified number of frames. */ + if (*args) + /* Call return_command with from_tty argument equal to 0 so as to + avoid being queried. */ + return_command (args, 0); + else + /* Call return_command with from_tty argument equal to 0 so as to + avoid being queried. */ + return_command (NULL, 0); + + /* Because we have called return_command with from_tty = 0, we need + to print the frame here. */ + print_stack_frame (get_selected_frame (NULL), 1, LOC_AND_ADDRESS); + + return MI_CMD_DONE; +} + +enum mi_cmd_result +mi_cmd_exec_continue (char *args, int from_tty) +{ + /* FIXME: Should call a libgdb function, not a cli wrapper. */ + return mi_execute_async_cli_command ("continue", args, from_tty); +} + +/* 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. */ +enum mi_cmd_result +mi_cmd_exec_interrupt (char *args, int from_tty) +{ + if (!target_executing) + { + mi_error_message = xstrprintf ("mi_cmd_exec_interrupt: Inferior not executing."); + return MI_CMD_ERROR; + } + interrupt_target_command (args, from_tty); + if (last_async_command) + fputs_unfiltered (last_async_command, raw_stdout); + fputs_unfiltered ("^done", raw_stdout); + xfree (last_async_command); + if (previous_async_command) + last_async_command = xstrdup (previous_async_command); + xfree (previous_async_command); + previous_async_command = NULL; + mi_out_put (uiout, raw_stdout); + mi_out_rewind (uiout); + fputs_unfiltered ("\n", raw_stdout); + return MI_CMD_QUIET; +} + +enum mi_cmd_result +mi_cmd_thread_select (char *command, char **argv, int argc) +{ + enum gdb_rc rc; + + if (argc != 1) + { + mi_error_message = xstrprintf ("mi_cmd_thread_select: USAGE: threadnum."); + return MI_CMD_ERROR; + } + else + rc = gdb_thread_select (uiout, argv[0], &mi_error_message); + + if (rc == GDB_RC_FAIL) + return MI_CMD_ERROR; + else + return MI_CMD_DONE; +} + +enum mi_cmd_result +mi_cmd_thread_list_ids (char *command, char **argv, int argc) +{ + enum gdb_rc rc; + + if (argc != 0) + { + mi_error_message = xstrprintf ("mi_cmd_thread_list_ids: No arguments required."); + return MI_CMD_ERROR; + } + else + rc = gdb_list_thread_ids (uiout, &mi_error_message); + + if (rc == GDB_RC_FAIL) + return MI_CMD_ERROR; + else + return MI_CMD_DONE; +} + +enum mi_cmd_result +mi_cmd_data_list_register_names (char *command, char **argv, int argc) +{ + int regnum, numregs; + int i; + 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. */ + + numregs = gdbarch_num_regs (current_gdbarch) + + gdbarch_num_pseudo_regs (current_gdbarch); + + cleanup = make_cleanup_ui_out_list_begin_end (uiout, "register-names"); + + if (argc == 0) /* No args, just do all the regs. */ + { + for (regnum = 0; + regnum < numregs; + regnum++) + { + if (gdbarch_register_name (current_gdbarch, regnum) == NULL + || *(gdbarch_register_name (current_gdbarch, regnum)) == '\0') + ui_out_field_string (uiout, NULL, ""); + else + ui_out_field_string (uiout, NULL, + gdbarch_register_name + (current_gdbarch, regnum)); + } + } + + /* Else, list of register #s, just do listed regs. */ + for (i = 0; i < argc; i++) + { + regnum = atoi (argv[i]); + if (regnum < 0 || regnum >= numregs) + { + do_cleanups (cleanup); + mi_error_message = xstrprintf ("bad register number"); + return MI_CMD_ERROR; + } + if (gdbarch_register_name (current_gdbarch, regnum) == NULL + || *(gdbarch_register_name (current_gdbarch, regnum)) == '\0') + ui_out_field_string (uiout, NULL, ""); + else + ui_out_field_string (uiout, NULL, + gdbarch_register_name (current_gdbarch, regnum)); + } + do_cleanups (cleanup); + return MI_CMD_DONE; +} + +enum mi_cmd_result +mi_cmd_data_list_changed_registers (char *command, char **argv, int argc) +{ + static struct regcache *this_regs = NULL; + struct regcache *prev_regs; + int regnum, numregs, changed; + 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. */ + + 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. */ + + numregs = gdbarch_num_regs (current_gdbarch) + + gdbarch_num_pseudo_regs (current_gdbarch); + + make_cleanup_ui_out_list_begin_end (uiout, "changed-registers"); + + if (argc == 0) /* No args, just do all the regs. */ + { + for (regnum = 0; + regnum < numregs; + regnum++) + { + if (gdbarch_register_name (current_gdbarch, regnum) == NULL + || *(gdbarch_register_name (current_gdbarch, regnum)) == '\0') + continue; + changed = register_changed_p (regnum, prev_regs, this_regs); + if (changed < 0) + { + do_cleanups (cleanup); + mi_error_message = xstrprintf ("mi_cmd_data_list_changed_registers: Unable to read register contents."); + return MI_CMD_ERROR; + } + else if (changed) + ui_out_field_int (uiout, NULL, regnum); + } + } + + /* Else, list of register #s, just do listed regs. */ + for (i = 0; i < argc; i++) + { + regnum = atoi (argv[i]); + + if (regnum >= 0 + && regnum < numregs + && gdbarch_register_name (current_gdbarch, regnum) != NULL + && *gdbarch_register_name (current_gdbarch, regnum) != '\000') + { + changed = register_changed_p (regnum, prev_regs, this_regs); + if (changed < 0) + { + do_cleanups (cleanup); + mi_error_message = xstrprintf ("mi_cmd_data_list_register_change: Unable to read register contents."); + return MI_CMD_ERROR; + } + else if (changed) + ui_out_field_int (uiout, NULL, regnum); + } + else + { + do_cleanups (cleanup); + mi_error_message = xstrprintf ("bad register number"); + return MI_CMD_ERROR; + } + } + do_cleanups (cleanup); + return MI_CMD_DONE; +} + +static int +register_changed_p (int regnum, struct regcache *prev_regs, + struct regcache *this_regs) +{ + struct gdbarch *gdbarch = get_regcache_arch (this_regs); + gdb_byte prev_buffer[MAX_REGISTER_SIZE]; + gdb_byte this_buffer[MAX_REGISTER_SIZE]; + + /* Registers not valid in this frame return count as unchanged. */ + if (!regcache_valid_p (this_regs, regnum)) + return 0; + + /* First time through or after gdbarch change consider all registers as + changed. Same for registers not valid in the previous frame. */ + if (!prev_regs || get_regcache_arch (prev_regs) != gdbarch + || !regcache_valid_p (prev_regs, regnum)) + return 1; + + /* Get register contents and compare. */ + regcache_cooked_read (prev_regs, regnum, prev_buffer); + regcache_cooked_read (this_regs, regnum, this_buffer); + + return memcmp (prev_buffer, this_buffer, + register_size (gdbarch, regnum)) != 0; +} + +/* 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. */ +enum mi_cmd_result +mi_cmd_data_list_register_values (char *command, char **argv, int argc) +{ + int regnum, numregs, format, result; + int i; + 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. */ + + numregs = gdbarch_num_regs (current_gdbarch) + + gdbarch_num_pseudo_regs (current_gdbarch); + + if (argc == 0) + { + mi_error_message = xstrprintf ("mi_cmd_data_list_register_values: Usage: -data-list-register-values [...]"); + return MI_CMD_ERROR; + } + + format = (int) argv[0][0]; + + list_cleanup = make_cleanup_ui_out_list_begin_end (uiout, "register-values"); + + if (argc == 1) /* No args, beside the format: do all the regs. */ + { + for (regnum = 0; + regnum < numregs; + regnum++) + { + if (gdbarch_register_name (current_gdbarch, regnum) == NULL + || *(gdbarch_register_name (current_gdbarch, regnum)) == '\0') + continue; + tuple_cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); + ui_out_field_int (uiout, "number", regnum); + result = get_register (regnum, format); + if (result == -1) + { + do_cleanups (list_cleanup); + return MI_CMD_ERROR; + } + do_cleanups (tuple_cleanup); + } + } + + /* Else, list of register #s, just do listed regs. */ + for (i = 1; i < argc; i++) + { + regnum = atoi (argv[i]); + + if (regnum >= 0 + && regnum < numregs + && gdbarch_register_name (current_gdbarch, regnum) != NULL + && *gdbarch_register_name (current_gdbarch, regnum) != '\000') + { + tuple_cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); + ui_out_field_int (uiout, "number", regnum); + result = get_register (regnum, format); + if (result == -1) + { + do_cleanups (list_cleanup); + return MI_CMD_ERROR; + } + do_cleanups (tuple_cleanup); + } + else + { + do_cleanups (list_cleanup); + mi_error_message = xstrprintf ("bad register number"); + return MI_CMD_ERROR; + } + } + do_cleanups (list_cleanup); + return MI_CMD_DONE; +} + +/* Output one register's contents in the desired format. */ +static int +get_register (int regnum, int format) +{ + gdb_byte buffer[MAX_REGISTER_SIZE]; + int optim; + int realnum; + CORE_ADDR addr; + enum lval_type lval; + static struct ui_stream *stb = NULL; + + stb = ui_out_stream_new (uiout); + + if (format == 'N') + format = 0; + + frame_register (get_selected_frame (NULL), regnum, &optim, &lval, &addr, + &realnum, buffer); + + if (optim) + { + mi_error_message = xstrprintf ("Optimized out"); + return -1; + } + + if (format == 'r') + { + int j; + char *ptr, buf[1024]; + + strcpy (buf, "0x"); + ptr = buf + 2; + for (j = 0; j < register_size (current_gdbarch, regnum); j++) + { + int idx = gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG ? j + : register_size (current_gdbarch, regnum) - 1 - j; + sprintf (ptr, "%02x", (unsigned char) buffer[idx]); + ptr += 2; + } + ui_out_field_string (uiout, "value", buf); + /*fputs_filtered (buf, gdb_stdout); */ + } + else + { + val_print (register_type (current_gdbarch, regnum), buffer, 0, 0, + stb->stream, format, 1, 0, Val_pretty_default); + ui_out_field_stream (uiout, "value", stb); + ui_out_stream_delete (stb); + } + return 1; +} + +/* Write given values into registers. The registers and values are + given as pairs. The corresponding MI command is + -data-write-register-values [ ... ]*/ +enum mi_cmd_result +mi_cmd_data_write_register_values (char *command, char **argv, int argc) +{ + int numregs, i; + 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. */ + + numregs = gdbarch_num_regs (current_gdbarch) + + gdbarch_num_pseudo_regs (current_gdbarch); + + if (argc == 0) + { + mi_error_message = xstrprintf ("mi_cmd_data_write_register_values: Usage: -data-write-register-values [ ... ]"); + return MI_CMD_ERROR; + } + + format = (int) argv[0][0]; + + if (!target_has_registers) + { + mi_error_message = xstrprintf ("mi_cmd_data_write_register_values: No registers."); + return MI_CMD_ERROR; + } + + if (!(argc - 1)) + { + mi_error_message = xstrprintf ("mi_cmd_data_write_register_values: No regs and values specified."); + return MI_CMD_ERROR; + } + + if ((argc - 1) % 2) + { + mi_error_message = xstrprintf ("mi_cmd_data_write_register_values: Regs and vals are not in pairs."); + return MI_CMD_ERROR; + } + + for (i = 1; i < argc; i = i + 2) + { + int regnum = atoi (argv[i]); + + if (regnum >= 0 && regnum < numregs + && gdbarch_register_name (current_gdbarch, regnum) + && *gdbarch_register_name (current_gdbarch, regnum)) + { + LONGEST value; + + /* Get the value as a number. */ + value = parse_and_eval_address (argv[i + 1]); + + /* Write it down. */ + regcache_cooked_write_signed (get_current_regcache (), regnum, value); + } + else + { + mi_error_message = xstrprintf ("bad register number"); + return MI_CMD_ERROR; + } + } + return MI_CMD_DONE; +} + +/* Evaluate the value of the argument. The argument is an + expression. If the expression contains spaces it needs to be + included in double quotes. */ +enum mi_cmd_result +mi_cmd_data_evaluate_expression (char *command, char **argv, int argc) +{ + struct expression *expr; + struct cleanup *old_chain = NULL; + struct value *val; + struct ui_stream *stb = NULL; + + stb = ui_out_stream_new (uiout); + + if (argc != 1) + { + mi_error_message = xstrprintf ("mi_cmd_data_evaluate_expression: Usage: -data-evaluate-expression expression"); + ui_out_stream_delete (stb); + return MI_CMD_ERROR; + } + + expr = parse_expression (argv[0]); + + old_chain = make_cleanup (free_current_contents, &expr); + + val = evaluate_expression (expr); + + /* Print the result of the expression evaluation. */ + val_print (value_type (val), value_contents (val), + value_embedded_offset (val), VALUE_ADDRESS (val), + stb->stream, 0, 0, 0, 0); + + ui_out_field_stream (uiout, "value", stb); + ui_out_stream_delete (stb); + + do_cleanups (old_chain); + + return MI_CMD_DONE; +} + +enum mi_cmd_result +mi_cmd_target_download (char *args, int from_tty) +{ + char *run; + struct cleanup *old_cleanups = NULL; + + run = xstrprintf ("load %s", args); + old_cleanups = make_cleanup (xfree, run); + execute_command (run, from_tty); + + do_cleanups (old_cleanups); + return MI_CMD_DONE; +} + +/* Connect to the remote target. */ +enum mi_cmd_result +mi_cmd_target_select (char *args, int from_tty) +{ + char *run; + struct cleanup *old_cleanups = NULL; + + run = xstrprintf ("target %s", args); + old_cleanups = make_cleanup (xfree, run); + + /* target-select is always synchronous. Once the call has returned + we know that we are connected. */ + /* NOTE: At present all targets that are connected are also + (implicitly) talking to a halted target. In the future this may + change. */ + execute_command (run, from_tty); + + do_cleanups (old_cleanups); + + /* Issue the completion message here. */ + if (last_async_command) + fputs_unfiltered (last_async_command, raw_stdout); + fputs_unfiltered ("^connected", raw_stdout); + mi_out_put (uiout, raw_stdout); + mi_out_rewind (uiout); + fputs_unfiltered ("\n", raw_stdout); + do_exec_cleanups (ALL_CLEANUPS); + return MI_CMD_QUIET; +} + +/* DATA-MEMORY-READ: + + ADDR: start address of data to be dumped. + WORD-FORMAT: a char indicating format for the ``word''. See + the ``x'' command. + WORD-SIZE: size of each ``word''; 1,2,4, or 8 bytes. + NR_ROW: Number of rows. + NR_COL: The number of colums (words per row). + ASCHAR: (OPTIONAL) Append an ascii character dump to each row. Use + ASCHAR for unprintable characters. + + Reads SIZE*NR_ROW*NR_COL bytes starting at ADDR from memory and + displayes them. Returns: + + {addr="...",rowN={wordN="..." ,... [,ascii="..."]}, ...} + + Returns: + The number of bytes read is SIZE*ROW*COL. */ + +enum mi_cmd_result +mi_cmd_data_read_memory (char *command, char **argv, int argc) +{ + struct cleanup *cleanups = make_cleanup (null_cleanup, NULL); + CORE_ADDR addr; + long total_bytes; + long nr_cols; + long nr_rows; + char word_format; + struct type *word_type; + long word_size; + char word_asize; + char aschar; + gdb_byte *mbuf; + int nr_bytes; + long offset = 0; + int optind = 0; + char *optarg; + enum opt + { + OFFSET_OPT + }; + static struct mi_opt opts[] = + { + {"o", OFFSET_OPT, 1}, + { 0, 0, 0 } + }; + + while (1) + { + int opt = mi_getopt ("mi_cmd_data_read_memory", argc, argv, opts, + &optind, &optarg); + if (opt < 0) + break; + switch ((enum opt) opt) + { + case OFFSET_OPT: + offset = atol (optarg); + break; + } + } + argv += optind; + argc -= optind; + + if (argc < 5 || argc > 6) + { + mi_error_message = xstrprintf ("mi_cmd_data_read_memory: Usage: ADDR WORD-FORMAT WORD-SIZE NR-ROWS NR-COLS [ASCHAR]."); + return MI_CMD_ERROR; + } + + /* Extract all the arguments. */ + + /* 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. */ + word_format = argv[1][0]; + /* The size of the memory word. */ + word_size = atol (argv[2]); + switch (word_size) + { + case 1: + word_type = builtin_type_int8; + word_asize = 'b'; + break; + case 2: + word_type = builtin_type_int16; + word_asize = 'h'; + break; + case 4: + word_type = builtin_type_int32; + word_asize = 'w'; + break; + case 8: + word_type = builtin_type_int64; + word_asize = 'g'; + break; + default: + word_type = builtin_type_int8; + word_asize = 'b'; + } + /* The number of rows. */ + nr_rows = atol (argv[3]); + if (nr_rows <= 0) + { + mi_error_message = xstrprintf ("mi_cmd_data_read_memory: invalid number of rows."); + return MI_CMD_ERROR; + } + /* Number of bytes per row. */ + nr_cols = atol (argv[4]); + if (nr_cols <= 0) + { + mi_error_message = xstrprintf ("mi_cmd_data_read_memory: invalid number of columns."); + return MI_CMD_ERROR; + } + /* The un-printable character when printing ascii. */ + if (argc == 6) + aschar = *argv[5]; + else + aschar = 0; + + /* Create a buffer and read it in. */ + total_bytes = word_size * nr_rows * nr_cols; + mbuf = xcalloc (total_bytes, 1); + make_cleanup (xfree, mbuf); + + nr_bytes = target_read (¤t_target, TARGET_OBJECT_MEMORY, NULL, + mbuf, addr, total_bytes); + if (nr_bytes <= 0) + { + do_cleanups (cleanups); + mi_error_message = xstrdup ("Unable to read memory."); + return MI_CMD_ERROR; + } + + /* Output the header information. */ + ui_out_field_core_addr (uiout, "addr", addr); + ui_out_field_int (uiout, "nr-bytes", nr_bytes); + ui_out_field_int (uiout, "total-bytes", total_bytes); + ui_out_field_core_addr (uiout, "next-row", addr + word_size * nr_cols); + ui_out_field_core_addr (uiout, "prev-row", addr - word_size * nr_cols); + ui_out_field_core_addr (uiout, "next-page", addr + total_bytes); + ui_out_field_core_addr (uiout, "prev-page", addr - total_bytes); + + /* Build the result as a two dimentional table. */ + { + struct ui_stream *stream = ui_out_stream_new (uiout); + 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; + row++, row_byte += nr_cols * word_size) + { + int col; + int col_byte; + struct cleanup *cleanup_tuple; + struct cleanup *cleanup_list_data; + cleanup_tuple = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); + ui_out_field_core_addr (uiout, "addr", addr + row_byte); + /* ui_out_field_core_addr_symbolic (uiout, "saddr", addr + row_byte); */ + cleanup_list_data = make_cleanup_ui_out_list_begin_end (uiout, "data"); + for (col = 0, col_byte = row_byte; + col < nr_cols; + col++, col_byte += word_size) + { + if (col_byte + word_size > nr_bytes) + { + ui_out_field_string (uiout, NULL, "N/A"); + } + else + { + ui_file_rewind (stream->stream); + print_scalar_formatted (mbuf + col_byte, word_type, word_format, + word_asize, stream->stream); + ui_out_field_stream (uiout, NULL, stream); + } + } + do_cleanups (cleanup_list_data); + if (aschar) + { + int byte; + ui_file_rewind (stream->stream); + for (byte = row_byte; byte < row_byte + word_size * nr_cols; byte++) + { + if (byte >= nr_bytes) + { + fputc_unfiltered ('X', stream->stream); + } + else if (mbuf[byte] < 32 || mbuf[byte] > 126) + { + fputc_unfiltered (aschar, stream->stream); + } + else + fputc_unfiltered (mbuf[byte], stream->stream); + } + ui_out_field_stream (uiout, "ascii", stream); + } + do_cleanups (cleanup_tuple); + } + ui_out_stream_delete (stream); + do_cleanups (cleanup_list_memory); + } + do_cleanups (cleanups); + return MI_CMD_DONE; +} + +/* DATA-MEMORY-WRITE: + + COLUMN_OFFSET: optional argument. Must be preceeded by '-o'. The + offset from the beginning of the memory grid row where the cell to + be written is. + ADDR: start address of the row in the memory grid where the memory + cell is, if OFFSET_COLUMN is specified. Otherwise, the address of + the location to write to. + FORMAT: a char indicating format for the ``word''. See + the ``x'' command. + WORD_SIZE: size of each ``word''; 1,2,4, or 8 bytes + VALUE: value to be written into the memory address. + + Writes VALUE into ADDR + (COLUMN_OFFSET * WORD_SIZE). + + Prints nothing. */ +enum mi_cmd_result +mi_cmd_data_write_memory (char *command, char **argv, int argc) +{ + CORE_ADDR addr; + char word_format; + long word_size; + /* FIXME: ezannoni 2000-02-17 LONGEST could possibly not be big + enough when using a compiler other than GCC. */ + LONGEST value; + void *buffer; + struct cleanup *old_chain; + long offset = 0; + int optind = 0; + char *optarg; + enum opt + { + OFFSET_OPT + }; + static struct mi_opt opts[] = + { + {"o", OFFSET_OPT, 1}, + { 0, 0, 0 } + }; + + while (1) + { + int opt = mi_getopt ("mi_cmd_data_write_memory", argc, argv, opts, + &optind, &optarg); + if (opt < 0) + break; + switch ((enum opt) opt) + { + case OFFSET_OPT: + offset = atol (optarg); + break; + } + } + argv += optind; + argc -= optind; + + if (argc != 4) + { + mi_error_message = xstrprintf ("mi_cmd_data_write_memory: Usage: [-o COLUMN_OFFSET] ADDR FORMAT WORD-SIZE VALUE."); + return MI_CMD_ERROR; + } + + /* Extract all the arguments. */ + /* Start address of the memory dump. */ + addr = parse_and_eval_address (argv[0]); + /* 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. */ + word_size = atol (argv[2]); + + /* Calculate the real address of the write destination. */ + addr += (offset * word_size); + + /* Get the value as a number. */ + value = parse_and_eval_address (argv[3]); + /* Get the value into an array. */ + buffer = xmalloc (word_size); + old_chain = make_cleanup (xfree, buffer); + store_signed_integer (buffer, word_size, value); + /* Write it down to memory. */ + write_memory (addr, buffer, word_size); + /* Free the buffer. */ + do_cleanups (old_chain); + + return MI_CMD_DONE; +} + +enum mi_cmd_result +mi_cmd_enable_timings (char *command, char **argv, int argc) +{ + if (argc == 0) + do_timings = 1; + else if (argc == 1) + { + if (strcmp (argv[0], "yes") == 0) + do_timings = 1; + else if (strcmp (argv[0], "no") == 0) + do_timings = 0; + else + goto usage_error; + } + else + goto usage_error; + + return MI_CMD_DONE; + + usage_error: + error ("mi_cmd_enable_timings: Usage: %s {yes|no}", command); + return MI_CMD_ERROR; +} + +enum mi_cmd_result +mi_cmd_list_features (char *command, char **argv, int argc) +{ + if (argc == 0) + { + struct cleanup *cleanup = NULL; + 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"); + + do_cleanups (cleanup); + + return MI_CMD_DONE; + } + + error ("-list-features should be passed no arguments"); + return MI_CMD_ERROR; +} + +/* Execute a command within a safe environment. + Return <0 for error; >=0 for ok. + + args->action will tell mi_execute_command what action + to perfrom after the given command has executed (display/supress + prompt, display error). */ + +static void +captured_mi_execute_command (struct ui_out *uiout, void *data) +{ + struct captured_mi_execute_command_args *args = + (struct captured_mi_execute_command_args *) data; + struct mi_parse *context = args->command; + + struct mi_timestamp cmd_finished; + + switch (context->op) + { + + case MI_COMMAND: + /* A MI command was read from the input stream. */ + if (mi_debug_p) + /* FIXME: gdb_???? */ + fprintf_unfiltered (raw_stdout, " token=`%s' command=`%s' args=`%s'\n", + context->token, context->command, context->args); + /* FIXME: cagney/1999-09-25: Rather than this convoluted + condition expression, each function should return an + indication of what action is required and then switch on + that. */ + args->action = EXECUTE_COMMAND_DISPLAY_PROMPT; + + if (do_timings) + current_command_ts = context->cmd_start; + + args->rc = mi_cmd_execute (context); + + if (do_timings) + timestamp (&cmd_finished); + + if (!target_can_async_p () || !target_executing) + { + /* 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. */ + if (args->rc == MI_CMD_DONE) + { + fputs_unfiltered (context->token, raw_stdout); + fputs_unfiltered ("^done", raw_stdout); + mi_out_put (uiout, raw_stdout); + mi_out_rewind (uiout); + /* Have to check cmd_start, since the command could be + -enable-timings. */ + if (do_timings && context->cmd_start) + print_diff (context->cmd_start, &cmd_finished); + fputs_unfiltered ("\n", raw_stdout); + } + else if (args->rc == MI_CMD_ERROR) + { + if (mi_error_message) + { + fputs_unfiltered (context->token, raw_stdout); + fputs_unfiltered ("^error,msg=\"", raw_stdout); + fputstr_unfiltered (mi_error_message, '"', raw_stdout); + xfree (mi_error_message); + mi_error_message = NULL; + fputs_unfiltered ("\"\n", raw_stdout); + } + mi_out_rewind (uiout); + } + else + mi_out_rewind (uiout); + } + else if (sync_execution) + { + /* Don't print the prompt. We are executing the target in + synchronous mode. */ + args->action = EXECUTE_COMMAND_SUPRESS_PROMPT; + return; + } + break; + + 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. */ + /* Echo the command on the console. */ + fprintf_unfiltered (gdb_stdlog, "%s\n", context->command); + /* Call the "console" interpreter. */ + argv[0] = "console"; + argv[1] = context->command; + args->rc = mi_cmd_interpreter_exec ("-interpreter-exec", argv, 2); + + /* If we changed interpreters, DON'T print out anything. */ + if (current_interp_named_p (INTERP_MI) + || current_interp_named_p (INTERP_MI1) + || current_interp_named_p (INTERP_MI2) + || current_interp_named_p (INTERP_MI3)) + { + if (args->rc == MI_CMD_DONE) + { + fputs_unfiltered (context->token, raw_stdout); + fputs_unfiltered ("^done", raw_stdout); + mi_out_put (uiout, raw_stdout); + mi_out_rewind (uiout); + fputs_unfiltered ("\n", raw_stdout); + args->action = EXECUTE_COMMAND_DISPLAY_PROMPT; + } + else if (args->rc == MI_CMD_ERROR) + { + if (mi_error_message) + { + fputs_unfiltered (context->token, raw_stdout); + fputs_unfiltered ("^error,msg=\"", raw_stdout); + fputstr_unfiltered (mi_error_message, '"', raw_stdout); + xfree (mi_error_message); + mi_error_message = NULL; + fputs_unfiltered ("\"\n", raw_stdout); + } + mi_out_rewind (uiout); + } + else + mi_out_rewind (uiout); + } + break; + } + + } + + return; +} + + +void +mi_execute_command (char *cmd, int from_tty) +{ + struct mi_parse *command; + struct captured_mi_execute_command_args args; + struct ui_out *saved_uiout = uiout; + + /* This is to handle EOF (^D). We just quit gdb. */ + /* FIXME: we should call some API function here. */ + if (cmd == 0) + quit_force (NULL, from_tty); + + command = mi_parse (cmd); + + if (command != NULL) + { + struct gdb_exception result; + + if (do_timings) + { + command->cmd_start = (struct mi_timestamp *) + xmalloc (sizeof (struct mi_timestamp)); + timestamp (command->cmd_start); + } + + /* FIXME: cagney/1999-11-04: Can this use of catch_exceptions either + be pushed even further down or even eliminated? */ + args.command = command; + result = catch_exception (uiout, captured_mi_execute_command, &args, + RETURN_MASK_ALL); + exception_print (gdb_stderr, result); + + if (args.action == EXECUTE_COMMAND_SUPRESS_PROMPT) + { + /* The command is executing synchronously. Bail out early + suppressing the finished prompt. */ + mi_parse_free (command); + return; + } + if (result.reason < 0) + { + /* The command execution failed and error() was called + somewhere. */ + fputs_unfiltered (command->token, raw_stdout); + fputs_unfiltered ("^error,msg=\"", raw_stdout); + if (result.message == NULL) + fputs_unfiltered ("unknown error", raw_stdout); + else + fputstr_unfiltered (result.message, '"', raw_stdout); + fputs_unfiltered ("\"\n", raw_stdout); + mi_out_rewind (uiout); + } + mi_parse_free (command); + } + + fputs_unfiltered ("(gdb) \n", raw_stdout); + gdb_flush (raw_stdout); + /* Print any buffered hook code. */ + /* ..... */ +} + +static enum mi_cmd_result +mi_cmd_execute (struct mi_parse *parse) +{ + free_all_values (); + + if (parse->cmd->argv_func != NULL + || parse->cmd->args_func != NULL) + { + /* FIXME: We need to save the token because the command executed + may be asynchronous and need to print the token again. + In the future we can pass the token down to the func + and get rid of the last_async_command. */ + /* The problem here is to keep the token around when we launch + the target, and we want to interrupt it later on. The + interrupt command will have its own token, but when the + target stops, we must display the token corresponding to the + last execution command given. So we have another string where + we copy the token (previous_async_command), if this was + indeed the token of an execution command, and when we stop we + print that one. This is possible because the interrupt + command, when over, will copy that token back into the + default token string (last_async_command). */ + + if (target_executing) + { + if (!previous_async_command) + previous_async_command = xstrdup (last_async_command); + if (strcmp (parse->command, "exec-interrupt")) + { + fputs_unfiltered (parse->token, raw_stdout); + fputs_unfiltered ("^error,msg=\"", raw_stdout); + fputs_unfiltered ("Cannot execute command ", raw_stdout); + fputstr_unfiltered (parse->command, '"', raw_stdout); + fputs_unfiltered (" while target running", raw_stdout); + fputs_unfiltered ("\"\n", raw_stdout); + return MI_CMD_ERROR; + } + } + last_async_command = xstrdup (parse->token); + make_exec_cleanup (free_current_contents, &last_async_command); + /* FIXME: DELETE THIS! */ + if (parse->cmd->args_func != NULL) + return parse->cmd->args_func (parse->args, 0 /*from_tty */ ); + return parse->cmd->argv_func (parse->command, parse->argv, parse->argc); + } + else if (parse->cmd->cli.cmd != 0) + { + /* FIXME: DELETE THIS. */ + /* The operation is still implemented by a cli command. */ + /* Must be a synchronous one. */ + mi_execute_cli_command (parse->cmd->cli.cmd, parse->cmd->cli.args_p, + parse->args); + return MI_CMD_DONE; + } + else + { + /* FIXME: DELETE THIS. */ + fputs_unfiltered (parse->token, raw_stdout); + fputs_unfiltered ("^error,msg=\"", raw_stdout); + fputs_unfiltered ("Undefined mi command: ", raw_stdout); + fputstr_unfiltered (parse->command, '"', raw_stdout); + fputs_unfiltered (" (missing implementation)", raw_stdout); + fputs_unfiltered ("\"\n", raw_stdout); + return MI_CMD_ERROR; + } +} + +/* FIXME: This is just a hack so we can get some extra commands going. + We don't want to channel things through the CLI, but call libgdb directly. + Use only for synchronous commands. */ + +void +mi_execute_cli_command (const char *cmd, int args_p, const char *args) +{ + if (cmd != 0) + { + struct cleanup *old_cleanups; + char *run; + if (args_p) + run = xstrprintf ("%s %s", cmd, args); + else + run = xstrdup (cmd); + if (mi_debug_p) + /* FIXME: gdb_???? */ + fprintf_unfiltered (gdb_stdout, "cli=%s run=%s\n", + cmd, run); + old_cleanups = make_cleanup (xfree, run); + execute_command ( /*ui */ run, 0 /*from_tty */ ); + do_cleanups (old_cleanups); + return; + } +} + +enum mi_cmd_result +mi_execute_async_cli_command (char *mi, char *args, int from_tty) +{ + struct cleanup *old_cleanups; + char *run; + char *async_args; + + if (target_can_async_p ()) + { + async_args = (char *) xmalloc (strlen (args) + 2); + make_exec_cleanup (free, async_args); + strcpy (async_args, args); + strcat (async_args, "&"); + run = xstrprintf ("%s %s", mi, async_args); + make_exec_cleanup (free, run); + add_continuation (mi_exec_async_cli_cmd_continuation, NULL); + old_cleanups = NULL; + } + else + { + run = xstrprintf ("%s %s", mi, args); + old_cleanups = make_cleanup (xfree, run); + } + + if (!target_can_async_p ()) + { + /* NOTE: For synchronous targets asynchronous behavour is faked by + printing out the GDB prompt before we even try to execute the + command. */ + if (last_async_command) + fputs_unfiltered (last_async_command, raw_stdout); + fputs_unfiltered ("^running\n", raw_stdout); + fputs_unfiltered ("(gdb) \n", raw_stdout); + gdb_flush (raw_stdout); + } + else + { + /* FIXME: cagney/1999-11-29: Printing this message before + calling execute_command is wrong. It should only be printed + once gdb has confirmed that it really has managed to send a + run command to the target. */ + if (last_async_command) + fputs_unfiltered (last_async_command, raw_stdout); + fputs_unfiltered ("^running\n", raw_stdout); + } + + execute_command ( /*ui */ run, 0 /*from_tty */ ); + + if (!target_can_async_p ()) + { + /* Do this before doing any printing. It would appear that some + print code leaves garbage around in the buffer. */ + do_cleanups (old_cleanups); + /* If the target was doing the operation synchronously we fake + the stopped message. */ + if (last_async_command) + fputs_unfiltered (last_async_command, raw_stdout); + fputs_unfiltered ("*stopped", raw_stdout); + mi_out_put (uiout, raw_stdout); + mi_out_rewind (uiout); + if (do_timings) + print_diff_now (current_command_ts); + fputs_unfiltered ("\n", raw_stdout); + return MI_CMD_QUIET; + } + return MI_CMD_DONE; +} + +void +mi_exec_async_cli_cmd_continuation (struct continuation_arg *arg) +{ + if (last_async_command) + fputs_unfiltered (last_async_command, raw_stdout); + fputs_unfiltered ("*stopped", raw_stdout); + mi_out_put (uiout, raw_stdout); + fputs_unfiltered ("\n", raw_stdout); + fputs_unfiltered ("(gdb) \n", raw_stdout); + gdb_flush (raw_stdout); + do_exec_cleanups (ALL_CLEANUPS); +} + +void +mi_load_progress (const char *section_name, + unsigned long sent_so_far, + unsigned long total_section, + unsigned long total_sent, + unsigned long grand_total) +{ + struct timeval time_now, delta, update_threshold; + static struct timeval last_update; + static char *previous_sect_name = NULL; + int new_section; + struct ui_out *saved_uiout; + + /* This function is called through deprecated_show_load_progress + which means uiout may not be correct. Fix it for the duration + of this function. */ + saved_uiout = uiout; + + if (current_interp_named_p (INTERP_MI) + || current_interp_named_p (INTERP_MI2)) + uiout = mi_out_new (2); + else if (current_interp_named_p (INTERP_MI1)) + uiout = mi_out_new (1); + else if (current_interp_named_p (INTERP_MI3)) + uiout = mi_out_new (3); + else + return; + + update_threshold.tv_sec = 0; + update_threshold.tv_usec = 500000; + gettimeofday (&time_now, NULL); + + delta.tv_usec = time_now.tv_usec - last_update.tv_usec; + delta.tv_sec = time_now.tv_sec - last_update.tv_sec; + + if (delta.tv_usec < 0) + { + delta.tv_sec -= 1; + delta.tv_usec += 1000000L; + } + + new_section = (previous_sect_name ? + strcmp (previous_sect_name, section_name) : 1); + if (new_section) + { + struct cleanup *cleanup_tuple; + xfree (previous_sect_name); + previous_sect_name = xstrdup (section_name); + + if (last_async_command) + fputs_unfiltered (last_async_command, raw_stdout); + fputs_unfiltered ("+download", raw_stdout); + cleanup_tuple = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); + ui_out_field_string (uiout, "section", section_name); + ui_out_field_int (uiout, "section-size", total_section); + ui_out_field_int (uiout, "total-size", grand_total); + do_cleanups (cleanup_tuple); + mi_out_put (uiout, raw_stdout); + fputs_unfiltered ("\n", raw_stdout); + gdb_flush (raw_stdout); + } + + if (delta.tv_sec >= update_threshold.tv_sec && + 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 (last_async_command) + fputs_unfiltered (last_async_command, raw_stdout); + fputs_unfiltered ("+download", raw_stdout); + cleanup_tuple = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); + ui_out_field_string (uiout, "section", section_name); + ui_out_field_int (uiout, "section-sent", sent_so_far); + ui_out_field_int (uiout, "section-size", total_section); + ui_out_field_int (uiout, "total-sent", total_sent); + ui_out_field_int (uiout, "total-size", grand_total); + do_cleanups (cleanup_tuple); + mi_out_put (uiout, raw_stdout); + fputs_unfiltered ("\n", raw_stdout); + gdb_flush (raw_stdout); + } + + xfree (uiout); + uiout = saved_uiout; +} + +static void +timestamp (struct mi_timestamp *tv) + { + long usec; + 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; +#else + 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 + } + +static void +print_diff_now (struct mi_timestamp *start) + { + struct mi_timestamp now; + timestamp (&now); + print_diff (start, &now); + } + +static long +timeval_diff (struct timeval start, struct timeval end) + { + 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); + }
mi-main.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mi-cmd-break.c =================================================================== --- mi-cmd-break.c (nonexistent) +++ mi-cmd-break.c (revision 816) @@ -0,0 +1,243 @@ +/* MI Command Set - breakpoint and watchpoint commands. + Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. + Contributed by Cygnus Solutions (a Red Hat company). + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include "defs.h" +#include "mi-cmds.h" +#include "ui-out.h" +#include "mi-out.h" +#include "breakpoint.h" +#include "gdb_string.h" +#include "mi-getopt.h" +#include "gdb-events.h" +#include "gdb.h" +#include "exceptions.h" + +enum + { + FROM_TTY = 0 + }; + +/* Output a single breakpoint. */ + +static void +breakpoint_notify (int b) +{ + gdb_breakpoint_query (uiout, b, NULL); +} + + +struct gdb_events breakpoint_hooks = +{ + breakpoint_notify, + breakpoint_notify, + breakpoint_notify, +}; + + +enum bp_type + { + REG_BP, + HW_BP, + REGEXP_BP + }; + +/* Implements the -break-insert command. + See the MI manual for the list of possible options. */ + +enum mi_cmd_result +mi_cmd_break_insert (char *command, char **argv, int argc) +{ + char *address = NULL; + enum bp_type type = REG_BP; + int temp_p = 0; + int thread = -1; + int ignore_count = 0; + char *condition = NULL; + int pending = 0; + struct gdb_exception e; + struct gdb_events *old_hooks; + enum opt + { + HARDWARE_OPT, TEMP_OPT /*, REGEXP_OPT */ , CONDITION_OPT, + IGNORE_COUNT_OPT, THREAD_OPT, PENDING_OPT + }; + static struct mi_opt opts[] = + { + {"h", HARDWARE_OPT, 0}, + {"t", TEMP_OPT, 0}, + {"c", CONDITION_OPT, 1}, + {"i", IGNORE_COUNT_OPT, 1}, + {"p", THREAD_OPT, 1}, + {"f", PENDING_OPT, 0}, + { 0, 0, 0 } + }; + + /* Parse arguments. It could be -r or -h or -t, or ``--'' + 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); + if (opt < 0) + break; + switch ((enum opt) opt) + { + case TEMP_OPT: + temp_p = 1; + break; + case HARDWARE_OPT: + type = HW_BP; + break; +#if 0 + case REGEXP_OPT: + type = REGEXP_BP; + break; +#endif + case CONDITION_OPT: + condition = optarg; + break; + case IGNORE_COUNT_OPT: + ignore_count = atol (optarg); + break; + case THREAD_OPT: + thread = atol (optarg); + break; + case PENDING_OPT: + pending = 1; + break; + } + } + + if (optind >= argc) + error (_("mi_cmd_break_insert: Missing ")); + if (optind < argc - 1) + error (_("mi_cmd_break_insert: Garbage following ")); + address = argv[optind]; + + /* Now we have what we need, let's insert the breakpoint! */ + old_hooks = deprecated_set_gdb_event_hooks (&breakpoint_hooks); + /* Make sure we restore hooks even if exception is thrown. */ + TRY_CATCH (e, RETURN_MASK_ALL) + { + switch (type) + { + case REG_BP: + set_breakpoint (address, condition, + 0 /*hardwareflag */ , temp_p, + thread, ignore_count, + pending); + break; + case HW_BP: + set_breakpoint (address, condition, + 1 /*hardwareflag */ , temp_p, + thread, ignore_count, + pending); + break; +#if 0 + case REGEXP_BP: + if (temp_p) + error (_("mi_cmd_break_insert: Unsupported tempoary regexp breakpoint")); + else + rbreak_command_wrapper (address, FROM_TTY); + return MI_CMD_DONE; + break; +#endif + default: + internal_error (__FILE__, __LINE__, + _("mi_cmd_break_insert: Bad switch.")); + } + } + deprecated_set_gdb_event_hooks (old_hooks); + if (e.reason < 0) + throw_exception (e); + + return MI_CMD_DONE; +} + +enum wp_type +{ + REG_WP, + READ_WP, + ACCESS_WP +}; + +/* Insert a watchpoint. The type of watchpoint is specified by the + first argument: + -break-watch --> insert a regular wp. + -break-watch -r --> insert a read watchpoint. + -break-watch -a --> insert an access wp. */ + +enum mi_cmd_result +mi_cmd_break_watch (char *command, char **argv, int argc) +{ + char *expr = NULL; + enum wp_type type = REG_WP; + enum opt + { + READ_OPT, ACCESS_OPT + }; + static struct mi_opt opts[] = + { + {"r", READ_OPT, 0}, + {"a", ACCESS_OPT, 0}, + { 0, 0, 0 } + }; + + /* Parse arguments. */ + int optind = 0; + char *optarg; + while (1) + { + int opt = mi_getopt ("mi_cmd_break_watch", argc, argv, opts, &optind, &optarg); + if (opt < 0) + break; + switch ((enum opt) opt) + { + case READ_OPT: + type = READ_WP; + break; + case ACCESS_OPT: + type = ACCESS_WP; + break; + } + } + if (optind >= argc) + error (_("mi_cmd_break_watch: Missing ")); + if (optind < argc - 1) + error (_("mi_cmd_break_watch: Garbage following ")); + expr = argv[optind]; + + /* Now we have what we need, let's insert the watchpoint! */ + switch (type) + { + case REG_WP: + watch_command_wrapper (expr, FROM_TTY); + break; + case READ_WP: + rwatch_command_wrapper (expr, FROM_TTY); + break; + case ACCESS_WP: + awatch_command_wrapper (expr, FROM_TTY); + break; + default: + error (_("mi_cmd_break_watch: Unknown watchpoint type.")); + } + return MI_CMD_DONE; +}
mi-cmd-break.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mi-cmds.c =================================================================== --- mi-cmds.c (nonexistent) +++ mi-cmds.c (revision 816) @@ -0,0 +1,266 @@ +/* MI Command Set for GDB, the GNU debugger. + + Copyright (C) 2000, 2001, 2003, 2007, 2008 Free Software Foundation, Inc. + + Contributed by Cygnus Solutions (a Red Hat company). + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include "defs.h" +#include "top.h" +#include "mi-cmds.h" +#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[] = +{ + { "break-after", { "ignore", 1 }, NULL, NULL }, + { "break-catch", { NULL, 0 }, NULL, NULL }, + { "break-commands", { NULL, 0 }, NULL, NULL }, + { "break-condition", { "cond", 1 }, NULL, NULL }, + { "break-delete", { "delete breakpoint", 1 }, NULL, NULL }, + { "break-disable", { "disable breakpoint", 1 }, NULL, NULL }, + { "break-enable", { "enable breakpoint", 1 }, NULL, NULL }, + { "break-info", { "info break", 1 }, NULL, NULL }, + { "break-insert", { NULL, 0 }, 0, mi_cmd_break_insert}, + { "break-list", { "info break", }, NULL, NULL }, + { "break-watch", { NULL, 0 }, 0, mi_cmd_break_watch}, + { "data-disassemble", { NULL, 0 }, 0, mi_cmd_disassemble}, + { "data-evaluate-expression", { NULL, 0 }, 0, mi_cmd_data_evaluate_expression}, + { "data-list-changed-registers", { NULL, 0 }, 0, mi_cmd_data_list_changed_registers}, + { "data-list-register-names", { NULL, 0 }, 0, mi_cmd_data_list_register_names}, + { "data-list-register-values", { NULL, 0 }, 0, mi_cmd_data_list_register_values}, + { "data-read-memory", { NULL, 0 }, 0, mi_cmd_data_read_memory}, + { "data-write-memory", { NULL, 0 }, 0, mi_cmd_data_write_memory}, + { "data-write-register-values", { NULL, 0 }, 0, mi_cmd_data_write_register_values}, + { "enable-timings", { NULL, 0 }, 0, mi_cmd_enable_timings}, + { "environment-cd", { NULL, 0 }, 0, mi_cmd_env_cd}, + { "environment-directory", { NULL, 0 }, 0, mi_cmd_env_dir}, + { "environment-path", { NULL, 0 }, 0, mi_cmd_env_path}, + { "environment-pwd", { NULL, 0 }, 0, mi_cmd_env_pwd}, + { "exec-abort", { NULL, 0 }, NULL, NULL }, + { "exec-arguments", { "set args", 1 }, NULL, NULL }, + { "exec-continue", { NULL, 0 }, mi_cmd_exec_continue}, + { "exec-finish", { NULL, 0 }, mi_cmd_exec_finish}, + { "exec-interrupt", { NULL, 0 }, mi_cmd_exec_interrupt}, + { "exec-next", { NULL, 0 }, mi_cmd_exec_next}, + { "exec-next-instruction", { NULL, 0 }, mi_cmd_exec_next_instruction}, + { "exec-return", { NULL, 0 }, mi_cmd_exec_return}, + { "exec-run", { NULL, 0 }, mi_cmd_exec_run}, + { "exec-show-arguments", { NULL, 0 }, NULL, NULL }, + { "exec-signal", { NULL, 0 }, NULL, NULL }, + { "exec-step", { NULL, 0 }, mi_cmd_exec_step}, + { "exec-step-instruction", { NULL, 0 }, mi_cmd_exec_step_instruction}, + { "exec-until", { NULL, 0 }, mi_cmd_exec_until}, + { "file-clear", { NULL, 0 }, NULL, NULL }, + { "file-exec-and-symbols", { "file", 1 }, NULL, NULL }, + { "file-exec-file", { "exec-file", 1 }, NULL, NULL }, + { "file-list-exec-sections", { NULL, 0 }, NULL, NULL }, + { "file-list-exec-source-file", { NULL, 0 }, 0, mi_cmd_file_list_exec_source_file}, + { "file-list-exec-source-files", { NULL, 0 }, NULL, mi_cmd_file_list_exec_source_files }, + { "file-list-shared-libraries", { NULL, 0 }, NULL, NULL }, + { "file-list-symbol-files", { NULL, 0 }, NULL, NULL }, + { "file-symbol-file", { "symbol-file", 1 }, NULL, NULL }, + { "gdb-complete", { NULL, 0 }, NULL, NULL }, + { "gdb-exit", { NULL, 0 }, 0, mi_cmd_gdb_exit}, + { "gdb-set", { "set", 1 }, NULL, NULL }, + { "gdb-show", { "show", 1 }, NULL, NULL }, + { "gdb-source", { NULL, 0 }, NULL, NULL }, + { "gdb-version", { "show version", 0 }, 0 }, + { "inferior-tty-set", { NULL, 0 }, NULL, mi_cmd_inferior_tty_set}, + { "inferior-tty-show", { NULL, 0 }, NULL, mi_cmd_inferior_tty_show}, + { "interpreter-exec", { NULL, 0 }, 0, mi_cmd_interpreter_exec}, + { "list-features", { NULL, 0 }, 0, mi_cmd_list_features}, + { "overlay-auto", { NULL, 0 }, NULL, NULL }, + { "overlay-list-mapping-state", { NULL, 0 }, NULL, NULL }, + { "overlay-list-overlays", { NULL, 0 }, NULL, NULL }, + { "overlay-map", { NULL, 0 }, NULL, NULL }, + { "overlay-off", { NULL, 0 }, NULL, NULL }, + { "overlay-on", { NULL, 0 }, NULL, NULL }, + { "overlay-unmap", { NULL, 0 }, NULL, NULL }, + { "signal-handle", { NULL, 0 }, NULL, NULL }, + { "signal-list-handle-actions", { NULL, 0 }, NULL, NULL }, + { "signal-list-signal-types", { NULL, 0 }, NULL, NULL }, + { "stack-info-depth", { NULL, 0 }, 0, mi_cmd_stack_info_depth}, + { "stack-info-frame", { NULL, 0 }, 0, mi_cmd_stack_info_frame}, + { "stack-list-arguments", { NULL, 0 }, 0, mi_cmd_stack_list_args}, + { "stack-list-exception-handlers", { NULL, 0 }, NULL, NULL }, + { "stack-list-frames", { NULL, 0 }, 0, mi_cmd_stack_list_frames}, + { "stack-list-locals", { NULL, 0 }, 0, mi_cmd_stack_list_locals}, + { "stack-select-frame", { NULL, 0 }, 0, mi_cmd_stack_select_frame}, + { "symbol-info-address", { NULL, 0 }, NULL, NULL }, + { "symbol-info-file", { NULL, 0 }, NULL, NULL }, + { "symbol-info-function", { NULL, 0 }, NULL, NULL }, + { "symbol-info-line", { NULL, 0 }, NULL, NULL }, + { "symbol-info-symbol", { NULL, 0 }, NULL, NULL }, + { "symbol-list-functions", { NULL, 0 }, NULL, NULL }, + { "symbol-list-lines", { NULL, 0 }, 0, mi_cmd_symbol_list_lines}, + { "symbol-list-types", { NULL, 0 }, NULL, NULL }, + { "symbol-list-variables", { NULL, 0 }, NULL, NULL }, + { "symbol-locate", { NULL, 0 }, NULL, NULL }, + { "symbol-type", { NULL, 0 }, NULL, NULL }, + { "target-attach", { NULL, 0 }, NULL, NULL }, + { "target-compare-sections", { NULL, 0 }, NULL, NULL }, + { "target-detach", { "detach", 0 }, 0 }, + { "target-disconnect", { "disconnect", 0 }, 0 }, + { "target-download", { NULL, 0 }, mi_cmd_target_download}, + { "target-exec-status", { NULL, 0 }, NULL, NULL }, + { "target-file-delete", { NULL, 0 }, NULL, mi_cmd_target_file_delete }, + { "target-file-get", { NULL, 0 }, NULL, mi_cmd_target_file_get }, + { "target-file-put", { NULL, 0 }, NULL, mi_cmd_target_file_put }, + { "target-list-available-targets", { NULL, 0 }, NULL, NULL }, + { "target-list-current-targets", { NULL, 0 }, NULL, NULL }, + { "target-list-parameters", { NULL, 0 }, NULL, NULL }, + { "target-select", { NULL, 0 }, mi_cmd_target_select}, + { "thread-info", { NULL, 0 }, NULL, NULL }, + { "thread-list-all-threads", { NULL, 0 }, NULL, NULL }, + { "thread-list-ids", { NULL, 0 }, 0, mi_cmd_thread_list_ids}, + { "thread-select", { NULL, 0 }, 0, mi_cmd_thread_select}, + { "trace-actions", { NULL, 0 }, NULL, NULL }, + { "trace-delete", { NULL, 0 }, NULL, NULL }, + { "trace-disable", { NULL, 0 }, NULL, NULL }, + { "trace-dump", { NULL, 0 }, NULL, NULL }, + { "trace-enable", { NULL, 0 }, NULL, NULL }, + { "trace-exists", { NULL, 0 }, NULL, NULL }, + { "trace-find", { NULL, 0 }, NULL, NULL }, + { "trace-frame-number", { NULL, 0 }, NULL, NULL }, + { "trace-info", { NULL, 0 }, NULL, NULL }, + { "trace-insert", { NULL, 0 }, NULL, NULL }, + { "trace-list", { NULL, 0 }, NULL, NULL }, + { "trace-pass-count", { NULL, 0 }, NULL, NULL }, + { "trace-save", { NULL, 0 }, NULL, NULL }, + { "trace-start", { NULL, 0 }, NULL, NULL }, + { "trace-stop", { NULL, 0 }, NULL, NULL }, + { "var-assign", { NULL, 0 }, 0, mi_cmd_var_assign}, + { "var-create", { NULL, 0 }, 0, mi_cmd_var_create}, + { "var-delete", { NULL, 0 }, 0, mi_cmd_var_delete}, + { "var-evaluate-expression", { NULL, 0 }, 0, mi_cmd_var_evaluate_expression}, + { "var-info-path-expression", { NULL, 0 }, 0, + mi_cmd_var_info_path_expression}, + { "var-info-expression", { NULL, 0 }, 0, mi_cmd_var_info_expression}, + { "var-info-num-children", { NULL, 0 }, 0, mi_cmd_var_info_num_children}, + { "var-info-type", { NULL, 0 }, 0, mi_cmd_var_info_type}, + { "var-list-children", { NULL, 0 }, 0, mi_cmd_var_list_children}, + { "var-set-format", { NULL, 0 }, 0, mi_cmd_var_set_format}, + { "var-set-frozen", { NULL, 0 }, 0, mi_cmd_var_set_frozen}, + { "var-show-attributes", { NULL, 0 }, 0, mi_cmd_var_show_attributes}, + { "var-show-format", { NULL, 0 }, 0, mi_cmd_var_show_format}, + { "var-update", { NULL, 0 }, 0, mi_cmd_var_update}, + { NULL, } +}; + +/* 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 */ +enum + { + MI_TABLE_SIZE = 227 + }; + +/* Exported function used to obtain info from the table */ +struct mi_cmd * +mi_lookup (const char *command) +{ + return *lookup_table (command); +} + +/* stat collecting */ +struct mi_cmd_stats +{ + int hit; + int miss; + int rehash; +}; +struct mi_cmd_stats stats; + +/* our lookup function */ +static struct mi_cmd ** +lookup_table (const char *command) +{ + const char *chp; + unsigned int index = 0; + /* compute our hash */ + for (chp = command; *chp; chp++) + { + /* some what arbitrary */ + index = ((index << 6) + (unsigned int) *chp) % MI_TABLE_SIZE; + } + /* look it up */ + while (1) + { + struct mi_cmd **entry = &mi_table[index]; + if ((*entry) == 0) + { + /* not found, return pointer to next free. */ + stats.miss++; + return entry; + } + if (strcmp (command, (*entry)->name) == 0) + { + stats.hit++; + return entry; /* found */ + } + index = (index + 1) % MI_TABLE_SIZE; + stats.rehash++; + } +} + +static void +build_table (struct mi_cmd *commands) +{ + int nr_rehash = 0; + int nr_entries = 0; + struct mi_cmd *command; + int sizeof_table = sizeof (struct mi_cmd **) * MI_TABLE_SIZE; + + mi_table = xmalloc (sizeof_table); + memset (mi_table, 0, sizeof_table); + 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"), + command->name); + *entry = command; + if (0) + { + fprintf_unfiltered (gdb_stdlog, "%-30s %2d\n", + command->name, stats.rehash - nr_rehash); + } + nr_entries++; + nr_rehash = stats.rehash; + } + if (0) + { + fprintf_filtered (gdb_stdlog, "Average %3.1f\n", + (double) nr_rehash / (double) nr_entries); + } +} + +void +_initialize_mi_cmds (void) +{ + build_table (mi_cmds); + memset (&stats, 0, sizeof (stats)); +}
mi-cmds.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mi-cmd-target.c =================================================================== --- mi-cmd-target.c (nonexistent) +++ mi-cmd-target.c (revision 816) @@ -0,0 +1,100 @@ +/* MI Command Set - target commands. + Copyright (C) 2007, 2008 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include "defs.h" +#include "mi-cmds.h" +#include "mi-getopt.h" +#include "remote.h" + +/* Get a file from the target. */ + +enum mi_cmd_result +mi_cmd_target_file_get (char *command, char **argv, int argc) +{ + int optind = 0; + char *optarg; + const char *remote_file, *local_file; + static struct mi_opt opts[] = + { + { 0, 0, 0 } + }; + static const char *prefix = "mi_cmd_target_file_get"; + + if (mi_getopt (prefix, argc, argv, opts, &optind, &optarg) != -1 + || optind != argc - 2) + error (_("mi_cmd_target_file_get: Usage: REMOTE_FILE LOCAL_FILE")); + + remote_file = argv[optind]; + local_file = argv[optind + 1]; + + remote_file_get (remote_file, local_file, 0); + + return MI_CMD_DONE; +} + +/* Send a file to the target. */ + +enum mi_cmd_result +mi_cmd_target_file_put (char *command, char **argv, int argc) +{ + int optind = 0; + char *optarg; + const char *remote_file, *local_file; + static struct mi_opt opts[] = + { + { 0, 0, 0 } + }; + static const char *prefix = "mi_cmd_target_file_put"; + + if (mi_getopt (prefix, argc, argv, opts, &optind, &optarg) != -1 + || optind != argc - 2) + error (_("mi_cmd_target_file_put: Usage: LOCAL_FILE REMOTE_FILE")); + + local_file = argv[optind]; + remote_file = argv[optind + 1]; + + remote_file_put (local_file, remote_file, 0); + + return MI_CMD_DONE; +} + +/* Delete a file on the target. */ + +enum mi_cmd_result +mi_cmd_target_file_delete (char *command, char **argv, int argc) +{ + int optind = 0; + char *optarg; + const char *remote_file, *local_file; + static struct mi_opt opts[] = + { + { 0, 0, 0 } + }; + static const char *prefix = "mi_cmd_target_file_delete"; + + if (mi_getopt (prefix, argc, argv, opts, &optind, &optarg) != -1 + || optind != argc - 1) + error (_("mi_cmd_target_file_delete: Usage: REMOTE_FILE")); + + remote_file = argv[optind]; + + remote_file_delete (remote_file, 0); + + return MI_CMD_DONE; +} +
mi-cmd-target.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mi-common.c =================================================================== --- mi-common.c (nonexistent) +++ mi-common.c (revision 816) @@ -0,0 +1,51 @@ +/* Interface for common GDB/MI data + Copyright (C) 2005, 2007, 2008 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include "defs.h" +#include "mi-common.h" + +static const char * const async_reason_string_lookup[] = +{ + "breakpoint-hit", + "watchpoint-trigger", + "read-watchpoint-trigger", + "access-watchpoint-trigger", + "function-finished", + "location-reached", + "watchpoint-scope", + "end-stepping-range", + "exited-signalled", + "exited", + "exited-normally", + "signal-received", + NULL +}; + +const char * +async_reason_lookup (enum async_reply_reason reason) +{ + return async_reason_string_lookup[reason]; +} + +void +_initialize_gdb_mi_common (void) +{ + if (ARRAY_SIZE (async_reason_string_lookup) != EXEC_ASYNC_LAST + 1) + internal_error (__FILE__, __LINE__, + _("async_reason_string_lookup is inconsistent")); +}
mi-common.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mi-cmd-var.c =================================================================== --- mi-cmd-var.c (nonexistent) +++ mi-cmd-var.c (revision 816) @@ -0,0 +1,655 @@ +/* MI Command Set - varobj commands. + + Copyright (C) 2000, 2002, 2004, 2005, 2007, 2008 + Free Software Foundation, Inc. + + Contributed by Cygnus Solutions (a Red Hat company). + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include "defs.h" +#include "mi-cmds.h" +#include "ui-out.h" +#include "mi-out.h" +#include "varobj.h" +#include "value.h" +#include +#include "gdb_string.h" + +const char mi_no_values[] = "--no-values"; +const char mi_simple_values[] = "--simple-values"; +const char mi_all_values[] = "--all-values"; + +extern int varobjdebug; /* defined in varobj.c. */ + +static void varobj_update_one (struct varobj *var, + enum print_values print_values, + int explicit); + +static int mi_print_value_p (struct type *type, 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) +{ + struct type *gdb_type; + char *type; + + ui_out_field_string (uiout, "name", varobj_get_objname (var)); + if (print_expression) + ui_out_field_string (uiout, "exp", varobj_get_expression (var)); + ui_out_field_int (uiout, "numchild", varobj_get_num_children (var)); + + if (mi_print_value_p (varobj_get_gdb_type (var), print_values)) + ui_out_field_string (uiout, "value", varobj_get_value (var)); + + type = varobj_get_type (var); + if (type != NULL) + { + ui_out_field_string (uiout, "type", type); + xfree (type); + } + + if (varobj_get_frozen (var)) + ui_out_field_int (uiout, "frozen", 1); +} + +/* VAROBJ operations */ + +enum mi_cmd_result +mi_cmd_var_create (char *command, char **argv, int argc) +{ + CORE_ADDR frameaddr = 0; + struct varobj *var; + char *name; + char *frame; + char *expr; + struct cleanup *old_cleanups; + enum varobj_type var_type; + + if (argc != 3) + { + /* mi_error_message = xstrprintf ("mi_cmd_var_create: Usage: + ...."); return MI_CMD_ERROR; */ + error (_("mi_cmd_var_create: Usage: NAME FRAME EXPRESSION.")); + } + + name = xstrdup (argv[0]); + /* 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]); + make_cleanup (xfree, frame); + + expr = xstrdup (argv[2]); + make_cleanup (xfree, expr); + + if (strcmp (name, "-") == 0) + { + xfree (name); + name = varobj_gen_name (); + } + else if (!isalpha (*name)) + error (_("mi_cmd_var_create: name of object must begin with a letter")); + + if (strcmp (frame, "*") == 0) + var_type = USE_CURRENT_FRAME; + else if (strcmp (frame, "@") == 0) + var_type = USE_SELECTED_FRAME; + else + { + var_type = USE_SPECIFIED_FRAME; + frameaddr = string_to_core_addr (frame); + } + + if (varobjdebug) + fprintf_unfiltered (gdb_stdlog, + "Name=\"%s\", Frame=\"%s\" (0x%s), Expression=\"%s\"\n", + name, frame, paddr (frameaddr), expr); + + var = varobj_create (name, expr, frameaddr, var_type); + + if (var == NULL) + error (_("mi_cmd_var_create: unable to create variable object")); + + print_varobj (var, PRINT_ALL_VALUES, 0 /* don't print expression */); + + do_cleanups (old_cleanups); + return MI_CMD_DONE; +} + +enum mi_cmd_result +mi_cmd_var_delete (char *command, char **argv, int argc) +{ + char *name; + struct varobj *var; + int numdel; + int children_only_p = 0; + struct cleanup *old_cleanups; + + if (argc < 1 || argc > 2) + error (_("mi_cmd_var_delete: Usage: [-c] EXPRESSION.")); + + name = xstrdup (argv[0]); + /* 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 '-'. */ + if (argc == 1) + { + if (strcmp (name, "-c") == 0) + error (_("mi_cmd_var_delete: Missing required argument after '-c': variable object name")); + if (*name == '-') + error (_("mi_cmd_var_delete: Illegal variable object name")); + } + + /* If we have 2 arguments they must be '-c' followed by a string + which would be the variable name. */ + if (argc == 2) + { + if (strcmp (name, "-c") != 0) + error (_("mi_cmd_var_delete: Invalid option.")); + children_only_p = 1; + do_cleanups (old_cleanups); + name = xstrdup (argv[1]); + make_cleanup (free_current_contents, &name); + } + + /* If we didn't error out, now NAME contains the name of the + variable. */ + + var = varobj_get_handle (name); + + if (var == NULL) + error (_("mi_cmd_var_delete: Variable object not found.")); + + numdel = varobj_delete (var, NULL, children_only_p); + + ui_out_field_int (uiout, "ndeleted", numdel); + + do_cleanups (old_cleanups); + return MI_CMD_DONE; +} + +enum mi_cmd_result +mi_cmd_var_set_format (char *command, char **argv, int argc) +{ + enum varobj_display_formats format; + int len; + struct varobj *var; + char *formspec; + + if (argc != 2) + error (_("mi_cmd_var_set_format: Usage: NAME FORMAT.")); + + /* Get varobj handle, if a valid var obj name was specified */ + var = varobj_get_handle (argv[0]); + + if (var == NULL) + error (_("mi_cmd_var_set_format: Variable object not found")); + + formspec = argv[1]; + if (formspec == NULL) + error (_("mi_cmd_var_set_format: Must specify the format as: \"natural\", \"binary\", \"decimal\", \"hexadecimal\", or \"octal\"")); + + len = strlen (formspec); + + if (strncmp (formspec, "natural", len) == 0) + format = FORMAT_NATURAL; + else if (strncmp (formspec, "binary", len) == 0) + format = FORMAT_BINARY; + else if (strncmp (formspec, "decimal", len) == 0) + format = FORMAT_DECIMAL; + else if (strncmp (formspec, "hexadecimal", len) == 0) + format = FORMAT_HEXADECIMAL; + else if (strncmp (formspec, "octal", len) == 0) + format = FORMAT_OCTAL; + else + error (_("mi_cmd_var_set_format: Unknown display format: must be: \"natural\", \"binary\", \"decimal\", \"hexadecimal\", or \"octal\"")); + + /* Set the format of VAR to given format */ + varobj_set_display_format (var, format); + + /* Report the new current format */ + ui_out_field_string (uiout, "format", varobj_format_string[(int) format]); + + /* Report the value in the new format */ + ui_out_field_string (uiout, "value", varobj_get_value (var)); + return MI_CMD_DONE; +} + +enum mi_cmd_result +mi_cmd_var_set_frozen (char *command, char **argv, int argc) +{ + struct varobj *var; + int frozen; + + if (argc != 2) + error (_("-var-set-format: Usage: NAME FROZEN_FLAG.")); + + var = varobj_get_handle (argv[0]); + if (var == NULL) + error (_("Variable object not found")); + + if (strcmp (argv[1], "0") == 0) + frozen = 0; + else if (strcmp (argv[1], "1") == 0) + frozen = 1; + else + error (_("Invalid flag value")); + + 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. */ + return MI_CMD_DONE; +} + + +enum mi_cmd_result +mi_cmd_var_show_format (char *command, char **argv, int argc) +{ + enum varobj_display_formats format; + struct varobj *var; + + if (argc != 1) + error (_("mi_cmd_var_show_format: Usage: NAME.")); + + /* Get varobj handle, if a valid var obj name was specified */ + var = varobj_get_handle (argv[0]); + if (var == NULL) + error (_("mi_cmd_var_show_format: Variable object not found")); + + format = varobj_get_display_format (var); + + /* Report the current format */ + ui_out_field_string (uiout, "format", varobj_format_string[(int) format]); + return MI_CMD_DONE; +} + +enum mi_cmd_result +mi_cmd_var_info_num_children (char *command, char **argv, int argc) +{ + struct varobj *var; + + if (argc != 1) + error (_("mi_cmd_var_info_num_children: Usage: NAME.")); + + /* Get varobj handle, if a valid var obj name was specified */ + var = varobj_get_handle (argv[0]); + if (var == NULL) + error (_("mi_cmd_var_info_num_children: Variable object not found")); + + ui_out_field_int (uiout, "numchild", varobj_get_num_children (var)); + return MI_CMD_DONE; +} + +/* Parse a string argument into a print_values value. */ + +static enum print_values +mi_parse_values_option (const char *arg) +{ + if (strcmp (arg, "0") == 0 + || strcmp (arg, mi_no_values) == 0) + return PRINT_NO_VALUES; + else if (strcmp (arg, "1") == 0 + || strcmp (arg, mi_all_values) == 0) + return PRINT_ALL_VALUES; + else if (strcmp (arg, "2") == 0 + || strcmp (arg, mi_simple_values) == 0) + return PRINT_SIMPLE_VALUES; + else + error (_("Unknown value for PRINT_VALUES\n\ +Must be: 0 or \"%s\", 1 or \"%s\", 2 or \"%s\""), + mi_no_values, mi_simple_values, mi_all_values); +} + +/* Return 1 if given the argument PRINT_VALUES we should display + a value of type TYPE. */ + +static int +mi_print_value_p (struct type *type, enum print_values print_values) +{ + + if (print_values == PRINT_NO_VALUES) + return 0; + + if (print_values == PRINT_ALL_VALUES) + return 1; + + if (type == NULL) + return 1; + else + { + type = check_typedef (type); + + /* For PRINT_SIMPLE_VALUES, only print the value if it has a type + and that type is not a compound type. */ + return (TYPE_CODE (type) != TYPE_CODE_ARRAY + && TYPE_CODE (type) != TYPE_CODE_STRUCT + && TYPE_CODE (type) != TYPE_CODE_UNION); + } +} + +enum mi_cmd_result +mi_cmd_var_list_children (char *command, char **argv, int argc) +{ + struct varobj *var; + VEC(varobj_p) *children; + struct varobj *child; + struct cleanup *cleanup_children; + int numchild; + enum print_values print_values; + int ix; + + if (argc != 1 && argc != 2) + error (_("mi_cmd_var_list_children: Usage: [PRINT_VALUES] NAME")); + + /* Get varobj handle, if a valid var obj name was specified */ + if (argc == 1) + var = varobj_get_handle (argv[0]); + else + var = varobj_get_handle (argv[1]); + if (var == NULL) + error (_("Variable object not found")); + + children = varobj_list_children (var); + ui_out_field_int (uiout, "numchild", VEC_length (varobj_p, children)); + if (argc == 2) + print_values = mi_parse_values_option (argv[0]); + else + print_values = PRINT_NO_VALUES; + + if (VEC_length (varobj_p, children) == 0) + return MI_CMD_DONE; + + if (mi_version (uiout) == 1) + cleanup_children = make_cleanup_ui_out_tuple_begin_end (uiout, "children"); + else + cleanup_children = make_cleanup_ui_out_list_begin_end (uiout, "children"); + for (ix = 0; VEC_iterate (varobj_p, children, ix, child); ++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); + } + do_cleanups (cleanup_children); + return MI_CMD_DONE; +} + +enum mi_cmd_result +mi_cmd_var_info_type (char *command, char **argv, int argc) +{ + struct varobj *var; + + if (argc != 1) + error (_("mi_cmd_var_info_type: Usage: NAME.")); + + /* Get varobj handle, if a valid var obj name was specified */ + var = varobj_get_handle (argv[0]); + if (var == NULL) + error (_("mi_cmd_var_info_type: Variable object not found")); + + ui_out_field_string (uiout, "type", varobj_get_type (var)); + return MI_CMD_DONE; +} + +enum mi_cmd_result +mi_cmd_var_info_path_expression (char *command, char **argv, int argc) +{ + struct varobj *var; + char *path_expr; + + if (argc != 1) + error (_("Usage: NAME.")); + + /* Get varobj handle, if a valid var obj name was specified. */ + var = varobj_get_handle (argv[0]); + if (var == NULL) + error (_("Variable object not found")); + + path_expr = varobj_get_path_expr (var); + + ui_out_field_string (uiout, "path_expr", path_expr); + + return MI_CMD_DONE; +} + +enum mi_cmd_result +mi_cmd_var_info_expression (char *command, char **argv, int argc) +{ + enum varobj_languages lang; + struct varobj *var; + + if (argc != 1) + error (_("mi_cmd_var_info_expression: Usage: NAME.")); + + /* Get varobj handle, if a valid var obj name was specified */ + var = varobj_get_handle (argv[0]); + if (var == NULL) + error (_("mi_cmd_var_info_expression: Variable object not found")); + + lang = varobj_get_language (var); + + ui_out_field_string (uiout, "lang", varobj_language_string[(int) lang]); + ui_out_field_string (uiout, "exp", varobj_get_expression (var)); + return MI_CMD_DONE; +} + +enum mi_cmd_result +mi_cmd_var_show_attributes (char *command, char **argv, int argc) +{ + int attr; + char *attstr; + struct varobj *var; + + if (argc != 1) + error (_("mi_cmd_var_show_attributes: Usage: NAME.")); + + /* Get varobj handle, if a valid var obj name was specified */ + var = varobj_get_handle (argv[0]); + if (var == NULL) + error (_("mi_cmd_var_show_attributes: Variable object not found")); + + attr = varobj_get_attributes (var); + /* FIXME: define masks for attributes */ + if (attr & 0x00000001) + attstr = "editable"; + else + attstr = "noneditable"; + + ui_out_field_string (uiout, "attr", attstr); + return MI_CMD_DONE; +} + +enum mi_cmd_result +mi_cmd_var_evaluate_expression (char *command, char **argv, int argc) +{ + struct varobj *var; + + if (argc != 1) + error (_("mi_cmd_var_evaluate_expression: Usage: NAME.")); + + /* Get varobj handle, if a valid var obj name was specified */ + var = varobj_get_handle (argv[0]); + if (var == NULL) + error (_("mi_cmd_var_evaluate_expression: Variable object not found")); + + ui_out_field_string (uiout, "value", varobj_get_value (var)); + return MI_CMD_DONE; +} + +enum mi_cmd_result +mi_cmd_var_assign (char *command, char **argv, int argc) +{ + struct varobj *var; + char *expression; + + if (argc != 2) + error (_("mi_cmd_var_assign: Usage: NAME EXPRESSION.")); + + /* Get varobj handle, if a valid var obj name was specified */ + var = varobj_get_handle (argv[0]); + if (var == NULL) + error (_("mi_cmd_var_assign: Variable object not found")); + + if (!varobj_editable_p (var)) + error (_("mi_cmd_var_assign: Variable object is not editable")); + + expression = xstrdup (argv[1]); + + if (!varobj_set_value (var, expression)) + error (_("mi_cmd_var_assign: Could not assign expression to variable object")); + + ui_out_field_string (uiout, "value", varobj_get_value (var)); + return MI_CMD_DONE; +} + +enum mi_cmd_result +mi_cmd_var_update (char *command, char **argv, int argc) +{ + struct varobj *var; + struct varobj **rootlist; + struct varobj **cr; + struct cleanup *cleanup; + char *name; + int nv; + enum print_values print_values; + + if (argc != 1 && argc != 2) + error (_("mi_cmd_var_update: Usage: [PRINT_VALUES] NAME.")); + + if (argc == 1) + name = argv[0]; + else + name = (argv[1]); + + if (argc == 2) + print_values = mi_parse_values_option (argv[0]); + else + print_values = PRINT_NO_VALUES; + + /* Check if the parameter is a "*" which means that we want + to update all variables */ + + if ((*name == '*') && (*(name + 1) == '\0')) + { + nv = varobj_list (&rootlist); + cleanup = make_cleanup (xfree, rootlist); + if (mi_version (uiout) <= 1) + make_cleanup_ui_out_tuple_begin_end (uiout, "changelist"); + else + make_cleanup_ui_out_list_begin_end (uiout, "changelist"); + if (nv <= 0) + { + do_cleanups (cleanup); + return MI_CMD_DONE; + } + cr = rootlist; + while (*cr != NULL) + { + varobj_update_one (*cr, print_values, 0 /* implicit */); + cr++; + } + do_cleanups (cleanup); + } + else + { + /* Get varobj handle, if a valid var obj name was specified */ + var = varobj_get_handle (name); + if (var == NULL) + error (_("mi_cmd_var_update: Variable object not found")); + + if (mi_version (uiout) <= 1) + cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, "changelist"); + else + cleanup = make_cleanup_ui_out_list_begin_end (uiout, "changelist"); + varobj_update_one (var, print_values, 1 /* explicit */); + do_cleanups (cleanup); + } + return MI_CMD_DONE; +} + +/* Helper for mi_cmd_var_update(). */ + +static void +varobj_update_one (struct varobj *var, enum print_values print_values, + int explicit) +{ + struct varobj **changelist; + struct varobj **cc; + struct cleanup *cleanup = NULL; + int nc; + + nc = varobj_update (&var, &changelist, explicit); + + /* nc >= 0 represents the number of changes reported into changelist. + nc < 0 means that an error occured or the the variable has + changed type (TYPE_CHANGED). */ + + if (nc == 0) + return; + else if (nc < 0) + { + if (mi_version (uiout) > 1) + cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); + ui_out_field_string (uiout, "name", varobj_get_objname(var)); + + switch (nc) + { + case NOT_IN_SCOPE: + ui_out_field_string (uiout, "in_scope", "false"); + break; + case INVALID: + ui_out_field_string (uiout, "in_scope", "invalid"); + break; + case TYPE_CHANGED: + ui_out_field_string (uiout, "in_scope", "true"); + ui_out_field_string (uiout, "new_type", varobj_get_type(var)); + ui_out_field_int (uiout, "new_num_children", + varobj_get_num_children(var)); + break; + } + if (mi_version (uiout) > 1) + do_cleanups (cleanup); + } + else + { + cc = changelist; + while (*cc != NULL) + { + if (mi_version (uiout) > 1) + cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); + ui_out_field_string (uiout, "name", varobj_get_objname (*cc)); + if (mi_print_value_p (varobj_get_gdb_type (*cc), print_values)) + ui_out_field_string (uiout, "value", varobj_get_value (*cc)); + ui_out_field_string (uiout, "in_scope", "true"); + ui_out_field_string (uiout, "type_changed", "false"); + if (mi_version (uiout) > 1) + do_cleanups (cleanup); + cc++; + } + xfree (changelist); + } +}
mi-cmd-var.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mi-main.h =================================================================== --- mi-main.h (nonexistent) +++ mi-main.h (revision 816) @@ -0,0 +1,29 @@ +/* MI Internal Functions for GDB, the GNU debugger. + + Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef MI_MAIN_H +#define MI_MAIN_H + +extern void mi_load_progress (const char *section_name, + unsigned long sent_so_far, + unsigned long total_section, + unsigned long total_sent, + unsigned long grand_total); +#endif +
mi-main.h Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: mi-symbol-cmds.c =================================================================== --- mi-symbol-cmds.c (nonexistent) +++ mi-symbol-cmds.c (revision 816) @@ -0,0 +1,65 @@ +/* MI Command Set - symbol commands. + Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include "defs.h" +#include "mi-cmds.h" +#include "symtab.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. */ + +enum mi_cmd_result +mi_cmd_symbol_list_lines (char *command, char **argv, int argc) +{ + char *filename; + struct symtab *s; + int i; + struct cleanup *cleanup_stack, *cleanup_tuple; + + if (argc != 1) + error (_("mi_cmd_symbol_list_lines: Usage: SOURCE_FILENAME")); + + filename = argv[0]; + s = lookup_symtab (filename); + + if (s == NULL) + error (_("mi_cmd_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. */ + + cleanup_stack = make_cleanup_ui_out_list_begin_end (uiout, "lines"); + + if (LINETABLE (s) != NULL && LINETABLE (s)->nitems > 0) + for (i = 0; i < LINETABLE (s)->nitems; i++) + { + cleanup_tuple = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); + ui_out_field_core_addr (uiout, "pc", LINETABLE (s)->item[i].pc); + ui_out_field_int (uiout, "line", LINETABLE (s)->item[i].line); + do_cleanups (cleanup_tuple); + } + + do_cleanups (cleanup_stack); + + return MI_CMD_DONE; +}
mi-symbol-cmds.c Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.