mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-02-17 13:10:12 +08:00
* ui-out.h (uiout): Rename to ... (current_uiout): ... this. * ui-out.c (uiout): Rename to ... (current_uiout): ... this. * ada-lang.c (print_it_exception, print_one_exception) (print_mention_exception): Adjust. * breakpoint.c (watchpoint_check): Adjust. (print_breakpoint_location, print_one_breakpoint, breakpoint_1) (default_collect_info, watchpoints_info, print_one_catch_fork) (print_one_catch_vfork, print_one_catch_syscall) (print_one_catch_exec, mention, print_it_ranged_breakpoint) (print_one_ranged_breakpoint, print_mention_ranged_breakpoint) (print_it_watchpoint, print_mention_watchpoint) (print_it_masked_watchpoint, print_mention_masked_watchpoint) (print_it_exception_catchpoint, print_one_exception_catchpoint) (print_mention_exception_catchpoint, say_where, bkpt_print_it) (bkpt_print_mention, momentary_bkpt_print_it) (tracepoint_print_mention, update_static_tracepoint) (tracepoints_info, save_breakpoints): Adjust. * cli-out.c (field_separator): Adjust. * cp-abi.c (list_cp_abis, show_cp_abi_cmd): Adjust. * exceptions.c (catch_exceptions_with_msg, catch_errors): Adjust. * frame.c (get_current_frame): Adjust. * infcmd.c (run_command_1, print_return_value): Adjust. * inferior.c (inferior_command, info_inferiors_command): Adjust. * infrun.c (print_end_stepping_range_reason): Adjust. (print_signal_exited_reason, print_exited_reason): Adjust. (print_signal_received_reason, print_no_history_reason): Adjust. * interps.c (interp_set): Adjust. * osdata.c (info_osdata_command): Adjust. * progspace.c (maintenance_info_program_spaces_command): Adjust. * remote-fileio.c (remote_fileio_request): Adjust. * remote.c (show_remote_cmd): Adjust. * solib.c (info_sharedlibrary_command): Adjust. * source.c (print_source_lines_base): Adjust. * stack.c (print_stack_frame): Adjust. (do_gdb_disassembly, print_frame_info, print_frame): Adjust. * symfile-mem.c (add_vsyscall_page): Adjust. * symfile.c (load_progress, generic_load) (print_transfer_performance): Adjust. * thread.c (info_threads_command, restore_selected_frame) (thread_command): Adjust. * top.c (make_cleanup_restore_ui_file): Adjust. * tracepoint.c (tvariables_info_1, trace_status_mi, tfind_1) (print_one_static_tracepoint_marker): Adjust. * cli/cli-cmds.c (print_disassembly): Adjust. * cli/cli-decode.c (print_doc_line): Adjust. * cli/cli-interp.c (safe_execute_command): Adjust. * cli/cli-logging.c (set_logging_redirect, pop_output_files) (handle_redirections): Adjust. * cli/cli-script.c (show_user_1): Adjust. * cli/cli-setshow.c (do_setshow_command, cmd_show_list): Adjust. * mi/mi-cmd-break.c (breakpoint_notify): Adjust. * mi/mi-cmd-disas.c (mi_cmd_disassemble): Adjust. * mi/mi-cmd-env.c (mi_cmd_env_pwd, mi_cmd_env_path) (mi_cmd_env_dir): Adjust. * mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_file) (print_partial_file_name, mi_cmd_file_list_exec_source_files): Adjust. * mi/mi-cmd-stack.c (mi_cmd_stack_list_frames) (mi_cmd_stack_info_depth, mi_cmd_stack_list_args) (list_args_or_locals): Adjust. * mi/mi-cmd-var.c (print_varobj, mi_cmd_var_create) (mi_cmd_var_delete, mi_cmd_var_set_format, mi_cmd_var_set_frozen) (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_path_expression, 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): Adjust. * mi/mi-interp.c (mi_on_normal_stop): Adjust. * mi/mi-main.c (mi_cmd_gdb_exit, mi_cmd_thread_select) (mi_cmd_thread_list_ids, mi_cmd_thread_info, print_one_inferior) (list_available_thread_groups, mi_cmd_list_thread_groups) (mi_cmd_data_list_register_names) (mi_cmd_data_list_changed_registers) (mi_cmd_data_list_register_values, get_register) (mi_cmd_data_evaluate_expression, mi_cmd_data_read_memory) (mi_cmd_data_read_memory_bytes, mi_cmd_list_features) (mi_cmd_list_target_features, mi_cmd_add_inferior) (mi_execute_command, mi_load_progress): Adjust. * mi/mi-symbol-cmds.c (mi_cmd_symbol_list_lines): Adjust. * python/py-auto-load.c (print_script, info_auto_load_scripts): Adjust. * python/py-breakpoint.c (bppy_get_commands): Adjust. * tui/tui-interp.c (tui_command_loop): Adjust. * tui/tui-io.c (tui_setup_io, tui_initialize_io): Adjust.
240 lines
6.6 KiB
C
240 lines
6.6 KiB
C
/* TUI Interpreter definitions for GDB, the GNU debugger.
|
|
|
|
Copyright (C) 2003, 2007, 2008, 2009, 2010, 2011
|
|
Free Software Foundation, Inc.
|
|
|
|
This file is part of GDB.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
#include "defs.h"
|
|
#include "interps.h"
|
|
#include "top.h"
|
|
#include "event-top.h"
|
|
#include "event-loop.h"
|
|
#include "ui-out.h"
|
|
#include "cli-out.h"
|
|
#include "tui/tui-data.h"
|
|
#include "readline/readline.h"
|
|
#include "tui/tui-win.h"
|
|
#include "tui/tui.h"
|
|
#include "tui/tui-io.h"
|
|
#include "exceptions.h"
|
|
|
|
/* Set to 1 when the TUI mode must be activated when we first start
|
|
gdb. */
|
|
static int tui_start_enabled = 0;
|
|
|
|
/* Cleanup the tui before exiting. */
|
|
|
|
static void
|
|
tui_exit (void)
|
|
{
|
|
/* Disable the tui. Curses mode is left leaving the screen in a
|
|
clean state (see endwin()). */
|
|
tui_disable ();
|
|
}
|
|
|
|
/* True if TUI is the top-level interpreter. */
|
|
static int tui_is_toplevel = 0;
|
|
|
|
/* These implement the TUI interpreter. */
|
|
|
|
static void *
|
|
tui_init (int top_level)
|
|
{
|
|
tui_is_toplevel = top_level;
|
|
|
|
/* Install exit handler to leave the screen in a good shape. */
|
|
atexit (tui_exit);
|
|
|
|
tui_initialize_static_data ();
|
|
|
|
tui_initialize_io ();
|
|
tui_initialize_win ();
|
|
if (ui_file_isatty (gdb_stdout))
|
|
tui_initialize_readline ();
|
|
|
|
return NULL;
|
|
}
|
|
|
|
/* 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);
|
|
}
|
|
|
|
static int
|
|
tui_resume (void *data)
|
|
{
|
|
struct ui_file *stream;
|
|
|
|
/* 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. */
|
|
|
|
stream = cli_out_set_stream (tui_old_uiout, gdb_stdout);
|
|
if (stream != gdb_stdout)
|
|
{
|
|
cli_out_set_stream (tui_old_uiout, stream);
|
|
stream = NULL;
|
|
}
|
|
|
|
gdb_setup_readline ();
|
|
|
|
if (stream != NULL)
|
|
cli_out_set_stream (tui_old_uiout, gdb_stdout);
|
|
|
|
if (tui_start_enabled)
|
|
tui_enable ();
|
|
return 1;
|
|
}
|
|
|
|
static int
|
|
tui_suspend (void *data)
|
|
{
|
|
tui_start_enabled = tui_active;
|
|
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;
|
|
}
|
|
|
|
static struct gdb_exception
|
|
tui_exec (void *data, const char *command_str)
|
|
{
|
|
internal_error (__FILE__, __LINE__, _("tui_exec called"));
|
|
}
|
|
|
|
|
|
/* Initialize all the necessary variables, start the event loop,
|
|
register readline, and stdin, start the loop. */
|
|
|
|
static void
|
|
tui_command_loop (void *data)
|
|
{
|
|
/* If we are using readline, set things up and display the first
|
|
prompt, otherwise just print the prompt. */
|
|
if (async_command_editing_p)
|
|
{
|
|
int length;
|
|
char *a_prompt;
|
|
char *gdb_prompt = get_prompt (0);
|
|
|
|
/* Tell readline what the prompt to display is and what function
|
|
it will need to call after a whole line is read. This also
|
|
displays the first prompt. */
|
|
length = strlen (get_prefix (0))
|
|
+ strlen (gdb_prompt) + strlen (get_suffix (0)) + 1;
|
|
a_prompt = (char *) alloca (length);
|
|
strcpy (a_prompt, get_prefix (0));
|
|
strcat (a_prompt, gdb_prompt);
|
|
strcat (a_prompt, get_suffix (0));
|
|
rl_callback_handler_install (a_prompt, input_handler);
|
|
}
|
|
else
|
|
display_gdb_prompt (0);
|
|
|
|
/* Loop until there is nothing to do. This is the entry point to the
|
|
event loop engine. gdb_do_one_event, called via catch_errors()
|
|
will process one event for each invocation. It blocks waits for
|
|
an event and then processes it. >0 when an event is processed, 0
|
|
when catch_errors() caught an error and <0 when there are no
|
|
longer any event sources registered. */
|
|
while (1)
|
|
{
|
|
int result = catch_errors (gdb_do_one_event, 0, "", RETURN_MASK_ALL);
|
|
|
|
if (result < 0)
|
|
break;
|
|
|
|
/* Update gdb output according to TUI mode. Since catch_errors
|
|
preserves the uiout from changing, this must be done at top
|
|
level of event loop. */
|
|
if (tui_active)
|
|
current_uiout = tui_out;
|
|
else
|
|
current_uiout = tui_old_uiout;
|
|
|
|
if (result == 0)
|
|
{
|
|
/* If any exception escaped to here, we better enable
|
|
stdin. Otherwise, any command that calls async_disable_stdin,
|
|
and then throws, will leave stdin inoperable. */
|
|
async_enable_stdin ();
|
|
/* FIXME: this should really be a call to a hook that is
|
|
interface specific, because interfaces can display the
|
|
prompt in their own way. */
|
|
display_gdb_prompt (0);
|
|
/* This call looks bizarre, but it is required. If the user
|
|
entered a command that caused an error,
|
|
after_char_processing_hook won't be called from
|
|
rl_callback_read_char_wrapper. Using a cleanup there
|
|
won't work, since we want this function to be called
|
|
after a new prompt is printed. */
|
|
if (after_char_processing_hook)
|
|
(*after_char_processing_hook) ();
|
|
/* Maybe better to set a flag to be checked somewhere as to
|
|
whether display the prompt or not. */
|
|
}
|
|
}
|
|
|
|
/* We are done with the event loop. There are no more event sources
|
|
to listen to. So we exit GDB. */
|
|
return;
|
|
}
|
|
|
|
/* Provide a prototype to silence -Wmissing-prototypes. */
|
|
extern initialize_file_ftype _initialize_tui_interp;
|
|
|
|
void
|
|
_initialize_tui_interp (void)
|
|
{
|
|
static const struct interp_procs procs = {
|
|
tui_init,
|
|
tui_resume,
|
|
tui_suspend,
|
|
tui_exec,
|
|
tui_display_prompt_p,
|
|
tui_command_loop,
|
|
};
|
|
|
|
/* Create a default uiout builder for the TUI. */
|
|
tui_out = tui_out_new (gdb_stdout);
|
|
interp_add (interp_new (INTERP_TUI, NULL, tui_out, &procs));
|
|
if (interpreter_p && strcmp (interpreter_p, INTERP_TUI) == 0)
|
|
tui_start_enabled = 1;
|
|
|
|
if (interpreter_p && strcmp (interpreter_p, INTERP_CONSOLE) == 0)
|
|
{
|
|
xfree (interpreter_p);
|
|
interpreter_p = xstrdup (INTERP_TUI);
|
|
}
|
|
}
|