2003-02-06 13:30:17 +08:00
|
|
|
/* MI Interpreter Definitions and Commands for GDB, the GNU debugger.
|
|
|
|
|
2009-01-03 13:58:08 +08:00
|
|
|
Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009
|
2008-01-02 06:53:26 +08:00
|
|
|
Free Software Foundation, Inc.
|
2003-02-06 13:30:17 +08:00
|
|
|
|
|
|
|
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
|
2007-08-24 02:08:50 +08:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
2003-02-06 13:30:17 +08:00
|
|
|
(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
|
2007-08-24 02:08:50 +08:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
2003-02-06 13:30:17 +08:00
|
|
|
|
|
|
|
#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"
|
2005-01-13 10:35:39 +08:00
|
|
|
#include "exceptions.h"
|
2003-02-06 13:30:17 +08:00
|
|
|
#include "mi-main.h"
|
|
|
|
#include "mi-cmds.h"
|
|
|
|
#include "mi-out.h"
|
|
|
|
#include "mi-console.h"
|
2008-11-18 00:43:34 +08:00
|
|
|
#include "mi-common.h"
|
2008-03-15 01:21:08 +08:00
|
|
|
#include "observer.h"
|
|
|
|
#include "gdbthread.h"
|
2009-02-18 15:28:34 +08:00
|
|
|
#include "solist.h"
|
2003-02-06 13:30:17 +08:00
|
|
|
|
|
|
|
/* These are the interpreter setup, etc. functions for the MI interpreter */
|
|
|
|
static void mi_execute_command_wrapper (char *cmd);
|
|
|
|
static void mi_command_loop (int mi_version);
|
|
|
|
|
|
|
|
/* These are hooks that we put in place while doing interpreter_exec
|
|
|
|
so we can report interesting things that happened "behind the mi's
|
|
|
|
back" in this command */
|
From Kaveh R. Ghazi <ghazi@caip.rutgers.edu>:
gdb/
* cli-out.c (cli_field_fmt, cli_message, out_field_fmt): Add
ATTR_FORMAT or ATTRIBUTE_FPTR_PRINTF.
* complaints.c (vcomplaint): Likewise.
* defs.h (xvasprintf, xstrvprintf, verror, vfatal)
(internal_verror, internal_vwarning, vwarning)
(deprecated_query_hook, deprecated_warning_hook)
(deprecated_readline_begin_hook): Likewise.
* disasm.c (fprintf_disasm): Likewise.
* exceptions.c (throw_it): Likewise.
* exceptions.h (throw_verror, throw_vfatal): Likewise.
* mi/mi-interp.c (mi_interp_query_hook): Likewise.
* mi/mi-out.c (mi_field_fmt, mi_message): Likewise.
* tui/tui-hooks.c (tui_query_hook): Likewise.
* tui/tui-out.c (tui_field_fmt, tui_message, out_field_fmt):
Likewise.
* ui-out.c (default_field_fmt, default_message, uo_field_fmt)
(uo_message): Likewise.
* ui-out.h (ui_out_field_fmt, ui_out_message, field_fmt_ftype)
(message_ftype): Likewise.
* utils.c (vfprintf_maybe_filtered, internal_vproblem)
(defaulted_query, printchar): Likewise.
gdb/gdbserver/
* server.h (error, fatal, warning): Add ATTR_FORMAT.
2005-08-01 04:56:26 +08:00
|
|
|
static int mi_interp_query_hook (const char *ctlstr, va_list ap)
|
|
|
|
ATTR_FORMAT (printf, 1, 0);
|
2003-02-06 13:30:17 +08:00
|
|
|
|
2003-08-09 03:00:08 +08:00
|
|
|
static void mi3_command_loop (void);
|
2003-02-06 13:30:17 +08:00
|
|
|
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);
|
2009-02-14 23:24:44 +08:00
|
|
|
static void mi_on_normal_stop (struct bpstats *bs, int print_frame);
|
2003-02-06 13:30:17 +08:00
|
|
|
|
2008-03-15 01:21:08 +08:00
|
|
|
static void mi_new_thread (struct thread_info *t);
|
2009-03-26 05:53:11 +08:00
|
|
|
static void mi_thread_exit (struct thread_info *t, int silent);
|
2008-11-17 20:28:05 +08:00
|
|
|
static void mi_new_inferior (int pid);
|
|
|
|
static void mi_inferior_exit (int pid);
|
2008-06-10 18:23:54 +08:00
|
|
|
static void mi_on_resume (ptid_t ptid);
|
2009-02-18 15:28:34 +08:00
|
|
|
static void mi_solib_loaded (struct so_list *solib);
|
|
|
|
static void mi_solib_unloaded (struct so_list *solib);
|
2009-03-23 02:06:07 +08:00
|
|
|
static void mi_about_to_proceed (void);
|
2008-03-15 01:21:08 +08:00
|
|
|
|
2003-02-06 13:30:17 +08:00
|
|
|
static void *
|
2008-03-15 01:21:08 +08:00
|
|
|
mi_interpreter_init (int top_level)
|
2003-02-06 13:30:17 +08:00
|
|
|
{
|
|
|
|
struct mi_interp *mi = XMALLOC (struct mi_interp);
|
|
|
|
|
|
|
|
/* HACK: We need to force stdout/stderr to point at the console. This avoids
|
|
|
|
any potential side effects caused by legacy code that is still
|
|
|
|
using the TUI / fputs_unfiltered_hook. So we set up output channels for
|
|
|
|
this now, and swap them in when we are run. */
|
|
|
|
|
|
|
|
raw_stdout = stdio_fileopen (stdout);
|
|
|
|
|
|
|
|
/* Create MI channels */
|
|
|
|
mi->out = mi_console_file_new (raw_stdout, "~", '"');
|
|
|
|
mi->err = mi_console_file_new (raw_stdout, "&", '"');
|
|
|
|
mi->log = mi->err;
|
|
|
|
mi->targ = mi_console_file_new (raw_stdout, "@", '"');
|
|
|
|
mi->event_channel = mi_console_file_new (raw_stdout, "=", 0);
|
|
|
|
|
2008-03-15 01:21:08 +08:00
|
|
|
if (top_level)
|
2008-05-03 23:10:42 +08:00
|
|
|
{
|
|
|
|
observer_attach_new_thread (mi_new_thread);
|
|
|
|
observer_attach_thread_exit (mi_thread_exit);
|
2008-11-17 20:28:05 +08:00
|
|
|
observer_attach_new_inferior (mi_new_inferior);
|
|
|
|
observer_attach_inferior_exit (mi_inferior_exit);
|
2008-06-10 17:35:09 +08:00
|
|
|
observer_attach_normal_stop (mi_on_normal_stop);
|
2008-06-10 18:23:54 +08:00
|
|
|
observer_attach_target_resumed (mi_on_resume);
|
2009-02-18 15:28:34 +08:00
|
|
|
observer_attach_solib_loaded (mi_solib_loaded);
|
|
|
|
observer_attach_solib_unloaded (mi_solib_unloaded);
|
2009-03-23 02:06:07 +08:00
|
|
|
observer_attach_about_to_proceed (mi_about_to_proceed);
|
2008-05-03 23:10:42 +08:00
|
|
|
}
|
2008-03-15 01:21:08 +08:00
|
|
|
|
2003-02-06 13:30:17 +08:00
|
|
|
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 ();
|
|
|
|
|
2004-09-13 Andrew Cagney <cagney@gnu.org>
Eliminate event_loop_p, always has the value 1.
* defs.h (event_loop_p): Delete macro.
* breakpoint.c (until_break_command): Simplify.
* utils.c (prompt_for_continue): Simplify.
* tracepoint.c (read_actions): Simplify.
* top.c (throw_exception, execute_command, gdb_readline_wrapper)
(gdb_rl_operate_and_get_next, command_line_input, get_prompt)
(set_prompt, init_main): Simplify.
(init_signals, disconnect): Delete, unused.
* remote.c (remote_async_resume)
(extended_remote_async_create_inferior): Simplify.
* mi/mi-interp.c (mi_input): Delete, unused.
(mi_interpreter_resume, mi_command_loop): Simplify.
* interps.c (current_interp_command_loop): Simplify.
* infrun.c (proceed): Simplify.
* infcmd.c (run_command, continue_command, step_1, jump_command)
(until_command, advance_command, finish_command)
(interrupt_target_command): Simplify.
* event-top.c (gdb_setup_readline, gdb_disable_readline): Simplify.
2004-09-14 02:26:31 +08:00
|
|
|
/* 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;
|
2003-02-06 13:30:17 +08:00
|
|
|
|
|
|
|
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;
|
2005-12-06 13:53:46 +08:00
|
|
|
/* Route target error through the MI as well. */
|
|
|
|
gdb_stdtargerr = mi->targ;
|
2003-02-06 13:30:17 +08:00
|
|
|
|
|
|
|
/* Replace all the hooks that we know about. There really needs to
|
|
|
|
be a better way of doing this... */
|
|
|
|
clear_interpreter_hooks ();
|
|
|
|
|
2004-04-21 Andrew Cagney <cagney@redhat.com>
* annotate.h (deprecated_annotate_starting_hook)
(deprecated_annotate_stopped_hook)
(deprecated_annotate_exited_hook)
(deprecated_annotate_signal_hook)
(deprecated_annotate_signalled_hook): Deprecate.
* tracepoint.h (deprecated_create_tracepoint_hook)
(deprecated_delete_tracepoint_hook)
(deprecated_modify_tracepoint_hook)
(deprecated_trace_find_hook)
(deprecated_trace_start_stop_hook): Deprecate.
* target.h (deprecated_target_new_objfile_hook): Deprecate.
* remote.h (deprecated_target_resume_hook)
(deprecated_target_wait_loop_hook): Deprecate.
* gdbcore.h (deprecated_exec_file_display_hook)
(deprecated_file_changed_hook): Deprecate.
* frame.h (deprecated_selected_frame_level_changed_hook): Deprecate.
* defs.h (deprecated_modify_breakpoint_hook)
(deprecated_command_loop_hook, deprecated_show_load_progress)
(deprecated_print_frame_info_listing_hook)
(deprecated_query_hook, deprecated_warning_hook)
(deprecated_flush_hook, deprecated_create_breakpoint_hook)
(deprecated_delete_breakpoint_hook)
(deprecated_interactive_hook, deprecated_registers_changed_hook)
(deprecated_readline_begin_hook, deprecated_readline_hook)
(deprecated_readline_end_hook, deprecated_register_changed_hook)
(deprecated_memory_changed_hook, deprecated_init_ui_hook)
(deprecated_context_hook, deprecated_target_wait_hook)
(deprecated_attach_hook, deprecated_detach_hook)
(deprecated_call_command_hook, deprecated_set_hook)
(deprecated_error_hook, deprecated_error_begin_hook)
(deprecated_ui_load_progress_hook): Deprecate.
* valops.c, uw-thread.c, utils.c, tui/tui-io.c: Update.
* tui/tui-hooks.c, tracepoint.c, top.c, thread-db.c: Update.
* target.c, symfile.c, stack.c, sol-thread.c, rs6000-nat.c: Update.
* remote.c, remote-mips.c, regcache.c, mi/mi-interp.c: Update.
* main.c, interps.c, infcmd.c, hpux-thread.c, frame.c: Update.
* exec.c, dsrec.c, d10v-tdep.c, corefile.c, complaints.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, breakpoint.c: Update.
* annotate.c, aix-thread.c: Update.
2004-04-22 07:52:21 +08:00
|
|
|
deprecated_show_load_progress = mi_load_progress;
|
2003-02-06 13:30:17 +08:00
|
|
|
|
|
|
|
/* If we're _the_ interpreter, take control. */
|
|
|
|
if (current_interp_named_p (INTERP_MI1))
|
2004-04-21 Andrew Cagney <cagney@redhat.com>
* annotate.h (deprecated_annotate_starting_hook)
(deprecated_annotate_stopped_hook)
(deprecated_annotate_exited_hook)
(deprecated_annotate_signal_hook)
(deprecated_annotate_signalled_hook): Deprecate.
* tracepoint.h (deprecated_create_tracepoint_hook)
(deprecated_delete_tracepoint_hook)
(deprecated_modify_tracepoint_hook)
(deprecated_trace_find_hook)
(deprecated_trace_start_stop_hook): Deprecate.
* target.h (deprecated_target_new_objfile_hook): Deprecate.
* remote.h (deprecated_target_resume_hook)
(deprecated_target_wait_loop_hook): Deprecate.
* gdbcore.h (deprecated_exec_file_display_hook)
(deprecated_file_changed_hook): Deprecate.
* frame.h (deprecated_selected_frame_level_changed_hook): Deprecate.
* defs.h (deprecated_modify_breakpoint_hook)
(deprecated_command_loop_hook, deprecated_show_load_progress)
(deprecated_print_frame_info_listing_hook)
(deprecated_query_hook, deprecated_warning_hook)
(deprecated_flush_hook, deprecated_create_breakpoint_hook)
(deprecated_delete_breakpoint_hook)
(deprecated_interactive_hook, deprecated_registers_changed_hook)
(deprecated_readline_begin_hook, deprecated_readline_hook)
(deprecated_readline_end_hook, deprecated_register_changed_hook)
(deprecated_memory_changed_hook, deprecated_init_ui_hook)
(deprecated_context_hook, deprecated_target_wait_hook)
(deprecated_attach_hook, deprecated_detach_hook)
(deprecated_call_command_hook, deprecated_set_hook)
(deprecated_error_hook, deprecated_error_begin_hook)
(deprecated_ui_load_progress_hook): Deprecate.
* valops.c, uw-thread.c, utils.c, tui/tui-io.c: Update.
* tui/tui-hooks.c, tracepoint.c, top.c, thread-db.c: Update.
* target.c, symfile.c, stack.c, sol-thread.c, rs6000-nat.c: Update.
* remote.c, remote-mips.c, regcache.c, mi/mi-interp.c: Update.
* main.c, interps.c, infcmd.c, hpux-thread.c, frame.c: Update.
* exec.c, dsrec.c, d10v-tdep.c, corefile.c, complaints.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, breakpoint.c: Update.
* annotate.c, aix-thread.c: Update.
2004-04-22 07:52:21 +08:00
|
|
|
deprecated_command_loop_hook = mi1_command_loop;
|
2003-08-09 03:00:08 +08:00
|
|
|
else if (current_interp_named_p (INTERP_MI2))
|
2004-04-21 Andrew Cagney <cagney@redhat.com>
* annotate.h (deprecated_annotate_starting_hook)
(deprecated_annotate_stopped_hook)
(deprecated_annotate_exited_hook)
(deprecated_annotate_signal_hook)
(deprecated_annotate_signalled_hook): Deprecate.
* tracepoint.h (deprecated_create_tracepoint_hook)
(deprecated_delete_tracepoint_hook)
(deprecated_modify_tracepoint_hook)
(deprecated_trace_find_hook)
(deprecated_trace_start_stop_hook): Deprecate.
* target.h (deprecated_target_new_objfile_hook): Deprecate.
* remote.h (deprecated_target_resume_hook)
(deprecated_target_wait_loop_hook): Deprecate.
* gdbcore.h (deprecated_exec_file_display_hook)
(deprecated_file_changed_hook): Deprecate.
* frame.h (deprecated_selected_frame_level_changed_hook): Deprecate.
* defs.h (deprecated_modify_breakpoint_hook)
(deprecated_command_loop_hook, deprecated_show_load_progress)
(deprecated_print_frame_info_listing_hook)
(deprecated_query_hook, deprecated_warning_hook)
(deprecated_flush_hook, deprecated_create_breakpoint_hook)
(deprecated_delete_breakpoint_hook)
(deprecated_interactive_hook, deprecated_registers_changed_hook)
(deprecated_readline_begin_hook, deprecated_readline_hook)
(deprecated_readline_end_hook, deprecated_register_changed_hook)
(deprecated_memory_changed_hook, deprecated_init_ui_hook)
(deprecated_context_hook, deprecated_target_wait_hook)
(deprecated_attach_hook, deprecated_detach_hook)
(deprecated_call_command_hook, deprecated_set_hook)
(deprecated_error_hook, deprecated_error_begin_hook)
(deprecated_ui_load_progress_hook): Deprecate.
* valops.c, uw-thread.c, utils.c, tui/tui-io.c: Update.
* tui/tui-hooks.c, tracepoint.c, top.c, thread-db.c: Update.
* target.c, symfile.c, stack.c, sol-thread.c, rs6000-nat.c: Update.
* remote.c, remote-mips.c, regcache.c, mi/mi-interp.c: Update.
* main.c, interps.c, infcmd.c, hpux-thread.c, frame.c: Update.
* exec.c, dsrec.c, d10v-tdep.c, corefile.c, complaints.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, breakpoint.c: Update.
* annotate.c, aix-thread.c: Update.
2004-04-22 07:52:21 +08:00
|
|
|
deprecated_command_loop_hook = mi2_command_loop;
|
2003-08-09 03:00:08 +08:00
|
|
|
else if (current_interp_named_p (INTERP_MI3))
|
2004-04-21 Andrew Cagney <cagney@redhat.com>
* annotate.h (deprecated_annotate_starting_hook)
(deprecated_annotate_stopped_hook)
(deprecated_annotate_exited_hook)
(deprecated_annotate_signal_hook)
(deprecated_annotate_signalled_hook): Deprecate.
* tracepoint.h (deprecated_create_tracepoint_hook)
(deprecated_delete_tracepoint_hook)
(deprecated_modify_tracepoint_hook)
(deprecated_trace_find_hook)
(deprecated_trace_start_stop_hook): Deprecate.
* target.h (deprecated_target_new_objfile_hook): Deprecate.
* remote.h (deprecated_target_resume_hook)
(deprecated_target_wait_loop_hook): Deprecate.
* gdbcore.h (deprecated_exec_file_display_hook)
(deprecated_file_changed_hook): Deprecate.
* frame.h (deprecated_selected_frame_level_changed_hook): Deprecate.
* defs.h (deprecated_modify_breakpoint_hook)
(deprecated_command_loop_hook, deprecated_show_load_progress)
(deprecated_print_frame_info_listing_hook)
(deprecated_query_hook, deprecated_warning_hook)
(deprecated_flush_hook, deprecated_create_breakpoint_hook)
(deprecated_delete_breakpoint_hook)
(deprecated_interactive_hook, deprecated_registers_changed_hook)
(deprecated_readline_begin_hook, deprecated_readline_hook)
(deprecated_readline_end_hook, deprecated_register_changed_hook)
(deprecated_memory_changed_hook, deprecated_init_ui_hook)
(deprecated_context_hook, deprecated_target_wait_hook)
(deprecated_attach_hook, deprecated_detach_hook)
(deprecated_call_command_hook, deprecated_set_hook)
(deprecated_error_hook, deprecated_error_begin_hook)
(deprecated_ui_load_progress_hook): Deprecate.
* valops.c, uw-thread.c, utils.c, tui/tui-io.c: Update.
* tui/tui-hooks.c, tracepoint.c, top.c, thread-db.c: Update.
* target.c, symfile.c, stack.c, sol-thread.c, rs6000-nat.c: Update.
* remote.c, remote-mips.c, regcache.c, mi/mi-interp.c: Update.
* main.c, interps.c, infcmd.c, hpux-thread.c, frame.c: Update.
* exec.c, dsrec.c, d10v-tdep.c, corefile.c, complaints.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, breakpoint.c: Update.
* annotate.c, aix-thread.c: Update.
2004-04-22 07:52:21 +08:00
|
|
|
deprecated_command_loop_hook = mi3_command_loop;
|
2003-02-06 13:30:17 +08:00
|
|
|
else
|
2004-04-21 Andrew Cagney <cagney@redhat.com>
* annotate.h (deprecated_annotate_starting_hook)
(deprecated_annotate_stopped_hook)
(deprecated_annotate_exited_hook)
(deprecated_annotate_signal_hook)
(deprecated_annotate_signalled_hook): Deprecate.
* tracepoint.h (deprecated_create_tracepoint_hook)
(deprecated_delete_tracepoint_hook)
(deprecated_modify_tracepoint_hook)
(deprecated_trace_find_hook)
(deprecated_trace_start_stop_hook): Deprecate.
* target.h (deprecated_target_new_objfile_hook): Deprecate.
* remote.h (deprecated_target_resume_hook)
(deprecated_target_wait_loop_hook): Deprecate.
* gdbcore.h (deprecated_exec_file_display_hook)
(deprecated_file_changed_hook): Deprecate.
* frame.h (deprecated_selected_frame_level_changed_hook): Deprecate.
* defs.h (deprecated_modify_breakpoint_hook)
(deprecated_command_loop_hook, deprecated_show_load_progress)
(deprecated_print_frame_info_listing_hook)
(deprecated_query_hook, deprecated_warning_hook)
(deprecated_flush_hook, deprecated_create_breakpoint_hook)
(deprecated_delete_breakpoint_hook)
(deprecated_interactive_hook, deprecated_registers_changed_hook)
(deprecated_readline_begin_hook, deprecated_readline_hook)
(deprecated_readline_end_hook, deprecated_register_changed_hook)
(deprecated_memory_changed_hook, deprecated_init_ui_hook)
(deprecated_context_hook, deprecated_target_wait_hook)
(deprecated_attach_hook, deprecated_detach_hook)
(deprecated_call_command_hook, deprecated_set_hook)
(deprecated_error_hook, deprecated_error_begin_hook)
(deprecated_ui_load_progress_hook): Deprecate.
* valops.c, uw-thread.c, utils.c, tui/tui-io.c: Update.
* tui/tui-hooks.c, tracepoint.c, top.c, thread-db.c: Update.
* target.c, symfile.c, stack.c, sol-thread.c, rs6000-nat.c: Update.
* remote.c, remote-mips.c, regcache.c, mi/mi-interp.c: Update.
* main.c, interps.c, infcmd.c, hpux-thread.c, frame.c: Update.
* exec.c, dsrec.c, d10v-tdep.c, corefile.c, complaints.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, breakpoint.c: Update.
* annotate.c, aix-thread.c: Update.
2004-04-22 07:52:21 +08:00
|
|
|
deprecated_command_loop_hook = mi2_command_loop;
|
2003-02-06 13:30:17 +08:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mi_interpreter_suspend (void *data)
|
|
|
|
{
|
|
|
|
gdb_disable_readline ();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2005-04-26 13:03:41 +08:00
|
|
|
static struct gdb_exception
|
2003-02-06 13:30:17 +08:00
|
|
|
mi_interpreter_exec (void *data, const char *command)
|
|
|
|
{
|
2005-04-26 13:03:41 +08:00
|
|
|
static struct gdb_exception ok;
|
2003-02-06 13:30:17 +08:00
|
|
|
char *tmp = alloca (strlen (command) + 1);
|
|
|
|
strcpy (tmp, command);
|
|
|
|
mi_execute_command_wrapper (tmp);
|
2005-01-13 10:35:39 +08:00
|
|
|
return exception_none;
|
2003-02-06 13:30:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Never display the default gdb prompt in mi case. */
|
|
|
|
static int
|
|
|
|
mi_interpreter_prompt_p (void *data)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-06-25 23:15:42 +08:00
|
|
|
void
|
2003-02-06 13:30:17 +08:00
|
|
|
mi_cmd_interpreter_exec (char *command, char **argv, int argc)
|
|
|
|
{
|
|
|
|
struct interp *interp_to_use;
|
|
|
|
int i;
|
|
|
|
struct interp_procs *procs;
|
gdb/
2008-04-04 Pedro Alves <pedro@codesourcery.com>
* mi/mi-cmds.h (enum mi_cmd_result): Delete MI_CMD_ERROR.
(mi_error_message): Delete declaration.
* mi/mi-interp.c (mi_cmd_interpreter_exec): Call error instead of
returning MI_CMD_ERROR.
* mi/mi-main.c (mi_error_message): Delete.
(mi_cmd_exec_interrupt):
(mi_cmd_thread_select, mi_cmd_thread_list_ids)
(mi_cmd_thread_info): Call error instead of returning
MI_CMD_ERROR.
(mi_cmd_data_list_register_values): Call error instead of
returning MI_CMD_ERROR. Adapt to new get_register interface.
(get_register): Change return typo to void. Call error instead of
returning MI_CMD_ERROR.
(mi_cmd_data_write_register_values): Call error instead of
returning MI_CMD_ERROR.
(mi_cmd_list_features): Return MI_CMD_DONE.
(captured_mi_execute_command): Remove MI_CMD_ERROR handling.
(mi_execute_command): Always print exceptions with -error.
gdb/testsuite/
2008-04-04 Pedro Alves <pedro@codesourcery.com>
* gdb.mi/mi-disassemble.exp, gdb.mi/mi-stack.exp,
gdb.mi/mi-syn-frame.exp, gdb.mi/mi-var-block.exp,
gdb.mi/mi-var-cmd.exp, gdb.mi/mi-var-display.exp,
gdb.mi/mi2-disassemble.exp, gdb.mi/mi2-stack.exp,
gdb.mi/mi2-syn-frame.exp, gdb.mi/mi2-var-block.exp,
gdb.mi/mi2-var-cmd.exp, gdb.mi/mi2-var-display.exp: Update to not
expect an mi error duplicated in stderr.
2008-04-05 05:59:25 +08:00
|
|
|
char *mi_error_message = NULL;
|
|
|
|
struct cleanup *old_chain;
|
2003-02-06 13:30:17 +08:00
|
|
|
|
|
|
|
if (argc < 2)
|
gdb/
2008-04-04 Pedro Alves <pedro@codesourcery.com>
* mi/mi-cmds.h (enum mi_cmd_result): Delete MI_CMD_ERROR.
(mi_error_message): Delete declaration.
* mi/mi-interp.c (mi_cmd_interpreter_exec): Call error instead of
returning MI_CMD_ERROR.
* mi/mi-main.c (mi_error_message): Delete.
(mi_cmd_exec_interrupt):
(mi_cmd_thread_select, mi_cmd_thread_list_ids)
(mi_cmd_thread_info): Call error instead of returning
MI_CMD_ERROR.
(mi_cmd_data_list_register_values): Call error instead of
returning MI_CMD_ERROR. Adapt to new get_register interface.
(get_register): Change return typo to void. Call error instead of
returning MI_CMD_ERROR.
(mi_cmd_data_write_register_values): Call error instead of
returning MI_CMD_ERROR.
(mi_cmd_list_features): Return MI_CMD_DONE.
(captured_mi_execute_command): Remove MI_CMD_ERROR handling.
(mi_execute_command): Always print exceptions with -error.
gdb/testsuite/
2008-04-04 Pedro Alves <pedro@codesourcery.com>
* gdb.mi/mi-disassemble.exp, gdb.mi/mi-stack.exp,
gdb.mi/mi-syn-frame.exp, gdb.mi/mi-var-block.exp,
gdb.mi/mi-var-cmd.exp, gdb.mi/mi-var-display.exp,
gdb.mi/mi2-disassemble.exp, gdb.mi/mi2-stack.exp,
gdb.mi/mi2-syn-frame.exp, gdb.mi/mi2-var-block.exp,
gdb.mi/mi2-var-cmd.exp, gdb.mi/mi2-var-display.exp: Update to not
expect an mi error duplicated in stderr.
2008-04-05 05:59:25 +08:00
|
|
|
error ("mi_cmd_interpreter_exec: Usage: -interpreter-exec interp command");
|
2003-02-06 13:30:17 +08:00
|
|
|
|
|
|
|
interp_to_use = interp_lookup (argv[0]);
|
|
|
|
if (interp_to_use == NULL)
|
gdb/
2008-04-04 Pedro Alves <pedro@codesourcery.com>
* mi/mi-cmds.h (enum mi_cmd_result): Delete MI_CMD_ERROR.
(mi_error_message): Delete declaration.
* mi/mi-interp.c (mi_cmd_interpreter_exec): Call error instead of
returning MI_CMD_ERROR.
* mi/mi-main.c (mi_error_message): Delete.
(mi_cmd_exec_interrupt):
(mi_cmd_thread_select, mi_cmd_thread_list_ids)
(mi_cmd_thread_info): Call error instead of returning
MI_CMD_ERROR.
(mi_cmd_data_list_register_values): Call error instead of
returning MI_CMD_ERROR. Adapt to new get_register interface.
(get_register): Change return typo to void. Call error instead of
returning MI_CMD_ERROR.
(mi_cmd_data_write_register_values): Call error instead of
returning MI_CMD_ERROR.
(mi_cmd_list_features): Return MI_CMD_DONE.
(captured_mi_execute_command): Remove MI_CMD_ERROR handling.
(mi_execute_command): Always print exceptions with -error.
gdb/testsuite/
2008-04-04 Pedro Alves <pedro@codesourcery.com>
* gdb.mi/mi-disassemble.exp, gdb.mi/mi-stack.exp,
gdb.mi/mi-syn-frame.exp, gdb.mi/mi-var-block.exp,
gdb.mi/mi-var-cmd.exp, gdb.mi/mi-var-display.exp,
gdb.mi/mi2-disassemble.exp, gdb.mi/mi2-stack.exp,
gdb.mi/mi2-syn-frame.exp, gdb.mi/mi2-var-block.exp,
gdb.mi/mi2-var-cmd.exp, gdb.mi/mi2-var-display.exp: Update to not
expect an mi error duplicated in stderr.
2008-04-05 05:59:25 +08:00
|
|
|
error ("mi_cmd_interpreter_exec: could not find interpreter \"%s\"", argv[0]);
|
2003-02-06 13:30:17 +08:00
|
|
|
|
|
|
|
if (!interp_exec_p (interp_to_use))
|
gdb/
2008-04-04 Pedro Alves <pedro@codesourcery.com>
* mi/mi-cmds.h (enum mi_cmd_result): Delete MI_CMD_ERROR.
(mi_error_message): Delete declaration.
* mi/mi-interp.c (mi_cmd_interpreter_exec): Call error instead of
returning MI_CMD_ERROR.
* mi/mi-main.c (mi_error_message): Delete.
(mi_cmd_exec_interrupt):
(mi_cmd_thread_select, mi_cmd_thread_list_ids)
(mi_cmd_thread_info): Call error instead of returning
MI_CMD_ERROR.
(mi_cmd_data_list_register_values): Call error instead of
returning MI_CMD_ERROR. Adapt to new get_register interface.
(get_register): Change return typo to void. Call error instead of
returning MI_CMD_ERROR.
(mi_cmd_data_write_register_values): Call error instead of
returning MI_CMD_ERROR.
(mi_cmd_list_features): Return MI_CMD_DONE.
(captured_mi_execute_command): Remove MI_CMD_ERROR handling.
(mi_execute_command): Always print exceptions with -error.
gdb/testsuite/
2008-04-04 Pedro Alves <pedro@codesourcery.com>
* gdb.mi/mi-disassemble.exp, gdb.mi/mi-stack.exp,
gdb.mi/mi-syn-frame.exp, gdb.mi/mi-var-block.exp,
gdb.mi/mi-var-cmd.exp, gdb.mi/mi-var-display.exp,
gdb.mi/mi2-disassemble.exp, gdb.mi/mi2-stack.exp,
gdb.mi/mi2-syn-frame.exp, gdb.mi/mi2-var-block.exp,
gdb.mi/mi2-var-cmd.exp, gdb.mi/mi2-var-display.exp: Update to not
expect an mi error duplicated in stderr.
2008-04-05 05:59:25 +08:00
|
|
|
error ("mi_cmd_interpreter_exec: interpreter \"%s\" does not support command execution",
|
|
|
|
argv[0]);
|
2003-02-06 13:30:17 +08:00
|
|
|
|
|
|
|
/* 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... */
|
|
|
|
|
gdb/
2008-04-04 Pedro Alves <pedro@codesourcery.com>
* mi/mi-cmds.h (enum mi_cmd_result): Delete MI_CMD_ERROR.
(mi_error_message): Delete declaration.
* mi/mi-interp.c (mi_cmd_interpreter_exec): Call error instead of
returning MI_CMD_ERROR.
* mi/mi-main.c (mi_error_message): Delete.
(mi_cmd_exec_interrupt):
(mi_cmd_thread_select, mi_cmd_thread_list_ids)
(mi_cmd_thread_info): Call error instead of returning
MI_CMD_ERROR.
(mi_cmd_data_list_register_values): Call error instead of
returning MI_CMD_ERROR. Adapt to new get_register interface.
(get_register): Change return typo to void. Call error instead of
returning MI_CMD_ERROR.
(mi_cmd_data_write_register_values): Call error instead of
returning MI_CMD_ERROR.
(mi_cmd_list_features): Return MI_CMD_DONE.
(captured_mi_execute_command): Remove MI_CMD_ERROR handling.
(mi_execute_command): Always print exceptions with -error.
gdb/testsuite/
2008-04-04 Pedro Alves <pedro@codesourcery.com>
* gdb.mi/mi-disassemble.exp, gdb.mi/mi-stack.exp,
gdb.mi/mi-syn-frame.exp, gdb.mi/mi-var-block.exp,
gdb.mi/mi-var-cmd.exp, gdb.mi/mi-var-display.exp,
gdb.mi/mi2-disassemble.exp, gdb.mi/mi2-stack.exp,
gdb.mi/mi2-syn-frame.exp, gdb.mi/mi2-var-block.exp,
gdb.mi/mi2-var-cmd.exp, gdb.mi/mi2-var-display.exp: Update to not
expect an mi error duplicated in stderr.
2008-04-05 05:59:25 +08:00
|
|
|
old_chain = make_cleanup (null_cleanup, 0);
|
2003-02-06 13:30:17 +08:00
|
|
|
for (i = 1; i < argc; i++)
|
|
|
|
{
|
2008-03-15 02:57:44 +08:00
|
|
|
struct gdb_exception e = interp_exec (interp_to_use, argv[i]);
|
|
|
|
if (e.reason < 0)
|
|
|
|
{
|
|
|
|
mi_error_message = xstrdup (e.message);
|
gdb/
2008-04-04 Pedro Alves <pedro@codesourcery.com>
* mi/mi-cmds.h (enum mi_cmd_result): Delete MI_CMD_ERROR.
(mi_error_message): Delete declaration.
* mi/mi-interp.c (mi_cmd_interpreter_exec): Call error instead of
returning MI_CMD_ERROR.
* mi/mi-main.c (mi_error_message): Delete.
(mi_cmd_exec_interrupt):
(mi_cmd_thread_select, mi_cmd_thread_list_ids)
(mi_cmd_thread_info): Call error instead of returning
MI_CMD_ERROR.
(mi_cmd_data_list_register_values): Call error instead of
returning MI_CMD_ERROR. Adapt to new get_register interface.
(get_register): Change return typo to void. Call error instead of
returning MI_CMD_ERROR.
(mi_cmd_data_write_register_values): Call error instead of
returning MI_CMD_ERROR.
(mi_cmd_list_features): Return MI_CMD_DONE.
(captured_mi_execute_command): Remove MI_CMD_ERROR handling.
(mi_execute_command): Always print exceptions with -error.
gdb/testsuite/
2008-04-04 Pedro Alves <pedro@codesourcery.com>
* gdb.mi/mi-disassemble.exp, gdb.mi/mi-stack.exp,
gdb.mi/mi-syn-frame.exp, gdb.mi/mi-var-block.exp,
gdb.mi/mi-var-cmd.exp, gdb.mi/mi-var-display.exp,
gdb.mi/mi2-disassemble.exp, gdb.mi/mi2-stack.exp,
gdb.mi/mi2-syn-frame.exp, gdb.mi/mi2-var-block.exp,
gdb.mi/mi2-var-cmd.exp, gdb.mi/mi2-var-display.exp: Update to not
expect an mi error duplicated in stderr.
2008-04-05 05:59:25 +08:00
|
|
|
make_cleanup (xfree, mi_error_message);
|
2008-03-15 02:57:44 +08:00
|
|
|
break;
|
|
|
|
}
|
2003-02-06 13:30:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
mi_remove_notify_hooks ();
|
|
|
|
|
gdb/
2008-04-04 Pedro Alves <pedro@codesourcery.com>
* mi/mi-cmds.h (enum mi_cmd_result): Delete MI_CMD_ERROR.
(mi_error_message): Delete declaration.
* mi/mi-interp.c (mi_cmd_interpreter_exec): Call error instead of
returning MI_CMD_ERROR.
* mi/mi-main.c (mi_error_message): Delete.
(mi_cmd_exec_interrupt):
(mi_cmd_thread_select, mi_cmd_thread_list_ids)
(mi_cmd_thread_info): Call error instead of returning
MI_CMD_ERROR.
(mi_cmd_data_list_register_values): Call error instead of
returning MI_CMD_ERROR. Adapt to new get_register interface.
(get_register): Change return typo to void. Call error instead of
returning MI_CMD_ERROR.
(mi_cmd_data_write_register_values): Call error instead of
returning MI_CMD_ERROR.
(mi_cmd_list_features): Return MI_CMD_DONE.
(captured_mi_execute_command): Remove MI_CMD_ERROR handling.
(mi_execute_command): Always print exceptions with -error.
gdb/testsuite/
2008-04-04 Pedro Alves <pedro@codesourcery.com>
* gdb.mi/mi-disassemble.exp, gdb.mi/mi-stack.exp,
gdb.mi/mi-syn-frame.exp, gdb.mi/mi-var-block.exp,
gdb.mi/mi-var-cmd.exp, gdb.mi/mi-var-display.exp,
gdb.mi/mi2-disassemble.exp, gdb.mi/mi2-stack.exp,
gdb.mi/mi2-syn-frame.exp, gdb.mi/mi2-var-block.exp,
gdb.mi/mi2-var-cmd.exp, gdb.mi/mi2-var-display.exp: Update to not
expect an mi error duplicated in stderr.
2008-04-05 05:59:25 +08:00
|
|
|
if (mi_error_message != NULL)
|
|
|
|
error ("%s", mi_error_message);
|
|
|
|
do_cleanups (old_chain);
|
2003-02-06 13:30:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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)
|
|
|
|
{
|
2004-04-21 Andrew Cagney <cagney@redhat.com>
* annotate.h (deprecated_annotate_starting_hook)
(deprecated_annotate_stopped_hook)
(deprecated_annotate_exited_hook)
(deprecated_annotate_signal_hook)
(deprecated_annotate_signalled_hook): Deprecate.
* tracepoint.h (deprecated_create_tracepoint_hook)
(deprecated_delete_tracepoint_hook)
(deprecated_modify_tracepoint_hook)
(deprecated_trace_find_hook)
(deprecated_trace_start_stop_hook): Deprecate.
* target.h (deprecated_target_new_objfile_hook): Deprecate.
* remote.h (deprecated_target_resume_hook)
(deprecated_target_wait_loop_hook): Deprecate.
* gdbcore.h (deprecated_exec_file_display_hook)
(deprecated_file_changed_hook): Deprecate.
* frame.h (deprecated_selected_frame_level_changed_hook): Deprecate.
* defs.h (deprecated_modify_breakpoint_hook)
(deprecated_command_loop_hook, deprecated_show_load_progress)
(deprecated_print_frame_info_listing_hook)
(deprecated_query_hook, deprecated_warning_hook)
(deprecated_flush_hook, deprecated_create_breakpoint_hook)
(deprecated_delete_breakpoint_hook)
(deprecated_interactive_hook, deprecated_registers_changed_hook)
(deprecated_readline_begin_hook, deprecated_readline_hook)
(deprecated_readline_end_hook, deprecated_register_changed_hook)
(deprecated_memory_changed_hook, deprecated_init_ui_hook)
(deprecated_context_hook, deprecated_target_wait_hook)
(deprecated_attach_hook, deprecated_detach_hook)
(deprecated_call_command_hook, deprecated_set_hook)
(deprecated_error_hook, deprecated_error_begin_hook)
(deprecated_ui_load_progress_hook): Deprecate.
* valops.c, uw-thread.c, utils.c, tui/tui-io.c: Update.
* tui/tui-hooks.c, tracepoint.c, top.c, thread-db.c: Update.
* target.c, symfile.c, stack.c, sol-thread.c, rs6000-nat.c: Update.
* remote.c, remote-mips.c, regcache.c, mi/mi-interp.c: Update.
* main.c, interps.c, infcmd.c, hpux-thread.c, frame.c: Update.
* exec.c, dsrec.c, d10v-tdep.c, corefile.c, complaints.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, breakpoint.c: Update.
* annotate.c, aix-thread.c: Update.
2004-04-22 07:52:21 +08:00
|
|
|
deprecated_query_hook = mi_interp_query_hook;
|
2003-02-06 13:30:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-02-09 18:47:37 +08:00
|
|
|
mi_remove_notify_hooks (void)
|
2003-02-06 13:30:17 +08:00
|
|
|
{
|
2004-04-21 Andrew Cagney <cagney@redhat.com>
* annotate.h (deprecated_annotate_starting_hook)
(deprecated_annotate_stopped_hook)
(deprecated_annotate_exited_hook)
(deprecated_annotate_signal_hook)
(deprecated_annotate_signalled_hook): Deprecate.
* tracepoint.h (deprecated_create_tracepoint_hook)
(deprecated_delete_tracepoint_hook)
(deprecated_modify_tracepoint_hook)
(deprecated_trace_find_hook)
(deprecated_trace_start_stop_hook): Deprecate.
* target.h (deprecated_target_new_objfile_hook): Deprecate.
* remote.h (deprecated_target_resume_hook)
(deprecated_target_wait_loop_hook): Deprecate.
* gdbcore.h (deprecated_exec_file_display_hook)
(deprecated_file_changed_hook): Deprecate.
* frame.h (deprecated_selected_frame_level_changed_hook): Deprecate.
* defs.h (deprecated_modify_breakpoint_hook)
(deprecated_command_loop_hook, deprecated_show_load_progress)
(deprecated_print_frame_info_listing_hook)
(deprecated_query_hook, deprecated_warning_hook)
(deprecated_flush_hook, deprecated_create_breakpoint_hook)
(deprecated_delete_breakpoint_hook)
(deprecated_interactive_hook, deprecated_registers_changed_hook)
(deprecated_readline_begin_hook, deprecated_readline_hook)
(deprecated_readline_end_hook, deprecated_register_changed_hook)
(deprecated_memory_changed_hook, deprecated_init_ui_hook)
(deprecated_context_hook, deprecated_target_wait_hook)
(deprecated_attach_hook, deprecated_detach_hook)
(deprecated_call_command_hook, deprecated_set_hook)
(deprecated_error_hook, deprecated_error_begin_hook)
(deprecated_ui_load_progress_hook): Deprecate.
* valops.c, uw-thread.c, utils.c, tui/tui-io.c: Update.
* tui/tui-hooks.c, tracepoint.c, top.c, thread-db.c: Update.
* target.c, symfile.c, stack.c, sol-thread.c, rs6000-nat.c: Update.
* remote.c, remote-mips.c, regcache.c, mi/mi-interp.c: Update.
* main.c, interps.c, infcmd.c, hpux-thread.c, frame.c: Update.
* exec.c, dsrec.c, d10v-tdep.c, corefile.c, complaints.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, breakpoint.c: Update.
* annotate.c, aix-thread.c: Update.
2004-04-22 07:52:21 +08:00
|
|
|
deprecated_query_hook = NULL;
|
2003-02-06 13:30:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2003-08-09 03:00:08 +08:00
|
|
|
static void
|
|
|
|
mi3_command_loop (void)
|
|
|
|
{
|
|
|
|
mi_command_loop (3);
|
|
|
|
}
|
|
|
|
|
2003-02-06 13:30:17 +08:00
|
|
|
static void
|
|
|
|
mi_command_loop (int mi_version)
|
|
|
|
{
|
|
|
|
/* Turn off 8 bit strings in quoted output. Any character with the
|
|
|
|
high bit set is printed using C's octal format. */
|
|
|
|
sevenbit_strings = 1;
|
|
|
|
/* Tell the world that we're alive */
|
|
|
|
fputs_unfiltered ("(gdb) \n", raw_stdout);
|
|
|
|
gdb_flush (raw_stdout);
|
2004-09-13 Andrew Cagney <cagney@gnu.org>
Eliminate event_loop_p, always has the value 1.
* defs.h (event_loop_p): Delete macro.
* breakpoint.c (until_break_command): Simplify.
* utils.c (prompt_for_continue): Simplify.
* tracepoint.c (read_actions): Simplify.
* top.c (throw_exception, execute_command, gdb_readline_wrapper)
(gdb_rl_operate_and_get_next, command_line_input, get_prompt)
(set_prompt, init_main): Simplify.
(init_signals, disconnect): Delete, unused.
* remote.c (remote_async_resume)
(extended_remote_async_create_inferior): Simplify.
* mi/mi-interp.c (mi_input): Delete, unused.
(mi_interpreter_resume, mi_command_loop): Simplify.
* interps.c (current_interp_command_loop): Simplify.
* infrun.c (proceed): Simplify.
* infcmd.c (run_command, continue_command, step_1, jump_command)
(until_command, advance_command, finish_command)
(interrupt_target_command): Simplify.
* event-top.c (gdb_setup_readline, gdb_disable_readline): Simplify.
2004-09-14 02:26:31 +08:00
|
|
|
start_event_loop ();
|
2003-02-06 13:30:17 +08:00
|
|
|
}
|
|
|
|
|
2008-03-15 01:21:08 +08:00
|
|
|
static void
|
|
|
|
mi_new_thread (struct thread_info *t)
|
|
|
|
{
|
|
|
|
struct mi_interp *mi = top_level_interpreter_data ();
|
|
|
|
|
2008-11-17 20:34:19 +08:00
|
|
|
fprintf_unfiltered (mi->event_channel,
|
|
|
|
"thread-created,id=\"%d\",group-id=\"%d\"",
|
|
|
|
t->num, t->ptid.pid);
|
2008-03-15 01:21:08 +08:00
|
|
|
gdb_flush (mi->event_channel);
|
|
|
|
}
|
|
|
|
|
2008-05-03 23:10:42 +08:00
|
|
|
static void
|
2009-03-26 05:53:11 +08:00
|
|
|
mi_thread_exit (struct thread_info *t, int silent)
|
2008-05-03 23:10:42 +08:00
|
|
|
{
|
2009-03-26 05:53:11 +08:00
|
|
|
struct mi_interp *mi;
|
|
|
|
|
|
|
|
if (silent)
|
|
|
|
return;
|
|
|
|
|
|
|
|
mi = top_level_interpreter_data ();
|
2008-05-03 23:10:42 +08:00
|
|
|
target_terminal_ours ();
|
2008-11-17 20:34:19 +08:00
|
|
|
fprintf_unfiltered (mi->event_channel,
|
|
|
|
"thread-exited,id=\"%d\",group-id=\"%d\"",
|
|
|
|
t->num,t->ptid.pid);
|
2008-05-03 23:10:42 +08:00
|
|
|
gdb_flush (mi->event_channel);
|
|
|
|
}
|
|
|
|
|
2008-11-17 20:28:05 +08:00
|
|
|
static void
|
|
|
|
mi_new_inferior (int pid)
|
|
|
|
{
|
|
|
|
struct mi_interp *mi = top_level_interpreter_data ();
|
|
|
|
target_terminal_ours ();
|
|
|
|
fprintf_unfiltered (mi->event_channel, "thread-group-created,id=\"%d\"",
|
|
|
|
pid);
|
|
|
|
gdb_flush (mi->event_channel);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
mi_inferior_exit (int pid)
|
|
|
|
{
|
|
|
|
struct mi_interp *mi = top_level_interpreter_data ();
|
|
|
|
target_terminal_ours ();
|
|
|
|
fprintf_unfiltered (mi->event_channel, "thread-group-exited,id=\"%d\"",
|
|
|
|
pid);
|
|
|
|
gdb_flush (mi->event_channel);
|
|
|
|
}
|
|
|
|
|
2008-06-10 17:35:09 +08:00
|
|
|
static void
|
2009-02-14 23:24:44 +08:00
|
|
|
mi_on_normal_stop (struct bpstats *bs, int print_frame)
|
2008-06-10 17:35:09 +08:00
|
|
|
{
|
|
|
|
/* Since this can be called when CLI command is executing,
|
|
|
|
using cli interpreter, be sure to use MI uiout for output,
|
|
|
|
not the current one. */
|
2009-02-14 23:24:44 +08:00
|
|
|
struct ui_out *mi_uiout = interp_ui_out (top_level_interpreter ());
|
2008-06-10 17:35:09 +08:00
|
|
|
struct mi_interp *mi = top_level_interpreter_data ();
|
|
|
|
|
2009-02-14 23:24:44 +08:00
|
|
|
if (print_frame)
|
|
|
|
{
|
|
|
|
if (uiout != mi_uiout)
|
|
|
|
{
|
|
|
|
/* The normal_stop function has printed frame information into
|
|
|
|
CLI uiout, or some other non-MI uiout. There's no way we
|
|
|
|
can extract proper fields from random uiout object, so we print
|
|
|
|
the frame again. In practice, this can only happen when running
|
|
|
|
a CLI command in MI. */
|
|
|
|
struct ui_out *saved_uiout = uiout;
|
|
|
|
uiout = mi_uiout;
|
|
|
|
print_stack_frame (get_selected_frame (NULL), 0, SRC_AND_LOC);
|
|
|
|
uiout = saved_uiout;
|
|
|
|
}
|
|
|
|
|
|
|
|
ui_out_field_int (mi_uiout, "thread-id",
|
|
|
|
pid_to_thread_id (inferior_ptid));
|
|
|
|
if (non_stop)
|
|
|
|
{
|
|
|
|
struct cleanup *back_to = make_cleanup_ui_out_list_begin_end
|
|
|
|
(mi_uiout, "stopped-threads");
|
|
|
|
ui_out_field_int (mi_uiout, NULL,
|
|
|
|
pid_to_thread_id (inferior_ptid));
|
|
|
|
do_cleanups (back_to);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ui_out_field_string (mi_uiout, "stopped-threads", "all");
|
|
|
|
}
|
|
|
|
|
2008-06-10 17:35:09 +08:00
|
|
|
fputs_unfiltered ("*stopped", raw_stdout);
|
2009-02-14 23:24:44 +08:00
|
|
|
mi_out_put (mi_uiout, raw_stdout);
|
|
|
|
mi_out_rewind (mi_uiout);
|
2009-03-13 03:54:54 +08:00
|
|
|
mi_print_timing_maybe ();
|
2008-06-10 17:35:09 +08:00
|
|
|
fputs_unfiltered ("\n", raw_stdout);
|
|
|
|
gdb_flush (raw_stdout);
|
|
|
|
}
|
|
|
|
|
2009-03-23 02:06:07 +08:00
|
|
|
static void
|
|
|
|
mi_about_to_proceed (void)
|
|
|
|
{
|
|
|
|
/* Suppress output while calling an inferior function. */
|
|
|
|
|
|
|
|
if (!ptid_equal (inferior_ptid, null_ptid))
|
|
|
|
{
|
|
|
|
struct thread_info *tp = inferior_thread ();
|
|
|
|
if (tp->in_infcall)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mi_proceeded = 1;
|
|
|
|
}
|
|
|
|
|
2008-06-10 18:23:54 +08:00
|
|
|
static void
|
|
|
|
mi_on_resume (ptid_t ptid)
|
|
|
|
{
|
2009-03-23 01:59:59 +08:00
|
|
|
struct thread_info *tp = NULL;
|
|
|
|
|
|
|
|
if (ptid_equal (ptid, minus_one_ptid))
|
|
|
|
tp = inferior_thread ();
|
|
|
|
else
|
|
|
|
tp = find_thread_pid (ptid);
|
|
|
|
|
|
|
|
/* Suppress output while calling an inferior function. */
|
|
|
|
if (tp->in_infcall)
|
|
|
|
return;
|
|
|
|
|
2008-06-25 22:32:34 +08:00
|
|
|
/* To cater for older frontends, emit ^running, but do it only once
|
|
|
|
per each command. We do it here, since at this point we know
|
|
|
|
that the target was successfully resumed, and in non-async mode,
|
|
|
|
we won't return back to MI interpreter code until the target
|
|
|
|
is done running, so delaying the output of "^running" until then
|
|
|
|
will make it impossible for frontend to know what's going on.
|
|
|
|
|
|
|
|
In future (MI3), we'll be outputting "^done" here. */
|
2009-03-23 02:06:07 +08:00
|
|
|
if (!running_result_record_printed && mi_proceeded)
|
2008-06-25 22:32:34 +08:00
|
|
|
{
|
|
|
|
if (current_token)
|
|
|
|
fputs_unfiltered (current_token, raw_stdout);
|
|
|
|
fputs_unfiltered ("^running\n", raw_stdout);
|
|
|
|
}
|
|
|
|
|
2008-06-10 18:23:54 +08:00
|
|
|
if (PIDGET (ptid) == -1)
|
|
|
|
fprintf_unfiltered (raw_stdout, "*running,thread-id=\"all\"\n");
|
2008-07-06 01:57:24 +08:00
|
|
|
else if (thread_count () == 0)
|
|
|
|
{
|
|
|
|
/* This is a target where for single-threaded programs the thread
|
|
|
|
table has zero threads. Don't print any thread-id field. */
|
|
|
|
fprintf_unfiltered (raw_stdout, "*running\n");
|
|
|
|
}
|
2008-06-10 18:23:54 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
struct thread_info *ti = find_thread_pid (ptid);
|
|
|
|
gdb_assert (ti);
|
|
|
|
fprintf_unfiltered (raw_stdout, "*running,thread-id=\"%d\"\n", ti->num);
|
|
|
|
}
|
2008-06-25 22:32:34 +08:00
|
|
|
|
2009-03-23 02:06:07 +08:00
|
|
|
if (!running_result_record_printed && mi_proceeded)
|
2008-06-25 22:32:34 +08:00
|
|
|
{
|
|
|
|
running_result_record_printed = 1;
|
|
|
|
/* This is what gdb used to do historically -- printing prompt even if
|
|
|
|
it cannot actually accept any input. This will be surely removed
|
|
|
|
for MI3, and may be removed even earler. */
|
|
|
|
/* FIXME: review the use of target_is_async_p here -- is that
|
|
|
|
what we want? */
|
|
|
|
if (!target_is_async_p ())
|
|
|
|
fputs_unfiltered ("(gdb) \n", raw_stdout);
|
|
|
|
}
|
2008-10-04 22:58:54 +08:00
|
|
|
gdb_flush (raw_stdout);
|
2008-06-10 18:23:54 +08:00
|
|
|
}
|
|
|
|
|
2009-02-18 15:28:34 +08:00
|
|
|
static void
|
|
|
|
mi_solib_loaded (struct so_list *solib)
|
|
|
|
{
|
|
|
|
struct mi_interp *mi = top_level_interpreter_data ();
|
|
|
|
target_terminal_ours ();
|
|
|
|
fprintf_unfiltered (mi->event_channel,
|
|
|
|
"library-loaded,id=\"%s\",target-name=\"%s\",host-name=\"%s\",symbols-loaded=\"%d\"",
|
|
|
|
solib->so_original_name, solib->so_original_name,
|
|
|
|
solib->so_name, solib->symbols_loaded);
|
|
|
|
gdb_flush (mi->event_channel);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
mi_solib_unloaded (struct so_list *solib)
|
|
|
|
{
|
|
|
|
struct mi_interp *mi = top_level_interpreter_data ();
|
|
|
|
target_terminal_ours ();
|
|
|
|
fprintf_unfiltered (mi->event_channel,
|
|
|
|
"library-unloaded,id=\"%s\",target-name=\"%s\",host-name=\"%s\"",
|
|
|
|
solib->so_original_name, solib->so_original_name,
|
|
|
|
solib->so_name);
|
|
|
|
gdb_flush (mi->event_channel);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-06-08 Andrew Cagney <cagney@redhat.com>
* acinclude.m4 (gcc_AC_CHECK_DECL, (gcc_AC_CHECK_DECL): Stolen
from GCC's acinclude.m4.
* configure.in: Check for getopt's delcaration.
* aclocal.m4, config.in, configure: Re-generate.
* main.c (error_init): Delete declaration.
* defs.h (error_init): Declare.
* rs6000-tdep.c (rs6000_fetch_pointer_argument): Make static.
(rs6000_convert_from_func_ptr_addr): Make static.
(_initialize_rs6000_tdep): Add declaration.
* cli/cli-cmds.c (dont_repeat): Delete declaration.
(show_commands, set_verbose, show_history): Delete declaration.
* top.h (set_verbose): Add declaration.
(show_history, set_history, show_commands): Add declaration.
(do_restore_instream_cleanup): Add declaration.
* objc-lang.c (specialcmp): Make static.
(print_object_command): Make static.
(find_objc_msgsend): Make static.
(find_objc_msgcall_submethod_helper): Make static.
(find_objc_msgcall_submethod): Make static.
(_initialize_objc_language): Add declaration.
(find_implementation_from_class): Make static.
(find_implementation): Make static.
* objc-exp.y (yylex): Delete lookup_struct_typedef declaration.
* objc-lang.h (lookup_struct_typedef): Add declaration.
* cli/cli-interp.c (_initialize_cli_interp): Add declaration.
* cli/cli-script.c (clear_hook_in_cleanup): Make static.
(do_restore_user_call_depth): Make static.
(do_restore_instream_cleanup): Delete declaration.
(dont_repeat): Delete declaration.
* cli/cli-decode.c (add_abbrev_cmd): Delete function.
* cli/cli-dump.c (_initialize_cli_dump): Add declaration.
* reggroups.c (_initialize_reggroup): Add declaration.
* cp-support.c (_initialize_cp_support): Add declaration.
* cp-abi.c (_initialize_cp_abi): Add declaration.
* hpacc-abi.c (_initialize_hpacc_abi): Add declaration.
* gnu-v3-abi.c (gnuv3_baseclass_offset): Make static.
(_initialize_gnu_v3_abi): Add declaration.
* gnu-v2-abi.c (gnuv2_value_rtti_type): Make static.
(_initialize_gnu_v2_abi): Add declaration.
* frame-base.c (_initialize_frame_base): Add declaration.
* doublest.c (floatformat_from_length): Make static.
* frame-unwind.c (_initialize_frame_unwind): Add declaration.
* frame.c (create_sentinel_frame): Make static.
(_initialize_frame): Add declaration.
* top.c (do_catch_errors): Make static.
(gdb_rl_operate_and_get_next_completion): Make static.
* typeprint.c: Include "typeprint.h".
* sentinel-frame.c (sentinel_frame_prev_register): Make static.
(sentinel_frame_this_id): Make static.
* p-valprint.c (_initialize_pascal_valprint): Add declaration.
* ui-out.c (make_cleanup_ui_out_begin_end): Delete function.
* dwarf2-frame.c (dwarf2_frame_cache): Make static.
* p-exp.y (push_current_type, pop_current_type): ISO C declaration.
* dwarf2expr.h (dwarf_expr_context): ISO C declaration.
* maint.c (maintenance_print_architecture): Make static.
* signals/signals.c (_initialize_signals): Add declaration.
* std-regs.c (_initialize_frame_reg): Add declaration.
* jv-exp.y (push_variable): ISO C definition.
(push_qualified_expression_name): Ditto.
* memattr.c (_initialize_mem): Add declaration.
* remote.c (remote_check_watch_resources): Make static.
(remote_stopped_by_watchpoint): Make static.
(remote_stopped_data_address): Make static.
* d10v-tdep.c (nr_dmap_regs): Make static.
(a0_regnum): Make static.
(d10v_frame_unwind_cache): Make static.
(d10v_frame_p): Make static.
* osabi.c (show_osabi): Make static.
(_initialize_gdb_osabi): Add extern declaration.
* gdbtypes.c (make_qualified_type): Make static.
(safe_parse_type): Make static.
* macrocmd.c (_initialize_macrocmd): Add extern declaration.
* macrotab.c (macro_bcache_free): Make static.
* interps.c (interp_set_quiet): Make static.
(interpreter_exec_cmd): Make static.
* stack.h (select_frame_command): New file.
* stack.c: Include "stack.h".
(select_frame_command_wrapper): Delete function.
(select_frame_command): Make global.
* infcall.c: Include "infcall.h".
* linespec.c: Include "linespec.h".
* symfile.c (sections_overlap): Make static.
* cp-support.h (cp_initialize_namespace): ISO C declaration.
* charset.c (_initialize_charset): Add missing prototype.
* regcache.c (init_legacy_regcache_descr): Make static.
(do_regcache_xfree): Make static.
(regcache_xfer_part): Make static.
(_initialize_regcache): Add missing prototype.
* breakpoint.c (parse_breakpoint_sals): Make static.
(breakpoint_sals_to_pc): Make static.
* interps.h (clear_interpreter_hooks): ISO C declaration.
* Makefile.in (stack_h): Define.
(stack.o, typeprint.o, mi-main.o): Update dependencies.
(mi-cmd-stack.o, infcall.o, linespec.o): Update dependencies.
Index: mi/ChangeLog
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-06-09 02:27:14 +08:00
|
|
|
extern initialize_file_ftype _initialize_mi_interp; /* -Wmissing-prototypes */
|
|
|
|
|
2003-02-06 13:30:17 +08:00
|
|
|
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 */
|
|
|
|
};
|
|
|
|
|
Index: ChangeLog
2003-08-07 Andrew Cagney <cagney@redhat.com>
* interps.h (INTERP_MI2, INTERP_MI3): Define.
Index: doc/ChangeLog
2003-08-07 Andrew Cagney <cagney@redhat.com>
* gdb.texinfo (Mode Options): Mention that "mi2" was included in
GDB 6.0.
Index: mi/ChangeLog
2003-08-07 Andrew Cagney <cagney@redhat.com>
* mi-interp.c (_initialize_mi_interp): Register "mi2" and "mi3".
Make "mi" select "mi2".
Index: testsuite/gdb.mi/ChangeLog
2003-08-07 Andrew Cagney <cagney@redhat.com>
* mi2-basics.exp: Copy base MI .exp file, set MIFLAGS to -i=mi2.
* mi2-break.exp, mi2-cli.exp, mi2-console.exp: Ditto.
* mi2-disassemble.exp, mi2-eval.exp, mi2-file.exp: Ditto.
* mi2-hack-cli.exp, mi2-pthreads.exp, mi2-read-memory.exp: Ditto.
* mi2-regs.exp, mi2-return.exp, mi2-simplerun.exp: Ditto.
* mi2-stack.exp, mi2-stepi.exp, mi2-syn-frame.exp: Ditto.
* mi2-until.exp, mi2-var-block.exp, mi2-var-child.exp: Ditto.
* mi2-var-cmd.exp, mi2-var-display.exp, mi2-watch.exp: Ditto.
2003-08-08 01:47:42 +08:00
|
|
|
/* The various interpreter levels. */
|
2003-02-06 13:30:17 +08:00
|
|
|
interp_add (interp_new (INTERP_MI1, NULL, mi_out_new (1), &procs));
|
Index: ChangeLog
2003-08-07 Andrew Cagney <cagney@redhat.com>
* interps.h (INTERP_MI2, INTERP_MI3): Define.
Index: doc/ChangeLog
2003-08-07 Andrew Cagney <cagney@redhat.com>
* gdb.texinfo (Mode Options): Mention that "mi2" was included in
GDB 6.0.
Index: mi/ChangeLog
2003-08-07 Andrew Cagney <cagney@redhat.com>
* mi-interp.c (_initialize_mi_interp): Register "mi2" and "mi3".
Make "mi" select "mi2".
Index: testsuite/gdb.mi/ChangeLog
2003-08-07 Andrew Cagney <cagney@redhat.com>
* mi2-basics.exp: Copy base MI .exp file, set MIFLAGS to -i=mi2.
* mi2-break.exp, mi2-cli.exp, mi2-console.exp: Ditto.
* mi2-disassemble.exp, mi2-eval.exp, mi2-file.exp: Ditto.
* mi2-hack-cli.exp, mi2-pthreads.exp, mi2-read-memory.exp: Ditto.
* mi2-regs.exp, mi2-return.exp, mi2-simplerun.exp: Ditto.
* mi2-stack.exp, mi2-stepi.exp, mi2-syn-frame.exp: Ditto.
* mi2-until.exp, mi2-var-block.exp, mi2-var-child.exp: Ditto.
* mi2-var-cmd.exp, mi2-var-display.exp, mi2-watch.exp: Ditto.
2003-08-08 01:47:42 +08:00
|
|
|
interp_add (interp_new (INTERP_MI2, NULL, mi_out_new (2), &procs));
|
|
|
|
interp_add (interp_new (INTERP_MI3, NULL, mi_out_new (3), &procs));
|
2003-02-06 13:30:17 +08:00
|
|
|
|
Index: ChangeLog
2003-08-07 Andrew Cagney <cagney@redhat.com>
* interps.h (INTERP_MI2, INTERP_MI3): Define.
Index: doc/ChangeLog
2003-08-07 Andrew Cagney <cagney@redhat.com>
* gdb.texinfo (Mode Options): Mention that "mi2" was included in
GDB 6.0.
Index: mi/ChangeLog
2003-08-07 Andrew Cagney <cagney@redhat.com>
* mi-interp.c (_initialize_mi_interp): Register "mi2" and "mi3".
Make "mi" select "mi2".
Index: testsuite/gdb.mi/ChangeLog
2003-08-07 Andrew Cagney <cagney@redhat.com>
* mi2-basics.exp: Copy base MI .exp file, set MIFLAGS to -i=mi2.
* mi2-break.exp, mi2-cli.exp, mi2-console.exp: Ditto.
* mi2-disassemble.exp, mi2-eval.exp, mi2-file.exp: Ditto.
* mi2-hack-cli.exp, mi2-pthreads.exp, mi2-read-memory.exp: Ditto.
* mi2-regs.exp, mi2-return.exp, mi2-simplerun.exp: Ditto.
* mi2-stack.exp, mi2-stepi.exp, mi2-syn-frame.exp: Ditto.
* mi2-until.exp, mi2-var-block.exp, mi2-var-child.exp: Ditto.
* mi2-var-cmd.exp, mi2-var-display.exp, mi2-watch.exp: Ditto.
2003-08-08 01:47:42 +08:00
|
|
|
/* "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));
|
2003-02-06 13:30:17 +08:00
|
|
|
}
|