2003-02-14 14:58:06 +01:00
|
|
|
/* TUI Interpreter definitions for GDB, the GNU debugger.
|
|
|
|
|
2011-01-01 16:34:07 +01:00
|
|
|
Copyright (C) 2003, 2007, 2008, 2009, 2010, 2011
|
|
|
|
Free Software Foundation, Inc.
|
2003-02-14 14:58:06 +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-14 14:58:06 +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-14 14:58:06 +01:00
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
#include "interps.h"
|
|
|
|
#include "top.h"
|
|
|
|
#include "event-top.h"
|
|
|
|
#include "event-loop.h"
|
|
|
|
#include "ui-out.h"
|
2003-08-04 21:28:17 +02:00
|
|
|
#include "cli-out.h"
|
2004-01-19 05:31:53 +01:00
|
|
|
#include "tui/tui-data.h"
|
2003-02-14 14:58:06 +01:00
|
|
|
#include "readline/readline.h"
|
2004-01-19 05:31:53 +01:00
|
|
|
#include "tui/tui-win.h"
|
2003-02-14 14:58:06 +01:00
|
|
|
#include "tui/tui.h"
|
2004-01-19 05:31:53 +01:00
|
|
|
#include "tui/tui-io.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-14 14:58:06 +01:00
|
|
|
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
/* Set to 1 when the TUI mode must be activated when we first start
|
|
|
|
gdb. */
|
2003-07-23 23:22:14 +02:00
|
|
|
static int tui_start_enabled = 0;
|
|
|
|
|
2003-02-14 14:58:06 +01:00
|
|
|
/* Cleanup the tui before exiting. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
tui_exit (void)
|
|
|
|
{
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
/* Disable the tui. Curses mode is left leaving the screen in a
|
|
|
|
clean state (see endwin()). */
|
2003-02-14 14:58:06 +01:00
|
|
|
tui_disable ();
|
|
|
|
}
|
|
|
|
|
2010-03-31 00:21:34 +02:00
|
|
|
/* True if TUI is the top-level interpreter. */
|
|
|
|
static int tui_is_toplevel = 0;
|
|
|
|
|
2003-02-14 14:58:06 +01:00
|
|
|
/* These implement the TUI interpreter. */
|
|
|
|
|
|
|
|
static void *
|
2011-09-12 23:25:22 +02:00
|
|
|
tui_init (struct interp *self, int top_level)
|
2003-02-14 14:58:06 +01:00
|
|
|
{
|
2010-03-31 00:21:34 +02:00
|
|
|
tui_is_toplevel = top_level;
|
|
|
|
|
2003-02-14 14:58:06 +01:00
|
|
|
/* Install exit handler to leave the screen in a good shape. */
|
|
|
|
atexit (tui_exit);
|
|
|
|
|
2004-02-07 05:40:36 +01:00
|
|
|
tui_initialize_static_data ();
|
2003-02-14 14:58:06 +01:00
|
|
|
|
|
|
|
tui_initialize_io ();
|
2007-10-02 18:50:08 +02:00
|
|
|
tui_initialize_win ();
|
2010-02-04 18:37:59 +01:00
|
|
|
if (ui_file_isatty (gdb_stdout))
|
|
|
|
tui_initialize_readline ();
|
2003-02-14 14:58:06 +01:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-03-31 00:21:34 +02:00
|
|
|
/* True if enabling the TUI is allowed. Example, if the top level
|
|
|
|
interpreter is MI, enabling curses will certainly lose. */
|
|
|
|
|
|
|
|
int
|
|
|
|
tui_allowed_p (void)
|
|
|
|
{
|
|
|
|
/* Only if TUI is the top level interpreter. Also don't try to
|
|
|
|
setup curses (and print funny control characters) if we're not
|
|
|
|
outputting to a terminal. */
|
|
|
|
return tui_is_toplevel && ui_file_isatty (gdb_stdout);
|
|
|
|
}
|
|
|
|
|
2003-02-14 14:58:06 +01:00
|
|
|
static int
|
|
|
|
tui_resume (void *data)
|
|
|
|
{
|
2003-08-04 21:28:17 +02:00
|
|
|
struct ui_file *stream;
|
|
|
|
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
/* gdb_setup_readline will change gdb_stdout. If the TUI was
|
|
|
|
previously writing to gdb_stdout, then set it to the new
|
|
|
|
gdb_stdout afterwards. */
|
2003-08-04 21:28:17 +02:00
|
|
|
|
|
|
|
stream = cli_out_set_stream (tui_old_uiout, gdb_stdout);
|
|
|
|
if (stream != gdb_stdout)
|
|
|
|
{
|
|
|
|
cli_out_set_stream (tui_old_uiout, stream);
|
|
|
|
stream = NULL;
|
|
|
|
}
|
|
|
|
|
2003-02-14 14:58:06 +01:00
|
|
|
gdb_setup_readline ();
|
2003-08-04 21:28:17 +02:00
|
|
|
|
|
|
|
if (stream != NULL)
|
|
|
|
cli_out_set_stream (tui_old_uiout, gdb_stdout);
|
|
|
|
|
2003-07-23 23:22:14 +02:00
|
|
|
if (tui_start_enabled)
|
|
|
|
tui_enable ();
|
2003-02-14 14:58:06 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tui_suspend (void *data)
|
|
|
|
{
|
2003-07-23 23:22:14 +02:00
|
|
|
tui_start_enabled = tui_active;
|
2003-02-14 14:58:06 +01:00
|
|
|
tui_disable ();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Display the prompt if we are silent. */
|
|
|
|
|
|
|
|
static int
|
|
|
|
tui_display_prompt_p (void *data)
|
|
|
|
{
|
|
|
|
if (interp_quiet_p (NULL))
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2011-09-12 23:25:22 +02:00
|
|
|
static struct ui_out *
|
|
|
|
tui_ui_out (struct interp *self)
|
|
|
|
{
|
|
|
|
if (tui_active)
|
|
|
|
return tui_out;
|
|
|
|
else
|
|
|
|
return tui_old_uiout;
|
|
|
|
}
|
|
|
|
|
2005-04-26 07:03:41 +02:00
|
|
|
static struct gdb_exception
|
2003-02-14 14:58:06 +01:00
|
|
|
tui_exec (void *data, const char *command_str)
|
|
|
|
{
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up error_no_arg, query, perror_with_name, complaint, and
internal_error.
* breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update.
* cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update.
* dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update.
* exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update.
* frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update.
* gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update.
* go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update.
* i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update.
* infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update.
* interps.c, language.c, linespec.c, linux-nat.c: Update.
* m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update.
* m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update.
* macrotab.c, maint.c, mdebugread.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update.
* mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update.
* objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update.
* parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update.
* ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update.
* regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update.
* remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update.
* s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update.
* sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update.
* solib-aix5.c, solib-svr4.c, solib.c, source.c: Update.
* sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update.
* symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update.
* utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update.
* win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update.
* cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update.
* cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update.
* mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update.
* tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-11 19:13:55 +01:00
|
|
|
internal_error (__FILE__, __LINE__, _("tui_exec called"));
|
2003-02-14 14:58:06 +01:00
|
|
|
}
|
|
|
|
|
2008-02-21 Pedro Alves <pedro@codesorcery.com>
Silence a few -Wmissing-prototypes warnings.
PR build/9877:
* amd64-nat.c: Include "amd64-nat.h".
* fork-child.c (_initialize_fork_child): Ditto.
* gcore.c (_initialize_gcore): Ditto.
* inf-ptrace.c: Include "inf-ptrace.h".
(inf_ptrace_store_registers): Make it static.
* linux-nat.c (linux_nat_terminal_ours): Make it static.
(_initialize_linux_nat): Declare before definition.
* linux-tdep.c: Include "linux-tdep.h".
* linux-thread-db.c (_initialize_thread_db): Declare before
definition.
* proc-service.c (_initialize_proc_service): Ditto.
* remote.c (remote_send_printf): Make it static.
* solib.c: Include "solib.h".
* symfile-mem.c (_initialize_symfile_mem): Declare before
definition.
* ada-lang.c (ada_la_decode, ada_match_name)
(ada_suppress_symbol_printing, ada_is_array_type)
(ada_value_ptr_subscript, ada_array_length)
(ada_to_static_fixed_value): Make them static.
(_initialize_ada_language): Declare before definition.
* ada-tasks.c (ada_get_task_number, ada_get_environment_task)
(ada_task_list_changed, ada_new_objfile_observer): Make them
static.
(_initialize_tasks): Declare before definition.
* addrmap.c (_initialize_addrmap): Declare before definition.
* auxv.c (default_auxv_parse): Make it static.
* bfd-target.c (target_bfd_xfer_partial, target_bfd_xclose): Make
them static.
* breakpoint.c (remove_sal): Add line break.
(expand_line_sal_maybe): Make it static.
* cp-name-parser.y: Include "cp-support.h".
* cp-valprint.c (cp_find_class_member): Make it static.
* eval.c (value_f90_subarray): Ditto.
* exceptions.c (print_any_exception): Ditto.
* findcmd.c (_initialize_mem_search): Declare before definition.
* frame.c (frame_observer_target_changed): Make it static.
* gnu-v3-abi.c (gnuv3_find_method_in): Make it static.
* inf-child.c: Include "inf-child.h".
* inferior.h (valid_inferior_id): Rename to ...
(valid_gdb_inferior_id): ... this.
* infrun.c (infrun_thread_stop_requested, siginfo_make_value):
Make them static.
* jv-lang.c (java_language_arch_info): Make it static.
* m2-typeprint.c (m2_get_discrete_bounds): Ditto.
* osdata.c (info_osdata_command): Make it static.
* regcache.c (regcache_observer_target_changed): Make it static.
* reverse.c (_initialize_reverse): Declare before definition.
* stabsread.c (cleanup_undefined_types_noname)
(cleanup_undefined_types_1): Make them static.
* symfile.c (place_section): Make it static.
* symtab.c (find_pc_sect_psymtab_closer): Make it static.
* target-descriptions.c (_initialize_target_descriptions): Declare
before definition.
* target.c (default_get_ada_task_ptid, find_default_can_async_p)
(find_default_is_async_p, find_default_supports_non_stop): Make
them static.
(target_supports_non_stop): Add prototype.
(dummy_pid_to_str): Make it static.
* utils.c (_initialize_utils): Declare before definition.
* ada-exp.y (_initialize_ada_exp): Declare before definition.
* solib-svr4.c (HAS_LM_DYNAMIC_FROM_LINK_MAP): Add a prototype.
* target.h (struct target_ops): Add a prototype to the
to_can_execute_reverse callback.
* macroscope.c (_initialize_macroscope): Declare before definition.
* cp-namespace.c (_initialize_cp_namespace): Declare before definition.
* python/python.c (_initialize_python): Declare before definition.
* tui/tui-command.c: Include "tui/tui-command.h".
* tui/tui-data.c (init_content_element, init_win_info): Make them
static.
* tui/tui-disasm.c: Include "tui/tui-disasm.h".
* tui/tui-interp.c (_initialize_tui_interp): Declare before
definition.
* tui/tui-layout.c: Include "tui/tui-layout.h".
(_initialize_tui_layout): Declare before definition.
* tui/tui-regs.c: Include "tui/tui-regs.h".
(tui_display_reg_element_at_line): Make it static.
(_initialize_tui_regs): Declare before definition.
* tui/tui-stack.c (_initialize_tui_stack): Declare before
definition.
* tui/tui-win.c: Include "tui/tui-win.h".
(_initialize_tui_win): Declare before definition.
(tui_sigwinch_handler): Make it static. Wrap in ifdef SIGWINCH.
* tui/tui-win.h (tui_sigwinch_handler): Delete declaration.
(tui_get_cmd_list): Add a prototype.
* tui/tui-windata.c: Include tui-windata.h.
* tui/tui-wingeneral.c (box_win): Make it static.
* cli/cli-logging.c (show_logging_command): Make it static.
(_initialize_cli_logging): Declare before definition.
* mi/mi-common.c (_initialize_gdb_mi_common): Declare before
definition.
2009-02-21 17:14:50 +01:00
|
|
|
/* Provide a prototype to silence -Wmissing-prototypes. */
|
|
|
|
extern initialize_file_ftype _initialize_tui_interp;
|
|
|
|
|
2003-02-14 14:58:06 +01:00
|
|
|
void
|
|
|
|
_initialize_tui_interp (void)
|
|
|
|
{
|
|
|
|
static const struct interp_procs procs = {
|
|
|
|
tui_init,
|
|
|
|
tui_resume,
|
|
|
|
tui_suspend,
|
|
|
|
tui_exec,
|
|
|
|
tui_display_prompt_p,
|
2011-09-12 23:25:22 +02:00
|
|
|
tui_ui_out,
|
2003-02-14 14:58:06 +01:00
|
|
|
};
|
2011-09-12 23:25:22 +02:00
|
|
|
struct interp *tui_interp;
|
2003-02-14 14:58:06 +01:00
|
|
|
|
2007-08-14 Michael Snyder <msnyder@access-company.com>
* tui-command.c, tui-data.c, tui-data.h, tui-disasm.c, tui-file.c,
tui-hooks.c, tui-interp.c, tui-io.c, tui-layout.c, tui-out.c,
tui-regs.c, tui-regs.h, tui-source.c, tui-stack.c, tui-win.c,
tui-windata.c, tui-wingeneral.c, tui-winsource.c, tui-winsource.h,
tui.c, tui.h: Comment reformatting to coding standard (capitals,
spaces after periods, etc).
2007-08-14 23:20:09 +02:00
|
|
|
/* Create a default uiout builder for the TUI. */
|
2011-09-12 23:25:22 +02:00
|
|
|
tui_interp = interp_new (INTERP_TUI, &procs);
|
|
|
|
interp_add (tui_interp);
|
2005-11-07 13:46:38 +01:00
|
|
|
if (interpreter_p && strcmp (interpreter_p, INTERP_TUI) == 0)
|
2003-07-23 23:22:14 +02:00
|
|
|
tui_start_enabled = 1;
|
|
|
|
|
|
|
|
if (interpreter_p && strcmp (interpreter_p, INTERP_CONSOLE) == 0)
|
|
|
|
{
|
|
|
|
xfree (interpreter_p);
|
2005-11-07 13:46:38 +01:00
|
|
|
interpreter_p = xstrdup (INTERP_TUI);
|
2003-07-23 23:22:14 +02:00
|
|
|
}
|
2003-02-14 14:58:06 +01:00
|
|
|
}
|