2003-02-06 06:30:17 +01:00
|
|
|
/* CLI Definitions for GDB, the GNU debugger.
|
|
|
|
|
2008-01-01 23:53:26 +01:00
|
|
|
Copyright (c) 2002, 2003, 2007, 2008 Free Software Foundation, Inc.
|
2003-02-06 06:30:17 +01: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-23 20:08:50 +02:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
2003-02-06 06:30:17 +01: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-23 20:08:50 +02:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
2003-02-06 06:30:17 +01:00
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
#include "interps.h"
|
|
|
|
#include "wrapper.h"
|
|
|
|
#include "event-top.h"
|
|
|
|
#include "ui-out.h"
|
|
|
|
#include "cli-out.h"
|
|
|
|
#include "top.h" /* for "execute_command" */
|
|
|
|
#include "gdb_string.h"
|
2005-01-12 Andrew Cagney <cagney@gnu.org>
* exceptions.h (enum return_reason, RETURN_MASK)
(RETURN_MASK_QUIT, RETURN_MASK_ERROR, RETURN_MASK_ALL)
(return_mask, throw_exception, catch_exceptions_ftype)
(catch_exceptions_with_msg, catch_errors_ftype, catch_errors)
(catch_command_errors_ftype, catch_command_errors): Move to
exceptions.h.
* exceptions.c, exceptions.h: New files.
* top.c: Do not include <setjmp.h>.
(SIGJMP_BUF, SIGSETJMP, SIGLONGJMP, catch_return)
(throw_exception, catcher, catch_exceptions)
(catch_exceptions_with_msg, struct catch_errors_args)
(do_catch_errors, catch_errors, struct captured_command_args)
(do_captured_command, catch_command_errors): Move to exceptions.c.
* wrapper.c, wince.c, win32-nat.c, utils.c: Include "exceptions.h".
* tui/tui-interp.c, top.c, thread.c, symmisc.c: Ditto.
* symfile-mem.c, stack.c, solib.c, rs6000-nat.c: Ditto.
* remote-sds.c, remote-mips.c, remote-fileio.c: Ditto.
* remote-e7000.c, objc-lang.c, ocd.c: Ditto.
* remote.c, nto-procfs.c, monitor.c, mi/mi-main.c: Ditto.
* main.c, m32r-rom.c, infrun.c, inf-loop.c: Ditto.
* hppa-hpux-tdep.c, frame.c, event-top.c, event-loop.c: Ditto.
* corelow.c, corefile.c, cli/cli-interp.c, breakpoint.c: Ditto.
* ada-valprint.c, ada-lang.c: Ditto.
* Makefile.in (HFILES_NO_SRCDIR, COMMON_OBS): Add exceptions.h and
exceptions.o. Update all dependencies.
2005-01-12 19:31:35 +01:00
|
|
|
#include "exceptions.h"
|
2003-02-06 06:30:17 +01:00
|
|
|
|
|
|
|
struct ui_out *cli_uiout;
|
|
|
|
|
2005-01-14 00:31:17 +01:00
|
|
|
/* These are the ui_out and the interpreter for the console interpreter. */
|
2003-02-06 06:30:17 +01:00
|
|
|
|
2005-01-14 00:31:17 +01:00
|
|
|
/* Longjmp-safe wrapper for "execute_command". */
|
2005-04-26 07:03:41 +02:00
|
|
|
static struct gdb_exception safe_execute_command (struct ui_out *uiout,
|
|
|
|
char *command, int from_tty);
|
2003-02-06 06:30:17 +01:00
|
|
|
struct captured_execute_command_args
|
|
|
|
{
|
|
|
|
char *command;
|
|
|
|
int from_tty;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* These implement the cli out interpreter: */
|
|
|
|
|
|
|
|
static void *
|
2008-03-14 18:21:08 +01:00
|
|
|
cli_interpreter_init (int top_level)
|
2003-02-06 06:30:17 +01:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
cli_interpreter_resume (void *data)
|
|
|
|
{
|
2003-07-03 16:49:26 +02:00
|
|
|
struct ui_file *stream;
|
|
|
|
|
2003-02-06 06:30:17 +01:00
|
|
|
/*sync_execution = 1; */
|
2003-07-03 16:49:26 +02:00
|
|
|
|
|
|
|
/* gdb_setup_readline will change gdb_stdout. If the CLI was previously
|
|
|
|
writing to gdb_stdout, then set it to the new gdb_stdout afterwards. */
|
|
|
|
|
|
|
|
stream = cli_out_set_stream (cli_uiout, gdb_stdout);
|
|
|
|
if (stream != gdb_stdout)
|
|
|
|
{
|
|
|
|
cli_out_set_stream (cli_uiout, stream);
|
|
|
|
stream = NULL;
|
|
|
|
}
|
|
|
|
|
2003-02-06 06:30:17 +01:00
|
|
|
gdb_setup_readline ();
|
2003-07-03 16:49:26 +02:00
|
|
|
|
|
|
|
if (stream != NULL)
|
|
|
|
cli_out_set_stream (cli_uiout, gdb_stdout);
|
|
|
|
|
2003-02-06 06:30:17 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
cli_interpreter_suspend (void *data)
|
|
|
|
{
|
|
|
|
gdb_disable_readline ();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Don't display the prompt if we are set quiet. */
|
|
|
|
static int
|
|
|
|
cli_interpreter_display_prompt_p (void *data)
|
|
|
|
{
|
|
|
|
if (interp_quiet_p (NULL))
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2005-04-26 07:03:41 +02:00
|
|
|
static struct gdb_exception
|
2003-02-06 06:30:17 +01:00
|
|
|
cli_interpreter_exec (void *data, const char *command_str)
|
|
|
|
{
|
|
|
|
struct ui_file *old_stream;
|
2005-04-26 07:03:41 +02:00
|
|
|
struct gdb_exception result;
|
2003-02-06 06:30:17 +01:00
|
|
|
|
|
|
|
/* FIXME: cagney/2003-02-01: Need to const char *propogate
|
|
|
|
safe_execute_command. */
|
|
|
|
char *str = strcpy (alloca (strlen (command_str) + 1), command_str);
|
|
|
|
|
|
|
|
/* gdb_stdout could change between the time cli_uiout was initialized
|
|
|
|
and now. Since we're probably using a different interpreter which has
|
|
|
|
a new ui_file for gdb_stdout, use that one instead of the default.
|
|
|
|
|
|
|
|
It is important that it gets reset everytime, since the user could
|
2005-01-14 00:31:17 +01:00
|
|
|
set gdb to use a different interpreter. */
|
2003-02-06 06:30:17 +01:00
|
|
|
old_stream = cli_out_set_stream (cli_uiout, gdb_stdout);
|
|
|
|
result = safe_execute_command (cli_uiout, str, 1);
|
|
|
|
cli_out_set_stream (cli_uiout, old_stream);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2005-01-13 03:35:39 +01:00
|
|
|
static void
|
2003-02-06 06:30:17 +01:00
|
|
|
do_captured_execute_command (struct ui_out *uiout, void *data)
|
|
|
|
{
|
|
|
|
struct captured_execute_command_args *args =
|
|
|
|
(struct captured_execute_command_args *) data;
|
|
|
|
execute_command (args->command, args->from_tty);
|
|
|
|
}
|
|
|
|
|
2005-04-26 07:03:41 +02:00
|
|
|
static struct gdb_exception
|
2003-02-06 06:30:17 +01:00
|
|
|
safe_execute_command (struct ui_out *uiout, char *command, int from_tty)
|
|
|
|
{
|
2005-04-26 07:03:41 +02:00
|
|
|
struct gdb_exception e;
|
2003-02-06 06:30:17 +01:00
|
|
|
struct captured_execute_command_args args;
|
|
|
|
args.command = command;
|
|
|
|
args.from_tty = from_tty;
|
2005-01-14 19:55:33 +01:00
|
|
|
e = catch_exception (uiout, do_captured_execute_command, &args,
|
|
|
|
RETURN_MASK_ALL);
|
|
|
|
/* FIXME: cagney/2005-01-13: This shouldn't be needed. Instead the
|
|
|
|
caller should print the exception. */
|
2005-01-14 23:59:36 +01:00
|
|
|
exception_print (gdb_stderr, e);
|
2005-01-14 19:55:33 +01:00
|
|
|
return e;
|
2003-02-06 06:30:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-01-14 00:31:17 +01:00
|
|
|
/* Standard gdb initialization hook. */
|
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-08 20:27:14 +02:00
|
|
|
extern initialize_file_ftype _initialize_cli_interp; /* -Wmissing-prototypes */
|
|
|
|
|
2003-02-06 06:30:17 +01:00
|
|
|
void
|
|
|
|
_initialize_cli_interp (void)
|
|
|
|
{
|
|
|
|
static const struct interp_procs procs = {
|
|
|
|
cli_interpreter_init, /* init_proc */
|
|
|
|
cli_interpreter_resume, /* resume_proc */
|
|
|
|
cli_interpreter_suspend, /* suspend_proc */
|
|
|
|
cli_interpreter_exec, /* exec_proc */
|
|
|
|
cli_interpreter_display_prompt_p /* prompt_proc_p */
|
|
|
|
};
|
|
|
|
struct interp *cli_interp;
|
|
|
|
|
2005-01-14 00:31:17 +01:00
|
|
|
/* Create a default uiout builder for the CLI. */
|
2003-02-06 06:30:17 +01:00
|
|
|
cli_uiout = cli_out_new (gdb_stdout);
|
|
|
|
cli_interp = interp_new (INTERP_CONSOLE, NULL, cli_uiout, &procs);
|
|
|
|
|
|
|
|
interp_add (cli_interp);
|
|
|
|
}
|