summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/binutils/gdb/mi
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2004-05-21 19:18:40 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2004-05-21 19:18:40 +0000
commit6a565344557d0acb4bd34cc9a0bf698662f9006b (patch)
tree5c120526742e6dbb98c8c3d2857c18f7de16143a /gnu/usr.bin/binutils/gdb/mi
parenta0769fe1e18fcff10de0bca7c087aacab3cda1cb (diff)
GDB 6.1 (excluding .info files)
Diffstat (limited to 'gnu/usr.bin/binutils/gdb/mi')
-rw-r--r--gnu/usr.bin/binutils/gdb/mi/ChangeLog-1999-20032180
-rw-r--r--gnu/usr.bin/binutils/gdb/mi/mi-cmd-break.c240
-rw-r--r--gnu/usr.bin/binutils/gdb/mi/mi-cmd-disas.c163
-rw-r--r--gnu/usr.bin/binutils/gdb/mi/mi-cmd-env.c259
-rw-r--r--gnu/usr.bin/binutils/gdb/mi/mi-cmd-file.c67
-rw-r--r--gnu/usr.bin/binutils/gdb/mi/mi-cmd-stack.c349
-rw-r--r--gnu/usr.bin/binutils/gdb/mi/mi-cmd-var.c538
-rw-r--r--gnu/usr.bin/binutils/gdb/mi/mi-cmds.c267
-rw-r--r--gnu/usr.bin/binutils/gdb/mi/mi-cmds.h152
-rw-r--r--gnu/usr.bin/binutils/gdb/mi/mi-console.c125
-rw-r--r--gnu/usr.bin/binutils/gdb/mi/mi-console.h29
-rw-r--r--gnu/usr.bin/binutils/gdb/mi/mi-getopt.c92
-rw-r--r--gnu/usr.bin/binutils/gdb/mi/mi-getopt.h80
-rw-r--r--gnu/usr.bin/binutils/gdb/mi/mi-interp.c406
-rw-r--r--gnu/usr.bin/binutils/gdb/mi/mi-main.c1494
-rw-r--r--gnu/usr.bin/binutils/gdb/mi/mi-main.h33
-rw-r--r--gnu/usr.bin/binutils/gdb/mi/mi-out.c409
-rw-r--r--gnu/usr.bin/binutils/gdb/mi/mi-out.h36
-rw-r--r--gnu/usr.bin/binutils/gdb/mi/mi-parse.c233
-rw-r--r--gnu/usr.bin/binutils/gdb/mi/mi-parse.h55
-rw-r--r--gnu/usr.bin/binutils/gdb/mi/mi-symbol-cmds.c67
21 files changed, 7274 insertions, 0 deletions
diff --git a/gnu/usr.bin/binutils/gdb/mi/ChangeLog-1999-2003 b/gnu/usr.bin/binutils/gdb/mi/ChangeLog-1999-2003
new file mode 100644
index 00000000000..4821597f8d6
--- /dev/null
+++ b/gnu/usr.bin/binutils/gdb/mi/ChangeLog-1999-2003
@@ -0,0 +1,2180 @@
+2003-11-06 Andrew Cagney <cagney@redhat.com>
+
+ * mi-cmd-var.c (mi_cmd_var_set_format): Replace STREQN with
+ strncmp.
+
+2003-10-24 Andrew Cagney <cagney@redhat.com>
+
+ * tui-out.c: Fix "fortunatly"[sic].
+
+2003-10-02 Andrew Cagney <cagney@redhat.com>
+
+ * mi-main.c: Rename REGISTER_RAW_SIZE to
+ DEPRECATED_REGISTER_RAW_SIZE.
+
+2003-09-30 Andrew Cagney <cagney@redhat.com>
+
+ * mi-main.c: Rename REGISTER_VIRTUAL_SIZE to
+ DEPRECATED_REGISTER_VIRTUAL_SIZE.
+
+2003-09-17 Andrew Cagney <cagney@redhat.com>
+
+ * mi-main.c: Rename REGISTER_BYTE to DEPRECATED_REGISTER_BYTE.
+
+2003-09-10 Elena Zannoni <ezannoni@redhat.com>
+
+ * 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 <cagney@redhat.com>
+
+ * 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 <cagney@redhat.com>
+
+ * mi-interp.c (_initialize_mi_interp): Register "mi2" and "mi3".
+ Make "mi" select "mi2".
+
+2003-08-05 Andrew Cagney <cagney@redhat.com>
+
+ * 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 <cagney@redhat.com>
+
+ * 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 <carlton@kealia.com>
+
+ * mi-main.c (mi_error_last_message): Add "%s" second argument to
+ xasprintf call.
+
+2003-06-28 Daniel Jacobowitz <drow@mvista.com>
+
+ * mi-out.c (mi_ui_out_impl): Add NULL for redirect member.
+
+2003-06-17 Daniel Jacobowitz <drow@mvista.com>
+
+ * mi-cmds.c (mi_cmds): Add "-target-disconnect".
+
+2003-06-11 David Carlton <carlton@bactrian.org>
+
+ * mi-cmd-stack.c: Include dictionary.h.
+ (list_args_or_locals): Update use of ALL_BLOCK_SYMBOLS.
+
+2003-06-11 Andrew Cagney <cagney@redhat.com>
+
+ * mi-main.c (get_register): Replace REGISTER_CONVERTIBLE with
+ DEPRECATED_REGISTER_CONVERTIBLE.
+
+2003-06-08 Andrew Cagney <cagney@redhat.com>
+
+ * 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 <cagney@redhat.com>
+
+ * mi-main.c (mi_setup_architecture_data):
+
+2003-05-12 Elena Zannoni <ezannoni@redhat.com>
+
+ * mi-mi-cmd-stack.c (list_args_or_locals): Rename VAR_NAMESPACE to
+ VAR_DOMAIN.
+
+2003-05-11 Andrew Cagney <cagney@redhat.com>
+
+ * mi-symbol-cmds.c: Rename "mi-cmd-symbol.c", avoid 8.3 problem.
+
+2003-05-08 Andrew Cagney <cagney@redhat.com>
+
+ * mi-main.c (register_changed_p): Use MAX_REGISTER_SIZE instead of
+ MAX_REGISTER_RAW_SIZE.
+
+2003-05-08 Andrew Cagney <cagney@redhat.com>
+
+ * mi-main.c (get_register): Use MAX_REGISTER_SIZE.
+
+2003-05-05 Andrew Cagney <cagney@redhat.com>
+
+ * mi-main.c (mi_cmd_data_write_register_values): Replace
+ REGISTER_SIZE with DEPRECATED_REGISTER_SIZE.
+
+2003-05-03 J. Brobecker <brobecker@gnat.com>
+
+ From Thierry Schneider <tpschneider1@yahoo.com>:
+ * 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 <bob_rossi@cox.net>
+
+ * 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 <cagney@redhat.com>
+
+ * gdbmi.texinfo: Delete file. Contents moved to
+ ../doc/gdb.texinfo.
+
+2003-03-12 Andrew Cagney <cagney@redhat.com>
+
+ * mi-main.c (get_register): Use frame_register instead of
+ get_saved_register.
+
+2003-03-08 Andrew Cagney <cagney@redhat.com>
+
+ * mi-out.c: Update copyright.
+ (mi_out_data): Define typedef. Use instead of ui_out_data.
+
+2003-03-01 Andrew Cagney <cagney@redhat.com>
+
+ * mi-main.c (get_register): Use register_type instead of
+ REGISTER_VIRTUAL_TYPE.
+
+2003-02-25 David Carlton <carlton@math.stanford.edu>
+
+ * mi-cmd-stack.c: Replace all instances of SYMBOL_NAME with
+ DEPRECATED_SYMBOL_NAME. Update copyright.
+
+2003-02-21 Daniel Jacobowitz <drow@mvista.com>
+
+ * mi-cmd-stack.c (list_args_or_locals): Handle LOC_COMPUTED and
+ LOC_COMPUTED_ARG.
+
+2003-02-19 David Carlton <carlton@math.stanford.edu>
+
+ * mi-cmd-stack.c: #include "block.h"
+
+2003-02-09 Andrew Cagney <ac131313@redhat.com>
+
+ * mi-interp.c (mi_remove_notify_hooks): Convert function
+ definition to ISO C.
+
+2003-02-06 Andrew Cagney <ac131313@redhat.com>
+
+ * mi-cmd-env.c: Include "gdb_stat.h" instead of <sys/stat.h>.
+
+2003-02-04 Jim Ingham <jingham@apple.com>
+ Keith Seitz <keiths@redhat.com>
+ Elena Zannoni <ezannoni@redhat.com>
+ Andrew Cagney <ac131313@redhat.com>
+
+ * 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 <ac131313@redhat.com>
+
+ From Keith Seitz <keiths@redhat.com>:
+ * gdbmi.texinfo (GDB/MI Miscellaneous Commands): Document the
+ interpreter-exec command.
+
+2003-02-02 Andrew Cagney <ac131313@redhat.com>
+
+ 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 <ac131313@redhat.com>
+
+ * mi-cmd-env.c: Update copyright.
+
+2003-01-13 Elena Zannoni <ezannoni@redhat.com>
+
+ * mi-main.c (mi_cmd_exec_return): Use print_stack_frame instead of
+ show_and_print_stack_frame.
+
+2003-01-09 Andrew Cagney <ac131313@redhat.com>
+
+ * mi-cmd-env.c: Include "gdb_string.h" instead of <string.h>.
+ Move all includes to after "defs.h".
+
+2002-12-13 Jeff Johnston <jjohnstn@redhat.com>
+
+ * 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 <ac131313@redhat.com>
+
+ * mi/mi-cmd-stack.c, mi/mi-main.c: Update to use
+ deprecated_selected_frame.
+
+2002-11-13 Andrew Cagney <ac131313@redhat.com>
+
+ * mi-main.c (mi_cmd_data_write_register_values): Use
+ deprecated_write_register_bytes instead of write_register_bytes.
+
+2002-11-11 Jeff Johnston <jjohnstn@redhat.com>
+
+ * 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 <jjohnstn@redhat.com>
+
+ * 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 <jjohnstn@redhat.com>
+
+ * 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 <jjohnstn@redhat.com>
+
+ * 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 <keiths@redhat.com>
+
+ * 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 <jjohnstn@redhat.com>
+
+ * 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 <jjohnstn@redhat.com>
+
+ * 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 <ezannoni@redhat.com>
+
+ * 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 <ac131313@redhat.com>
+
+ * 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 <ac131313@redhat.com>
+
+ * mi-out.c (mi_version): New function.
+ * mi-out.h (mi_version): Declare.
+
+2002-09-27 Andrew Cagney <ac131313@redhat.com>
+
+ From 2002-07-12 Mo DeJong <supermo@bayarea.net>
+ * 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 <ezannoni@redhat.com>
+
+ * mi-cmd-disas.c (dump_insns): Add text only output for CLI.
+ (do_mixed_source_and_assembly): Ditto.
+
+2002-09-11 Keith Seitz <keiths@redhat.com>
+
+ * 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 <ac131313@redhat.com>
+
+ * mi-cmd-var.c: Include "gdb_string.h".
+ * mi-cmd-disas.c: Ditto.
+
+2002-06-17 Keith Seitz <keiths@redhat.com>
+
+ * gdbmi.texinfo: Update command examples with real MI behavior.
+
+2002-05-20 Keith Seitz <keiths@redhat.com>
+
+ * 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 <ac131313@redhat.com>
+
+ * mi-main.c (mi_cmd_exec_return):
+
+2002-04-09 Andrew Cagney <ac131313@redhat.com>
+
+ * 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 <ezannoni@redhat.com>
+
+ * mi-cmd-disas.c: Run through indent.
+
+2002-04-07 Elena Zannoni <ezannoni@redhat.com>
+
+ * 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 <jimb@redhat.com>
+
+ * 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 <ezannoni@redhat.com>
+
+ * mi-cmd-disas.c (mi_cmd_disassemble): Use TARGET_PRINT_INSN
+ instead of tm_print_insn.
+ Update copyright year.
+
+2002-04-04 Daniel Jacobowitz <drow@mvista.com>
+
+ * mi-cmd-disas.c (mi_cmd_disassemble): Skip end-of-function
+ markers in the line table.
+
+2002-03-15 Andrew Cagney <ac131313@redhat.com>
+
+ * 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 <ac131313@redhat.com>
+
+ From wiz at danbala:
+ * gdbmi.texinfo: Fix grammar and typos.
+ Fix PR gdb/287.
+
+2002-02-03 Jim Blandy <jimb@redhat.com>
+
+ * 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 <ac131313@redhat.com>
+
+ * gdbmi.texinfo: Remove makeinfo 3.12 hacks.
+
+2002-01-21 Andrew Cagney <ac131313@redhat.com>
+
+ * 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 <eliz@is.elta.co.il>
+
+ * gdbmi.texinfo: Fix the application of GFDL in the Copyright notice.
+
+2001-10-12 Daniel Jacobowitz <drow@mvista.com>
+
+ * mi-cmd-stack.c (list_args_or_locals): Use ALL_BLOCK_SYMBOLS.
+
+2001-09-18 Andrew Cagney <ac131313@redhat.com>
+
+ * 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 <keiths@redhat.com>
+
+ * mi-cmd-var.c (varobj_update_one): Update call to
+ varobj_update to reflect recent api change.
+
+2001-07-26 Andrew Cagney <ac131313@redhat.com>
+
+ * mi-main.c: Include "gdb.h".
+ * mi-cmd-break.c: Include "gdb.h".
+
+2001-07-12 Andrew Cagney <ac131313@redhat.com>
+
+ * 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 <kettenis@gnu.org>
+
+ * mi-out.c (mi_out_new): Initialize suppress_ouput field of newly
+ created `struct ui_out_data'.
+
+2001-07-09 Kevin Buettner <kevinb@redhat.com>
+
+ * 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 <ac131313@redhat.com>
+
+ * mi-main.c (mi_cmd_data_evaluate_expression): Replace value_ptr
+ with `struct value *'.
+
+2001-07-08 Kevin Buettner <kevinb@redhat.com>
+
+ * 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 <ac131313@redhat.com>
+
+ * mi-out.c (mi_ui_out_impl): Initialize is_mi_like_p to one.
+
+2001-06-27 Andrew Cagney <ac131313@redhat.com>
+
+ * 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 <ac131313@redhat.com>
+
+ * gdbmi.texinfo (GDB/MI Output Syntax): Delete reference to query
+ packet.
+
+2001-06-26 Andrew Cagney <ac131313@redhat.com>
+
+ * 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 <ac131313@redhat.com>
+
+ * 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 <ac131313@redhat.com>
+
+ * gdbmi.texinfo: Update output examples that contain stop reason
+ output, change the args=.... to a list.
+ (exec-return): Ditto.
+
+2001-06-25 Andrew Cagney <ac131313@redhat.com>
+
+ * 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 <ac131313@redhat.com>
+
+ * 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 <ac131313@redhat.com>
+
+ * 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 <ac131313@redhat.com>
+
+ * 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 <ac131313@redhat.com>
+
+ * gdbmi.texinfo (data-disassemble): Update documentation of
+ output. Produces a list of instructions and a list of source
+ lines.
+
+2001-06-22 Andrew Cagney <ac131313@redhat.com>
+
+ * mi-cmd-disas.c (mi_cmd_disassemble): For "-data-disassemble",
+ output a list instead of a tupple.
+
+2001-06-21 Andrew Cagney <ac131313@redhat.com>
+
+ * 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 <ac131313@redhat.com>
+
+ * mi-out.c (mi_open): For lists, when mi_version > 0, use ``[''.
+ (mi_close): Ditto for ``]''.
+
+2001-06-20 Andrew Cagney <ac131313@redhat.com>
+
+ * mi-out.c (mi_table_header): Add parameter ``col_name''.
+
+2001-06-18 Andrew Cagney <ac131313@redhat.com>
+
+ * mi-out.c: Include "gdb_assert.h".
+ (mi_table_begin): Add parameter ``nr_rows''.
+
+2001-06-18 Andrew Cagney <ac131313@redhat.com>
+
+ * 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 <ac131313@redhat.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * mi-out.c: Fix typo. s/supress/suppress/.
+
+2001-06-09 Andrew Cagney <ac131313@redhat.com>
+
+ * 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 <ac131313@redhat.com>
+
+ * 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 <ac131313@redhat.com>
+
+ * mi-out.c (mi_close, mi_open): Output ``[]'' when a list.
+
+Fri May 11 13:55:07 2001 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * 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 <ac131313@redhat.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * mi-main.c (mi_execute_async_cli_command): Always initialize
+ old_cleanups.
+
+2001-05-08 Andrew Cagney <ac131313@redhat.com>
+
+ * 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 <ac131313@redhat.com>
+
+ * mi-main.c (mi_cmd_data_read_memory): Use xcalloc.
+
+2001-03-26 Eli Zaretskii <eliz@is.elta.co.il>
+
+ * gdbmi.texinfo: Update copyright. Change Permissions to GFDL.
+
+2001-03-20 Andrew Cagney <ac131313@redhat.com>
+
+ * mi-cmd-disas.c (mi_cmd_disassemble): Initialize ``file_string''
+ and ``line_num''. Consolidate declaration of argument variables.
+
+2001-03-19 Andrew Cagney <ac131313@redhat.com>
+
+ * mi-out.h: Remove #ifdef __STDC__.
+
+2001-03-08 Andrew Cagney <ac131313@redhat.com>
+
+ * 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 <kevinb@redhat.com>
+
+ * 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 <cagney@redhat.com>
+
+ * 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 <fnasser@redhat.com>
+
+ From Momchil Velikov <velco@fadata.bg>
+ * 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 <kevinb@redhat.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * mi-main.c: Replace asprintf with xasprintf.
+ * mi-cmd-var.c (mi_cmd_var_create): Ditto.
+
+2000-10-16 Eli Zaretskii <eliz@is.elta.co.il>
+
+ * gdbmi.texinfo (GDB/MI Variable Objects): Dimensions of
+ multitable changed to "@columnfractions .4 .6". Suggested by
+ Dmitry Sivachenko <dima@Chg.RU>.
+
+2000-08-23 Eli Zaretskii <eliz@is.elta.co.il>
+
+ * gdbmi.texinfo: Change flathead -> @sc{gdb/mi}.
+ Fix typos and markup mistakes (from Dmitry S.
+ Sivachenko <dima@Chg.RU>).
+
+2000-07-24 Eli Zaretskii <eliz@is.elta.co.il>
+
+ * gdbmi.texinfo: Change GDB -> @value{GDBN}, and
+ (gdb) -> (@value{GDBP}). Fix a few typos and some markup. From
+ Dmitry S. Sivachenko <dima@Chg.RU>.
+
+Tue May 16 14:13:41 2000 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * mi-main.c (mi_cmd_execute): Use free_current_contents.
+ (free_and_reset): Delete.
+
+Mon May 15 16:17:56 2000 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * 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 <eliz@is.elta.co.il>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * 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 <eliz@is.elta.co.il>
+
+ * gdbmi.texinfo: Lots of changes, to include this document as part
+ of the GDB manual.
+
+2000-03-13 James Ingham <jingham@leda.cygnus.com>
+
+ * 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 <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <ezannoni@kwikemart.cygnus.com>
+
+ * gdbmi.texinfo: Update data-disassemble documentation.
+
+2000-03-01 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * 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 <ezannoni@kwikemart.cygnus.com>
+
+ * mi-main.c: Add include of gdbcore.h for write_memory()
+ prototype.
+
+2000-02-18 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <ezannoni@kwikemart.cygnus.com>
+
+ * mi-cmd-disas.c (mi_cmd_disassemble):
+
+2000-02-17 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * mi-main.c (mi_command_loop): Delete reference to
+ fputs_unfiltered_hook.
+
+2000-01-27 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <ezannoni@kwikemart.cygnus.com>
+
+ * mi-main.c (mi_cmd_data_read_memory): Correct the computation of
+ next-row.
+
+2000-01-27 Fernando Nasser <fnasser@totem.to.cygnus.com>
+
+ * 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 <fnasser@totem.to.cygnus.com>
+
+ * mi-out.c (mi_field_string): Test for NULL string pointer.
+
+2000-01-17 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <ezannoni@kwikemart.cygnus.com>
+
+ * mi-main.c: Move disassemble commands from here.
+
+ * mi-cmd-disas.c: To here. New file.
+
+2000-01-13 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <ezannoni@kwikemart.cygnus.com>
+
+ * mi-main.c: Move stack commands from here.
+
+ * mi-cmd-stack.c: To here. New file.
+
+2000-01-07 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * mi-cmd-break.c (mi_cmd_break_insert): Add support for -c
+ <condition>, -i <ignore-count> and -p <thread>.
+ (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 <cagney@b1.cygnus.com>
+
+ * mi-main.c (gdb_do_disassemble): Strip out more useless #ifdef
+ UI_OUTs.
+
+1999-12-23 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <fnasser@totem.to.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * gdbmi.texinfo: Document recommended syntax for options.
+
+ * mi-main.c (mi_cmd_data_read_memory): Add support for ``-o
+ <offset>''.
+ * gdbmi.texinfo: Document.
+
+Wed Dec 15 17:43:08 1999 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * 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 <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * 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 <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <ezannoni@kwikemart.cygnus.com>
+
+ * mi-main.c (gdb_do_disassemble): Update output for UI_OUT case.
+
+1999-12-02 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * gdbmi.texinfo: Update exec-until output, including the reason
+ for stopping.
+
+Thu Dec 2 17:17:22 1999 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * mi-cmds.c: Include <string.h> for memset.
+
+1999-12-01 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * mi-main.c (mi_cmd_exec_return): ifdef the references to
+ return_command_wrapper().
+
+1999-12-01 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <ezannoni@kwikemart.cygnus.com>
+
+ * mi-main.c (mi_cmd_exec_return): Reimplement using
+ return_command() instead of mi_execute_async_cli_command().
+
+1999-12-01 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <ezannoni@kwikemart.cygnus.com>
+
+ * gdbmi.texinfo: Fix some texinfo formatting errors.
+
+1999-12-01 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * mi-main.c (mi_execute_async_cli_command): Append missing "\n"
+ for synchronous stopped message.
+
+1999-11-30 James Ingham <jingham@leda.cygnus.com>
+
+ * gdbmi.texinfo: Fix obvious typo in @end statement.
+
+Wed Dec 1 12:36:27 1999 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * mi-cmd-var.c: Include "value.h".
+ * mi-console.c: Include <string.h>.
+
+Wed Dec 1 00:21:03 1999 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * gdbmi.texinfo: Explain NR-BYTES and ADDR.
+
+Tue Nov 30 23:31:57 1999 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * mi-main.c (captured_mi_execute_command): Use fputstr_unfiltered
+ when printing error messages.
+ (mi_cmd_execute): Ditto.
+
+1999-11-29 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <ezannoni@kwikemart.cygnus.com>
+
+ * gdbmi.texinfo: Remove mentioning of inaccurate watchpoint hit
+ count.
+
+Mon Nov 29 19:28:55 1999 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * 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 <cagney@rat-in-a-hat.cygnus.com>
+
+ * mi-parse.c: Include <ctype.h> and <string.h>
+
+1999-11-26 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * gdbmi.texinfo (section Output Syntax): For lists, the <string>
+ part of a <result> 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 <cagney@b1.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * mi-parse.c (mi_parse): Initialize TOKEN when a CLI command.
+
+ * gdbmi.texinfo: Allow a <token> 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 <cagney@b1.cygnus.com>
+
+ * mi-parse.h: Remove const, from cmd parameter. Causes cascading
+ warnings.
+
+Wed Nov 24 15:03:34 1999 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * mi-parse.c, mi-parse.h: New files. Implement mi_parse_env.
+
+Wed Nov 24 11:24:05 1999 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * mi-out.c (mi_field_string): Make string parameter constant.
+
+1999-11-23 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * mi-cmds.h (mi_cmd_target_download): Export.
+
+ * mi-cmds.c (mi_cmds): Add mi_cmd_target_download.
+
+ * mi-main.c: Include <sys/time.h>.
+ (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 <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * 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 <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * mi-out.c (mi_field_string): Always quote the string.
+
+1999-11-10 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * mi-main.c (mi_execute_command): Correctly quote error messages.
+
+Wed Nov 10 11:05:14 1999 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * mi/gdbmi.texinfo: Delete <stream-output>. Replaced by
+ <c-string>.
+
+ * mi-main.c (mi_console_raw_packet): Always quote console output.
+
+Tue Nov 9 17:53:05 1999 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * 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 <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * mi-main.c (clean): Delete.
+ (mi_command_loop): Delete extern declaration of
+ mi_execute_command.
+
+1999-10-28 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * mi-main.c (mi_command_loop): Don't initialize ``flush_hook''.
+
+1999-10-13 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * mi/gdbmi.texinfo: More reformatting of the grammars.
+
+1999-10-12 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * mi/gdbmi.texinfo: More TeX formatting.
+
+1999-10-11 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <ezannoni@kwikemart.cygnus.com>
+
+ * mi/gdbmi.texinfo: Filled in part of file command section, and
+ stack section.
+
+1999-10-07 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * mi/gdbmi.texinfo: Filled in some sections about execution
+ commands.
+
+Tue Oct 5 15:27:28 1999 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * mi-cmds.h: Sort table
+ * mi-cmds.c: Ditto.
+ (MI_TABLE_SIZE): Increase to 251.
+
+1999-10-04 Fernando Nasser <fnasser@totem.to.cygnus.com>
+
+ * mi-main.c (mi_cmd_var_create, mi_cmd_var_delete): Add missing
+ cleanups.
+
+1999-10-04 Fernando Nasser <fnasser@totem.to.cygnus.com>
+
+ * 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 <fnasser@totem.to.cygnus.com>
+
+ * mi-main.c (mi_execute_command): Fix handling of errors.
+
+1999-10-04 Fernando Nasser <fnasser@totem.to.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * 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 <ezannoni@kwikemart.cygnus.com>
+
+ * mi-main.c (mi_execute_async_cli_command): Don't do the cleanups
+ if target_executing is null.
+
+1999-09-28 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * mi-main.c (async_p): Change var name to event_loop_p.
+
+Mon Sep 27 15:11:00 1999 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * 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 <fnasser@totem.to.cygnus.com>
+
+ * mi-main.c (mi_cmd_var_create): Use paddr() to format address
+ on trace output.
+
+1999-09-21 Fernando Nasser <fnasser@totem.to.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * Makefile.in (mi-out.o): Add dependency list.
+ * mi-out.c: Include "mi-out.h".
+
+1999-09-18 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * mi-main.c (_initialize_mi_main): Events on stadin are now
+ handled by stdin_event_handler.
+
+1999-09-17 Fernando Nasser <fnasser@totem.to.cygnus.com>
+
+ * mi-cmds.c (mi_cmds): Add var-* commands.
+
+1999-09-17 Fernando Nasser <fnasser@totem.to.cygnus.com>
+
+ * 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 <fnasser@totem.to.cygnus.com>
+
+ * mi-cmds.c (mi_cmds): Add detach command.
+
+1999-09-09 Fernando Nasser <fnasser@totem.to.cygnus.com>
+
+ * mi-cmds.c (lookup_table): Fix typo.
+
+1999-09-09 Fernando Nasser <fnasser@totem.to.cygnus.com>
+
+ * mi-cmds.c (mi_cmds): Fix typo and missing command.
+
+1999-09-09 Fernando Nasser <fnasser@totem.to.cygnus.com>
+
+ * mi-main.c: Properly align function prototypes.
+ (mi_cmd_target_select): Proper check for NULL value.
+
+1999-09-09 Fernando Nasser <fnasser@totem.to.cygnus.com>
+
+ * mi-main.c (mi_execute_async_cli_command): Fix for native targets
+ that do not have async yet.
+
+1999-09-01 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * mi-main.c (mi_cmd_disassemble): Remove unused var.
+ (gdb_do_disassemble): Ditto.
+
+1999-08-30 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * mi-main.c: #include <ctype.h> for isspace().
+
+1999-08-27 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * mi-main.c (gdb_do_disassemble): This function returns void, not
+ int.
+
+1999-08-26 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * mi-main.c (mi_command_loop): Remove references to ui-hooks.
+
+1999-08-21 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <ezannoni@kwikemart.cygnus.com>
+
+ From Christopher Faylor <cgf@cygnus.com>
+ * mi-main.c (mi_execute_command): Make sure we flush all the
+ output after each command.
+
+1999-08-10 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * mi-main.c (_initialize_mi_main): Remove casting in call to
+ add_file_handler.
+
+Sun Aug 8 17:20:57 1999 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * 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 <fnasser@totem.to.cygnus.com>
+
+ * 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 <fnasser@totem.to.cygnus.com>
+
+ * 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 <fnasser@totem.to.cygnus.com>
+
+ * 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 <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <fnasser@totem.to.cygnus.com>
+
+ * mi-main.c (mi_gdb_exit): Add \n at the end.
+
+1999-07-15 Fernando Nasser <fnasser@totem.to.cygnus.com>
+
+ * mi-main.c (mi_cmd_execute): New function. Dispatch a mi operation.
+ (mi_execute_command): Use the above.
+
+1999-07-15 Fernando Nasser <fnasser@totem.to.cygnus.com>
+
+ * mi-main.c: Fix identation.
+
+1999-07-15 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * 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 <fnasser@totem.to.cygnus.com>
+
+ * 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 <fnasser@totem.to.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * 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 <fnasser@totem.to.cygnus.com>
+
+ * top.c (print_gdb_version): Add the word HEADLESS when output
+ follows headless format.
+ (print_command_lines): Fix typo.
+
+1999-06-25 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
+
+ * 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 <fnasser@totem.to.cygnus.com>
+
+ * 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 <fnasser@totem.to.cygnus.com>
+
+ * mi-out.c (mi_table_begin): Add missing field separator call.
+
+Thu Jun 17 21:05:40 1999 Fernando Nasser <fnasser@tofu.to.cygnus.com>
+
+ * breakpoint.c (breakpoint_1): Remove space in breakpoint table
+ id.
+ (mention): Use ui_out for last new line (forgotten).
+
+1999-06-16 Fernando Nasser <fnasser@totem.to.cygnus.com>
+
+ * 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 <fnasser@totem.to.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * 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 <fnasser@totem.to.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ From Fernando Nasser <fnasser@totem.to.cygnus.com>
+ * 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 <cagney@b1.cygnus.com>
+
+ From Fernando Nasser <fnasser@totem.to.cygnus.com>:
+ * 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 <fnasser@totem.to.cygnus.com>
+
+ * mi-out.c (mi_table_end): Remove unwanted "\n".
+
+Thu May 27 14:59:06 1999 Andrew Cagney <cagney@b1.cygnus.com>
+
+ * 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 <cagney@b1.cygnus.com>
+
+ * top.c (call_interp_loop): Hack. Add extern declaration for
+ mi_ui_out_impl.
+
+1999-05-25 Fernando Nasser <fnasser@totem.to.cygnus.com>
+
+ * mi-out.c: New table syntax.
+
+Mon May 24 16:16:29 1999 Andrew Cagney <cagney@amy.cygnus.com>
+
+ mi-out.c (_initialize_mi_out): Add external declaration.
+
+1999-05-21 Fernando Nasser <fnasser@totem.to.cygnus.com>
+
+ * mi-out.c (mi_table_begin): Added missing parameter.
+
+1999-05-21 Fernando Nasser <fnasser@totem.to.cygnus.com>
+
+ * mi-out.c: Changed table markers and added table id.
+
+1999-05-21 Fernando Nasser <fnasser@totem.to.cygnus.com>
+
+ * 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:
diff --git a/gnu/usr.bin/binutils/gdb/mi/mi-cmd-break.c b/gnu/usr.bin/binutils/gdb/mi/mi-cmd-break.c
new file mode 100644
index 00000000000..5d15aa98b8a
--- /dev/null
+++ b/gnu/usr.bin/binutils/gdb/mi/mi-cmd-break.c
@@ -0,0 +1,240 @@
+/* MI Command Set - breakpoint and watchpoint commands.
+ Copyright 2000, 2001, 2002 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 2 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#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"
+
+enum
+ {
+ FROM_TTY = 0
+ };
+
+/* Output a single breakpoint. */
+
+static void
+breakpoint_notify (int b)
+{
+ gdb_breakpoint_query (uiout, b);
+}
+
+
+struct gdb_events breakpoint_hooks =
+{
+ breakpoint_notify,
+ breakpoint_notify,
+ breakpoint_notify,
+};
+
+
+enum bp_type
+ {
+ REG_BP,
+ HW_BP,
+ REGEXP_BP
+ };
+
+/* Insert a breakpoint. The type of breakpoint is specified by the
+ first argument: -break-insert <location> --> insert a regular
+ breakpoint. -break-insert -t <location> --> insert a temporary
+ breakpoint. -break-insert -h <location> --> insert an hardware
+ breakpoint. -break-insert -t -h <location> --> insert a temporary
+ hw bp.
+ -break-insert -r <regexp> --> insert a bp at functions matching
+ <regexp> */
+
+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;
+ enum gdb_rc rc;
+ struct gdb_events *old_hooks;
+ enum opt
+ {
+ HARDWARE_OPT, TEMP_OPT /*, REGEXP_OPT */ , CONDITION_OPT,
+ IGNORE_COUNT_OPT, THREAD_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},
+ 0
+ };
+
+ /* Parse arguments. It could be -r or -h or -t, <location> 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;
+ }
+ }
+
+ if (optind >= argc)
+ error ("mi_cmd_break_insert: Missing <location>");
+ if (optind < argc - 1)
+ error ("mi_cmd_break_insert: Garbage following <location>");
+ address = argv[optind];
+
+ /* Now we have what we need, let's insert the breakpoint! */
+ old_hooks = set_gdb_event_hooks (&breakpoint_hooks);
+ switch (type)
+ {
+ case REG_BP:
+ rc = gdb_breakpoint (address, condition,
+ 0 /*hardwareflag */ , temp_p,
+ thread, ignore_count);
+ break;
+ case HW_BP:
+ rc = gdb_breakpoint (address, condition,
+ 1 /*hardwareflag */ , temp_p,
+ thread, ignore_count);
+ 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.");
+ }
+ set_gdb_event_hooks (old_hooks);
+
+ if (rc == GDB_RC_FAIL)
+ return MI_CMD_CAUGHT_ERROR;
+ else
+ 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 <expr> --> insert a regular wp.
+ -break-watch -r <expr> --> insert a read watchpoint.
+ -break-watch -a <expr> --> 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
+ };
+
+ /* 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 <expression>");
+ if (optind < argc - 1)
+ error ("mi_cmd_break_watch: Garbage following <expression>");
+ 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;
+}
diff --git a/gnu/usr.bin/binutils/gdb/mi/mi-cmd-disas.c b/gnu/usr.bin/binutils/gdb/mi/mi-cmd-disas.c
new file mode 100644
index 00000000000..168ca171666
--- /dev/null
+++ b/gnu/usr.bin/binutils/gdb/mi/mi-cmd-disas.c
@@ -0,0 +1,163 @@
+/* MI Command Set - disassemble commands.
+ Copyright 2000, 2001, 2002 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 2 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#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
+ };
+
+ /* 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;
+}
diff --git a/gnu/usr.bin/binutils/gdb/mi/mi-cmd-env.c b/gnu/usr.bin/binutils/gdb/mi/mi-cmd-env.c
new file mode 100644
index 00000000000..439c71912bd
--- /dev/null
+++ b/gnu/usr.bin/binutils/gdb/mi/mi-cmd-env.c
@@ -0,0 +1,259 @@
+/* MI Command Set - environment commands.
+
+ Copyright 2002, 2003, 2004 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 2 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#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)
+ xasprintf (&run, "%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. */
+enum mi_cmd_result
+mi_cmd_env_pwd (char *command, char **argv, int argc)
+{
+ 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. */
+
+ getcwd (gdb_dirbuf, sizeof (gdb_dirbuf));
+ 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
+ };
+
+ 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
+ };
+
+ 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;
+}
+
+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);
+}
diff --git a/gnu/usr.bin/binutils/gdb/mi/mi-cmd-file.c b/gnu/usr.bin/binutils/gdb/mi/mi-cmd-file.c
new file mode 100644
index 00000000000..eb1d67a6a8d
--- /dev/null
+++ b/gnu/usr.bin/binutils/gdb/mi/mi-cmd-file.c
@@ -0,0 +1,67 @@
+/* MI Command Set - breakpoint and watchpoint commands.
+ Copyright 2000, 2001, 2002 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 2 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include "defs.h"
+#include "mi-cmds.h"
+#include "mi-getopt.h"
+#include "ui-out.h"
+#include "symtab.h"
+#include "source.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 */
+ if (st.symtab->fullname == NULL)
+ symtab_to_filename (st.symtab);
+
+ /* We may not be able to open the file (not available). */
+ if (st.symtab->fullname == NULL)
+ error ("mi_cmd_file_list_exec_source_file: File not found");
+
+ /* 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);
+ ui_out_field_string (uiout, "fullname", st.symtab->fullname);
+
+ return MI_CMD_DONE;
+}
diff --git a/gnu/usr.bin/binutils/gdb/mi/mi-cmd-stack.c b/gnu/usr.bin/binutils/gdb/mi/mi-cmd-stack.c
new file mode 100644
index 00000000000..7db9ffbea63
--- /dev/null
+++ b/gnu/usr.bin/binutils/gdb/mi/mi-cmd-stack.c
@@ -0,0 +1,349 @@
+/* MI Command Set - stack commands.
+ Copyright 2000, 2002, 2003, 2004 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 2 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#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 (!target_has_stack)
+ error ("mi_cmd_stack_list_frames: No stack.");
+
+ 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;
+ /* level == i: always print the level 'i'
+ source == LOC_AND_ADDRESS: print the location and the address
+ always, even for level 0.
+ args == 0: don't print the arguments. */
+ print_frame_info (fi /* frame info */ ,
+ i /* level */ ,
+ LOC_AND_ADDRESS /* source */ ,
+ 0 /* args */ );
+ }
+
+ do_cleanups (cleanup_stack);
+ if (i < frame_high)
+ error ("mi_cmd_stack_list_frames: Not enough frames in 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 (!target_has_stack)
+ error ("mi_cmd_stack_info_depth: No stack.");
+
+ 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 ();
+
+ if (strcmp (argv[0], "0") == 0
+ || strcmp (argv[0], "--no-values") == 0)
+ print_values = PRINT_NO_VALUES;
+ else if (strcmp (argv[0], "1") == 0
+ || strcmp (argv[0], "--all-values") == 0)
+ print_values = PRINT_ALL_VALUES;
+ else if (strcmp (argv[0], "2") == 0
+ || strcmp (argv[0], "--simple-values") == 0)
+ print_values = PRINT_SIMPLE_VALUES;
+ else
+ error ("Unknown value for PRINT_VALUES: must be: 0 or \"--no-values\", 1 or \"--all-values\", 2 or \"--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);
+ if (i < frame_high)
+ error ("mi_cmd_stack_list_args: Not enough frames in stack.");
+
+ 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;
+ 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)
+ {
+ print_variable_value (sym2, fi, stb->stream);
+ ui_out_field_stream (uiout, "value", stb);
+ }
+ do_cleanups (cleanup_tuple);
+ break;
+ case PRINT_ALL_VALUES:
+ print_variable_value (sym2, fi, stb->stream);
+ 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 (!target_has_stack)
+ error ("mi_cmd_stack_select_frame: No stack.");
+
+ if (argc > 1)
+ error ("mi_cmd_stack_select_frame: Usage: [FRAME_SPEC]");
+
+ /* with no args, don't change frame */
+ if (argc == 0)
+ select_frame_command (0, 1 /* not used */ );
+ else
+ select_frame_command (argv[0], 1 /* not used */ );
+ return MI_CMD_DONE;
+}
diff --git a/gnu/usr.bin/binutils/gdb/mi/mi-cmd-var.c b/gnu/usr.bin/binutils/gdb/mi/mi-cmd-var.c
new file mode 100644
index 00000000000..709ed301052
--- /dev/null
+++ b/gnu/usr.bin/binutils/gdb/mi/mi-cmd-var.c
@@ -0,0 +1,538 @@
+/* MI Command Set - varobj commands.
+
+ Copyright 2000, 2002, 2004 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 2 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include "defs.h"
+#include "mi-cmds.h"
+#include "ui-out.h"
+#include "mi-out.h"
+#include "varobj.h"
+#include "value.h"
+#include <ctype.h>
+#include "gdb_string.h"
+
+extern int varobjdebug; /* defined in varobj.c */
+
+static int varobj_update_one (struct varobj *var);
+
+/* 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;
+ char *type;
+ struct cleanup *old_cleanups;
+ enum varobj_type var_type;
+
+ if (argc != 3)
+ {
+ /* xasprintf (&mi_error_message,
+ "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]);
+ old_cleanups = make_cleanup (xfree, frame);
+
+ expr = xstrdup (argv[2]);
+
+ 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");
+
+ ui_out_field_string (uiout, "name", name);
+ ui_out_field_int (uiout, "numchild", varobj_get_num_children (var));
+ type = varobj_get_type (var);
+ if (type == NULL)
+ ui_out_field_string (uiout, "type", "");
+ else
+ {
+ ui_out_field_string (uiout, "type", type);
+ xfree (type);
+ }
+
+ do_cleanups (old_cleanups);
+ return MI_CMD_DONE;
+}
+
+enum mi_cmd_result
+mi_cmd_var_delete (char *command, char **argv, int argc)
+{
+ char *name;
+ char *expr;
+ 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)
+ {
+ expr = xstrdup (argv[1]);
+ if (strcmp (name, "-c") != 0)
+ error ("mi_cmd_var_delete: Invalid option.");
+ children_only_p = 1;
+ xfree (name);
+ name = xstrdup (expr);
+ xfree (expr);
+ }
+
+ /* 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 = xstrdup (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]);
+ 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;
+}
+
+enum mi_cmd_result
+mi_cmd_var_list_children (char *command, char **argv, int argc)
+{
+ struct varobj *var;
+ struct varobj **childlist;
+ struct varobj **cc;
+ struct cleanup *cleanup_children;
+ int numchild;
+ char *type;
+ enum print_values print_values;
+
+ 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");
+
+ numchild = varobj_list_children (var, &childlist);
+ ui_out_field_int (uiout, "numchild", numchild);
+ if (argc == 2)
+ if (strcmp (argv[0], "0") == 0
+ || strcmp (argv[0], "--no-values") == 0)
+ print_values = PRINT_NO_VALUES;
+ else if (strcmp (argv[0], "1") == 0
+ || strcmp (argv[0], "--all-values") == 0)
+ print_values = PRINT_ALL_VALUES;
+ else
+ error ("Unknown value for PRINT_VALUES: must be: 0 or \"--no-values\", 1 or \"--all-values\"");
+ else print_values = PRINT_NO_VALUES;
+
+ if (numchild <= 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");
+ cc = childlist;
+ while (*cc != NULL)
+ {
+ struct cleanup *cleanup_child;
+ cleanup_child = make_cleanup_ui_out_tuple_begin_end (uiout, "child");
+ ui_out_field_string (uiout, "name", varobj_get_objname (*cc));
+ ui_out_field_string (uiout, "exp", varobj_get_expression (*cc));
+ ui_out_field_int (uiout, "numchild", varobj_get_num_children (*cc));
+ if (print_values)
+ ui_out_field_string (uiout, "value", varobj_get_value (*cc));
+ type = varobj_get_type (*cc);
+ /* C++ pseudo-variables (public, private, protected) do not have a type */
+ if (type)
+ ui_out_field_string (uiout, "type", varobj_get_type (*cc));
+ do_cleanups (cleanup_child);
+ cc++;
+ }
+ do_cleanups (cleanup_children);
+ xfree (childlist);
+ 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_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");
+
+ /* FIXME: define masks for attributes */
+ if (!(varobj_get_attributes (var) & 0x00000001))
+ 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 varible 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;
+
+ if (argc != 1)
+ error ("mi_cmd_var_update: Usage: NAME.");
+
+ name = argv[0];
+
+ /* Check if the parameter is a "*" which means that we want
+ to update all variables */
+
+ if ((*name == '*') && (*(name + 1) == '\0'))
+ {
+ nv = varobj_list (&rootlist);
+ 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");
+ if (nv <= 0)
+ {
+ do_cleanups (cleanup);
+ return MI_CMD_DONE;
+ }
+ cr = rootlist;
+ while (*cr != NULL)
+ {
+ varobj_update_one (*cr);
+ cr++;
+ }
+ xfree (rootlist);
+ 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);
+ do_cleanups (cleanup);
+ }
+ return MI_CMD_DONE;
+}
+
+/* Helper for mi_cmd_var_update() Returns 0 if the update for
+ the variable fails (usually because the variable is out of
+ scope), and 1 if it succeeds. */
+
+static int
+varobj_update_one (struct varobj *var)
+{
+ struct varobj **changelist;
+ struct varobj **cc;
+ struct cleanup *cleanup = NULL;
+ int nc;
+
+ nc = varobj_update (&var, &changelist);
+
+ /* nc == 0 means that nothing has changed.
+ nc == -1 means that an error occured in updating the variable.
+ nc == -2 means the variable has changed type. */
+
+ if (nc == 0)
+ return 1;
+ else if (nc == -1)
+ {
+ 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));
+ ui_out_field_string (uiout, "in_scope", "false");
+ if (mi_version (uiout) > 1)
+ do_cleanups (cleanup);
+ return -1;
+ }
+ else if (nc == -2)
+ {
+ 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));
+ 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));
+ 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));
+ 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);
+ return 1;
+ }
+ return 1;
+}
diff --git a/gnu/usr.bin/binutils/gdb/mi/mi-cmds.c b/gnu/usr.bin/binutils/gdb/mi/mi-cmds.c
new file mode 100644
index 00000000000..0dfc2170ec9
--- /dev/null
+++ b/gnu/usr.bin/binutils/gdb/mi/mi-cmds.c
@@ -0,0 +1,267 @@
+/* MI Command Set for GDB, the GNU debugger.
+
+ Copyright 2000, 2001, 2003 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 2 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#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},
+ { "display-delete", { NULL, 0 }, NULL, NULL },
+ { "display-disable", { NULL, 0 }, NULL, NULL },
+ { "display-enable", { NULL, 0 }, NULL, NULL },
+ { "display-insert", { NULL, 0 }, NULL, NULL },
+ { "display-list", { NULL, 0 }, NULL, NULL },
+ { "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, NULL },
+ { "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 },
+ { "interpreter-exec", { NULL, 0 }, 0, mi_cmd_interpreter_exec},
+ { "kod-info", { NULL, 0 }, NULL, NULL },
+ { "kod-list", { NULL, 0 }, NULL, NULL },
+ { "kod-list-object-types", { NULL, 0 }, NULL, NULL },
+ { "kod-show", { NULL, 0 }, NULL, NULL },
+ { "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 }, NULL, NULL },
+ { "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-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-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-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));
+}
diff --git a/gnu/usr.bin/binutils/gdb/mi/mi-cmds.h b/gnu/usr.bin/binutils/gdb/mi/mi-cmds.h
new file mode 100644
index 00000000000..545305986c6
--- /dev/null
+++ b/gnu/usr.bin/binutils/gdb/mi/mi-cmds.h
@@ -0,0 +1,152 @@
+/* MI Command Set for GDB, the GNU debugger.
+
+ Copyright 2000, 2003, 2004 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 2 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#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,
+ /* An error condition was detected and caught. The error message is
+ in the global error message buffer. The main loop will display
+ the error message and the completion prompt. */
+ MI_CMD_CAUGHT_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
+};
+
+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_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_gdb_exit;
+extern mi_cmd_argv_ftype mi_cmd_interpreter_exec;
+extern mi_cmd_argv_ftype mi_cmd_stack_info_depth;
+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_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_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_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_error_last_message (void);
+extern void mi_execute_command (char *cmd, int from_tty);
+
+#endif
diff --git a/gnu/usr.bin/binutils/gdb/mi/mi-console.c b/gnu/usr.bin/binutils/gdb/mi/mi-console.c
new file mode 100644
index 00000000000..aca008640fd
--- /dev/null
+++ b/gnu/usr.bin/binutils/gdb/mi/mi-console.c
@@ -0,0 +1,125 @@
+/* MI Console code.
+
+ Copyright 2000, 2001, 2002 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 2 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#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);
+}
diff --git a/gnu/usr.bin/binutils/gdb/mi/mi-console.h b/gnu/usr.bin/binutils/gdb/mi/mi-console.h
new file mode 100644
index 00000000000..bc6c0085398
--- /dev/null
+++ b/gnu/usr.bin/binutils/gdb/mi/mi-console.h
@@ -0,0 +1,29 @@
+/* MI Command Set - MI Console.
+ Copyright 2000 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 2 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#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
diff --git a/gnu/usr.bin/binutils/gdb/mi/mi-getopt.c b/gnu/usr.bin/binutils/gdb/mi/mi-getopt.c
new file mode 100644
index 00000000000..3f2a9021002
--- /dev/null
+++ b/gnu/usr.bin/binutils/gdb/mi/mi-getopt.c
@@ -0,0 +1,92 @@
+/* MI Command Set - MI Option Parser.
+ Copyright 2000, 2001 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 2 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#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
+ };
+
+ if (mi_getopt (prefix, argc, argv, opts, &optind, &optarg) == -1)
+ return 1;
+ else
+ return 0;
+}
diff --git a/gnu/usr.bin/binutils/gdb/mi/mi-getopt.h b/gnu/usr.bin/binutils/gdb/mi/mi-getopt.h
new file mode 100644
index 00000000000..17d66fb2654
--- /dev/null
+++ b/gnu/usr.bin/binutils/gdb/mi/mi-getopt.h
@@ -0,0 +1,80 @@
+/* MI Option Parser.
+ Copyright 2000 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 2 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifndef MI_GETOPT_H
+#define MI_GETOPT_H
+
+/* Like getopt() but with simpler semantics.
+
+ An option has the form ``-<name>''. 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
diff --git a/gnu/usr.bin/binutils/gdb/mi/mi-interp.c b/gnu/usr.bin/binutils/gdb/mi/mi-interp.c
new file mode 100644
index 00000000000..08201ca5bb2
--- /dev/null
+++ b/gnu/usr.bin/binutils/gdb/mi/mi-interp.c
@@ -0,0 +1,406 @@
+/* MI Interpreter Definitions and Commands for GDB, the GNU debugger.
+
+ Copyright 2002, 2003, 2003 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 2 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#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 "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);
+static char *mi_input (char *);
+
+/* 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);
+
+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);
+
+ /* Why is this a part of the mi architecture? */
+
+ mi_setup_architecture_data ();
+
+ /* 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 ();
+
+ if (event_loop_p)
+ {
+ /* 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;
+
+ /* Replace all the hooks that we know about. There really needs to
+ be a better way of doing this... */
+ clear_interpreter_hooks ();
+
+ show_load_progress = mi_load_progress;
+
+ /* If we're _the_ interpreter, take control. */
+ if (current_interp_named_p (INTERP_MI1))
+ command_loop_hook = mi1_command_loop;
+ else if (current_interp_named_p (INTERP_MI2))
+ command_loop_hook = mi2_command_loop;
+ else if (current_interp_named_p (INTERP_MI3))
+ command_loop_hook = mi3_command_loop;
+ else
+ command_loop_hook = mi2_command_loop;
+
+ return 1;
+}
+
+static int
+mi_interpreter_suspend (void *data)
+{
+ gdb_disable_readline ();
+ return 1;
+}
+
+static int
+mi_interpreter_exec (void *data, const char *command)
+{
+ char *tmp = alloca (strlen (command) + 1);
+ strcpy (tmp, command);
+ mi_execute_command_wrapper (tmp);
+ return 1;
+}
+
+/* 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)
+ {
+ xasprintf (&mi_error_message,
+ "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)
+ {
+ xasprintf (&mi_error_message,
+ "mi_cmd_interpreter_exec: could not find interpreter \"%s\"",
+ argv[0]);
+ return MI_CMD_ERROR;
+ }
+
+ if (!interp_exec_p (interp_to_use))
+ {
+ xasprintf (&mi_error_message,
+ "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++)
+ {
+ char *buff = NULL;
+ /* Do this in a cleaner way... We want to force execution to be
+ asynchronous for commands that run the target. */
+ if (target_can_async_p () && (strcmp (argv[0], "console") == 0))
+ {
+ int len = strlen (argv[i]);
+ buff = xmalloc (len + 2);
+ memcpy (buff, argv[i], len);
+ buff[len] = '&';
+ buff[len + 1] = '\0';
+ }
+
+ /* 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;
+ if (interp_exec (interp_to_use, argv[i]) < 0)
+ {
+ mi_error_last_message ();
+ result = MI_CMD_ERROR;
+ break;
+ }
+ xfree (buff);
+ 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)
+{
+ query_hook = mi_interp_query_hook;
+}
+
+static void
+mi_remove_notify_hooks (void)
+{
+ 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. */
+ init_ui_hook = 0;
+ /* command_loop_hook = 0; */
+ print_frame_info_listing_hook = 0;
+ query_hook = 0;
+ warning_hook = 0;
+ create_breakpoint_hook = 0;
+ delete_breakpoint_hook = 0;
+ modify_breakpoint_hook = 0;
+ interactive_hook = 0;
+ registers_changed_hook = 0;
+ readline_begin_hook = 0;
+ readline_hook = 0;
+ readline_end_hook = 0;
+ register_changed_hook = 0;
+ memory_changed_hook = 0;
+ context_hook = 0;
+ target_wait_hook = 0;
+ call_command_hook = 0;
+ error_hook = 0;
+ error_begin_hook = 0;
+ 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);
+ if (!event_loop_p)
+ simplified_command_loop (mi_input, mi_execute_command);
+ else
+ start_event_loop ();
+}
+
+static char *
+mi_input (char *buf)
+{
+ return gdb_readline (NULL);
+}
+
+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));
+}
diff --git a/gnu/usr.bin/binutils/gdb/mi/mi-main.c b/gnu/usr.bin/binutils/gdb/mi/mi-main.c
new file mode 100644
index 00000000000..c46bf636597
--- /dev/null
+++ b/gnu/usr.bin/binutils/gdb/mi/mi-main.c
@@ -0,0 +1,1494 @@
+/* MI Command Set.
+
+ Copyright 2000, 2001, 2002, 2003, 2004 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 2 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+/* Work in progress */
+
+#include "defs.h"
+#include "target.h"
+#include "inferior.h"
+#include "gdb_string.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" /* for deprecated_write_register_bytes() */
+#include "regcache.h"
+#include "gdb.h"
+#include "frame.h"
+#include "mi-main.h"
+
+#include <ctype.h>
+#include <sys/time.h>
+
+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,
+ EXECUTE_COMMAND_DISPLAY_ERROR
+ };
+
+/* 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;
+
+/* The token of the last asynchronous command */
+static char *last_async_command;
+static char *previous_async_command;
+char *mi_error_message;
+static char *old_regs;
+
+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);
+static int get_register (int regnum, int format);
+
+/* A helper function which will set mi_error_message to
+ error_last_message. */
+void
+mi_error_last_message (void)
+{
+ char *s = error_last_message ();
+ xasprintf (&mi_error_message, "%s", s);
+ xfree (s);
+}
+
+/* Command implementations. FIXME: Is this libgdb? No. This is the MI
+ layer that calls libgdb. Any operation used in the below should be
+ formalized. */
+
+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 (deprecated_selected_frame,
+ frame_relative_level (deprecated_selected_frame),
+ 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 varialbes, 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)
+ {
+ xasprintf (&mi_error_message,
+ "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)
+ {
+ xasprintf (&mi_error_message,
+ "mi_cmd_thread_select: USAGE: threadnum.");
+ return MI_CMD_ERROR;
+ }
+ else
+ rc = gdb_thread_select (uiout, argv[0]);
+
+ /* RC is enum gdb_rc if it is successful (>=0)
+ enum return_reason if not (<0). */
+ if ((int) rc < 0 && (enum return_reason) rc == RETURN_ERROR)
+ return MI_CMD_CAUGHT_ERROR;
+ else if ((int) rc >= 0 && 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 = MI_CMD_DONE;
+
+ if (argc != 0)
+ {
+ xasprintf (&mi_error_message,
+ "mi_cmd_thread_list_ids: No arguments required.");
+ return MI_CMD_ERROR;
+ }
+ else
+ rc = gdb_list_thread_ids (uiout);
+
+ if (rc == GDB_RC_FAIL)
+ return MI_CMD_CAUGHT_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
+ REGISTER_NAME because NUM_REGS may be allocated for the union of
+ the register sets within a family of related processors. In this
+ case, some entries of REGISTER_NAME will change depending upon
+ the particular processor being debugged. */
+
+ numregs = NUM_REGS + NUM_PSEUDO_REGS;
+
+ 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 (REGISTER_NAME (regnum) == NULL
+ || *(REGISTER_NAME (regnum)) == '\0')
+ ui_out_field_string (uiout, NULL, "");
+ else
+ ui_out_field_string (uiout, NULL, REGISTER_NAME (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);
+ xasprintf (&mi_error_message, "bad register number");
+ return MI_CMD_ERROR;
+ }
+ if (REGISTER_NAME (regnum) == NULL
+ || *(REGISTER_NAME (regnum)) == '\0')
+ ui_out_field_string (uiout, NULL, "");
+ else
+ ui_out_field_string (uiout, NULL, REGISTER_NAME (regnum));
+ }
+ do_cleanups (cleanup);
+ return MI_CMD_DONE;
+}
+
+enum mi_cmd_result
+mi_cmd_data_list_changed_registers (char *command, char **argv, int argc)
+{
+ int regnum, numregs, changed;
+ int i;
+ struct cleanup *cleanup;
+
+ /* Note that the test for a valid register must include checking the
+ REGISTER_NAME because NUM_REGS may be allocated for the union of
+ the register sets within a family of related processors. In this
+ case, some entries of REGISTER_NAME will change depending upon
+ the particular processor being debugged. */
+
+ numregs = NUM_REGS;
+
+ cleanup = 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 (REGISTER_NAME (regnum) == NULL
+ || *(REGISTER_NAME (regnum)) == '\0')
+ continue;
+ changed = register_changed_p (regnum);
+ if (changed < 0)
+ {
+ do_cleanups (cleanup);
+ xasprintf (&mi_error_message,
+ "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
+ && REGISTER_NAME (regnum) != NULL
+ && *REGISTER_NAME (regnum) != '\000')
+ {
+ changed = register_changed_p (regnum);
+ if (changed < 0)
+ {
+ do_cleanups (cleanup);
+ xasprintf (&mi_error_message,
+ "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);
+ xasprintf (&mi_error_message, "bad register number");
+ return MI_CMD_ERROR;
+ }
+ }
+ do_cleanups (cleanup);
+ return MI_CMD_DONE;
+}
+
+static int
+register_changed_p (int regnum)
+{
+ char raw_buffer[MAX_REGISTER_SIZE];
+
+ if (! frame_register_read (deprecated_selected_frame, regnum, raw_buffer))
+ return -1;
+
+ if (memcmp (&old_regs[DEPRECATED_REGISTER_BYTE (regnum)], raw_buffer,
+ DEPRECATED_REGISTER_RAW_SIZE (regnum)) == 0)
+ return 0;
+
+ /* Found a changed register. Return 1. */
+
+ memcpy (&old_regs[DEPRECATED_REGISTER_BYTE (regnum)], raw_buffer,
+ DEPRECATED_REGISTER_RAW_SIZE (regnum));
+
+ return 1;
+}
+
+/* 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
+ REGISTER_NAME because NUM_REGS may be allocated for the union of
+ the register sets within a family of related processors. In this
+ case, some entries of REGISTER_NAME will change depending upon
+ the particular processor being debugged. */
+
+ numregs = NUM_REGS;
+
+ if (argc == 0)
+ {
+ xasprintf (&mi_error_message,
+ "mi_cmd_data_list_register_values: Usage: -data-list-register-values <format> [<regnum1>...<regnumN>]");
+ return MI_CMD_ERROR;
+ }
+
+ format = (int) argv[0][0];
+
+ if (!target_has_registers)
+ {
+ xasprintf (&mi_error_message,
+ "mi_cmd_data_list_register_values: No registers.");
+ return MI_CMD_ERROR;
+ }
+
+ 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 (REGISTER_NAME (regnum) == NULL
+ || *(REGISTER_NAME (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
+ && REGISTER_NAME (regnum) != NULL
+ && *REGISTER_NAME (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);
+ xasprintf (&mi_error_message, "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)
+{
+ char raw_buffer[MAX_REGISTER_SIZE];
+ char virtual_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 (deprecated_selected_frame, regnum, &optim, &lval, &addr,
+ &realnum, raw_buffer);
+
+ if (optim)
+ {
+ xasprintf (&mi_error_message, "Optimized out");
+ return -1;
+ }
+
+ /* Convert raw data to virtual format if necessary. */
+
+ if (DEPRECATED_REGISTER_CONVERTIBLE_P ()
+ && DEPRECATED_REGISTER_CONVERTIBLE (regnum))
+ {
+ DEPRECATED_REGISTER_CONVERT_TO_VIRTUAL (regnum,
+ register_type (current_gdbarch, regnum),
+ raw_buffer, virtual_buffer);
+ }
+ else
+ memcpy (virtual_buffer, raw_buffer, DEPRECATED_REGISTER_VIRTUAL_SIZE (regnum));
+
+ if (format == 'r')
+ {
+ int j;
+ char *ptr, buf[1024];
+
+ strcpy (buf, "0x");
+ ptr = buf + 2;
+ for (j = 0; j < DEPRECATED_REGISTER_RAW_SIZE (regnum); j++)
+ {
+ int idx = TARGET_BYTE_ORDER == BFD_ENDIAN_BIG ? j
+ : DEPRECATED_REGISTER_RAW_SIZE (regnum) - 1 - j;
+ sprintf (ptr, "%02x", (unsigned char) raw_buffer[idx]);
+ ptr += 2;
+ }
+ ui_out_field_string (uiout, "value", buf);
+ /*fputs_filtered (buf, gdb_stdout); */
+ }
+ else
+ {
+ val_print (register_type (current_gdbarch, regnum), virtual_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 <format> [<regnum1> <value1>...<regnumN> <valueN>]*/
+enum mi_cmd_result
+mi_cmd_data_write_register_values (char *command, char **argv, int argc)
+{
+ int regnum;
+ int i;
+ int numregs;
+ LONGEST value;
+ char format;
+
+ /* Note that the test for a valid register must include checking the
+ REGISTER_NAME because NUM_REGS may be allocated for the union of
+ the register sets within a family of related processors. In this
+ case, some entries of REGISTER_NAME will change depending upon
+ the particular processor being debugged. */
+
+ numregs = NUM_REGS;
+
+ if (argc == 0)
+ {
+ xasprintf (&mi_error_message,
+ "mi_cmd_data_write_register_values: Usage: -data-write-register-values <format> [<regnum1> <value1>...<regnumN> <valueN>]");
+ return MI_CMD_ERROR;
+ }
+
+ format = (int) argv[0][0];
+
+ if (!target_has_registers)
+ {
+ xasprintf (&mi_error_message,
+ "mi_cmd_data_write_register_values: No registers.");
+ return MI_CMD_ERROR;
+ }
+
+ if (!(argc - 1))
+ {
+ xasprintf (&mi_error_message,
+ "mi_cmd_data_write_register_values: No regs and values specified.");
+ return MI_CMD_ERROR;
+ }
+
+ if ((argc - 1) % 2)
+ {
+ xasprintf (&mi_error_message,
+ "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)
+ {
+ regnum = atoi (argv[i]);
+
+ if (regnum >= 0
+ && regnum < numregs
+ && REGISTER_NAME (regnum) != NULL
+ && *REGISTER_NAME (regnum) != '\000')
+ {
+ void *buffer;
+ struct cleanup *old_chain;
+
+ /* Get the value as a number */
+ value = parse_and_eval_address (argv[i + 1]);
+ /* Get the value into an array */
+ buffer = xmalloc (DEPRECATED_REGISTER_SIZE);
+ old_chain = make_cleanup (xfree, buffer);
+ store_signed_integer (buffer, DEPRECATED_REGISTER_SIZE, value);
+ /* Write it down */
+ deprecated_write_register_bytes (DEPRECATED_REGISTER_BYTE (regnum), buffer, DEPRECATED_REGISTER_RAW_SIZE (regnum));
+ /* Free the buffer. */
+ do_cleanups (old_chain);
+ }
+ else
+ {
+ xasprintf (&mi_error_message, "bad register number");
+ return MI_CMD_ERROR;
+ }
+ }
+ return MI_CMD_DONE;
+}
+
+#if 0
+/*This is commented out because we decided it was not useful. I leave
+ it, just in case. ezannoni:1999-12-08 */
+
+/* Assign a value to a variable. The expression argument must be in
+ the form A=2 or "A = 2" (I.e. if there are spaces it needs to be
+ quoted. */
+enum mi_cmd_result
+mi_cmd_data_assign (char *command, char **argv, int argc)
+{
+ struct expression *expr;
+ struct cleanup *old_chain;
+
+ if (argc != 1)
+ {
+ xasprintf (&mi_error_message,
+ "mi_cmd_data_assign: Usage: -data-assign expression");
+ return MI_CMD_ERROR;
+ }
+
+ /* NOTE what follows is a clone of set_command(). FIXME: ezannoni
+ 01-12-1999: Need to decide what to do with this for libgdb purposes. */
+
+ expr = parse_expression (argv[0]);
+ old_chain = make_cleanup (free_current_contents, &expr);
+ evaluate_expression (expr);
+ do_cleanups (old_chain);
+ return MI_CMD_DONE;
+}
+#endif
+
+/* 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)
+ {
+ xasprintf (&mi_error_message,
+ "mi_cmd_data_evaluate_expression: Usage: -data-evaluate-expression expression");
+ 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;
+
+ xasprintf (&run, "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;
+
+ xasprintf (&run, "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;
+ char *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
+ };
+
+ 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)
+ {
+ xasprintf (&mi_error_message,
+ "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)
+ {
+ xasprintf (&mi_error_message,
+ "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)
+ {
+ xasprintf (&mi_error_message,
+ "mi_cmd_data_read_memory: invalid number of columns.");
+ }
+ /* 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);
+ if (mbuf == NULL)
+ {
+ xasprintf (&mi_error_message,
+ "mi_cmd_data_read_memory: out of memory.");
+ return MI_CMD_ERROR;
+ }
+ nr_bytes = 0;
+ while (nr_bytes < total_bytes)
+ {
+ int error;
+ long num = target_read_memory_partial (addr + nr_bytes, mbuf + nr_bytes,
+ total_bytes - nr_bytes,
+ &error);
+ if (num <= 0)
+ break;
+ nr_bytes += num;
+ }
+
+ /* 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
+ };
+
+ 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)
+ {
+ xasprintf (&mi_error_message,
+ "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;
+}
+
+/* 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 int
+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;
+
+ 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;
+ args->rc = mi_cmd_execute (context);
+
+ 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);
+ 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);
+ fputs_unfiltered ("\"\n", raw_stdout);
+ }
+ mi_out_rewind (uiout);
+ }
+ else if (args->rc == MI_CMD_CAUGHT_ERROR)
+ {
+ mi_out_rewind (uiout);
+ args->action = EXECUTE_COMMAND_DISPLAY_ERROR;
+ return 1;
+ }
+ 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 1;
+ }
+ break;
+
+ case CLI_COMMAND:
+ /* A CLI command was read from the input stream */
+ /* This 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);
+ mi_execute_cli_command (context->command, 0, NULL);
+
+ /* 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))
+ {
+ /* print the result */
+ /* FIXME: Check for errors here. */
+ 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;
+ args->rc = MI_CMD_DONE;
+ }
+ break;
+
+ }
+
+ return 1;
+}
+
+
+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;
+ int result;
+
+ /* 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)
+ {
+ /* 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_exceptions (uiout, captured_mi_execute_command, &args, "",
+ RETURN_MASK_ALL);
+
+ 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 (args.action == EXECUTE_COMMAND_DISPLAY_ERROR || result < 0)
+ {
+ char *msg = error_last_message ();
+ struct cleanup *cleanup = make_cleanup (xfree, msg);
+ /* The command execution failed and error() was called
+ somewhere */
+ fputs_unfiltered (command->token, raw_stdout);
+ fputs_unfiltered ("^error,msg=\"", raw_stdout);
+ fputstr_unfiltered (msg, '"', raw_stdout);
+ fputs_unfiltered ("\"\n", raw_stdout);
+ }
+ 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)
+{
+ 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)
+ xasprintf (&run, "%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, "&");
+ xasprintf (&run, "%s %s", mi, async_args);
+ make_exec_cleanup (free, run);
+ add_continuation (mi_exec_async_cli_cmd_continuation, NULL);
+ old_cleanups = NULL;
+ }
+ else
+ {
+ xasprintf (&run, "%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);
+ 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;
+
+ if (!current_interp_named_p (INTERP_MI)
+ && !current_interp_named_p (INTERP_MI1))
+ 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 += 1000000;
+ }
+
+ 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);
+ }
+}
+
+void
+mi_setup_architecture_data (void)
+{
+ old_regs = xmalloc ((NUM_REGS + NUM_PSEUDO_REGS) * MAX_REGISTER_SIZE + 1);
+ memset (old_regs, 0, (NUM_REGS + NUM_PSEUDO_REGS) * MAX_REGISTER_SIZE + 1);
+}
+
+void
+_initialize_mi_main (void)
+{
+ DEPRECATED_REGISTER_GDBARCH_SWAP (old_regs);
+ deprecated_register_gdbarch_swap (NULL, 0, mi_setup_architecture_data);
+}
diff --git a/gnu/usr.bin/binutils/gdb/mi/mi-main.h b/gnu/usr.bin/binutils/gdb/mi/mi-main.h
new file mode 100644
index 00000000000..8e504c6076e
--- /dev/null
+++ b/gnu/usr.bin/binutils/gdb/mi/mi-main.h
@@ -0,0 +1,33 @@
+/* MI Internal Functions for GDB, the GNU debugger.
+
+ Copyright 2003 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 2 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifndef MI_MAIN_H
+#define MI_MAIN_H
+
+extern void mi_setup_architecture_data (void);
+
+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
+
diff --git a/gnu/usr.bin/binutils/gdb/mi/mi-out.c b/gnu/usr.bin/binutils/gdb/mi/mi-out.c
new file mode 100644
index 00000000000..2be9d17b357
--- /dev/null
+++ b/gnu/usr.bin/binutils/gdb/mi/mi-out.c
@@ -0,0 +1,409 @@
+/* MI Command Set - output generating routines.
+
+ Copyright 2000, 2002, 2003, 2004 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 2 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#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);
+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);
+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 */
+}
diff --git a/gnu/usr.bin/binutils/gdb/mi/mi-out.h b/gnu/usr.bin/binutils/gdb/mi/mi-out.h
new file mode 100644
index 00000000000..817f2eb53b9
--- /dev/null
+++ b/gnu/usr.bin/binutils/gdb/mi/mi-out.h
@@ -0,0 +1,36 @@
+/* MI Command Set - MI output generating routines for GDB.
+ Copyright 2000 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 2 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#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 */
diff --git a/gnu/usr.bin/binutils/gdb/mi/mi-parse.c b/gnu/usr.bin/binutils/gdb/mi/mi-parse.c
new file mode 100644
index 00000000000..a0ff8898ff5
--- /dev/null
+++ b/gnu/usr.bin/binutils/gdb/mi/mi-parse.c
@@ -0,0 +1,233 @@
+/* MI Command Set - MI parser.
+
+ Copyright 2000, 2001, 2002 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 2 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include "defs.h"
+#include "mi-cmds.h"
+#include "mi-parse.h"
+
+#include <ctype.h>
+#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;
+}
diff --git a/gnu/usr.bin/binutils/gdb/mi/mi-parse.h b/gnu/usr.bin/binutils/gdb/mi/mi-parse.h
new file mode 100644
index 00000000000..ae9f181f90c
--- /dev/null
+++ b/gnu/usr.bin/binutils/gdb/mi/mi-parse.h
@@ -0,0 +1,55 @@
+/* MI Command Set - MI Command Parser.
+ Copyright 2000 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 2 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifndef MI_PARSE_H
+#define MI_PARSE_H
+
+/* MI parser */
+
+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;
+ 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
diff --git a/gnu/usr.bin/binutils/gdb/mi/mi-symbol-cmds.c b/gnu/usr.bin/binutils/gdb/mi/mi-symbol-cmds.c
new file mode 100644
index 00000000000..1d86d21d517
--- /dev/null
+++ b/gnu/usr.bin/binutils/gdb/mi/mi-symbol-cmds.c
@@ -0,0 +1,67 @@
+/* MI Command Set - symbol commands.
+ Copyright 2003 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 2 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#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;
+}