binutils-gdb/gdb/interps.c

459 lines
12 KiB
C
Raw Permalink Normal View History

2003-02-06 06:30:17 +01:00
/* Manages interpreters for GDB, the GNU debugger.
Copyright (C) 2000-2020 Free Software Foundation, Inc.
2003-02-06 06:30:17 +01:00
Written by Jim Ingham <jingham@apple.com> of Apple Computer, 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
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
along with this program. If not, see <http://www.gnu.org/licenses/>. */
2003-02-06 06:30:17 +01:00
/* This is just a first cut at separating out the "interpreter"
functions of gdb into self-contained modules. There are a couple
of open areas that need to be sorted out:
1) The interpreter explicitly contains a UI_OUT, and can insert itself
into the event loop, but it doesn't explicitly contain hooks for readline.
I did this because it seems to me many interpreters won't want to use
the readline command interface, and it is probably simpler to just let
them take over the input in their resume proc. */
#include "defs.h"
#include "gdbcmd.h"
#include "ui-out.h"
#include "gdbsupport/event-loop.h"
2003-02-06 06:30:17 +01:00
#include "event-top.h"
#include "interps.h"
#include "completer.h"
#include "top.h" /* For command_loop. */
#include "continuations.h"
#include "main.h"
2003-02-06 06:30:17 +01:00
Make the interpreters be per UI Make each UI have its own interpreter list, top level interpreter, current interpreter, etc. The "interpreter_async" global is not really specific to an struct interp (it crosses interpreter-exec ...), so I moved it to "struct ui" directly, while the other globals were left hidden in interps.c, opaque to the rest of GDB. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * breakpoint.c (bpstat_do_actions_1): Access the current UI's async field instead of the interpreter_async global. * cli/cli-script.c (execute_user_command, while_command) (if_command, script_from_file): Likewise. * compile/compile.c: Include top.h instead of interps.h. (compile_file_command, compile_code_command) (compile_print_command): Access the current UI's async field instead of the interpreter_async global. * guile/guile.c: Include top.h instead of interps.h. (guile_repl_command, guile_command, gdbscm_execute_gdb_command): Access the current UI's async field instead of the interpreter_async global. * guile/scm-ports.c: Include top.h instead of interps.h. (ioscm_with_output_to_port_worker): Access the current UI's async field instead of the interpreter_async global. * inf-loop.c (inferior_event_handler): Likewise. * infcall.c (run_inferior_call): Likewise. * infrun.c (reinstall_readline_callback_handler_cleanup) (fetch_inferior_event): Likewise. * interps.c (interpreter_async): Delete. (struct ui_interp_info): New. (get_current_interp_info): New function. (interp_list, current_interpreter, top_level_interpreter_ptr): Delete. (interp_add, interp_set, interp_lookup, interp_ui_out) (current_interp_set_logging, interp_set_temp) (current_interp_named_p): Adjust to per-UI interpreters. (command_interpreter): Delete. (command_interp, current_interp_command_loop, interp_quiet_p) (interp_exec, interpreter_exec_cmd, interpreter_completer) (top_level_interpreter, top_level_interpreter_data): Adjust to per-UI interpreters. * interps.h (interpreter_async): Delete. * main.c (captured_command_loop): Access the current UI's async field instead of the interpreter_async global. * python/python.c (python_interactive_command, python_command) (execute_gdb_command): Likewise. * top.c (maybe_wait_sync_command_done, execute_command_to_string): Access the current UI's async field instead of the interpreter_async global. * top.h (struct tl_interp_info): Forward declare. (struct ui) <interp_info, async>: New fields.
2016-06-21 02:11:45 +02:00
/* Each UI has its own independent set of interpreters. */
struct ui_interp_info
{
/* Each top level has its own independent set of interpreters. */
struct interp *interp_list;
struct interp *current_interpreter;
struct interp *top_level_interpreter;
/* The interpreter that is active while `interp_exec' is active, NULL
at all other times. */
struct interp *command_interpreter;
};
Introduce interpreter factories If every UI instance has its own set of interpreters, then the current scheme of creating the interpreters at GDB initialization time no longer works. We need to create them whenever a new UI instance is created. The scheme implemented here has each interpreter register a factory callback that when called creates a new instance of a specific interpreter type. Then, when some code in gdb looks up an interpreter (always by name), if there's none yet, the factory method is called to construct one. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_uiout): Delete, moved into ... (struct cli_interp): ... this new structure. (cli_on_normal_stop, cli_on_signal_received) (cli_on_end_stepping_range, cli_on_signal_exited, cli_on_exited) (cli_on_no_history): Use interp_ui_out. (cli_interpreter_init): If top level, set the cli_interp global. (cli_interpreter_init): Return the interp's data instead of NULL. (cli_interpreter_resume, cli_interpreter_exec, cli_ui_out): Adjust to cli_uiout being in the interpreter's data. (cli_interp_procs): New, factored out from _initialize_cli_interp. (cli_interp_factory): New function. (_initialize_cli_interp): Call interp_factory_register. * interps.c (get_interp_info): New, factored out from ... (get_current_interp_info): ... this. (interp_new): Add parameter 'data'. Store it. (struct interp_factory): New function. (interp_factory_p): New typedef. Define a VEC_P. (interpreter_factories): New global. (interp_factory_register): New function. (interp_add): Add 'ui' parameter. Use get_interp_info and interp_lookup_existing. (interp_lookup): Rename to ... (interp_lookup_existing): ... this. Add 'ui' parameter. Don't check for NULL or empty name here. (interp_lookup): Add 'ui' parameter and reimplement. (interp_set_temp, interpreter_exec_cmd): Adjust. (interpreter_completer): Complete on registered interpreter factories instead of interpreters. * interps.h (interp_factory_func): New typedef. (interp_factory_register): Declare. (interp_new, interp_add): Adjust. (interp_lookup): Declare. * main.c (captured_main): Adjust. * mi/mi-interp.c (mi_cmd_interpreter_exec): Adjust. (mi_interp_procs): New, factored out from _initialize_mi_interp. (mi_interp_factory): New function. * python/python.c (execute_gdb_command): Adjust. * tui/tui-interp.c (tui_init): If top level, set the tui_interp global. (tui_interp_procs): New. (tui_interp_factory): New function. (_initialize_tui_interp): Call interp_factory_register.
2016-06-21 02:11:45 +02:00
/* Get UI's ui_interp_info object. Never returns NULL. */
Make the interpreters be per UI Make each UI have its own interpreter list, top level interpreter, current interpreter, etc. The "interpreter_async" global is not really specific to an struct interp (it crosses interpreter-exec ...), so I moved it to "struct ui" directly, while the other globals were left hidden in interps.c, opaque to the rest of GDB. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * breakpoint.c (bpstat_do_actions_1): Access the current UI's async field instead of the interpreter_async global. * cli/cli-script.c (execute_user_command, while_command) (if_command, script_from_file): Likewise. * compile/compile.c: Include top.h instead of interps.h. (compile_file_command, compile_code_command) (compile_print_command): Access the current UI's async field instead of the interpreter_async global. * guile/guile.c: Include top.h instead of interps.h. (guile_repl_command, guile_command, gdbscm_execute_gdb_command): Access the current UI's async field instead of the interpreter_async global. * guile/scm-ports.c: Include top.h instead of interps.h. (ioscm_with_output_to_port_worker): Access the current UI's async field instead of the interpreter_async global. * inf-loop.c (inferior_event_handler): Likewise. * infcall.c (run_inferior_call): Likewise. * infrun.c (reinstall_readline_callback_handler_cleanup) (fetch_inferior_event): Likewise. * interps.c (interpreter_async): Delete. (struct ui_interp_info): New. (get_current_interp_info): New function. (interp_list, current_interpreter, top_level_interpreter_ptr): Delete. (interp_add, interp_set, interp_lookup, interp_ui_out) (current_interp_set_logging, interp_set_temp) (current_interp_named_p): Adjust to per-UI interpreters. (command_interpreter): Delete. (command_interp, current_interp_command_loop, interp_quiet_p) (interp_exec, interpreter_exec_cmd, interpreter_completer) (top_level_interpreter, top_level_interpreter_data): Adjust to per-UI interpreters. * interps.h (interpreter_async): Delete. * main.c (captured_command_loop): Access the current UI's async field instead of the interpreter_async global. * python/python.c (python_interactive_command, python_command) (execute_gdb_command): Likewise. * top.c (maybe_wait_sync_command_done, execute_command_to_string): Access the current UI's async field instead of the interpreter_async global. * top.h (struct tl_interp_info): Forward declare. (struct ui) <interp_info, async>: New fields.
2016-06-21 02:11:45 +02:00
static struct ui_interp_info *
Introduce interpreter factories If every UI instance has its own set of interpreters, then the current scheme of creating the interpreters at GDB initialization time no longer works. We need to create them whenever a new UI instance is created. The scheme implemented here has each interpreter register a factory callback that when called creates a new instance of a specific interpreter type. Then, when some code in gdb looks up an interpreter (always by name), if there's none yet, the factory method is called to construct one. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_uiout): Delete, moved into ... (struct cli_interp): ... this new structure. (cli_on_normal_stop, cli_on_signal_received) (cli_on_end_stepping_range, cli_on_signal_exited, cli_on_exited) (cli_on_no_history): Use interp_ui_out. (cli_interpreter_init): If top level, set the cli_interp global. (cli_interpreter_init): Return the interp's data instead of NULL. (cli_interpreter_resume, cli_interpreter_exec, cli_ui_out): Adjust to cli_uiout being in the interpreter's data. (cli_interp_procs): New, factored out from _initialize_cli_interp. (cli_interp_factory): New function. (_initialize_cli_interp): Call interp_factory_register. * interps.c (get_interp_info): New, factored out from ... (get_current_interp_info): ... this. (interp_new): Add parameter 'data'. Store it. (struct interp_factory): New function. (interp_factory_p): New typedef. Define a VEC_P. (interpreter_factories): New global. (interp_factory_register): New function. (interp_add): Add 'ui' parameter. Use get_interp_info and interp_lookup_existing. (interp_lookup): Rename to ... (interp_lookup_existing): ... this. Add 'ui' parameter. Don't check for NULL or empty name here. (interp_lookup): Add 'ui' parameter and reimplement. (interp_set_temp, interpreter_exec_cmd): Adjust. (interpreter_completer): Complete on registered interpreter factories instead of interpreters. * interps.h (interp_factory_func): New typedef. (interp_factory_register): Declare. (interp_new, interp_add): Adjust. (interp_lookup): Declare. * main.c (captured_main): Adjust. * mi/mi-interp.c (mi_cmd_interpreter_exec): Adjust. (mi_interp_procs): New, factored out from _initialize_mi_interp. (mi_interp_factory): New function. * python/python.c (execute_gdb_command): Adjust. * tui/tui-interp.c (tui_init): If top level, set the tui_interp global. (tui_interp_procs): New. (tui_interp_factory): New function. (_initialize_tui_interp): Call interp_factory_register.
2016-06-21 02:11:45 +02:00
get_interp_info (struct ui *ui)
Make the interpreters be per UI Make each UI have its own interpreter list, top level interpreter, current interpreter, etc. The "interpreter_async" global is not really specific to an struct interp (it crosses interpreter-exec ...), so I moved it to "struct ui" directly, while the other globals were left hidden in interps.c, opaque to the rest of GDB. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * breakpoint.c (bpstat_do_actions_1): Access the current UI's async field instead of the interpreter_async global. * cli/cli-script.c (execute_user_command, while_command) (if_command, script_from_file): Likewise. * compile/compile.c: Include top.h instead of interps.h. (compile_file_command, compile_code_command) (compile_print_command): Access the current UI's async field instead of the interpreter_async global. * guile/guile.c: Include top.h instead of interps.h. (guile_repl_command, guile_command, gdbscm_execute_gdb_command): Access the current UI's async field instead of the interpreter_async global. * guile/scm-ports.c: Include top.h instead of interps.h. (ioscm_with_output_to_port_worker): Access the current UI's async field instead of the interpreter_async global. * inf-loop.c (inferior_event_handler): Likewise. * infcall.c (run_inferior_call): Likewise. * infrun.c (reinstall_readline_callback_handler_cleanup) (fetch_inferior_event): Likewise. * interps.c (interpreter_async): Delete. (struct ui_interp_info): New. (get_current_interp_info): New function. (interp_list, current_interpreter, top_level_interpreter_ptr): Delete. (interp_add, interp_set, interp_lookup, interp_ui_out) (current_interp_set_logging, interp_set_temp) (current_interp_named_p): Adjust to per-UI interpreters. (command_interpreter): Delete. (command_interp, current_interp_command_loop, interp_quiet_p) (interp_exec, interpreter_exec_cmd, interpreter_completer) (top_level_interpreter, top_level_interpreter_data): Adjust to per-UI interpreters. * interps.h (interpreter_async): Delete. * main.c (captured_command_loop): Access the current UI's async field instead of the interpreter_async global. * python/python.c (python_interactive_command, python_command) (execute_gdb_command): Likewise. * top.c (maybe_wait_sync_command_done, execute_command_to_string): Access the current UI's async field instead of the interpreter_async global. * top.h (struct tl_interp_info): Forward declare. (struct ui) <interp_info, async>: New fields.
2016-06-21 02:11:45 +02:00
{
if (ui->interp_info == NULL)
ui->interp_info = XCNEW (struct ui_interp_info);
return ui->interp_info;
}
Introduce interpreter factories If every UI instance has its own set of interpreters, then the current scheme of creating the interpreters at GDB initialization time no longer works. We need to create them whenever a new UI instance is created. The scheme implemented here has each interpreter register a factory callback that when called creates a new instance of a specific interpreter type. Then, when some code in gdb looks up an interpreter (always by name), if there's none yet, the factory method is called to construct one. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_uiout): Delete, moved into ... (struct cli_interp): ... this new structure. (cli_on_normal_stop, cli_on_signal_received) (cli_on_end_stepping_range, cli_on_signal_exited, cli_on_exited) (cli_on_no_history): Use interp_ui_out. (cli_interpreter_init): If top level, set the cli_interp global. (cli_interpreter_init): Return the interp's data instead of NULL. (cli_interpreter_resume, cli_interpreter_exec, cli_ui_out): Adjust to cli_uiout being in the interpreter's data. (cli_interp_procs): New, factored out from _initialize_cli_interp. (cli_interp_factory): New function. (_initialize_cli_interp): Call interp_factory_register. * interps.c (get_interp_info): New, factored out from ... (get_current_interp_info): ... this. (interp_new): Add parameter 'data'. Store it. (struct interp_factory): New function. (interp_factory_p): New typedef. Define a VEC_P. (interpreter_factories): New global. (interp_factory_register): New function. (interp_add): Add 'ui' parameter. Use get_interp_info and interp_lookup_existing. (interp_lookup): Rename to ... (interp_lookup_existing): ... this. Add 'ui' parameter. Don't check for NULL or empty name here. (interp_lookup): Add 'ui' parameter and reimplement. (interp_set_temp, interpreter_exec_cmd): Adjust. (interpreter_completer): Complete on registered interpreter factories instead of interpreters. * interps.h (interp_factory_func): New typedef. (interp_factory_register): Declare. (interp_new, interp_add): Adjust. (interp_lookup): Declare. * main.c (captured_main): Adjust. * mi/mi-interp.c (mi_cmd_interpreter_exec): Adjust. (mi_interp_procs): New, factored out from _initialize_mi_interp. (mi_interp_factory): New function. * python/python.c (execute_gdb_command): Adjust. * tui/tui-interp.c (tui_init): If top level, set the tui_interp global. (tui_interp_procs): New. (tui_interp_factory): New function. (_initialize_tui_interp): Call interp_factory_register.
2016-06-21 02:11:45 +02:00
/* Get the current UI's ui_interp_info object. Never returns
NULL. */
static struct ui_interp_info *
get_current_interp_info (void)
{
return get_interp_info (current_ui);
}
/* The magic initialization routine for this module. */
2003-02-06 06:30:17 +01:00
Introduce interpreter factories If every UI instance has its own set of interpreters, then the current scheme of creating the interpreters at GDB initialization time no longer works. We need to create them whenever a new UI instance is created. The scheme implemented here has each interpreter register a factory callback that when called creates a new instance of a specific interpreter type. Then, when some code in gdb looks up an interpreter (always by name), if there's none yet, the factory method is called to construct one. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_uiout): Delete, moved into ... (struct cli_interp): ... this new structure. (cli_on_normal_stop, cli_on_signal_received) (cli_on_end_stepping_range, cli_on_signal_exited, cli_on_exited) (cli_on_no_history): Use interp_ui_out. (cli_interpreter_init): If top level, set the cli_interp global. (cli_interpreter_init): Return the interp's data instead of NULL. (cli_interpreter_resume, cli_interpreter_exec, cli_ui_out): Adjust to cli_uiout being in the interpreter's data. (cli_interp_procs): New, factored out from _initialize_cli_interp. (cli_interp_factory): New function. (_initialize_cli_interp): Call interp_factory_register. * interps.c (get_interp_info): New, factored out from ... (get_current_interp_info): ... this. (interp_new): Add parameter 'data'. Store it. (struct interp_factory): New function. (interp_factory_p): New typedef. Define a VEC_P. (interpreter_factories): New global. (interp_factory_register): New function. (interp_add): Add 'ui' parameter. Use get_interp_info and interp_lookup_existing. (interp_lookup): Rename to ... (interp_lookup_existing): ... this. Add 'ui' parameter. Don't check for NULL or empty name here. (interp_lookup): Add 'ui' parameter and reimplement. (interp_set_temp, interpreter_exec_cmd): Adjust. (interpreter_completer): Complete on registered interpreter factories instead of interpreters. * interps.h (interp_factory_func): New typedef. (interp_factory_register): Declare. (interp_new, interp_add): Adjust. (interp_lookup): Declare. * main.c (captured_main): Adjust. * mi/mi-interp.c (mi_cmd_interpreter_exec): Adjust. (mi_interp_procs): New, factored out from _initialize_mi_interp. (mi_interp_factory): New function. * python/python.c (execute_gdb_command): Adjust. * tui/tui-interp.c (tui_init): If top level, set the tui_interp global. (tui_interp_procs): New. (tui_interp_factory): New function. (_initialize_tui_interp): Call interp_factory_register.
2016-06-21 02:11:45 +02:00
static struct interp *interp_lookup_existing (struct ui *ui,
const char *name);
C++-fy struct interp/cli_interp/tui_interp/mi_interp - The interp->data field disappears, since we can put data in the interpreter directly now. The "init" method remains in place, but it now returns void. - A few places check if the interpreter method is NULL before calling it, and also check whether the method returns true/false. For some of those methods, all current implementations always return true. In those cases, this commit makes the C++-fied method return void instead and cleans up the callers. Tested on x86_64 Fedora 23. gdb/ChangeLog: 2017-02-03 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_interp_base::cli_interp_base) (cli_interp_base::~cli_interp_base): New. (cli_interp): New struct. (as_cli_interp): Cast the interp itself to cli_interp. (cli_interpreter_pre_command_loop): Rename to ... (cli_interp_base::pre_command_loop): ... this. Remove 'self' parameter. (cli_interpreter_init): Rename to ... (cli_interp::init): ... this. Remove 'self' parameter. Use boolean. Make extern. (cli_interpreter_resume): Rename to ... (cli_interp::resume): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_suspend): Rename to ... (cli_interp::suspend): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_exec): Rename to ... (cli_interp::exec): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_supports_command_editing): Rename to ... (cli_interp_base::supports_command_editing): ... this. Remove 'interp' parameter. Make extern. (cli_ui_out): Rename to ... (cli_interp::interp_ui_out): ... this. Remove 'interp' parameter. Make extern. (cli_set_logging): Rename to ... (cli_interp_base::set_logging): ... this. Remove 'interp' parameter. Make extern. (cli_interp_procs): Delete. (cli_interp_factory): Adjust to use "new". * cli/cli-interp.h: Include "interps.h". (struct cli_interp_base): New struct. * interps.c (struct interp): Delete. Fields moved to interps.h. (interp_new): Delete. (interp::interp, interp::~interp): New. (interp_set): Use bool, and return void. Assume the interpreter has suspend, init and resume methods, and that the all return void. (set_top_level_interpreter): interp_set returns void. (interp_ui_out): Adapt. (current_interp_set_logging): Adapt. (interp_data): Delete. (interp_pre_command_loop, interp_supports_command_editing): Adapt. (interp_exec): Adapt. (top_level_interpreter_data): Delete. * interps.h (interp_init_ftype, interp_resume_ftype) (interp_suspend_ftype, interp_exec_ftype) (interp_pre_command_loop_ftype, interp_ui_out_ftype): Delete. (class interp): New. (interp_new): Delete. (interp_set): Now returns void. Use bool. (interp_data, top_level_interpreter_data): Delete. * mi/mi-common.h: Include interps.h. (class mi_interp): Inherit from interp. Define a ctor. Declare init, resume, suspect, exec, interp_ui_out, set_logging and pre_command_loop methods. * mi/mi-interp.c (as_mi_interp): Cast the interp itself. (mi_interpreter_init): Rename to ... (mi_interp::init): ... this. Remove the 'interp' parameter, use bool, return void and make extern. Adjust. (mi_interpreter_resume): ... Rename to ... (mi_interp::resume): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (mi_interpreter_suspend): ... Rename to ... (mi_interp::suspend): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (mi_interpreter_exec): ... Rename to ... (mi_interp::exec): ... this. Remove the 'data' parameter and make extern. Adjust. (mi_interpreter_pre_command_loop): ... Rename to ... (mi_interp::pre_command_loop): ... this. Remove the 'self' parameter and make extern. (mi_on_normal_stop_1): Adjust. (mi_ui_out): Rename to ... (mi_interp::interp_ui_out): ... this. Remove the 'interp' parameter and make extern. Adjust. (mi_set_logging): Rename to ... (mi_interp::set_logging): ... this. Remove the 'interp' parameter and make extern. Adjust. (mi_interp_procs): Delete. (mi_interp_factory): Adjust to use 'new'. * mi/mi-main.c (mi_cmd_gdb_exit, captured_mi_execute_command) (mi_print_exception, mi_execute_command, mi_load_progress): Adjust. * tui/tui-interp.c (tui_interp): New class. (as_tui_interp): Return a tui_interp pointer. (tui_on_normal_stop, tui_on_signal_received) (tui_on_end_stepping_range, tui_on_signal_exited, tui_on_exited) (tui_on_no_history, tui_on_user_selected_context_changed): Adjust to use interp::interp_ui_out. (tui_init): Rename to ... (tui_interp::init): ... this. Remove the 'self' parameter, use bool, return void and make extern. Adjust. (tui_resume): Rename to ... (tui_interp::resume): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (tui_suspend): Rename to ... (tui_interp::suspend): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (tui_ui_out): Rename to ... (tui_interp::interp_ui_out): ... this. Remove the 'self' parameter, and make extern. Adjust. (tui_exec): Rename to ... (tui_interp::exec): ... this. Remove the 'data' parameter and make extern. (tui_interp_procs): Delete. (tui_interp_factory): Use "new".
2017-02-03 17:30:04 +01:00
interp::interp (const char *name)
: m_name (xstrdup (name))
2003-02-06 06:30:17 +01:00
{
C++-fy struct interp/cli_interp/tui_interp/mi_interp - The interp->data field disappears, since we can put data in the interpreter directly now. The "init" method remains in place, but it now returns void. - A few places check if the interpreter method is NULL before calling it, and also check whether the method returns true/false. For some of those methods, all current implementations always return true. In those cases, this commit makes the C++-fied method return void instead and cleans up the callers. Tested on x86_64 Fedora 23. gdb/ChangeLog: 2017-02-03 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_interp_base::cli_interp_base) (cli_interp_base::~cli_interp_base): New. (cli_interp): New struct. (as_cli_interp): Cast the interp itself to cli_interp. (cli_interpreter_pre_command_loop): Rename to ... (cli_interp_base::pre_command_loop): ... this. Remove 'self' parameter. (cli_interpreter_init): Rename to ... (cli_interp::init): ... this. Remove 'self' parameter. Use boolean. Make extern. (cli_interpreter_resume): Rename to ... (cli_interp::resume): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_suspend): Rename to ... (cli_interp::suspend): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_exec): Rename to ... (cli_interp::exec): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_supports_command_editing): Rename to ... (cli_interp_base::supports_command_editing): ... this. Remove 'interp' parameter. Make extern. (cli_ui_out): Rename to ... (cli_interp::interp_ui_out): ... this. Remove 'interp' parameter. Make extern. (cli_set_logging): Rename to ... (cli_interp_base::set_logging): ... this. Remove 'interp' parameter. Make extern. (cli_interp_procs): Delete. (cli_interp_factory): Adjust to use "new". * cli/cli-interp.h: Include "interps.h". (struct cli_interp_base): New struct. * interps.c (struct interp): Delete. Fields moved to interps.h. (interp_new): Delete. (interp::interp, interp::~interp): New. (interp_set): Use bool, and return void. Assume the interpreter has suspend, init and resume methods, and that the all return void. (set_top_level_interpreter): interp_set returns void. (interp_ui_out): Adapt. (current_interp_set_logging): Adapt. (interp_data): Delete. (interp_pre_command_loop, interp_supports_command_editing): Adapt. (interp_exec): Adapt. (top_level_interpreter_data): Delete. * interps.h (interp_init_ftype, interp_resume_ftype) (interp_suspend_ftype, interp_exec_ftype) (interp_pre_command_loop_ftype, interp_ui_out_ftype): Delete. (class interp): New. (interp_new): Delete. (interp_set): Now returns void. Use bool. (interp_data, top_level_interpreter_data): Delete. * mi/mi-common.h: Include interps.h. (class mi_interp): Inherit from interp. Define a ctor. Declare init, resume, suspect, exec, interp_ui_out, set_logging and pre_command_loop methods. * mi/mi-interp.c (as_mi_interp): Cast the interp itself. (mi_interpreter_init): Rename to ... (mi_interp::init): ... this. Remove the 'interp' parameter, use bool, return void and make extern. Adjust. (mi_interpreter_resume): ... Rename to ... (mi_interp::resume): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (mi_interpreter_suspend): ... Rename to ... (mi_interp::suspend): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (mi_interpreter_exec): ... Rename to ... (mi_interp::exec): ... this. Remove the 'data' parameter and make extern. Adjust. (mi_interpreter_pre_command_loop): ... Rename to ... (mi_interp::pre_command_loop): ... this. Remove the 'self' parameter and make extern. (mi_on_normal_stop_1): Adjust. (mi_ui_out): Rename to ... (mi_interp::interp_ui_out): ... this. Remove the 'interp' parameter and make extern. Adjust. (mi_set_logging): Rename to ... (mi_interp::set_logging): ... this. Remove the 'interp' parameter and make extern. Adjust. (mi_interp_procs): Delete. (mi_interp_factory): Adjust to use 'new'. * mi/mi-main.c (mi_cmd_gdb_exit, captured_mi_execute_command) (mi_print_exception, mi_execute_command, mi_load_progress): Adjust. * tui/tui-interp.c (tui_interp): New class. (as_tui_interp): Return a tui_interp pointer. (tui_on_normal_stop, tui_on_signal_received) (tui_on_end_stepping_range, tui_on_signal_exited, tui_on_exited) (tui_on_no_history, tui_on_user_selected_context_changed): Adjust to use interp::interp_ui_out. (tui_init): Rename to ... (tui_interp::init): ... this. Remove the 'self' parameter, use bool, return void and make extern. Adjust. (tui_resume): Rename to ... (tui_interp::resume): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (tui_suspend): Rename to ... (tui_interp::suspend): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (tui_ui_out): Rename to ... (tui_interp::interp_ui_out): ... this. Remove the 'self' parameter, and make extern. Adjust. (tui_exec): Rename to ... (tui_interp::exec): ... this. Remove the 'data' parameter and make extern. (tui_interp_procs): Delete. (tui_interp_factory): Use "new".
2017-02-03 17:30:04 +01:00
this->inited = false;
2003-02-06 06:30:17 +01:00
}
C++-fy struct interp/cli_interp/tui_interp/mi_interp - The interp->data field disappears, since we can put data in the interpreter directly now. The "init" method remains in place, but it now returns void. - A few places check if the interpreter method is NULL before calling it, and also check whether the method returns true/false. For some of those methods, all current implementations always return true. In those cases, this commit makes the C++-fied method return void instead and cleans up the callers. Tested on x86_64 Fedora 23. gdb/ChangeLog: 2017-02-03 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_interp_base::cli_interp_base) (cli_interp_base::~cli_interp_base): New. (cli_interp): New struct. (as_cli_interp): Cast the interp itself to cli_interp. (cli_interpreter_pre_command_loop): Rename to ... (cli_interp_base::pre_command_loop): ... this. Remove 'self' parameter. (cli_interpreter_init): Rename to ... (cli_interp::init): ... this. Remove 'self' parameter. Use boolean. Make extern. (cli_interpreter_resume): Rename to ... (cli_interp::resume): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_suspend): Rename to ... (cli_interp::suspend): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_exec): Rename to ... (cli_interp::exec): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_supports_command_editing): Rename to ... (cli_interp_base::supports_command_editing): ... this. Remove 'interp' parameter. Make extern. (cli_ui_out): Rename to ... (cli_interp::interp_ui_out): ... this. Remove 'interp' parameter. Make extern. (cli_set_logging): Rename to ... (cli_interp_base::set_logging): ... this. Remove 'interp' parameter. Make extern. (cli_interp_procs): Delete. (cli_interp_factory): Adjust to use "new". * cli/cli-interp.h: Include "interps.h". (struct cli_interp_base): New struct. * interps.c (struct interp): Delete. Fields moved to interps.h. (interp_new): Delete. (interp::interp, interp::~interp): New. (interp_set): Use bool, and return void. Assume the interpreter has suspend, init and resume methods, and that the all return void. (set_top_level_interpreter): interp_set returns void. (interp_ui_out): Adapt. (current_interp_set_logging): Adapt. (interp_data): Delete. (interp_pre_command_loop, interp_supports_command_editing): Adapt. (interp_exec): Adapt. (top_level_interpreter_data): Delete. * interps.h (interp_init_ftype, interp_resume_ftype) (interp_suspend_ftype, interp_exec_ftype) (interp_pre_command_loop_ftype, interp_ui_out_ftype): Delete. (class interp): New. (interp_new): Delete. (interp_set): Now returns void. Use bool. (interp_data, top_level_interpreter_data): Delete. * mi/mi-common.h: Include interps.h. (class mi_interp): Inherit from interp. Define a ctor. Declare init, resume, suspect, exec, interp_ui_out, set_logging and pre_command_loop methods. * mi/mi-interp.c (as_mi_interp): Cast the interp itself. (mi_interpreter_init): Rename to ... (mi_interp::init): ... this. Remove the 'interp' parameter, use bool, return void and make extern. Adjust. (mi_interpreter_resume): ... Rename to ... (mi_interp::resume): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (mi_interpreter_suspend): ... Rename to ... (mi_interp::suspend): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (mi_interpreter_exec): ... Rename to ... (mi_interp::exec): ... this. Remove the 'data' parameter and make extern. Adjust. (mi_interpreter_pre_command_loop): ... Rename to ... (mi_interp::pre_command_loop): ... this. Remove the 'self' parameter and make extern. (mi_on_normal_stop_1): Adjust. (mi_ui_out): Rename to ... (mi_interp::interp_ui_out): ... this. Remove the 'interp' parameter and make extern. Adjust. (mi_set_logging): Rename to ... (mi_interp::set_logging): ... this. Remove the 'interp' parameter and make extern. Adjust. (mi_interp_procs): Delete. (mi_interp_factory): Adjust to use 'new'. * mi/mi-main.c (mi_cmd_gdb_exit, captured_mi_execute_command) (mi_print_exception, mi_execute_command, mi_load_progress): Adjust. * tui/tui-interp.c (tui_interp): New class. (as_tui_interp): Return a tui_interp pointer. (tui_on_normal_stop, tui_on_signal_received) (tui_on_end_stepping_range, tui_on_signal_exited, tui_on_exited) (tui_on_no_history, tui_on_user_selected_context_changed): Adjust to use interp::interp_ui_out. (tui_init): Rename to ... (tui_interp::init): ... this. Remove the 'self' parameter, use bool, return void and make extern. Adjust. (tui_resume): Rename to ... (tui_interp::resume): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (tui_suspend): Rename to ... (tui_interp::suspend): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (tui_ui_out): Rename to ... (tui_interp::interp_ui_out): ... this. Remove the 'self' parameter, and make extern. Adjust. (tui_exec): Rename to ... (tui_interp::exec): ... this. Remove the 'data' parameter and make extern. (tui_interp_procs): Delete. (tui_interp_factory): Use "new".
2017-02-03 17:30:04 +01:00
interp::~interp ()
{
xfree (m_name);
}
C++-fy struct interp/cli_interp/tui_interp/mi_interp - The interp->data field disappears, since we can put data in the interpreter directly now. The "init" method remains in place, but it now returns void. - A few places check if the interpreter method is NULL before calling it, and also check whether the method returns true/false. For some of those methods, all current implementations always return true. In those cases, this commit makes the C++-fied method return void instead and cleans up the callers. Tested on x86_64 Fedora 23. gdb/ChangeLog: 2017-02-03 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_interp_base::cli_interp_base) (cli_interp_base::~cli_interp_base): New. (cli_interp): New struct. (as_cli_interp): Cast the interp itself to cli_interp. (cli_interpreter_pre_command_loop): Rename to ... (cli_interp_base::pre_command_loop): ... this. Remove 'self' parameter. (cli_interpreter_init): Rename to ... (cli_interp::init): ... this. Remove 'self' parameter. Use boolean. Make extern. (cli_interpreter_resume): Rename to ... (cli_interp::resume): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_suspend): Rename to ... (cli_interp::suspend): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_exec): Rename to ... (cli_interp::exec): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_supports_command_editing): Rename to ... (cli_interp_base::supports_command_editing): ... this. Remove 'interp' parameter. Make extern. (cli_ui_out): Rename to ... (cli_interp::interp_ui_out): ... this. Remove 'interp' parameter. Make extern. (cli_set_logging): Rename to ... (cli_interp_base::set_logging): ... this. Remove 'interp' parameter. Make extern. (cli_interp_procs): Delete. (cli_interp_factory): Adjust to use "new". * cli/cli-interp.h: Include "interps.h". (struct cli_interp_base): New struct. * interps.c (struct interp): Delete. Fields moved to interps.h. (interp_new): Delete. (interp::interp, interp::~interp): New. (interp_set): Use bool, and return void. Assume the interpreter has suspend, init and resume methods, and that the all return void. (set_top_level_interpreter): interp_set returns void. (interp_ui_out): Adapt. (current_interp_set_logging): Adapt. (interp_data): Delete. (interp_pre_command_loop, interp_supports_command_editing): Adapt. (interp_exec): Adapt. (top_level_interpreter_data): Delete. * interps.h (interp_init_ftype, interp_resume_ftype) (interp_suspend_ftype, interp_exec_ftype) (interp_pre_command_loop_ftype, interp_ui_out_ftype): Delete. (class interp): New. (interp_new): Delete. (interp_set): Now returns void. Use bool. (interp_data, top_level_interpreter_data): Delete. * mi/mi-common.h: Include interps.h. (class mi_interp): Inherit from interp. Define a ctor. Declare init, resume, suspect, exec, interp_ui_out, set_logging and pre_command_loop methods. * mi/mi-interp.c (as_mi_interp): Cast the interp itself. (mi_interpreter_init): Rename to ... (mi_interp::init): ... this. Remove the 'interp' parameter, use bool, return void and make extern. Adjust. (mi_interpreter_resume): ... Rename to ... (mi_interp::resume): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (mi_interpreter_suspend): ... Rename to ... (mi_interp::suspend): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (mi_interpreter_exec): ... Rename to ... (mi_interp::exec): ... this. Remove the 'data' parameter and make extern. Adjust. (mi_interpreter_pre_command_loop): ... Rename to ... (mi_interp::pre_command_loop): ... this. Remove the 'self' parameter and make extern. (mi_on_normal_stop_1): Adjust. (mi_ui_out): Rename to ... (mi_interp::interp_ui_out): ... this. Remove the 'interp' parameter and make extern. Adjust. (mi_set_logging): Rename to ... (mi_interp::set_logging): ... this. Remove the 'interp' parameter and make extern. Adjust. (mi_interp_procs): Delete. (mi_interp_factory): Adjust to use 'new'. * mi/mi-main.c (mi_cmd_gdb_exit, captured_mi_execute_command) (mi_print_exception, mi_execute_command, mi_load_progress): Adjust. * tui/tui-interp.c (tui_interp): New class. (as_tui_interp): Return a tui_interp pointer. (tui_on_normal_stop, tui_on_signal_received) (tui_on_end_stepping_range, tui_on_signal_exited, tui_on_exited) (tui_on_no_history, tui_on_user_selected_context_changed): Adjust to use interp::interp_ui_out. (tui_init): Rename to ... (tui_interp::init): ... this. Remove the 'self' parameter, use bool, return void and make extern. Adjust. (tui_resume): Rename to ... (tui_interp::resume): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (tui_suspend): Rename to ... (tui_interp::suspend): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (tui_ui_out): Rename to ... (tui_interp::interp_ui_out): ... this. Remove the 'self' parameter, and make extern. Adjust. (tui_exec): Rename to ... (tui_interp::exec): ... this. Remove the 'data' parameter and make extern. (tui_interp_procs): Delete. (tui_interp_factory): Use "new".
2017-02-03 17:30:04 +01:00
Introduce interpreter factories If every UI instance has its own set of interpreters, then the current scheme of creating the interpreters at GDB initialization time no longer works. We need to create them whenever a new UI instance is created. The scheme implemented here has each interpreter register a factory callback that when called creates a new instance of a specific interpreter type. Then, when some code in gdb looks up an interpreter (always by name), if there's none yet, the factory method is called to construct one. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_uiout): Delete, moved into ... (struct cli_interp): ... this new structure. (cli_on_normal_stop, cli_on_signal_received) (cli_on_end_stepping_range, cli_on_signal_exited, cli_on_exited) (cli_on_no_history): Use interp_ui_out. (cli_interpreter_init): If top level, set the cli_interp global. (cli_interpreter_init): Return the interp's data instead of NULL. (cli_interpreter_resume, cli_interpreter_exec, cli_ui_out): Adjust to cli_uiout being in the interpreter's data. (cli_interp_procs): New, factored out from _initialize_cli_interp. (cli_interp_factory): New function. (_initialize_cli_interp): Call interp_factory_register. * interps.c (get_interp_info): New, factored out from ... (get_current_interp_info): ... this. (interp_new): Add parameter 'data'. Store it. (struct interp_factory): New function. (interp_factory_p): New typedef. Define a VEC_P. (interpreter_factories): New global. (interp_factory_register): New function. (interp_add): Add 'ui' parameter. Use get_interp_info and interp_lookup_existing. (interp_lookup): Rename to ... (interp_lookup_existing): ... this. Add 'ui' parameter. Don't check for NULL or empty name here. (interp_lookup): Add 'ui' parameter and reimplement. (interp_set_temp, interpreter_exec_cmd): Adjust. (interpreter_completer): Complete on registered interpreter factories instead of interpreters. * interps.h (interp_factory_func): New typedef. (interp_factory_register): Declare. (interp_new, interp_add): Adjust. (interp_lookup): Declare. * main.c (captured_main): Adjust. * mi/mi-interp.c (mi_cmd_interpreter_exec): Adjust. (mi_interp_procs): New, factored out from _initialize_mi_interp. (mi_interp_factory): New function. * python/python.c (execute_gdb_command): Adjust. * tui/tui-interp.c (tui_init): If top level, set the tui_interp global. (tui_interp_procs): New. (tui_interp_factory): New function. (_initialize_tui_interp): Call interp_factory_register.
2016-06-21 02:11:45 +02:00
/* An interpreter factory. Maps an interpreter name to the factory
function that instantiates an interpreter by that name. */
struct interp_factory
{
interp_factory (const char *name_, interp_factory_func func_)
: name (name_), func (func_)
{}
Introduce interpreter factories If every UI instance has its own set of interpreters, then the current scheme of creating the interpreters at GDB initialization time no longer works. We need to create them whenever a new UI instance is created. The scheme implemented here has each interpreter register a factory callback that when called creates a new instance of a specific interpreter type. Then, when some code in gdb looks up an interpreter (always by name), if there's none yet, the factory method is called to construct one. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_uiout): Delete, moved into ... (struct cli_interp): ... this new structure. (cli_on_normal_stop, cli_on_signal_received) (cli_on_end_stepping_range, cli_on_signal_exited, cli_on_exited) (cli_on_no_history): Use interp_ui_out. (cli_interpreter_init): If top level, set the cli_interp global. (cli_interpreter_init): Return the interp's data instead of NULL. (cli_interpreter_resume, cli_interpreter_exec, cli_ui_out): Adjust to cli_uiout being in the interpreter's data. (cli_interp_procs): New, factored out from _initialize_cli_interp. (cli_interp_factory): New function. (_initialize_cli_interp): Call interp_factory_register. * interps.c (get_interp_info): New, factored out from ... (get_current_interp_info): ... this. (interp_new): Add parameter 'data'. Store it. (struct interp_factory): New function. (interp_factory_p): New typedef. Define a VEC_P. (interpreter_factories): New global. (interp_factory_register): New function. (interp_add): Add 'ui' parameter. Use get_interp_info and interp_lookup_existing. (interp_lookup): Rename to ... (interp_lookup_existing): ... this. Add 'ui' parameter. Don't check for NULL or empty name here. (interp_lookup): Add 'ui' parameter and reimplement. (interp_set_temp, interpreter_exec_cmd): Adjust. (interpreter_completer): Complete on registered interpreter factories instead of interpreters. * interps.h (interp_factory_func): New typedef. (interp_factory_register): Declare. (interp_new, interp_add): Adjust. (interp_lookup): Declare. * main.c (captured_main): Adjust. * mi/mi-interp.c (mi_cmd_interpreter_exec): Adjust. (mi_interp_procs): New, factored out from _initialize_mi_interp. (mi_interp_factory): New function. * python/python.c (execute_gdb_command): Adjust. * tui/tui-interp.c (tui_init): If top level, set the tui_interp global. (tui_interp_procs): New. (tui_interp_factory): New function. (_initialize_tui_interp): Call interp_factory_register.
2016-06-21 02:11:45 +02:00
/* This is the name in "-i=INTERP" and "interpreter-exec INTERP". */
const char *name;
/* The function that creates the interpreter. */
interp_factory_func func;
};
/* The registered interpreter factories. */
static std::vector<interp_factory> interpreter_factories;
Introduce interpreter factories If every UI instance has its own set of interpreters, then the current scheme of creating the interpreters at GDB initialization time no longer works. We need to create them whenever a new UI instance is created. The scheme implemented here has each interpreter register a factory callback that when called creates a new instance of a specific interpreter type. Then, when some code in gdb looks up an interpreter (always by name), if there's none yet, the factory method is called to construct one. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_uiout): Delete, moved into ... (struct cli_interp): ... this new structure. (cli_on_normal_stop, cli_on_signal_received) (cli_on_end_stepping_range, cli_on_signal_exited, cli_on_exited) (cli_on_no_history): Use interp_ui_out. (cli_interpreter_init): If top level, set the cli_interp global. (cli_interpreter_init): Return the interp's data instead of NULL. (cli_interpreter_resume, cli_interpreter_exec, cli_ui_out): Adjust to cli_uiout being in the interpreter's data. (cli_interp_procs): New, factored out from _initialize_cli_interp. (cli_interp_factory): New function. (_initialize_cli_interp): Call interp_factory_register. * interps.c (get_interp_info): New, factored out from ... (get_current_interp_info): ... this. (interp_new): Add parameter 'data'. Store it. (struct interp_factory): New function. (interp_factory_p): New typedef. Define a VEC_P. (interpreter_factories): New global. (interp_factory_register): New function. (interp_add): Add 'ui' parameter. Use get_interp_info and interp_lookup_existing. (interp_lookup): Rename to ... (interp_lookup_existing): ... this. Add 'ui' parameter. Don't check for NULL or empty name here. (interp_lookup): Add 'ui' parameter and reimplement. (interp_set_temp, interpreter_exec_cmd): Adjust. (interpreter_completer): Complete on registered interpreter factories instead of interpreters. * interps.h (interp_factory_func): New typedef. (interp_factory_register): Declare. (interp_new, interp_add): Adjust. (interp_lookup): Declare. * main.c (captured_main): Adjust. * mi/mi-interp.c (mi_cmd_interpreter_exec): Adjust. (mi_interp_procs): New, factored out from _initialize_mi_interp. (mi_interp_factory): New function. * python/python.c (execute_gdb_command): Adjust. * tui/tui-interp.c (tui_init): If top level, set the tui_interp global. (tui_interp_procs): New. (tui_interp_factory): New function. (_initialize_tui_interp): Call interp_factory_register.
2016-06-21 02:11:45 +02:00
/* See interps.h. */
void
interp_factory_register (const char *name, interp_factory_func func)
{
/* Assert that no factory for NAME is already registered. */
for (const interp_factory &f : interpreter_factories)
if (strcmp (f.name, name) == 0)
Introduce interpreter factories If every UI instance has its own set of interpreters, then the current scheme of creating the interpreters at GDB initialization time no longer works. We need to create them whenever a new UI instance is created. The scheme implemented here has each interpreter register a factory callback that when called creates a new instance of a specific interpreter type. Then, when some code in gdb looks up an interpreter (always by name), if there's none yet, the factory method is called to construct one. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_uiout): Delete, moved into ... (struct cli_interp): ... this new structure. (cli_on_normal_stop, cli_on_signal_received) (cli_on_end_stepping_range, cli_on_signal_exited, cli_on_exited) (cli_on_no_history): Use interp_ui_out. (cli_interpreter_init): If top level, set the cli_interp global. (cli_interpreter_init): Return the interp's data instead of NULL. (cli_interpreter_resume, cli_interpreter_exec, cli_ui_out): Adjust to cli_uiout being in the interpreter's data. (cli_interp_procs): New, factored out from _initialize_cli_interp. (cli_interp_factory): New function. (_initialize_cli_interp): Call interp_factory_register. * interps.c (get_interp_info): New, factored out from ... (get_current_interp_info): ... this. (interp_new): Add parameter 'data'. Store it. (struct interp_factory): New function. (interp_factory_p): New typedef. Define a VEC_P. (interpreter_factories): New global. (interp_factory_register): New function. (interp_add): Add 'ui' parameter. Use get_interp_info and interp_lookup_existing. (interp_lookup): Rename to ... (interp_lookup_existing): ... this. Add 'ui' parameter. Don't check for NULL or empty name here. (interp_lookup): Add 'ui' parameter and reimplement. (interp_set_temp, interpreter_exec_cmd): Adjust. (interpreter_completer): Complete on registered interpreter factories instead of interpreters. * interps.h (interp_factory_func): New typedef. (interp_factory_register): Declare. (interp_new, interp_add): Adjust. (interp_lookup): Declare. * main.c (captured_main): Adjust. * mi/mi-interp.c (mi_cmd_interpreter_exec): Adjust. (mi_interp_procs): New, factored out from _initialize_mi_interp. (mi_interp_factory): New function. * python/python.c (execute_gdb_command): Adjust. * tui/tui-interp.c (tui_init): If top level, set the tui_interp global. (tui_interp_procs): New. (tui_interp_factory): New function. (_initialize_tui_interp): Call interp_factory_register.
2016-06-21 02:11:45 +02:00
{
internal_error (__FILE__, __LINE__,
_("interpreter factory already registered: \"%s\"\n"),
name);
}
interpreter_factories.emplace_back (name, func);
Introduce interpreter factories If every UI instance has its own set of interpreters, then the current scheme of creating the interpreters at GDB initialization time no longer works. We need to create them whenever a new UI instance is created. The scheme implemented here has each interpreter register a factory callback that when called creates a new instance of a specific interpreter type. Then, when some code in gdb looks up an interpreter (always by name), if there's none yet, the factory method is called to construct one. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_uiout): Delete, moved into ... (struct cli_interp): ... this new structure. (cli_on_normal_stop, cli_on_signal_received) (cli_on_end_stepping_range, cli_on_signal_exited, cli_on_exited) (cli_on_no_history): Use interp_ui_out. (cli_interpreter_init): If top level, set the cli_interp global. (cli_interpreter_init): Return the interp's data instead of NULL. (cli_interpreter_resume, cli_interpreter_exec, cli_ui_out): Adjust to cli_uiout being in the interpreter's data. (cli_interp_procs): New, factored out from _initialize_cli_interp. (cli_interp_factory): New function. (_initialize_cli_interp): Call interp_factory_register. * interps.c (get_interp_info): New, factored out from ... (get_current_interp_info): ... this. (interp_new): Add parameter 'data'. Store it. (struct interp_factory): New function. (interp_factory_p): New typedef. Define a VEC_P. (interpreter_factories): New global. (interp_factory_register): New function. (interp_add): Add 'ui' parameter. Use get_interp_info and interp_lookup_existing. (interp_lookup): Rename to ... (interp_lookup_existing): ... this. Add 'ui' parameter. Don't check for NULL or empty name here. (interp_lookup): Add 'ui' parameter and reimplement. (interp_set_temp, interpreter_exec_cmd): Adjust. (interpreter_completer): Complete on registered interpreter factories instead of interpreters. * interps.h (interp_factory_func): New typedef. (interp_factory_register): Declare. (interp_new, interp_add): Adjust. (interp_lookup): Declare. * main.c (captured_main): Adjust. * mi/mi-interp.c (mi_cmd_interpreter_exec): Adjust. (mi_interp_procs): New, factored out from _initialize_mi_interp. (mi_interp_factory): New function. * python/python.c (execute_gdb_command): Adjust. * tui/tui-interp.c (tui_init): If top level, set the tui_interp global. (tui_interp_procs): New. (tui_interp_factory): New function. (_initialize_tui_interp): Call interp_factory_register.
2016-06-21 02:11:45 +02:00
}
2003-02-06 06:30:17 +01:00
/* Add interpreter INTERP to the gdb interpreter list. The
interpreter must not have previously been added. */
void
Introduce interpreter factories If every UI instance has its own set of interpreters, then the current scheme of creating the interpreters at GDB initialization time no longer works. We need to create them whenever a new UI instance is created. The scheme implemented here has each interpreter register a factory callback that when called creates a new instance of a specific interpreter type. Then, when some code in gdb looks up an interpreter (always by name), if there's none yet, the factory method is called to construct one. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_uiout): Delete, moved into ... (struct cli_interp): ... this new structure. (cli_on_normal_stop, cli_on_signal_received) (cli_on_end_stepping_range, cli_on_signal_exited, cli_on_exited) (cli_on_no_history): Use interp_ui_out. (cli_interpreter_init): If top level, set the cli_interp global. (cli_interpreter_init): Return the interp's data instead of NULL. (cli_interpreter_resume, cli_interpreter_exec, cli_ui_out): Adjust to cli_uiout being in the interpreter's data. (cli_interp_procs): New, factored out from _initialize_cli_interp. (cli_interp_factory): New function. (_initialize_cli_interp): Call interp_factory_register. * interps.c (get_interp_info): New, factored out from ... (get_current_interp_info): ... this. (interp_new): Add parameter 'data'. Store it. (struct interp_factory): New function. (interp_factory_p): New typedef. Define a VEC_P. (interpreter_factories): New global. (interp_factory_register): New function. (interp_add): Add 'ui' parameter. Use get_interp_info and interp_lookup_existing. (interp_lookup): Rename to ... (interp_lookup_existing): ... this. Add 'ui' parameter. Don't check for NULL or empty name here. (interp_lookup): Add 'ui' parameter and reimplement. (interp_set_temp, interpreter_exec_cmd): Adjust. (interpreter_completer): Complete on registered interpreter factories instead of interpreters. * interps.h (interp_factory_func): New typedef. (interp_factory_register): Declare. (interp_new, interp_add): Adjust. (interp_lookup): Declare. * main.c (captured_main): Adjust. * mi/mi-interp.c (mi_cmd_interpreter_exec): Adjust. (mi_interp_procs): New, factored out from _initialize_mi_interp. (mi_interp_factory): New function. * python/python.c (execute_gdb_command): Adjust. * tui/tui-interp.c (tui_init): If top level, set the tui_interp global. (tui_interp_procs): New. (tui_interp_factory): New function. (_initialize_tui_interp): Call interp_factory_register.
2016-06-21 02:11:45 +02:00
interp_add (struct ui *ui, struct interp *interp)
2003-02-06 06:30:17 +01:00
{
Introduce interpreter factories If every UI instance has its own set of interpreters, then the current scheme of creating the interpreters at GDB initialization time no longer works. We need to create them whenever a new UI instance is created. The scheme implemented here has each interpreter register a factory callback that when called creates a new instance of a specific interpreter type. Then, when some code in gdb looks up an interpreter (always by name), if there's none yet, the factory method is called to construct one. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_uiout): Delete, moved into ... (struct cli_interp): ... this new structure. (cli_on_normal_stop, cli_on_signal_received) (cli_on_end_stepping_range, cli_on_signal_exited, cli_on_exited) (cli_on_no_history): Use interp_ui_out. (cli_interpreter_init): If top level, set the cli_interp global. (cli_interpreter_init): Return the interp's data instead of NULL. (cli_interpreter_resume, cli_interpreter_exec, cli_ui_out): Adjust to cli_uiout being in the interpreter's data. (cli_interp_procs): New, factored out from _initialize_cli_interp. (cli_interp_factory): New function. (_initialize_cli_interp): Call interp_factory_register. * interps.c (get_interp_info): New, factored out from ... (get_current_interp_info): ... this. (interp_new): Add parameter 'data'. Store it. (struct interp_factory): New function. (interp_factory_p): New typedef. Define a VEC_P. (interpreter_factories): New global. (interp_factory_register): New function. (interp_add): Add 'ui' parameter. Use get_interp_info and interp_lookup_existing. (interp_lookup): Rename to ... (interp_lookup_existing): ... this. Add 'ui' parameter. Don't check for NULL or empty name here. (interp_lookup): Add 'ui' parameter and reimplement. (interp_set_temp, interpreter_exec_cmd): Adjust. (interpreter_completer): Complete on registered interpreter factories instead of interpreters. * interps.h (interp_factory_func): New typedef. (interp_factory_register): Declare. (interp_new, interp_add): Adjust. (interp_lookup): Declare. * main.c (captured_main): Adjust. * mi/mi-interp.c (mi_cmd_interpreter_exec): Adjust. (mi_interp_procs): New, factored out from _initialize_mi_interp. (mi_interp_factory): New function. * python/python.c (execute_gdb_command): Adjust. * tui/tui-interp.c (tui_init): If top level, set the tui_interp global. (tui_interp_procs): New. (tui_interp_factory): New function. (_initialize_tui_interp): Call interp_factory_register.
2016-06-21 02:11:45 +02:00
struct ui_interp_info *ui_interp = get_interp_info (ui);
Make the interpreters be per UI Make each UI have its own interpreter list, top level interpreter, current interpreter, etc. The "interpreter_async" global is not really specific to an struct interp (it crosses interpreter-exec ...), so I moved it to "struct ui" directly, while the other globals were left hidden in interps.c, opaque to the rest of GDB. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * breakpoint.c (bpstat_do_actions_1): Access the current UI's async field instead of the interpreter_async global. * cli/cli-script.c (execute_user_command, while_command) (if_command, script_from_file): Likewise. * compile/compile.c: Include top.h instead of interps.h. (compile_file_command, compile_code_command) (compile_print_command): Access the current UI's async field instead of the interpreter_async global. * guile/guile.c: Include top.h instead of interps.h. (guile_repl_command, guile_command, gdbscm_execute_gdb_command): Access the current UI's async field instead of the interpreter_async global. * guile/scm-ports.c: Include top.h instead of interps.h. (ioscm_with_output_to_port_worker): Access the current UI's async field instead of the interpreter_async global. * inf-loop.c (inferior_event_handler): Likewise. * infcall.c (run_inferior_call): Likewise. * infrun.c (reinstall_readline_callback_handler_cleanup) (fetch_inferior_event): Likewise. * interps.c (interpreter_async): Delete. (struct ui_interp_info): New. (get_current_interp_info): New function. (interp_list, current_interpreter, top_level_interpreter_ptr): Delete. (interp_add, interp_set, interp_lookup, interp_ui_out) (current_interp_set_logging, interp_set_temp) (current_interp_named_p): Adjust to per-UI interpreters. (command_interpreter): Delete. (command_interp, current_interp_command_loop, interp_quiet_p) (interp_exec, interpreter_exec_cmd, interpreter_completer) (top_level_interpreter, top_level_interpreter_data): Adjust to per-UI interpreters. * interps.h (interpreter_async): Delete. * main.c (captured_command_loop): Access the current UI's async field instead of the interpreter_async global. * python/python.c (python_interactive_command, python_command) (execute_gdb_command): Likewise. * top.c (maybe_wait_sync_command_done, execute_command_to_string): Access the current UI's async field instead of the interpreter_async global. * top.h (struct tl_interp_info): Forward declare. (struct ui) <interp_info, async>: New fields.
2016-06-21 02:11:45 +02:00
gdb_assert (interp_lookup_existing (ui, interp->name ()) == NULL);
2003-02-06 06:30:17 +01:00
Make the interpreters be per UI Make each UI have its own interpreter list, top level interpreter, current interpreter, etc. The "interpreter_async" global is not really specific to an struct interp (it crosses interpreter-exec ...), so I moved it to "struct ui" directly, while the other globals were left hidden in interps.c, opaque to the rest of GDB. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * breakpoint.c (bpstat_do_actions_1): Access the current UI's async field instead of the interpreter_async global. * cli/cli-script.c (execute_user_command, while_command) (if_command, script_from_file): Likewise. * compile/compile.c: Include top.h instead of interps.h. (compile_file_command, compile_code_command) (compile_print_command): Access the current UI's async field instead of the interpreter_async global. * guile/guile.c: Include top.h instead of interps.h. (guile_repl_command, guile_command, gdbscm_execute_gdb_command): Access the current UI's async field instead of the interpreter_async global. * guile/scm-ports.c: Include top.h instead of interps.h. (ioscm_with_output_to_port_worker): Access the current UI's async field instead of the interpreter_async global. * inf-loop.c (inferior_event_handler): Likewise. * infcall.c (run_inferior_call): Likewise. * infrun.c (reinstall_readline_callback_handler_cleanup) (fetch_inferior_event): Likewise. * interps.c (interpreter_async): Delete. (struct ui_interp_info): New. (get_current_interp_info): New function. (interp_list, current_interpreter, top_level_interpreter_ptr): Delete. (interp_add, interp_set, interp_lookup, interp_ui_out) (current_interp_set_logging, interp_set_temp) (current_interp_named_p): Adjust to per-UI interpreters. (command_interpreter): Delete. (command_interp, current_interp_command_loop, interp_quiet_p) (interp_exec, interpreter_exec_cmd, interpreter_completer) (top_level_interpreter, top_level_interpreter_data): Adjust to per-UI interpreters. * interps.h (interpreter_async): Delete. * main.c (captured_command_loop): Access the current UI's async field instead of the interpreter_async global. * python/python.c (python_interactive_command, python_command) (execute_gdb_command): Likewise. * top.c (maybe_wait_sync_command_done, execute_command_to_string): Access the current UI's async field instead of the interpreter_async global. * top.h (struct tl_interp_info): Forward declare. (struct ui) <interp_info, async>: New fields.
2016-06-21 02:11:45 +02:00
interp->next = ui_interp->interp_list;
ui_interp->interp_list = interp;
2003-02-06 06:30:17 +01:00
}
/* This sets the current interpreter to be INTERP. If INTERP has not
C++-fy struct interp/cli_interp/tui_interp/mi_interp - The interp->data field disappears, since we can put data in the interpreter directly now. The "init" method remains in place, but it now returns void. - A few places check if the interpreter method is NULL before calling it, and also check whether the method returns true/false. For some of those methods, all current implementations always return true. In those cases, this commit makes the C++-fied method return void instead and cleans up the callers. Tested on x86_64 Fedora 23. gdb/ChangeLog: 2017-02-03 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_interp_base::cli_interp_base) (cli_interp_base::~cli_interp_base): New. (cli_interp): New struct. (as_cli_interp): Cast the interp itself to cli_interp. (cli_interpreter_pre_command_loop): Rename to ... (cli_interp_base::pre_command_loop): ... this. Remove 'self' parameter. (cli_interpreter_init): Rename to ... (cli_interp::init): ... this. Remove 'self' parameter. Use boolean. Make extern. (cli_interpreter_resume): Rename to ... (cli_interp::resume): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_suspend): Rename to ... (cli_interp::suspend): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_exec): Rename to ... (cli_interp::exec): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_supports_command_editing): Rename to ... (cli_interp_base::supports_command_editing): ... this. Remove 'interp' parameter. Make extern. (cli_ui_out): Rename to ... (cli_interp::interp_ui_out): ... this. Remove 'interp' parameter. Make extern. (cli_set_logging): Rename to ... (cli_interp_base::set_logging): ... this. Remove 'interp' parameter. Make extern. (cli_interp_procs): Delete. (cli_interp_factory): Adjust to use "new". * cli/cli-interp.h: Include "interps.h". (struct cli_interp_base): New struct. * interps.c (struct interp): Delete. Fields moved to interps.h. (interp_new): Delete. (interp::interp, interp::~interp): New. (interp_set): Use bool, and return void. Assume the interpreter has suspend, init and resume methods, and that the all return void. (set_top_level_interpreter): interp_set returns void. (interp_ui_out): Adapt. (current_interp_set_logging): Adapt. (interp_data): Delete. (interp_pre_command_loop, interp_supports_command_editing): Adapt. (interp_exec): Adapt. (top_level_interpreter_data): Delete. * interps.h (interp_init_ftype, interp_resume_ftype) (interp_suspend_ftype, interp_exec_ftype) (interp_pre_command_loop_ftype, interp_ui_out_ftype): Delete. (class interp): New. (interp_new): Delete. (interp_set): Now returns void. Use bool. (interp_data, top_level_interpreter_data): Delete. * mi/mi-common.h: Include interps.h. (class mi_interp): Inherit from interp. Define a ctor. Declare init, resume, suspect, exec, interp_ui_out, set_logging and pre_command_loop methods. * mi/mi-interp.c (as_mi_interp): Cast the interp itself. (mi_interpreter_init): Rename to ... (mi_interp::init): ... this. Remove the 'interp' parameter, use bool, return void and make extern. Adjust. (mi_interpreter_resume): ... Rename to ... (mi_interp::resume): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (mi_interpreter_suspend): ... Rename to ... (mi_interp::suspend): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (mi_interpreter_exec): ... Rename to ... (mi_interp::exec): ... this. Remove the 'data' parameter and make extern. Adjust. (mi_interpreter_pre_command_loop): ... Rename to ... (mi_interp::pre_command_loop): ... this. Remove the 'self' parameter and make extern. (mi_on_normal_stop_1): Adjust. (mi_ui_out): Rename to ... (mi_interp::interp_ui_out): ... this. Remove the 'interp' parameter and make extern. Adjust. (mi_set_logging): Rename to ... (mi_interp::set_logging): ... this. Remove the 'interp' parameter and make extern. Adjust. (mi_interp_procs): Delete. (mi_interp_factory): Adjust to use 'new'. * mi/mi-main.c (mi_cmd_gdb_exit, captured_mi_execute_command) (mi_print_exception, mi_execute_command, mi_load_progress): Adjust. * tui/tui-interp.c (tui_interp): New class. (as_tui_interp): Return a tui_interp pointer. (tui_on_normal_stop, tui_on_signal_received) (tui_on_end_stepping_range, tui_on_signal_exited, tui_on_exited) (tui_on_no_history, tui_on_user_selected_context_changed): Adjust to use interp::interp_ui_out. (tui_init): Rename to ... (tui_interp::init): ... this. Remove the 'self' parameter, use bool, return void and make extern. Adjust. (tui_resume): Rename to ... (tui_interp::resume): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (tui_suspend): Rename to ... (tui_interp::suspend): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (tui_ui_out): Rename to ... (tui_interp::interp_ui_out): ... this. Remove the 'self' parameter, and make extern. Adjust. (tui_exec): Rename to ... (tui_interp::exec): ... this. Remove the 'data' parameter and make extern. (tui_interp_procs): Delete. (tui_interp_factory): Use "new".
2017-02-03 17:30:04 +01:00
been initialized, then this will also run the init method.
The TOP_LEVEL parameter tells if this new interpreter is
the top-level one. The top-level is what is requested
on the command line, and is responsible for reporting general
notification about target state changes. For example, if
MI is the top-level interpreter, then it will always report
events such as target stops and new thread creation, even if they
are caused by CLI commands. */
C++-fy struct interp/cli_interp/tui_interp/mi_interp - The interp->data field disappears, since we can put data in the interpreter directly now. The "init" method remains in place, but it now returns void. - A few places check if the interpreter method is NULL before calling it, and also check whether the method returns true/false. For some of those methods, all current implementations always return true. In those cases, this commit makes the C++-fied method return void instead and cleans up the callers. Tested on x86_64 Fedora 23. gdb/ChangeLog: 2017-02-03 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_interp_base::cli_interp_base) (cli_interp_base::~cli_interp_base): New. (cli_interp): New struct. (as_cli_interp): Cast the interp itself to cli_interp. (cli_interpreter_pre_command_loop): Rename to ... (cli_interp_base::pre_command_loop): ... this. Remove 'self' parameter. (cli_interpreter_init): Rename to ... (cli_interp::init): ... this. Remove 'self' parameter. Use boolean. Make extern. (cli_interpreter_resume): Rename to ... (cli_interp::resume): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_suspend): Rename to ... (cli_interp::suspend): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_exec): Rename to ... (cli_interp::exec): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_supports_command_editing): Rename to ... (cli_interp_base::supports_command_editing): ... this. Remove 'interp' parameter. Make extern. (cli_ui_out): Rename to ... (cli_interp::interp_ui_out): ... this. Remove 'interp' parameter. Make extern. (cli_set_logging): Rename to ... (cli_interp_base::set_logging): ... this. Remove 'interp' parameter. Make extern. (cli_interp_procs): Delete. (cli_interp_factory): Adjust to use "new". * cli/cli-interp.h: Include "interps.h". (struct cli_interp_base): New struct. * interps.c (struct interp): Delete. Fields moved to interps.h. (interp_new): Delete. (interp::interp, interp::~interp): New. (interp_set): Use bool, and return void. Assume the interpreter has suspend, init and resume methods, and that the all return void. (set_top_level_interpreter): interp_set returns void. (interp_ui_out): Adapt. (current_interp_set_logging): Adapt. (interp_data): Delete. (interp_pre_command_loop, interp_supports_command_editing): Adapt. (interp_exec): Adapt. (top_level_interpreter_data): Delete. * interps.h (interp_init_ftype, interp_resume_ftype) (interp_suspend_ftype, interp_exec_ftype) (interp_pre_command_loop_ftype, interp_ui_out_ftype): Delete. (class interp): New. (interp_new): Delete. (interp_set): Now returns void. Use bool. (interp_data, top_level_interpreter_data): Delete. * mi/mi-common.h: Include interps.h. (class mi_interp): Inherit from interp. Define a ctor. Declare init, resume, suspect, exec, interp_ui_out, set_logging and pre_command_loop methods. * mi/mi-interp.c (as_mi_interp): Cast the interp itself. (mi_interpreter_init): Rename to ... (mi_interp::init): ... this. Remove the 'interp' parameter, use bool, return void and make extern. Adjust. (mi_interpreter_resume): ... Rename to ... (mi_interp::resume): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (mi_interpreter_suspend): ... Rename to ... (mi_interp::suspend): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (mi_interpreter_exec): ... Rename to ... (mi_interp::exec): ... this. Remove the 'data' parameter and make extern. Adjust. (mi_interpreter_pre_command_loop): ... Rename to ... (mi_interp::pre_command_loop): ... this. Remove the 'self' parameter and make extern. (mi_on_normal_stop_1): Adjust. (mi_ui_out): Rename to ... (mi_interp::interp_ui_out): ... this. Remove the 'interp' parameter and make extern. Adjust. (mi_set_logging): Rename to ... (mi_interp::set_logging): ... this. Remove the 'interp' parameter and make extern. Adjust. (mi_interp_procs): Delete. (mi_interp_factory): Adjust to use 'new'. * mi/mi-main.c (mi_cmd_gdb_exit, captured_mi_execute_command) (mi_print_exception, mi_execute_command, mi_load_progress): Adjust. * tui/tui-interp.c (tui_interp): New class. (as_tui_interp): Return a tui_interp pointer. (tui_on_normal_stop, tui_on_signal_received) (tui_on_end_stepping_range, tui_on_signal_exited, tui_on_exited) (tui_on_no_history, tui_on_user_selected_context_changed): Adjust to use interp::interp_ui_out. (tui_init): Rename to ... (tui_interp::init): ... this. Remove the 'self' parameter, use bool, return void and make extern. Adjust. (tui_resume): Rename to ... (tui_interp::resume): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (tui_suspend): Rename to ... (tui_interp::suspend): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (tui_ui_out): Rename to ... (tui_interp::interp_ui_out): ... this. Remove the 'self' parameter, and make extern. Adjust. (tui_exec): Rename to ... (tui_interp::exec): ... this. Remove the 'data' parameter and make extern. (tui_interp_procs): Delete. (tui_interp_factory): Use "new".
2017-02-03 17:30:04 +01:00
Eliminate interp::quiet_p This commit removes interp::quiet_p / interp_quiet_p / interp_set_quiet, because AFAICS, it doesn't really do anything. interp_quiet is only ever checked inside interp_set nowadays: if (!first_time && !interp_quiet_p (interp)) { xsnprintf (buffer, sizeof (buffer), "Switching to interpreter \"%.24s\".\n", interp->name); current_uiout->text (buffer); } I did a bit of archaelogy, and found that back in 4a8f6654 (2003), it was also called in another place, to decide whether to print the CLI prompt. AFAICS, that condition is always false today, making that if/then block always dead code. If we remove that code, then there are no interp_quiet_p uses left in the tree, so we can remove it all. There are two paths that lead to interp_set calls: #1 - When installing the top level interpreter. In this case, FIRST_TIME is true. #2 - In interpreter_exec_cmd. In this case, the interpreter is always set quiet before interp_set is called. Grepping a gdb.log of an x86_64 GNU/Linux run for "Switching to interpreter" (before this patch) doesn't find any hits. I suspect the intention of this message was to support something like a "set interpreter ..." command that would change the interpreter permanently. But there's no such command. Tested on x86_64 Fedora 23. gdb/ChangeLog: 2017-02-08 Pedro Alves <palves@redhat.com> * interps.c (interp::interp): Remove reference to quiet_p. (interp_set): Make static. Remove dead "Switching to" output code. (interp_quiet_p, interp_set_quiet): Delete. (interpreter_exec_cmd): Don't set the interpreter quiet. * interps.h (interp_quiet_p): Make static. (class interp) <quiet_p>: Remove field
2017-02-08 19:08:18 +01:00
static void
C++-fy struct interp/cli_interp/tui_interp/mi_interp - The interp->data field disappears, since we can put data in the interpreter directly now. The "init" method remains in place, but it now returns void. - A few places check if the interpreter method is NULL before calling it, and also check whether the method returns true/false. For some of those methods, all current implementations always return true. In those cases, this commit makes the C++-fied method return void instead and cleans up the callers. Tested on x86_64 Fedora 23. gdb/ChangeLog: 2017-02-03 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_interp_base::cli_interp_base) (cli_interp_base::~cli_interp_base): New. (cli_interp): New struct. (as_cli_interp): Cast the interp itself to cli_interp. (cli_interpreter_pre_command_loop): Rename to ... (cli_interp_base::pre_command_loop): ... this. Remove 'self' parameter. (cli_interpreter_init): Rename to ... (cli_interp::init): ... this. Remove 'self' parameter. Use boolean. Make extern. (cli_interpreter_resume): Rename to ... (cli_interp::resume): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_suspend): Rename to ... (cli_interp::suspend): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_exec): Rename to ... (cli_interp::exec): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_supports_command_editing): Rename to ... (cli_interp_base::supports_command_editing): ... this. Remove 'interp' parameter. Make extern. (cli_ui_out): Rename to ... (cli_interp::interp_ui_out): ... this. Remove 'interp' parameter. Make extern. (cli_set_logging): Rename to ... (cli_interp_base::set_logging): ... this. Remove 'interp' parameter. Make extern. (cli_interp_procs): Delete. (cli_interp_factory): Adjust to use "new". * cli/cli-interp.h: Include "interps.h". (struct cli_interp_base): New struct. * interps.c (struct interp): Delete. Fields moved to interps.h. (interp_new): Delete. (interp::interp, interp::~interp): New. (interp_set): Use bool, and return void. Assume the interpreter has suspend, init and resume methods, and that the all return void. (set_top_level_interpreter): interp_set returns void. (interp_ui_out): Adapt. (current_interp_set_logging): Adapt. (interp_data): Delete. (interp_pre_command_loop, interp_supports_command_editing): Adapt. (interp_exec): Adapt. (top_level_interpreter_data): Delete. * interps.h (interp_init_ftype, interp_resume_ftype) (interp_suspend_ftype, interp_exec_ftype) (interp_pre_command_loop_ftype, interp_ui_out_ftype): Delete. (class interp): New. (interp_new): Delete. (interp_set): Now returns void. Use bool. (interp_data, top_level_interpreter_data): Delete. * mi/mi-common.h: Include interps.h. (class mi_interp): Inherit from interp. Define a ctor. Declare init, resume, suspect, exec, interp_ui_out, set_logging and pre_command_loop methods. * mi/mi-interp.c (as_mi_interp): Cast the interp itself. (mi_interpreter_init): Rename to ... (mi_interp::init): ... this. Remove the 'interp' parameter, use bool, return void and make extern. Adjust. (mi_interpreter_resume): ... Rename to ... (mi_interp::resume): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (mi_interpreter_suspend): ... Rename to ... (mi_interp::suspend): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (mi_interpreter_exec): ... Rename to ... (mi_interp::exec): ... this. Remove the 'data' parameter and make extern. Adjust. (mi_interpreter_pre_command_loop): ... Rename to ... (mi_interp::pre_command_loop): ... this. Remove the 'self' parameter and make extern. (mi_on_normal_stop_1): Adjust. (mi_ui_out): Rename to ... (mi_interp::interp_ui_out): ... this. Remove the 'interp' parameter and make extern. Adjust. (mi_set_logging): Rename to ... (mi_interp::set_logging): ... this. Remove the 'interp' parameter and make extern. Adjust. (mi_interp_procs): Delete. (mi_interp_factory): Adjust to use 'new'. * mi/mi-main.c (mi_cmd_gdb_exit, captured_mi_execute_command) (mi_print_exception, mi_execute_command, mi_load_progress): Adjust. * tui/tui-interp.c (tui_interp): New class. (as_tui_interp): Return a tui_interp pointer. (tui_on_normal_stop, tui_on_signal_received) (tui_on_end_stepping_range, tui_on_signal_exited, tui_on_exited) (tui_on_no_history, tui_on_user_selected_context_changed): Adjust to use interp::interp_ui_out. (tui_init): Rename to ... (tui_interp::init): ... this. Remove the 'self' parameter, use bool, return void and make extern. Adjust. (tui_resume): Rename to ... (tui_interp::resume): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (tui_suspend): Rename to ... (tui_interp::suspend): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (tui_ui_out): Rename to ... (tui_interp::interp_ui_out): ... this. Remove the 'self' parameter, and make extern. Adjust. (tui_exec): Rename to ... (tui_interp::exec): ... this. Remove the 'data' parameter and make extern. (tui_interp_procs): Delete. (tui_interp_factory): Use "new".
2017-02-03 17:30:04 +01:00
interp_set (struct interp *interp, bool top_level)
2003-02-06 06:30:17 +01:00
{
Make the interpreters be per UI Make each UI have its own interpreter list, top level interpreter, current interpreter, etc. The "interpreter_async" global is not really specific to an struct interp (it crosses interpreter-exec ...), so I moved it to "struct ui" directly, while the other globals were left hidden in interps.c, opaque to the rest of GDB. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * breakpoint.c (bpstat_do_actions_1): Access the current UI's async field instead of the interpreter_async global. * cli/cli-script.c (execute_user_command, while_command) (if_command, script_from_file): Likewise. * compile/compile.c: Include top.h instead of interps.h. (compile_file_command, compile_code_command) (compile_print_command): Access the current UI's async field instead of the interpreter_async global. * guile/guile.c: Include top.h instead of interps.h. (guile_repl_command, guile_command, gdbscm_execute_gdb_command): Access the current UI's async field instead of the interpreter_async global. * guile/scm-ports.c: Include top.h instead of interps.h. (ioscm_with_output_to_port_worker): Access the current UI's async field instead of the interpreter_async global. * inf-loop.c (inferior_event_handler): Likewise. * infcall.c (run_inferior_call): Likewise. * infrun.c (reinstall_readline_callback_handler_cleanup) (fetch_inferior_event): Likewise. * interps.c (interpreter_async): Delete. (struct ui_interp_info): New. (get_current_interp_info): New function. (interp_list, current_interpreter, top_level_interpreter_ptr): Delete. (interp_add, interp_set, interp_lookup, interp_ui_out) (current_interp_set_logging, interp_set_temp) (current_interp_named_p): Adjust to per-UI interpreters. (command_interpreter): Delete. (command_interp, current_interp_command_loop, interp_quiet_p) (interp_exec, interpreter_exec_cmd, interpreter_completer) (top_level_interpreter, top_level_interpreter_data): Adjust to per-UI interpreters. * interps.h (interpreter_async): Delete. * main.c (captured_command_loop): Access the current UI's async field instead of the interpreter_async global. * python/python.c (python_interactive_command, python_command) (execute_gdb_command): Likewise. * top.c (maybe_wait_sync_command_done, execute_command_to_string): Access the current UI's async field instead of the interpreter_async global. * top.h (struct tl_interp_info): Forward declare. (struct ui) <interp_info, async>: New fields.
2016-06-21 02:11:45 +02:00
struct ui_interp_info *ui_interp = get_current_interp_info ();
struct interp *old_interp = ui_interp->current_interpreter;
2003-02-06 06:30:17 +01:00
/* If we already have an interpreter, then trying to
set top level interpreter is kinda pointless. */
Make the interpreters be per UI Make each UI have its own interpreter list, top level interpreter, current interpreter, etc. The "interpreter_async" global is not really specific to an struct interp (it crosses interpreter-exec ...), so I moved it to "struct ui" directly, while the other globals were left hidden in interps.c, opaque to the rest of GDB. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * breakpoint.c (bpstat_do_actions_1): Access the current UI's async field instead of the interpreter_async global. * cli/cli-script.c (execute_user_command, while_command) (if_command, script_from_file): Likewise. * compile/compile.c: Include top.h instead of interps.h. (compile_file_command, compile_code_command) (compile_print_command): Access the current UI's async field instead of the interpreter_async global. * guile/guile.c: Include top.h instead of interps.h. (guile_repl_command, guile_command, gdbscm_execute_gdb_command): Access the current UI's async field instead of the interpreter_async global. * guile/scm-ports.c: Include top.h instead of interps.h. (ioscm_with_output_to_port_worker): Access the current UI's async field instead of the interpreter_async global. * inf-loop.c (inferior_event_handler): Likewise. * infcall.c (run_inferior_call): Likewise. * infrun.c (reinstall_readline_callback_handler_cleanup) (fetch_inferior_event): Likewise. * interps.c (interpreter_async): Delete. (struct ui_interp_info): New. (get_current_interp_info): New function. (interp_list, current_interpreter, top_level_interpreter_ptr): Delete. (interp_add, interp_set, interp_lookup, interp_ui_out) (current_interp_set_logging, interp_set_temp) (current_interp_named_p): Adjust to per-UI interpreters. (command_interpreter): Delete. (command_interp, current_interp_command_loop, interp_quiet_p) (interp_exec, interpreter_exec_cmd, interpreter_completer) (top_level_interpreter, top_level_interpreter_data): Adjust to per-UI interpreters. * interps.h (interpreter_async): Delete. * main.c (captured_command_loop): Access the current UI's async field instead of the interpreter_async global. * python/python.c (python_interactive_command, python_command) (execute_gdb_command): Likewise. * top.c (maybe_wait_sync_command_done, execute_command_to_string): Access the current UI's async field instead of the interpreter_async global. * top.h (struct tl_interp_info): Forward declare. (struct ui) <interp_info, async>: New fields.
2016-06-21 02:11:45 +02:00
gdb_assert (!top_level || !ui_interp->current_interpreter);
gdb_assert (!top_level || !ui_interp->top_level_interpreter);
Make the interpreters be per UI Make each UI have its own interpreter list, top level interpreter, current interpreter, etc. The "interpreter_async" global is not really specific to an struct interp (it crosses interpreter-exec ...), so I moved it to "struct ui" directly, while the other globals were left hidden in interps.c, opaque to the rest of GDB. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * breakpoint.c (bpstat_do_actions_1): Access the current UI's async field instead of the interpreter_async global. * cli/cli-script.c (execute_user_command, while_command) (if_command, script_from_file): Likewise. * compile/compile.c: Include top.h instead of interps.h. (compile_file_command, compile_code_command) (compile_print_command): Access the current UI's async field instead of the interpreter_async global. * guile/guile.c: Include top.h instead of interps.h. (guile_repl_command, guile_command, gdbscm_execute_gdb_command): Access the current UI's async field instead of the interpreter_async global. * guile/scm-ports.c: Include top.h instead of interps.h. (ioscm_with_output_to_port_worker): Access the current UI's async field instead of the interpreter_async global. * inf-loop.c (inferior_event_handler): Likewise. * infcall.c (run_inferior_call): Likewise. * infrun.c (reinstall_readline_callback_handler_cleanup) (fetch_inferior_event): Likewise. * interps.c (interpreter_async): Delete. (struct ui_interp_info): New. (get_current_interp_info): New function. (interp_list, current_interpreter, top_level_interpreter_ptr): Delete. (interp_add, interp_set, interp_lookup, interp_ui_out) (current_interp_set_logging, interp_set_temp) (current_interp_named_p): Adjust to per-UI interpreters. (command_interpreter): Delete. (command_interp, current_interp_command_loop, interp_quiet_p) (interp_exec, interpreter_exec_cmd, interpreter_completer) (top_level_interpreter, top_level_interpreter_data): Adjust to per-UI interpreters. * interps.h (interpreter_async): Delete. * main.c (captured_command_loop): Access the current UI's async field instead of the interpreter_async global. * python/python.c (python_interactive_command, python_command) (execute_gdb_command): Likewise. * top.c (maybe_wait_sync_command_done, execute_command_to_string): Access the current UI's async field instead of the interpreter_async global. * top.h (struct tl_interp_info): Forward declare. (struct ui) <interp_info, async>: New fields.
2016-06-21 02:11:45 +02:00
if (old_interp != NULL)
2003-02-06 06:30:17 +01:00
{
Class-ify ui_out This patch finalizes the C++ conversion of the ui-out subsystem, by turning the ui_out and ui_out_impl structures into a single class hierarchy. ui_out functions are turned into virtual methods of that new class, so as a result there are a lot of call sites to update. In the previous version of the patchset, there were separate ui_out and ui_out_impl classes, but it wasn't really useful and added boilerplate. In this version there is simply an ui_out base class that is extended for CLI, TUI and MI. It's a bit hard to maintain a ChangeLog for such a big patch, I did my best but I'm sure there are some missing or outdated info in there... gdb/ChangeLog: * ui-out.h (ui_out_begin, ui_out_end, ui_out_table_header, ui_out_table_body, ui_out_field_int, ui_out_field_fmt_int, ui_out_field_core_addr, ui_out_field_string, ui_out_field_stream, ui_out_field_fmt, ui_out_field_skip, ui_out_spaces, ui_out_text, ui_out_message, ui_out_wrap_hint, ui_out_flush, ui_out_test_flags, ui_out_query_field, ui_out_is_mi_like_p, ui_out_redirect): Remove, replace with a method in class ui_out. (table_begin_ftype): Remove, replace with pure virtual method in class ui_out. (table_body_ftype): Likewise. (table_end_ftype): Likewise. (table_header_ftype): Likewise. (ui_out_begin_ftype): Likewise. (ui_out_end_ftype): Likewise. (field_int_ftype): Likewise. (field_skip_ftype): Likewise. (field_string_ftype): Likewise. (field_fmt_ftype): Likewise. (spaces_ftype): Likewise. (text_ftype): Likewise. (message_ftype): Likewise. (wrap_hint_ftype): Likewise. (flush_ftype): Likewise. (redirect_ftype): Likewise. (data_destroy_ftype): Likewise. (struct ui_out_impl): Remove, replace with class ui_out. (ui_out_new): Remove. (class ui_out): New class. * ui-out.c (struct ui_out): Remove, replaced with class ui_out. (current_level): Remove, replace with ui_out method. (push_level): Likewise. (pop_level): Likewise. (uo_table_begin, uo_table_body, uo_table_end, uo_table_header, uo_begin, uo_end, uo_field_int, uo_field_skip, uo_field_fmt, uo_spaces, uo_text, uo_message, uo_wrap_hint, uo_flush, uo_redirect, uo_field_string): Remove. (ui_out_table_begin): Replace with ... (ui_out::table_begin): ... this. (ui_out_table_body): Replace with ... (ui_out::table_body): ... this. (ui_out_table_end): Replace with ... (ui_out::table_end): ... this. (ui_out_table_header): Replace with ... (ui_out::table_header): ... this. (ui_out_begin): Replace with ... (ui_out::begin): ... this. (ui_out_end): Replace with ... (ui_out::end): ... this. (ui_out_field_int): Replace with ... (ui_out::field_int): ... this. (ui_out_field_fmt_int): Replace with ... (ui_out::field_fmt_int): ... this. (ui_out_field_core_addr): Replace with ... (ui_out::field_core_addr): ... this. (ui_out_field_stream): Replace with ... (ui_out::field_stream): ... this. (ui_out_field_skip): Replace with ... (ui_out::field_skip): ... this. (ui_out_field_string): Replace with ... (ui_out::field_string): ... this. (ui_out_field_fmt): Replace with ... (ui_out::field_fmt): ... this. (ui_out_spaces): Replace with ... (ui_out::spaces): ... this. (ui_out_text): Replace with ... (ui_out::text): ... this. (ui_out_message): Replace with ... (ui_out::message): ... this. (ui_out_wrap_hint): Replace with ... (ui_out::wrap_hint): ... this. (ui_out_flush): Replace with ... (ui_out::flush): ... this. (ui_out_redirect): Replace with ... (ui_out::redirect): ... this. (ui_out_test_flags): Replace with ... (ui_out::test_flags): ... this. (ui_out_is_mi_like_p): Replace with ... (ui_out::is_mi_like_p): ... this. (verify_field): Replace with ... (ui_out::verify_field): ... this. (ui_out_query_field): Replace with ... (ui_out::query_table_field): ... this. (ui_out_data): Remove. (ui_out_new): Remove, replace with ... (ui_out::ui_out): ... this constructor. (do_cleanup_table_end, make_cleanup_ui_out_tuple_begin_end, do_cleanup_end, make_cleanup_ui_out_tuple_begin_end, make_cleanup_ui_out_list_begin_end): Update fallouts of struct ui_out -> class ui_out change. * cli-out.c (cli_out_data): Remove. (cli_uiout_dtor): Remove. (cli_table_begin): Replace with ... (cli_ui_out::do_table_begin): ... this new method. (cli_table_body): Replace with ... (cli_ui_out::do_table_body): ... this new method. (cli_table_end): Replace with ... (cli_ui_out::do_table_end): ... this new method. (cli_table_header): Replace with ... (cli_ui_out::do_table_header): ... this new method. (cli_begin): Replace with ... (cli_ui_out::do_begin): ... this new method. (cli_end): Replace with ... (cli_ui_out::do_end): ... this new method. (cli_field_int): Replace with ... (cli_ui_out::do_field_int): ... this new method. (cli_field_skip): Replace with ... (cli_ui_out::do_field_skip): ... this new method. (cli_field_string): Replace with ... (cli_ui_out::do_field_string): ... this new method. (cli_field_fmt): Replace with ... (cli_ui_out::do_field_fmt): ... this new method. (cli_spaces): Replace with ... (cli_ui_out::do_spaces): ... this new method. (cli_text): Replace with ... (cli_ui_out::do_text): ... this new method. (cli_message): Replace with ... (cli_ui_out::do_message): ... this new method. (cli_wrap_hint): Replace with ... (cli_ui_out::do_wrap_hint): ... this new method. (cli_flush): Replace with ... (cli_ui_out::do_flush): ... this new method. (cli_redirect): Replace with ... (cli_ui_out::do_redirect): ... this new method. (out_field_fmt): Replace with ... (cli_ui_out::out_field_fmt): ... this new method. (field_separator): Replace with ... (cli_ui_out::field_separator): ... this new method. (cli_out_set_stream): Replace with ... (cli_ui_out::set_stream): ... this new method. (cli_ui_out_impl): Remove. (cli_out_data_ctor): Remove. (cli_ui_out_impl::cli_ui_out_impl): New constructor. (cli_ui_out_impl::~cli_ui_out_impl): New destructor. (cli_out_new): Change return type to cli_ui_out *, instantiate a cli_ui_out. * cli-out.h (cli_ui_out_data): Remove, replace with class cli_ui_out. (class cli_ui_out): New class. (cli_ui_out_impl): Remove. (cli_out_data_ctor): Remove. (cli_out_new): Change return type to cli_ui_out*. (cli_out_set_stream): Remove. * cli/cli-interp.c (struct cli_interp) <cli_uiout>: Change type to cli_ui_out*. (cli_interpreter_resume): Adapt. (cli_interpreter_exec): Adapt. * mi/mi-out.c (mi_ui_out_data, mi_out_data): Remove. (mi_ui_out_impl): Remove. (mi_table_begin): Replace with ... (mi_ui_out::do_table_begin): ... this. (mi_table_body): Replace with ... (mi_ui_out::do_table_body): ... this. (mi_table_end): Replace with ... (mi_ui_out::do_table_end): ... this. (mi_table_header): Replace with ... (mi_ui_out::do_table_header): ... this. (mi_begin): Replace with ... (mi_ui_out::do_begin): ... this. (mi_end): Replace with ... (mi_ui_out::do_end): ... this. (mi_field_int): Replace with ... (mi_ui_out::do_field_int): ... this. (mi_field_skip): Replace with ... (mi_ui_out::do_field_skip): ... this. (mi_field_string): Replace with ... (mi_ui_out::do_field_string): ... this. (mi_field_fmt): Replace with ... (mi_ui_out::do_field_fmt): ... this. (mi_spaces): Replace with ... (mi_ui_out::do_spaces): ... this. (mi_text): Replace with ... (mi_ui_out::do_text): ... this. (mi_message): Replace with ... (mi_ui_out::do_message): ... this. (mi_wrap_hint): Replace with ... (mi_ui_out::do_wrap_hint): ... this. (mi_flush): Replace with ... (mi_ui_out::do_flush): ... this. (mi_redirect): Replace with ... (mi_ui_out::do_redirect): (field_separator): Replace with ... (mi_ui_out::field_separator): (mi_open): Replace with ... (mi_ui_out::open): ... this. (mi_close): Replace with ... (mi_ui_out::close): ... this. (mi_out_rewind): Replace with ... (mi_ui_out::rewind): ... this. (mi_out_put): Replace with ... (mi_ui_out::put): ... this. (mi_version): Replace with ... (mi_ui_out::version): ... this. (mi_out_data_ctor): Replace with ... (mi_ui_out::mi_ui_out): ... this. (mi_out_data_dtor): Replace with ... (mi_ui_out::~mi_ui_out): ... this. (mi_out_new): Change return type to mi_ui_out*, instantiate an mi_ui_out object. (as_mi_ui_out): New function. (mi_version): Update fallouts of struct ui_out to class ui_out transition. (mi_out_put): Likewise. (mi_out_rewind): Likewise. * mi/mi-out.h (mi_out_new): Change return type to mi_ui_out*. * tui/tui-out.c (tui_ui_out_data, tui_out_data, tui_ui_out_impl): Remove. (tui_field_int): Replace with ... (tui_ui_out::do_field_int): ... this. (tui_field_string): Replace with ... (tui_ui_out::do_field_string): ... this. (tui_field_fmt): Replace with ... (tui_ui_out::do_field_fmt): ... this. (tui_text): Replace with ... (tui_ui_out::do_text): ... this. (tui_out_new): Change return type to tui_ui_out*, instantiate tui_ui_out object. (tui_ui_out::tui_ui_out): New. * tui/tui-out.h: New file. * tui/tui.h (tui_out_new): Move declaration to tui/tui-out.h. * tui/tui-io.c: Include tui/tui-out.h. (tui_old_uiout): Change type to cli_ui_out*. (tui_setup_io): Use dynamic_cast. * tui/tui-io.h (tui_old_uiout): Change type to cli_ui_out*. * tui/tui-interp.c (tui_resume): Adapt. * ada-lang.c (print_it_exception): Update fallouts of struct ui_out to class ui_out transition. (print_one_exception): Likewise. (print_mention_exception): Likewise. * ada-tasks.c (print_ada_task_info): Likewise. (info_task): Likewise. (task_command): Likewise. * auto-load.c (print_script): Likewise. (auto_load_info_scripts): Likewise. (info_auto_load_cmd): Likewise. * break-catch-sig.c (signal_catchpoint_print_one): Likewise. * break-catch-syscall.c (print_it_catch_syscall): Likewise. (print_one_catch_syscall): Likewise. * break-catch-throw.c (print_it_exception_catchpoint): Likewise. (print_one_exception_catchpoint): Likewise. (print_one_detail_exception_catchpoint): Likewise. (print_mention_exception_catchpoint): Likewise. * breakpoint.c (maybe_print_thread_hit_breakpoint): Likewise. (print_solib_event): Likewise. (watchpoint_check): Likewise. (wrap_indent_at_field): Likewise. (print_breakpoint_location): Likewise. (output_thread_groups): Likewise. (print_one_breakpoint_location): Likewise. (breakpoint_1): Likewise. (default_collect_info): Likewise. (watchpoints_info): Likewise. (print_it_catch_fork): Likewise. (print_one_catch_fork): Likewise. (print_it_catch_vfork): Likewise. (print_one_catch_vfork): Likewise. (print_it_catch_solib): Likewise. (print_one_catch_solib): Likewise. (print_it_catch_exec): Likewise. (print_one_catch_exec): Likewise. (mention): Likewise. (print_it_ranged_breakpoint): Likewise. (print_one_ranged_breakpoint): Likewise. (print_one_detail_ranged_breakpoint): Likewise. (print_mention_ranged_breakpoint): Likewise. (print_it_watchpoint): Likewise. (print_mention_watchpoint): Likewise. (print_it_masked_watchpoint): Likewise. (print_one_detail_masked_watchpoint): Likewise. (print_mention_masked_watchpoint): Likewise. (bkpt_print_it): Likewise. (tracepoint_print_one_detail): Likewise. (tracepoint_print_mention): Likewise. (update_static_tracepoint): Likewise. (tracepoints_info): Likewise. (save_breakpoints): Likewise. * cli/cli-cmds.c (complete_command): Likewise. * cli/cli-logging.c (set_logging_redirect): Likewise. (pop_output_files): Likewise. (handle_redirections): Likewise. * cli/cli-script.c (print_command_lines): Likewise. * cli/cli-setshow.c (do_show_command): Likewise. (cmd_show_list): Likewise. * cp-abi.c (list_cp_abis): Likewise. (show_cp_abi_cmd): Likewise. * darwin-nat-info.c (darwin_debug_regions_recurse): Likewise. * disasm.c (gdb_pretty_print_insn): Likewise. (do_mixed_source_and_assembly_deprecated): Likewise. (do_mixed_source_and_assembly): Likewise. * gdb_bfd.c (print_one_bfd): Likewise. (maintenance_info_bfds): Likewise. * guile/scm-breakpoint.c (gdbscm_breakpoint_commands): Likewise. * guile/scm-ports.c (ioscm_with_output_to_port_worker): Likewise. * i386-linux-tdep.c (i386_linux_handle_segmentation_fault): Likewise. * i386-tdep.c (i386_mpx_print_bounds): Likewise. * infcmd.c (run_command_1): Likewise. (print_return_value_1): Likewise. * inferior.c (print_selected_inferior): Likewise. (print_inferior): Likewise. * infrun.c (print_end_stepping_range_reason): Likewise. (print_signal_exited_reason): Likewise. (print_exited_reason): Likewise. (print_signal_received_reason): Likewise. (print_no_history_reason): Likewise. * interps.c (interp_set): Likewise. * linespec.c (decode_line_full): Likewise. * linux-thread-db.c (info_auto_load_libthread_db): Likewise. * mi/mi-cmd-env.c (mi_cmd_env_pwd): Likewise. (mi_cmd_env_path): Likewise. (mi_cmd_env_dir): Likewise. (mi_cmd_inferior_tty_show): Likewise. * mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_file): Likewise. (print_partial_file_name): Likewise. (mi_cmd_file_list_exec_source_files): Likewise. * mi/mi-cmd-info.c (mi_cmd_info_ada_exceptions): Likewise. (mi_cmd_info_gdb_mi_command): Likewise. * mi/mi-cmd-stack.c (mi_cmd_stack_info_depth): Likewise. (mi_cmd_stack_list_args): Likewise. (list_arg_or_local): Likewise. * mi/mi-cmd-var.c (print_varobj): Likewise. (mi_cmd_var_create): Likewise. (mi_cmd_var_delete): Likewise. (mi_cmd_var_set_format): Likewise. (mi_cmd_var_show_format): Likewise. (mi_cmd_var_info_num_children): Likewise. (mi_cmd_var_list_children): Likewise. (mi_cmd_var_info_type): Likewise. (mi_cmd_var_info_path_expression): Likewise. (mi_cmd_var_info_expression): Likewise. (mi_cmd_var_show_attributes): Likewise. (mi_cmd_var_evaluate_expression): Likewise. (mi_cmd_var_assign): Likewise. (varobj_update_one): Likewise. * mi/mi-interp.c (as_mi_interp): Likewise. (mi_on_normal_stop_1): Likewise. (mi_tsv_modified): Likewise. (mi_breakpoint_created): Likewise. (mi_breakpoint_modified): Likewise. (mi_solib_loaded): Likewise. (mi_solib_unloaded): Likewise. (mi_command_param_changed): Likewise. (mi_memory_changed): Likewise. (mi_user_selected_context_changed): Likewise. * mi/mi-main.c (print_one_inferior): Likewise. (output_cores): Likewise. (list_available_thread_groups): Likewise. (mi_cmd_data_list_register_names): Likewise. (mi_cmd_data_list_changed_registers): Likewise. (output_register): Likewise. (mi_cmd_data_evaluate_expression): Likewise. (mi_cmd_data_read_memory): Likewise. (mi_cmd_data_read_memory_bytes): Likewise. (mi_cmd_list_features): Likewise. (mi_cmd_list_target_features): Likewise. (mi_cmd_add_inferior): Likewise. (mi_execute_command): Likewise. (mi_load_progress): Likewise. (print_variable_or_computed): Likewise. (mi_cmd_trace_frame_collected): Likewise. * mi/mi-symbol-cmds.c (mi_cmd_symbol_list_lines): Likewise. * osdata.c (info_osdata_command): Likewise. * probe.c (gen_ui_out_table_header_info): Likewise. (print_ui_out_not_applicables): Likewise. (print_ui_out_info): Likewise. (info_probes_for_ops): Likewise. (enable_probes_command): Likewise. (disable_probes_command): Likewise. * progspace.c (print_program_space): Likewise. * python/py-breakpoint.c (bppy_get_commands): Likewise. * python/py-framefilter.c (py_print_type): Likewise. (py_print_value): Likewise. (py_print_single_arg): Likewise. (enumerate_args): Likewise. (enumerate_locals): Likewise. (py_print_args): Likewise. (py_print_frame): Likewise. * record-btrace.c (btrace_ui_out_decode_error): Likewise. (btrace_call_history_insn_range): Likewise. (btrace_call_history_src_line): Likewise. (btrace_call_history): Likewise. * remote.c (show_remote_cmd): Likewise. * skip.c (skip_info): Likewise. * solib.c (info_sharedlibrary_command): Likewise. * source.c (print_source_lines_base): Likewise. * spu-tdep.c (info_spu_event_command): Likewise. (info_spu_signal_command): Likewise. (info_spu_mailbox_list): Likewise. (info_spu_dma_cmdlist): Likewise. (info_spu_dma_command): Likewise. (info_spu_proxydma_command): Likewise. * stack.c (print_stack_frame): Likewise. (print_frame_arg): Likewise. (read_frame_arg): Likewise. (print_frame_args): Likewise. (print_frame_info): Likewise. (print_frame): Likewise. * symfile.c (load_progress): Likewise. (generic_load): Likewise. (print_transfer_performance): Likewise. * thread.c (do_captured_list_thread_ids): Likewise. (print_thread_info_1): Likewise. (restore_selected_frame): Likewise. (do_captured_thread_select): Likewise. (print_selected_thread_frame): Likewise. * top.c (execute_command_to_string): Likewise. * tracepoint.c (tvariables_info_1): Likewise. (trace_status_mi): Likewise. (tfind_1): Likewise. (print_one_static_tracepoint_marker): Likewise. (info_static_tracepoint_markers_command): Likewise. * utils.c (do_ui_out_redirect_pop): Likewise. (fputs_maybe_filtered): Likewise.
2016-12-22 22:17:31 +01:00
current_uiout->flush ();
C++-fy struct interp/cli_interp/tui_interp/mi_interp - The interp->data field disappears, since we can put data in the interpreter directly now. The "init" method remains in place, but it now returns void. - A few places check if the interpreter method is NULL before calling it, and also check whether the method returns true/false. For some of those methods, all current implementations always return true. In those cases, this commit makes the C++-fied method return void instead and cleans up the callers. Tested on x86_64 Fedora 23. gdb/ChangeLog: 2017-02-03 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_interp_base::cli_interp_base) (cli_interp_base::~cli_interp_base): New. (cli_interp): New struct. (as_cli_interp): Cast the interp itself to cli_interp. (cli_interpreter_pre_command_loop): Rename to ... (cli_interp_base::pre_command_loop): ... this. Remove 'self' parameter. (cli_interpreter_init): Rename to ... (cli_interp::init): ... this. Remove 'self' parameter. Use boolean. Make extern. (cli_interpreter_resume): Rename to ... (cli_interp::resume): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_suspend): Rename to ... (cli_interp::suspend): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_exec): Rename to ... (cli_interp::exec): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_supports_command_editing): Rename to ... (cli_interp_base::supports_command_editing): ... this. Remove 'interp' parameter. Make extern. (cli_ui_out): Rename to ... (cli_interp::interp_ui_out): ... this. Remove 'interp' parameter. Make extern. (cli_set_logging): Rename to ... (cli_interp_base::set_logging): ... this. Remove 'interp' parameter. Make extern. (cli_interp_procs): Delete. (cli_interp_factory): Adjust to use "new". * cli/cli-interp.h: Include "interps.h". (struct cli_interp_base): New struct. * interps.c (struct interp): Delete. Fields moved to interps.h. (interp_new): Delete. (interp::interp, interp::~interp): New. (interp_set): Use bool, and return void. Assume the interpreter has suspend, init and resume methods, and that the all return void. (set_top_level_interpreter): interp_set returns void. (interp_ui_out): Adapt. (current_interp_set_logging): Adapt. (interp_data): Delete. (interp_pre_command_loop, interp_supports_command_editing): Adapt. (interp_exec): Adapt. (top_level_interpreter_data): Delete. * interps.h (interp_init_ftype, interp_resume_ftype) (interp_suspend_ftype, interp_exec_ftype) (interp_pre_command_loop_ftype, interp_ui_out_ftype): Delete. (class interp): New. (interp_new): Delete. (interp_set): Now returns void. Use bool. (interp_data, top_level_interpreter_data): Delete. * mi/mi-common.h: Include interps.h. (class mi_interp): Inherit from interp. Define a ctor. Declare init, resume, suspect, exec, interp_ui_out, set_logging and pre_command_loop methods. * mi/mi-interp.c (as_mi_interp): Cast the interp itself. (mi_interpreter_init): Rename to ... (mi_interp::init): ... this. Remove the 'interp' parameter, use bool, return void and make extern. Adjust. (mi_interpreter_resume): ... Rename to ... (mi_interp::resume): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (mi_interpreter_suspend): ... Rename to ... (mi_interp::suspend): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (mi_interpreter_exec): ... Rename to ... (mi_interp::exec): ... this. Remove the 'data' parameter and make extern. Adjust. (mi_interpreter_pre_command_loop): ... Rename to ... (mi_interp::pre_command_loop): ... this. Remove the 'self' parameter and make extern. (mi_on_normal_stop_1): Adjust. (mi_ui_out): Rename to ... (mi_interp::interp_ui_out): ... this. Remove the 'interp' parameter and make extern. Adjust. (mi_set_logging): Rename to ... (mi_interp::set_logging): ... this. Remove the 'interp' parameter and make extern. Adjust. (mi_interp_procs): Delete. (mi_interp_factory): Adjust to use 'new'. * mi/mi-main.c (mi_cmd_gdb_exit, captured_mi_execute_command) (mi_print_exception, mi_execute_command, mi_load_progress): Adjust. * tui/tui-interp.c (tui_interp): New class. (as_tui_interp): Return a tui_interp pointer. (tui_on_normal_stop, tui_on_signal_received) (tui_on_end_stepping_range, tui_on_signal_exited, tui_on_exited) (tui_on_no_history, tui_on_user_selected_context_changed): Adjust to use interp::interp_ui_out. (tui_init): Rename to ... (tui_interp::init): ... this. Remove the 'self' parameter, use bool, return void and make extern. Adjust. (tui_resume): Rename to ... (tui_interp::resume): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (tui_suspend): Rename to ... (tui_interp::suspend): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (tui_ui_out): Rename to ... (tui_interp::interp_ui_out): ... this. Remove the 'self' parameter, and make extern. Adjust. (tui_exec): Rename to ... (tui_interp::exec): ... this. Remove the 'data' parameter and make extern. (tui_interp_procs): Delete. (tui_interp_factory): Use "new".
2017-02-03 17:30:04 +01:00
old_interp->suspend ();
2003-02-06 06:30:17 +01:00
}
Make the interpreters be per UI Make each UI have its own interpreter list, top level interpreter, current interpreter, etc. The "interpreter_async" global is not really specific to an struct interp (it crosses interpreter-exec ...), so I moved it to "struct ui" directly, while the other globals were left hidden in interps.c, opaque to the rest of GDB. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * breakpoint.c (bpstat_do_actions_1): Access the current UI's async field instead of the interpreter_async global. * cli/cli-script.c (execute_user_command, while_command) (if_command, script_from_file): Likewise. * compile/compile.c: Include top.h instead of interps.h. (compile_file_command, compile_code_command) (compile_print_command): Access the current UI's async field instead of the interpreter_async global. * guile/guile.c: Include top.h instead of interps.h. (guile_repl_command, guile_command, gdbscm_execute_gdb_command): Access the current UI's async field instead of the interpreter_async global. * guile/scm-ports.c: Include top.h instead of interps.h. (ioscm_with_output_to_port_worker): Access the current UI's async field instead of the interpreter_async global. * inf-loop.c (inferior_event_handler): Likewise. * infcall.c (run_inferior_call): Likewise. * infrun.c (reinstall_readline_callback_handler_cleanup) (fetch_inferior_event): Likewise. * interps.c (interpreter_async): Delete. (struct ui_interp_info): New. (get_current_interp_info): New function. (interp_list, current_interpreter, top_level_interpreter_ptr): Delete. (interp_add, interp_set, interp_lookup, interp_ui_out) (current_interp_set_logging, interp_set_temp) (current_interp_named_p): Adjust to per-UI interpreters. (command_interpreter): Delete. (command_interp, current_interp_command_loop, interp_quiet_p) (interp_exec, interpreter_exec_cmd, interpreter_completer) (top_level_interpreter, top_level_interpreter_data): Adjust to per-UI interpreters. * interps.h (interpreter_async): Delete. * main.c (captured_command_loop): Access the current UI's async field instead of the interpreter_async global. * python/python.c (python_interactive_command, python_command) (execute_gdb_command): Likewise. * top.c (maybe_wait_sync_command_done, execute_command_to_string): Access the current UI's async field instead of the interpreter_async global. * top.h (struct tl_interp_info): Forward declare. (struct ui) <interp_info, async>: New fields.
2016-06-21 02:11:45 +02:00
ui_interp->current_interpreter = interp;
if (top_level)
Make the interpreters be per UI Make each UI have its own interpreter list, top level interpreter, current interpreter, etc. The "interpreter_async" global is not really specific to an struct interp (it crosses interpreter-exec ...), so I moved it to "struct ui" directly, while the other globals were left hidden in interps.c, opaque to the rest of GDB. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * breakpoint.c (bpstat_do_actions_1): Access the current UI's async field instead of the interpreter_async global. * cli/cli-script.c (execute_user_command, while_command) (if_command, script_from_file): Likewise. * compile/compile.c: Include top.h instead of interps.h. (compile_file_command, compile_code_command) (compile_print_command): Access the current UI's async field instead of the interpreter_async global. * guile/guile.c: Include top.h instead of interps.h. (guile_repl_command, guile_command, gdbscm_execute_gdb_command): Access the current UI's async field instead of the interpreter_async global. * guile/scm-ports.c: Include top.h instead of interps.h. (ioscm_with_output_to_port_worker): Access the current UI's async field instead of the interpreter_async global. * inf-loop.c (inferior_event_handler): Likewise. * infcall.c (run_inferior_call): Likewise. * infrun.c (reinstall_readline_callback_handler_cleanup) (fetch_inferior_event): Likewise. * interps.c (interpreter_async): Delete. (struct ui_interp_info): New. (get_current_interp_info): New function. (interp_list, current_interpreter, top_level_interpreter_ptr): Delete. (interp_add, interp_set, interp_lookup, interp_ui_out) (current_interp_set_logging, interp_set_temp) (current_interp_named_p): Adjust to per-UI interpreters. (command_interpreter): Delete. (command_interp, current_interp_command_loop, interp_quiet_p) (interp_exec, interpreter_exec_cmd, interpreter_completer) (top_level_interpreter, top_level_interpreter_data): Adjust to per-UI interpreters. * interps.h (interpreter_async): Delete. * main.c (captured_command_loop): Access the current UI's async field instead of the interpreter_async global. * python/python.c (python_interactive_command, python_command) (execute_gdb_command): Likewise. * top.c (maybe_wait_sync_command_done, execute_command_to_string): Access the current UI's async field instead of the interpreter_async global. * top.h (struct tl_interp_info): Forward declare. (struct ui) <interp_info, async>: New fields.
2016-06-21 02:11:45 +02:00
ui_interp->top_level_interpreter = interp;
2003-02-06 06:30:17 +01:00
/* We use interpreter_p for the "set interpreter" variable, so we need
to make sure we have a malloc'ed copy for the set command to free. */
2003-02-06 06:30:17 +01:00
if (interpreter_p != NULL
&& strcmp (interp->name (), interpreter_p) != 0)
2003-02-06 06:30:17 +01:00
{
xfree (interpreter_p);
interpreter_p = xstrdup (interp->name ());
2003-02-06 06:30:17 +01:00
}
C++-fy struct interp/cli_interp/tui_interp/mi_interp - The interp->data field disappears, since we can put data in the interpreter directly now. The "init" method remains in place, but it now returns void. - A few places check if the interpreter method is NULL before calling it, and also check whether the method returns true/false. For some of those methods, all current implementations always return true. In those cases, this commit makes the C++-fied method return void instead and cleans up the callers. Tested on x86_64 Fedora 23. gdb/ChangeLog: 2017-02-03 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_interp_base::cli_interp_base) (cli_interp_base::~cli_interp_base): New. (cli_interp): New struct. (as_cli_interp): Cast the interp itself to cli_interp. (cli_interpreter_pre_command_loop): Rename to ... (cli_interp_base::pre_command_loop): ... this. Remove 'self' parameter. (cli_interpreter_init): Rename to ... (cli_interp::init): ... this. Remove 'self' parameter. Use boolean. Make extern. (cli_interpreter_resume): Rename to ... (cli_interp::resume): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_suspend): Rename to ... (cli_interp::suspend): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_exec): Rename to ... (cli_interp::exec): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_supports_command_editing): Rename to ... (cli_interp_base::supports_command_editing): ... this. Remove 'interp' parameter. Make extern. (cli_ui_out): Rename to ... (cli_interp::interp_ui_out): ... this. Remove 'interp' parameter. Make extern. (cli_set_logging): Rename to ... (cli_interp_base::set_logging): ... this. Remove 'interp' parameter. Make extern. (cli_interp_procs): Delete. (cli_interp_factory): Adjust to use "new". * cli/cli-interp.h: Include "interps.h". (struct cli_interp_base): New struct. * interps.c (struct interp): Delete. Fields moved to interps.h. (interp_new): Delete. (interp::interp, interp::~interp): New. (interp_set): Use bool, and return void. Assume the interpreter has suspend, init and resume methods, and that the all return void. (set_top_level_interpreter): interp_set returns void. (interp_ui_out): Adapt. (current_interp_set_logging): Adapt. (interp_data): Delete. (interp_pre_command_loop, interp_supports_command_editing): Adapt. (interp_exec): Adapt. (top_level_interpreter_data): Delete. * interps.h (interp_init_ftype, interp_resume_ftype) (interp_suspend_ftype, interp_exec_ftype) (interp_pre_command_loop_ftype, interp_ui_out_ftype): Delete. (class interp): New. (interp_new): Delete. (interp_set): Now returns void. Use bool. (interp_data, top_level_interpreter_data): Delete. * mi/mi-common.h: Include interps.h. (class mi_interp): Inherit from interp. Define a ctor. Declare init, resume, suspect, exec, interp_ui_out, set_logging and pre_command_loop methods. * mi/mi-interp.c (as_mi_interp): Cast the interp itself. (mi_interpreter_init): Rename to ... (mi_interp::init): ... this. Remove the 'interp' parameter, use bool, return void and make extern. Adjust. (mi_interpreter_resume): ... Rename to ... (mi_interp::resume): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (mi_interpreter_suspend): ... Rename to ... (mi_interp::suspend): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (mi_interpreter_exec): ... Rename to ... (mi_interp::exec): ... this. Remove the 'data' parameter and make extern. Adjust. (mi_interpreter_pre_command_loop): ... Rename to ... (mi_interp::pre_command_loop): ... this. Remove the 'self' parameter and make extern. (mi_on_normal_stop_1): Adjust. (mi_ui_out): Rename to ... (mi_interp::interp_ui_out): ... this. Remove the 'interp' parameter and make extern. Adjust. (mi_set_logging): Rename to ... (mi_interp::set_logging): ... this. Remove the 'interp' parameter and make extern. Adjust. (mi_interp_procs): Delete. (mi_interp_factory): Adjust to use 'new'. * mi/mi-main.c (mi_cmd_gdb_exit, captured_mi_execute_command) (mi_print_exception, mi_execute_command, mi_load_progress): Adjust. * tui/tui-interp.c (tui_interp): New class. (as_tui_interp): Return a tui_interp pointer. (tui_on_normal_stop, tui_on_signal_received) (tui_on_end_stepping_range, tui_on_signal_exited, tui_on_exited) (tui_on_no_history, tui_on_user_selected_context_changed): Adjust to use interp::interp_ui_out. (tui_init): Rename to ... (tui_interp::init): ... this. Remove the 'self' parameter, use bool, return void and make extern. Adjust. (tui_resume): Rename to ... (tui_interp::resume): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (tui_suspend): Rename to ... (tui_interp::suspend): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (tui_ui_out): Rename to ... (tui_interp::interp_ui_out): ... this. Remove the 'self' parameter, and make extern. Adjust. (tui_exec): Rename to ... (tui_interp::exec): ... this. Remove the 'data' parameter and make extern. (tui_interp_procs): Delete. (tui_interp_factory): Use "new".
2017-02-03 17:30:04 +01:00
/* Run the init proc. */
2003-02-06 06:30:17 +01:00
if (!interp->inited)
{
C++-fy struct interp/cli_interp/tui_interp/mi_interp - The interp->data field disappears, since we can put data in the interpreter directly now. The "init" method remains in place, but it now returns void. - A few places check if the interpreter method is NULL before calling it, and also check whether the method returns true/false. For some of those methods, all current implementations always return true. In those cases, this commit makes the C++-fied method return void instead and cleans up the callers. Tested on x86_64 Fedora 23. gdb/ChangeLog: 2017-02-03 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_interp_base::cli_interp_base) (cli_interp_base::~cli_interp_base): New. (cli_interp): New struct. (as_cli_interp): Cast the interp itself to cli_interp. (cli_interpreter_pre_command_loop): Rename to ... (cli_interp_base::pre_command_loop): ... this. Remove 'self' parameter. (cli_interpreter_init): Rename to ... (cli_interp::init): ... this. Remove 'self' parameter. Use boolean. Make extern. (cli_interpreter_resume): Rename to ... (cli_interp::resume): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_suspend): Rename to ... (cli_interp::suspend): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_exec): Rename to ... (cli_interp::exec): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_supports_command_editing): Rename to ... (cli_interp_base::supports_command_editing): ... this. Remove 'interp' parameter. Make extern. (cli_ui_out): Rename to ... (cli_interp::interp_ui_out): ... this. Remove 'interp' parameter. Make extern. (cli_set_logging): Rename to ... (cli_interp_base::set_logging): ... this. Remove 'interp' parameter. Make extern. (cli_interp_procs): Delete. (cli_interp_factory): Adjust to use "new". * cli/cli-interp.h: Include "interps.h". (struct cli_interp_base): New struct. * interps.c (struct interp): Delete. Fields moved to interps.h. (interp_new): Delete. (interp::interp, interp::~interp): New. (interp_set): Use bool, and return void. Assume the interpreter has suspend, init and resume methods, and that the all return void. (set_top_level_interpreter): interp_set returns void. (interp_ui_out): Adapt. (current_interp_set_logging): Adapt. (interp_data): Delete. (interp_pre_command_loop, interp_supports_command_editing): Adapt. (interp_exec): Adapt. (top_level_interpreter_data): Delete. * interps.h (interp_init_ftype, interp_resume_ftype) (interp_suspend_ftype, interp_exec_ftype) (interp_pre_command_loop_ftype, interp_ui_out_ftype): Delete. (class interp): New. (interp_new): Delete. (interp_set): Now returns void. Use bool. (interp_data, top_level_interpreter_data): Delete. * mi/mi-common.h: Include interps.h. (class mi_interp): Inherit from interp. Define a ctor. Declare init, resume, suspect, exec, interp_ui_out, set_logging and pre_command_loop methods. * mi/mi-interp.c (as_mi_interp): Cast the interp itself. (mi_interpreter_init): Rename to ... (mi_interp::init): ... this. Remove the 'interp' parameter, use bool, return void and make extern. Adjust. (mi_interpreter_resume): ... Rename to ... (mi_interp::resume): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (mi_interpreter_suspend): ... Rename to ... (mi_interp::suspend): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (mi_interpreter_exec): ... Rename to ... (mi_interp::exec): ... this. Remove the 'data' parameter and make extern. Adjust. (mi_interpreter_pre_command_loop): ... Rename to ... (mi_interp::pre_command_loop): ... this. Remove the 'self' parameter and make extern. (mi_on_normal_stop_1): Adjust. (mi_ui_out): Rename to ... (mi_interp::interp_ui_out): ... this. Remove the 'interp' parameter and make extern. Adjust. (mi_set_logging): Rename to ... (mi_interp::set_logging): ... this. Remove the 'interp' parameter and make extern. Adjust. (mi_interp_procs): Delete. (mi_interp_factory): Adjust to use 'new'. * mi/mi-main.c (mi_cmd_gdb_exit, captured_mi_execute_command) (mi_print_exception, mi_execute_command, mi_load_progress): Adjust. * tui/tui-interp.c (tui_interp): New class. (as_tui_interp): Return a tui_interp pointer. (tui_on_normal_stop, tui_on_signal_received) (tui_on_end_stepping_range, tui_on_signal_exited, tui_on_exited) (tui_on_no_history, tui_on_user_selected_context_changed): Adjust to use interp::interp_ui_out. (tui_init): Rename to ... (tui_interp::init): ... this. Remove the 'self' parameter, use bool, return void and make extern. Adjust. (tui_resume): Rename to ... (tui_interp::resume): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (tui_suspend): Rename to ... (tui_interp::suspend): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (tui_ui_out): Rename to ... (tui_interp::interp_ui_out): ... this. Remove the 'self' parameter, and make extern. Adjust. (tui_exec): Rename to ... (tui_interp::exec): ... this. Remove the 'data' parameter and make extern. (tui_interp_procs): Delete. (tui_interp_factory): Use "new".
2017-02-03 17:30:04 +01:00
interp->init (top_level);
interp->inited = true;
2003-02-06 06:30:17 +01:00
}
gdb/ 2011-09-12 Pedro Alves <pedro@codesourcery.com> Matt Rice <ratmice@gmail.com> PR gdb/13175 * interps.c (struct interp) <interpreter_out>: Delete field. (interp_new): Remove the data and uiout parameters and adjust. (interp_set): Only set the current_uiout from the interpreter's uiout after initializing the interpreter. Adjust call to init_proc. (interp_ui_out): Adjust to call procs->ui_out_proc. (interp_data, interp_name): New. * interps.h (interp_init_ftype): Add `self' parameter. (interp_ui_out_ftype): New typedef. (struct interp_procs) <ui_out_proc>: New method pointer. (interp_new): Remove the data and uiout parameters. (interp_data, interp_name): Declare. * tui/tui-interp.c (tui_init): Adjust prototype. (tui_ui_out): New. (_initialize_tui_interp): Install tui_ui_out. Don't instanciate tui_out here. Adjust call to interp_new. * tui/tui-io.c (tui_initialize_io): Don't set current_uiout here. * cli/cli-interp.c (cli_interpreter_init): Adjust prototype. (cli_ui_out): New. (_initialize_cli_interp): Install it. Adjust call to interp_new. * mi/mi-common.h (struct mi_interp) <uiout>: New field. * mi/mi-interp.c (mi_interpreter_init): Adjust prototype. Initialize mi->uiout depending on the mi_version as extracted from the interpreter's name. (mi_ui_out): New. (_initialize_mi_interp): Install mi_ui_out. Adjust calls to interp_new. Don't allocate the ui_out's of the interpreters here. gdb/testsuite/ 2011-09-12 Matt Rice <ratmice@gmail.com> Pedro Alves <pedro@codesourcery.com> PR gdb/13175 * gdb.base/interp.exp: New tests. * gdb.base/interp.c: New file.
2011-09-12 23:25:22 +02:00
/* Do this only after the interpreter is initialized. */
C++-fy struct interp/cli_interp/tui_interp/mi_interp - The interp->data field disappears, since we can put data in the interpreter directly now. The "init" method remains in place, but it now returns void. - A few places check if the interpreter method is NULL before calling it, and also check whether the method returns true/false. For some of those methods, all current implementations always return true. In those cases, this commit makes the C++-fied method return void instead and cleans up the callers. Tested on x86_64 Fedora 23. gdb/ChangeLog: 2017-02-03 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_interp_base::cli_interp_base) (cli_interp_base::~cli_interp_base): New. (cli_interp): New struct. (as_cli_interp): Cast the interp itself to cli_interp. (cli_interpreter_pre_command_loop): Rename to ... (cli_interp_base::pre_command_loop): ... this. Remove 'self' parameter. (cli_interpreter_init): Rename to ... (cli_interp::init): ... this. Remove 'self' parameter. Use boolean. Make extern. (cli_interpreter_resume): Rename to ... (cli_interp::resume): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_suspend): Rename to ... (cli_interp::suspend): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_exec): Rename to ... (cli_interp::exec): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_supports_command_editing): Rename to ... (cli_interp_base::supports_command_editing): ... this. Remove 'interp' parameter. Make extern. (cli_ui_out): Rename to ... (cli_interp::interp_ui_out): ... this. Remove 'interp' parameter. Make extern. (cli_set_logging): Rename to ... (cli_interp_base::set_logging): ... this. Remove 'interp' parameter. Make extern. (cli_interp_procs): Delete. (cli_interp_factory): Adjust to use "new". * cli/cli-interp.h: Include "interps.h". (struct cli_interp_base): New struct. * interps.c (struct interp): Delete. Fields moved to interps.h. (interp_new): Delete. (interp::interp, interp::~interp): New. (interp_set): Use bool, and return void. Assume the interpreter has suspend, init and resume methods, and that the all return void. (set_top_level_interpreter): interp_set returns void. (interp_ui_out): Adapt. (current_interp_set_logging): Adapt. (interp_data): Delete. (interp_pre_command_loop, interp_supports_command_editing): Adapt. (interp_exec): Adapt. (top_level_interpreter_data): Delete. * interps.h (interp_init_ftype, interp_resume_ftype) (interp_suspend_ftype, interp_exec_ftype) (interp_pre_command_loop_ftype, interp_ui_out_ftype): Delete. (class interp): New. (interp_new): Delete. (interp_set): Now returns void. Use bool. (interp_data, top_level_interpreter_data): Delete. * mi/mi-common.h: Include interps.h. (class mi_interp): Inherit from interp. Define a ctor. Declare init, resume, suspect, exec, interp_ui_out, set_logging and pre_command_loop methods. * mi/mi-interp.c (as_mi_interp): Cast the interp itself. (mi_interpreter_init): Rename to ... (mi_interp::init): ... this. Remove the 'interp' parameter, use bool, return void and make extern. Adjust. (mi_interpreter_resume): ... Rename to ... (mi_interp::resume): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (mi_interpreter_suspend): ... Rename to ... (mi_interp::suspend): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (mi_interpreter_exec): ... Rename to ... (mi_interp::exec): ... this. Remove the 'data' parameter and make extern. Adjust. (mi_interpreter_pre_command_loop): ... Rename to ... (mi_interp::pre_command_loop): ... this. Remove the 'self' parameter and make extern. (mi_on_normal_stop_1): Adjust. (mi_ui_out): Rename to ... (mi_interp::interp_ui_out): ... this. Remove the 'interp' parameter and make extern. Adjust. (mi_set_logging): Rename to ... (mi_interp::set_logging): ... this. Remove the 'interp' parameter and make extern. Adjust. (mi_interp_procs): Delete. (mi_interp_factory): Adjust to use 'new'. * mi/mi-main.c (mi_cmd_gdb_exit, captured_mi_execute_command) (mi_print_exception, mi_execute_command, mi_load_progress): Adjust. * tui/tui-interp.c (tui_interp): New class. (as_tui_interp): Return a tui_interp pointer. (tui_on_normal_stop, tui_on_signal_received) (tui_on_end_stepping_range, tui_on_signal_exited, tui_on_exited) (tui_on_no_history, tui_on_user_selected_context_changed): Adjust to use interp::interp_ui_out. (tui_init): Rename to ... (tui_interp::init): ... this. Remove the 'self' parameter, use bool, return void and make extern. Adjust. (tui_resume): Rename to ... (tui_interp::resume): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (tui_suspend): Rename to ... (tui_interp::suspend): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (tui_ui_out): Rename to ... (tui_interp::interp_ui_out): ... this. Remove the 'self' parameter, and make extern. Adjust. (tui_exec): Rename to ... (tui_interp::exec): ... this. Remove the 'data' parameter and make extern. (tui_interp_procs): Delete. (tui_interp_factory): Use "new".
2017-02-03 17:30:04 +01:00
current_uiout = interp->interp_ui_out ();
gdb/ 2011-09-12 Pedro Alves <pedro@codesourcery.com> Matt Rice <ratmice@gmail.com> PR gdb/13175 * interps.c (struct interp) <interpreter_out>: Delete field. (interp_new): Remove the data and uiout parameters and adjust. (interp_set): Only set the current_uiout from the interpreter's uiout after initializing the interpreter. Adjust call to init_proc. (interp_ui_out): Adjust to call procs->ui_out_proc. (interp_data, interp_name): New. * interps.h (interp_init_ftype): Add `self' parameter. (interp_ui_out_ftype): New typedef. (struct interp_procs) <ui_out_proc>: New method pointer. (interp_new): Remove the data and uiout parameters. (interp_data, interp_name): Declare. * tui/tui-interp.c (tui_init): Adjust prototype. (tui_ui_out): New. (_initialize_tui_interp): Install tui_ui_out. Don't instanciate tui_out here. Adjust call to interp_new. * tui/tui-io.c (tui_initialize_io): Don't set current_uiout here. * cli/cli-interp.c (cli_interpreter_init): Adjust prototype. (cli_ui_out): New. (_initialize_cli_interp): Install it. Adjust call to interp_new. * mi/mi-common.h (struct mi_interp) <uiout>: New field. * mi/mi-interp.c (mi_interpreter_init): Adjust prototype. Initialize mi->uiout depending on the mi_version as extracted from the interpreter's name. (mi_ui_out): New. (_initialize_mi_interp): Install mi_ui_out. Adjust calls to interp_new. Don't allocate the ui_out's of the interpreters here. gdb/testsuite/ 2011-09-12 Matt Rice <ratmice@gmail.com> Pedro Alves <pedro@codesourcery.com> PR gdb/13175 * gdb.base/interp.exp: New tests. * gdb.base/interp.c: New file.
2011-09-12 23:25:22 +02:00
/* Clear out any installed interpreter hooks/event handlers. */
2003-02-06 06:30:17 +01:00
clear_interpreter_hooks ();
C++-fy struct interp/cli_interp/tui_interp/mi_interp - The interp->data field disappears, since we can put data in the interpreter directly now. The "init" method remains in place, but it now returns void. - A few places check if the interpreter method is NULL before calling it, and also check whether the method returns true/false. For some of those methods, all current implementations always return true. In those cases, this commit makes the C++-fied method return void instead and cleans up the callers. Tested on x86_64 Fedora 23. gdb/ChangeLog: 2017-02-03 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_interp_base::cli_interp_base) (cli_interp_base::~cli_interp_base): New. (cli_interp): New struct. (as_cli_interp): Cast the interp itself to cli_interp. (cli_interpreter_pre_command_loop): Rename to ... (cli_interp_base::pre_command_loop): ... this. Remove 'self' parameter. (cli_interpreter_init): Rename to ... (cli_interp::init): ... this. Remove 'self' parameter. Use boolean. Make extern. (cli_interpreter_resume): Rename to ... (cli_interp::resume): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_suspend): Rename to ... (cli_interp::suspend): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_exec): Rename to ... (cli_interp::exec): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_supports_command_editing): Rename to ... (cli_interp_base::supports_command_editing): ... this. Remove 'interp' parameter. Make extern. (cli_ui_out): Rename to ... (cli_interp::interp_ui_out): ... this. Remove 'interp' parameter. Make extern. (cli_set_logging): Rename to ... (cli_interp_base::set_logging): ... this. Remove 'interp' parameter. Make extern. (cli_interp_procs): Delete. (cli_interp_factory): Adjust to use "new". * cli/cli-interp.h: Include "interps.h". (struct cli_interp_base): New struct. * interps.c (struct interp): Delete. Fields moved to interps.h. (interp_new): Delete. (interp::interp, interp::~interp): New. (interp_set): Use bool, and return void. Assume the interpreter has suspend, init and resume methods, and that the all return void. (set_top_level_interpreter): interp_set returns void. (interp_ui_out): Adapt. (current_interp_set_logging): Adapt. (interp_data): Delete. (interp_pre_command_loop, interp_supports_command_editing): Adapt. (interp_exec): Adapt. (top_level_interpreter_data): Delete. * interps.h (interp_init_ftype, interp_resume_ftype) (interp_suspend_ftype, interp_exec_ftype) (interp_pre_command_loop_ftype, interp_ui_out_ftype): Delete. (class interp): New. (interp_new): Delete. (interp_set): Now returns void. Use bool. (interp_data, top_level_interpreter_data): Delete. * mi/mi-common.h: Include interps.h. (class mi_interp): Inherit from interp. Define a ctor. Declare init, resume, suspect, exec, interp_ui_out, set_logging and pre_command_loop methods. * mi/mi-interp.c (as_mi_interp): Cast the interp itself. (mi_interpreter_init): Rename to ... (mi_interp::init): ... this. Remove the 'interp' parameter, use bool, return void and make extern. Adjust. (mi_interpreter_resume): ... Rename to ... (mi_interp::resume): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (mi_interpreter_suspend): ... Rename to ... (mi_interp::suspend): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (mi_interpreter_exec): ... Rename to ... (mi_interp::exec): ... this. Remove the 'data' parameter and make extern. Adjust. (mi_interpreter_pre_command_loop): ... Rename to ... (mi_interp::pre_command_loop): ... this. Remove the 'self' parameter and make extern. (mi_on_normal_stop_1): Adjust. (mi_ui_out): Rename to ... (mi_interp::interp_ui_out): ... this. Remove the 'interp' parameter and make extern. Adjust. (mi_set_logging): Rename to ... (mi_interp::set_logging): ... this. Remove the 'interp' parameter and make extern. Adjust. (mi_interp_procs): Delete. (mi_interp_factory): Adjust to use 'new'. * mi/mi-main.c (mi_cmd_gdb_exit, captured_mi_execute_command) (mi_print_exception, mi_execute_command, mi_load_progress): Adjust. * tui/tui-interp.c (tui_interp): New class. (as_tui_interp): Return a tui_interp pointer. (tui_on_normal_stop, tui_on_signal_received) (tui_on_end_stepping_range, tui_on_signal_exited, tui_on_exited) (tui_on_no_history, tui_on_user_selected_context_changed): Adjust to use interp::interp_ui_out. (tui_init): Rename to ... (tui_interp::init): ... this. Remove the 'self' parameter, use bool, return void and make extern. Adjust. (tui_resume): Rename to ... (tui_interp::resume): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (tui_suspend): Rename to ... (tui_interp::suspend): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (tui_ui_out): Rename to ... (tui_interp::interp_ui_out): ... this. Remove the 'self' parameter, and make extern. Adjust. (tui_exec): Rename to ... (tui_interp::exec): ... this. Remove the 'data' parameter and make extern. (tui_interp_procs): Delete. (tui_interp_factory): Use "new".
2017-02-03 17:30:04 +01:00
interp->resume ();
2003-02-06 06:30:17 +01:00
}
Introduce interpreter factories If every UI instance has its own set of interpreters, then the current scheme of creating the interpreters at GDB initialization time no longer works. We need to create them whenever a new UI instance is created. The scheme implemented here has each interpreter register a factory callback that when called creates a new instance of a specific interpreter type. Then, when some code in gdb looks up an interpreter (always by name), if there's none yet, the factory method is called to construct one. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_uiout): Delete, moved into ... (struct cli_interp): ... this new structure. (cli_on_normal_stop, cli_on_signal_received) (cli_on_end_stepping_range, cli_on_signal_exited, cli_on_exited) (cli_on_no_history): Use interp_ui_out. (cli_interpreter_init): If top level, set the cli_interp global. (cli_interpreter_init): Return the interp's data instead of NULL. (cli_interpreter_resume, cli_interpreter_exec, cli_ui_out): Adjust to cli_uiout being in the interpreter's data. (cli_interp_procs): New, factored out from _initialize_cli_interp. (cli_interp_factory): New function. (_initialize_cli_interp): Call interp_factory_register. * interps.c (get_interp_info): New, factored out from ... (get_current_interp_info): ... this. (interp_new): Add parameter 'data'. Store it. (struct interp_factory): New function. (interp_factory_p): New typedef. Define a VEC_P. (interpreter_factories): New global. (interp_factory_register): New function. (interp_add): Add 'ui' parameter. Use get_interp_info and interp_lookup_existing. (interp_lookup): Rename to ... (interp_lookup_existing): ... this. Add 'ui' parameter. Don't check for NULL or empty name here. (interp_lookup): Add 'ui' parameter and reimplement. (interp_set_temp, interpreter_exec_cmd): Adjust. (interpreter_completer): Complete on registered interpreter factories instead of interpreters. * interps.h (interp_factory_func): New typedef. (interp_factory_register): Declare. (interp_new, interp_add): Adjust. (interp_lookup): Declare. * main.c (captured_main): Adjust. * mi/mi-interp.c (mi_cmd_interpreter_exec): Adjust. (mi_interp_procs): New, factored out from _initialize_mi_interp. (mi_interp_factory): New function. * python/python.c (execute_gdb_command): Adjust. * tui/tui-interp.c (tui_init): If top level, set the tui_interp global. (tui_interp_procs): New. (tui_interp_factory): New function. (_initialize_tui_interp): Call interp_factory_register.
2016-06-21 02:11:45 +02:00
/* Look up the interpreter for NAME. If no such interpreter exists,
return NULL, otherwise return a pointer to the interpreter. */
static struct interp *
interp_lookup_existing (struct ui *ui, const char *name)
2003-02-06 06:30:17 +01:00
{
Introduce interpreter factories If every UI instance has its own set of interpreters, then the current scheme of creating the interpreters at GDB initialization time no longer works. We need to create them whenever a new UI instance is created. The scheme implemented here has each interpreter register a factory callback that when called creates a new instance of a specific interpreter type. Then, when some code in gdb looks up an interpreter (always by name), if there's none yet, the factory method is called to construct one. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_uiout): Delete, moved into ... (struct cli_interp): ... this new structure. (cli_on_normal_stop, cli_on_signal_received) (cli_on_end_stepping_range, cli_on_signal_exited, cli_on_exited) (cli_on_no_history): Use interp_ui_out. (cli_interpreter_init): If top level, set the cli_interp global. (cli_interpreter_init): Return the interp's data instead of NULL. (cli_interpreter_resume, cli_interpreter_exec, cli_ui_out): Adjust to cli_uiout being in the interpreter's data. (cli_interp_procs): New, factored out from _initialize_cli_interp. (cli_interp_factory): New function. (_initialize_cli_interp): Call interp_factory_register. * interps.c (get_interp_info): New, factored out from ... (get_current_interp_info): ... this. (interp_new): Add parameter 'data'. Store it. (struct interp_factory): New function. (interp_factory_p): New typedef. Define a VEC_P. (interpreter_factories): New global. (interp_factory_register): New function. (interp_add): Add 'ui' parameter. Use get_interp_info and interp_lookup_existing. (interp_lookup): Rename to ... (interp_lookup_existing): ... this. Add 'ui' parameter. Don't check for NULL or empty name here. (interp_lookup): Add 'ui' parameter and reimplement. (interp_set_temp, interpreter_exec_cmd): Adjust. (interpreter_completer): Complete on registered interpreter factories instead of interpreters. * interps.h (interp_factory_func): New typedef. (interp_factory_register): Declare. (interp_new, interp_add): Adjust. (interp_lookup): Declare. * main.c (captured_main): Adjust. * mi/mi-interp.c (mi_cmd_interpreter_exec): Adjust. (mi_interp_procs): New, factored out from _initialize_mi_interp. (mi_interp_factory): New function. * python/python.c (execute_gdb_command): Adjust. * tui/tui-interp.c (tui_init): If top level, set the tui_interp global. (tui_interp_procs): New. (tui_interp_factory): New function. (_initialize_tui_interp): Call interp_factory_register.
2016-06-21 02:11:45 +02:00
struct ui_interp_info *ui_interp = get_interp_info (ui);
2003-02-06 06:30:17 +01:00
struct interp *interp;
Make the interpreters be per UI Make each UI have its own interpreter list, top level interpreter, current interpreter, etc. The "interpreter_async" global is not really specific to an struct interp (it crosses interpreter-exec ...), so I moved it to "struct ui" directly, while the other globals were left hidden in interps.c, opaque to the rest of GDB. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * breakpoint.c (bpstat_do_actions_1): Access the current UI's async field instead of the interpreter_async global. * cli/cli-script.c (execute_user_command, while_command) (if_command, script_from_file): Likewise. * compile/compile.c: Include top.h instead of interps.h. (compile_file_command, compile_code_command) (compile_print_command): Access the current UI's async field instead of the interpreter_async global. * guile/guile.c: Include top.h instead of interps.h. (guile_repl_command, guile_command, gdbscm_execute_gdb_command): Access the current UI's async field instead of the interpreter_async global. * guile/scm-ports.c: Include top.h instead of interps.h. (ioscm_with_output_to_port_worker): Access the current UI's async field instead of the interpreter_async global. * inf-loop.c (inferior_event_handler): Likewise. * infcall.c (run_inferior_call): Likewise. * infrun.c (reinstall_readline_callback_handler_cleanup) (fetch_inferior_event): Likewise. * interps.c (interpreter_async): Delete. (struct ui_interp_info): New. (get_current_interp_info): New function. (interp_list, current_interpreter, top_level_interpreter_ptr): Delete. (interp_add, interp_set, interp_lookup, interp_ui_out) (current_interp_set_logging, interp_set_temp) (current_interp_named_p): Adjust to per-UI interpreters. (command_interpreter): Delete. (command_interp, current_interp_command_loop, interp_quiet_p) (interp_exec, interpreter_exec_cmd, interpreter_completer) (top_level_interpreter, top_level_interpreter_data): Adjust to per-UI interpreters. * interps.h (interpreter_async): Delete. * main.c (captured_command_loop): Access the current UI's async field instead of the interpreter_async global. * python/python.c (python_interactive_command, python_command) (execute_gdb_command): Likewise. * top.c (maybe_wait_sync_command_done, execute_command_to_string): Access the current UI's async field instead of the interpreter_async global. * top.h (struct tl_interp_info): Forward declare. (struct ui) <interp_info, async>: New fields.
2016-06-21 02:11:45 +02:00
for (interp = ui_interp->interp_list;
interp != NULL;
interp = interp->next)
2003-02-06 06:30:17 +01:00
{
if (strcmp (interp->name (), name) == 0)
2003-02-06 06:30:17 +01:00
return interp;
}
return NULL;
}
Introduce interpreter factories If every UI instance has its own set of interpreters, then the current scheme of creating the interpreters at GDB initialization time no longer works. We need to create them whenever a new UI instance is created. The scheme implemented here has each interpreter register a factory callback that when called creates a new instance of a specific interpreter type. Then, when some code in gdb looks up an interpreter (always by name), if there's none yet, the factory method is called to construct one. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_uiout): Delete, moved into ... (struct cli_interp): ... this new structure. (cli_on_normal_stop, cli_on_signal_received) (cli_on_end_stepping_range, cli_on_signal_exited, cli_on_exited) (cli_on_no_history): Use interp_ui_out. (cli_interpreter_init): If top level, set the cli_interp global. (cli_interpreter_init): Return the interp's data instead of NULL. (cli_interpreter_resume, cli_interpreter_exec, cli_ui_out): Adjust to cli_uiout being in the interpreter's data. (cli_interp_procs): New, factored out from _initialize_cli_interp. (cli_interp_factory): New function. (_initialize_cli_interp): Call interp_factory_register. * interps.c (get_interp_info): New, factored out from ... (get_current_interp_info): ... this. (interp_new): Add parameter 'data'. Store it. (struct interp_factory): New function. (interp_factory_p): New typedef. Define a VEC_P. (interpreter_factories): New global. (interp_factory_register): New function. (interp_add): Add 'ui' parameter. Use get_interp_info and interp_lookup_existing. (interp_lookup): Rename to ... (interp_lookup_existing): ... this. Add 'ui' parameter. Don't check for NULL or empty name here. (interp_lookup): Add 'ui' parameter and reimplement. (interp_set_temp, interpreter_exec_cmd): Adjust. (interpreter_completer): Complete on registered interpreter factories instead of interpreters. * interps.h (interp_factory_func): New typedef. (interp_factory_register): Declare. (interp_new, interp_add): Adjust. (interp_lookup): Declare. * main.c (captured_main): Adjust. * mi/mi-interp.c (mi_cmd_interpreter_exec): Adjust. (mi_interp_procs): New, factored out from _initialize_mi_interp. (mi_interp_factory): New function. * python/python.c (execute_gdb_command): Adjust. * tui/tui-interp.c (tui_init): If top level, set the tui_interp global. (tui_interp_procs): New. (tui_interp_factory): New function. (_initialize_tui_interp): Call interp_factory_register.
2016-06-21 02:11:45 +02:00
/* See interps.h. */
struct interp *
interp_lookup (struct ui *ui, const char *name)
{
if (name == NULL || strlen (name) == 0)
return NULL;
/* Only create each interpreter once per top level. */
struct interp *interp = interp_lookup_existing (ui, name);
Introduce interpreter factories If every UI instance has its own set of interpreters, then the current scheme of creating the interpreters at GDB initialization time no longer works. We need to create them whenever a new UI instance is created. The scheme implemented here has each interpreter register a factory callback that when called creates a new instance of a specific interpreter type. Then, when some code in gdb looks up an interpreter (always by name), if there's none yet, the factory method is called to construct one. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_uiout): Delete, moved into ... (struct cli_interp): ... this new structure. (cli_on_normal_stop, cli_on_signal_received) (cli_on_end_stepping_range, cli_on_signal_exited, cli_on_exited) (cli_on_no_history): Use interp_ui_out. (cli_interpreter_init): If top level, set the cli_interp global. (cli_interpreter_init): Return the interp's data instead of NULL. (cli_interpreter_resume, cli_interpreter_exec, cli_ui_out): Adjust to cli_uiout being in the interpreter's data. (cli_interp_procs): New, factored out from _initialize_cli_interp. (cli_interp_factory): New function. (_initialize_cli_interp): Call interp_factory_register. * interps.c (get_interp_info): New, factored out from ... (get_current_interp_info): ... this. (interp_new): Add parameter 'data'. Store it. (struct interp_factory): New function. (interp_factory_p): New typedef. Define a VEC_P. (interpreter_factories): New global. (interp_factory_register): New function. (interp_add): Add 'ui' parameter. Use get_interp_info and interp_lookup_existing. (interp_lookup): Rename to ... (interp_lookup_existing): ... this. Add 'ui' parameter. Don't check for NULL or empty name here. (interp_lookup): Add 'ui' parameter and reimplement. (interp_set_temp, interpreter_exec_cmd): Adjust. (interpreter_completer): Complete on registered interpreter factories instead of interpreters. * interps.h (interp_factory_func): New typedef. (interp_factory_register): Declare. (interp_new, interp_add): Adjust. (interp_lookup): Declare. * main.c (captured_main): Adjust. * mi/mi-interp.c (mi_cmd_interpreter_exec): Adjust. (mi_interp_procs): New, factored out from _initialize_mi_interp. (mi_interp_factory): New function. * python/python.c (execute_gdb_command): Adjust. * tui/tui-interp.c (tui_init): If top level, set the tui_interp global. (tui_interp_procs): New. (tui_interp_factory): New function. (_initialize_tui_interp): Call interp_factory_register.
2016-06-21 02:11:45 +02:00
if (interp != NULL)
return interp;
for (const interp_factory &factory : interpreter_factories)
if (strcmp (factory.name, name) == 0)
Introduce interpreter factories If every UI instance has its own set of interpreters, then the current scheme of creating the interpreters at GDB initialization time no longer works. We need to create them whenever a new UI instance is created. The scheme implemented here has each interpreter register a factory callback that when called creates a new instance of a specific interpreter type. Then, when some code in gdb looks up an interpreter (always by name), if there's none yet, the factory method is called to construct one. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_uiout): Delete, moved into ... (struct cli_interp): ... this new structure. (cli_on_normal_stop, cli_on_signal_received) (cli_on_end_stepping_range, cli_on_signal_exited, cli_on_exited) (cli_on_no_history): Use interp_ui_out. (cli_interpreter_init): If top level, set the cli_interp global. (cli_interpreter_init): Return the interp's data instead of NULL. (cli_interpreter_resume, cli_interpreter_exec, cli_ui_out): Adjust to cli_uiout being in the interpreter's data. (cli_interp_procs): New, factored out from _initialize_cli_interp. (cli_interp_factory): New function. (_initialize_cli_interp): Call interp_factory_register. * interps.c (get_interp_info): New, factored out from ... (get_current_interp_info): ... this. (interp_new): Add parameter 'data'. Store it. (struct interp_factory): New function. (interp_factory_p): New typedef. Define a VEC_P. (interpreter_factories): New global. (interp_factory_register): New function. (interp_add): Add 'ui' parameter. Use get_interp_info and interp_lookup_existing. (interp_lookup): Rename to ... (interp_lookup_existing): ... this. Add 'ui' parameter. Don't check for NULL or empty name here. (interp_lookup): Add 'ui' parameter and reimplement. (interp_set_temp, interpreter_exec_cmd): Adjust. (interpreter_completer): Complete on registered interpreter factories instead of interpreters. * interps.h (interp_factory_func): New typedef. (interp_factory_register): Declare. (interp_new, interp_add): Adjust. (interp_lookup): Declare. * main.c (captured_main): Adjust. * mi/mi-interp.c (mi_cmd_interpreter_exec): Adjust. (mi_interp_procs): New, factored out from _initialize_mi_interp. (mi_interp_factory): New function. * python/python.c (execute_gdb_command): Adjust. * tui/tui-interp.c (tui_init): If top level, set the tui_interp global. (tui_interp_procs): New. (tui_interp_factory): New function. (_initialize_tui_interp): Call interp_factory_register.
2016-06-21 02:11:45 +02:00
{
interp = factory.func (name);
Introduce interpreter factories If every UI instance has its own set of interpreters, then the current scheme of creating the interpreters at GDB initialization time no longer works. We need to create them whenever a new UI instance is created. The scheme implemented here has each interpreter register a factory callback that when called creates a new instance of a specific interpreter type. Then, when some code in gdb looks up an interpreter (always by name), if there's none yet, the factory method is called to construct one. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_uiout): Delete, moved into ... (struct cli_interp): ... this new structure. (cli_on_normal_stop, cli_on_signal_received) (cli_on_end_stepping_range, cli_on_signal_exited, cli_on_exited) (cli_on_no_history): Use interp_ui_out. (cli_interpreter_init): If top level, set the cli_interp global. (cli_interpreter_init): Return the interp's data instead of NULL. (cli_interpreter_resume, cli_interpreter_exec, cli_ui_out): Adjust to cli_uiout being in the interpreter's data. (cli_interp_procs): New, factored out from _initialize_cli_interp. (cli_interp_factory): New function. (_initialize_cli_interp): Call interp_factory_register. * interps.c (get_interp_info): New, factored out from ... (get_current_interp_info): ... this. (interp_new): Add parameter 'data'. Store it. (struct interp_factory): New function. (interp_factory_p): New typedef. Define a VEC_P. (interpreter_factories): New global. (interp_factory_register): New function. (interp_add): Add 'ui' parameter. Use get_interp_info and interp_lookup_existing. (interp_lookup): Rename to ... (interp_lookup_existing): ... this. Add 'ui' parameter. Don't check for NULL or empty name here. (interp_lookup): Add 'ui' parameter and reimplement. (interp_set_temp, interpreter_exec_cmd): Adjust. (interpreter_completer): Complete on registered interpreter factories instead of interpreters. * interps.h (interp_factory_func): New typedef. (interp_factory_register): Declare. (interp_new, interp_add): Adjust. (interp_lookup): Declare. * main.c (captured_main): Adjust. * mi/mi-interp.c (mi_cmd_interpreter_exec): Adjust. (mi_interp_procs): New, factored out from _initialize_mi_interp. (mi_interp_factory): New function. * python/python.c (execute_gdb_command): Adjust. * tui/tui-interp.c (tui_init): If top level, set the tui_interp global. (tui_interp_procs): New. (tui_interp_factory): New function. (_initialize_tui_interp): Call interp_factory_register.
2016-06-21 02:11:45 +02:00
interp_add (ui, interp);
return interp;
}
return NULL;
}
Add new command to create extra console/mi UIs With all the previous plumbing in place, it's now easy to add a command that actually creates a new console/mi UI. The intended use case is to make it possible and easy for MI frontends to provide a fully featured GDB console to users, with readline support, command line editing, history, etc., just like if gdb was started on the command line. Currently MI frontends have to try to implement all of that theirselves and make use of "-interpreter-exec console ...", which is far from perfect. If you ever tried Eclipse's gdb console window, you'll know what I mean... Instead of trying to multiplex console through MI, this command let's just leverage all the built in readline/editing support already inside gdb. The plan is for the MI frontend to start GDB in regular console mode, running inside a terminal emulator widget embedded in Eclipse (which already exists, for supporting the shell widget; other frontends have similar widgets), and then tell GDB to run a full MI interpreter on an specified input/output device, independent of the console. My original prototype planned to do things the other way around -- start GDB in MI mode, and then start an extra CLI console on separate tty. I handed over that prototype to Marc Khouzam @ Eclipse CDT, and after experimentation and discussion, we ended up concluding that starting GDB in CLI mode instead was both easier and actually also supported an interesting use case -- connect an Eclipse frontend to a GDB that is already running outside Eclipse. The current usage is "new-ui <interpreter> <tty>". E.g., on a terminal run this scriplet: $ cat gdb-client #!/bin/bash reset tty tail -f /dev/null $ gdb-client /dev/pts/15 Now run gdb on another terminal, and tell it to start a MI interpreter on the tty of the other terminal: ... (gdb) new-ui mi /dev/pts/15 New UI allocated Now back to the the gdb-client terminal, we'll get an MI prompt, ready for MI input: /dev/pts/15 =thread-group-added,id="i1" (gdb) You can also start a new UI running a CLI, with: (gdb) new-ui console /dev/pts/15 Though note that this console won't support readline command editing. It works as if "set editing off" was entered. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * interps.c (set_top_level_interpreter): New function, factored out from captured_main. (interpreter_completer): Make extern. * interps.h (set_top_level_interpreter, interpreter_completer): New declarations. (captured_main): Use set_top_level_interpreter. * top.c [!O_NOCTTY] (O_NOCTTY): Define as 0. (open_terminal_stream, new_ui_command): New functions. (init_main): Install the "new-ui" command.
2016-06-21 02:11:55 +02:00
/* See interps.h. */
void
set_top_level_interpreter (const char *name)
{
/* Find it. */
struct interp *interp = interp_lookup (current_ui, name);
if (interp == NULL)
error (_("Interpreter `%s' unrecognized"), name);
/* Install it. */
C++-fy struct interp/cli_interp/tui_interp/mi_interp - The interp->data field disappears, since we can put data in the interpreter directly now. The "init" method remains in place, but it now returns void. - A few places check if the interpreter method is NULL before calling it, and also check whether the method returns true/false. For some of those methods, all current implementations always return true. In those cases, this commit makes the C++-fied method return void instead and cleans up the callers. Tested on x86_64 Fedora 23. gdb/ChangeLog: 2017-02-03 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_interp_base::cli_interp_base) (cli_interp_base::~cli_interp_base): New. (cli_interp): New struct. (as_cli_interp): Cast the interp itself to cli_interp. (cli_interpreter_pre_command_loop): Rename to ... (cli_interp_base::pre_command_loop): ... this. Remove 'self' parameter. (cli_interpreter_init): Rename to ... (cli_interp::init): ... this. Remove 'self' parameter. Use boolean. Make extern. (cli_interpreter_resume): Rename to ... (cli_interp::resume): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_suspend): Rename to ... (cli_interp::suspend): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_exec): Rename to ... (cli_interp::exec): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_supports_command_editing): Rename to ... (cli_interp_base::supports_command_editing): ... this. Remove 'interp' parameter. Make extern. (cli_ui_out): Rename to ... (cli_interp::interp_ui_out): ... this. Remove 'interp' parameter. Make extern. (cli_set_logging): Rename to ... (cli_interp_base::set_logging): ... this. Remove 'interp' parameter. Make extern. (cli_interp_procs): Delete. (cli_interp_factory): Adjust to use "new". * cli/cli-interp.h: Include "interps.h". (struct cli_interp_base): New struct. * interps.c (struct interp): Delete. Fields moved to interps.h. (interp_new): Delete. (interp::interp, interp::~interp): New. (interp_set): Use bool, and return void. Assume the interpreter has suspend, init and resume methods, and that the all return void. (set_top_level_interpreter): interp_set returns void. (interp_ui_out): Adapt. (current_interp_set_logging): Adapt. (interp_data): Delete. (interp_pre_command_loop, interp_supports_command_editing): Adapt. (interp_exec): Adapt. (top_level_interpreter_data): Delete. * interps.h (interp_init_ftype, interp_resume_ftype) (interp_suspend_ftype, interp_exec_ftype) (interp_pre_command_loop_ftype, interp_ui_out_ftype): Delete. (class interp): New. (interp_new): Delete. (interp_set): Now returns void. Use bool. (interp_data, top_level_interpreter_data): Delete. * mi/mi-common.h: Include interps.h. (class mi_interp): Inherit from interp. Define a ctor. Declare init, resume, suspect, exec, interp_ui_out, set_logging and pre_command_loop methods. * mi/mi-interp.c (as_mi_interp): Cast the interp itself. (mi_interpreter_init): Rename to ... (mi_interp::init): ... this. Remove the 'interp' parameter, use bool, return void and make extern. Adjust. (mi_interpreter_resume): ... Rename to ... (mi_interp::resume): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (mi_interpreter_suspend): ... Rename to ... (mi_interp::suspend): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (mi_interpreter_exec): ... Rename to ... (mi_interp::exec): ... this. Remove the 'data' parameter and make extern. Adjust. (mi_interpreter_pre_command_loop): ... Rename to ... (mi_interp::pre_command_loop): ... this. Remove the 'self' parameter and make extern. (mi_on_normal_stop_1): Adjust. (mi_ui_out): Rename to ... (mi_interp::interp_ui_out): ... this. Remove the 'interp' parameter and make extern. Adjust. (mi_set_logging): Rename to ... (mi_interp::set_logging): ... this. Remove the 'interp' parameter and make extern. Adjust. (mi_interp_procs): Delete. (mi_interp_factory): Adjust to use 'new'. * mi/mi-main.c (mi_cmd_gdb_exit, captured_mi_execute_command) (mi_print_exception, mi_execute_command, mi_load_progress): Adjust. * tui/tui-interp.c (tui_interp): New class. (as_tui_interp): Return a tui_interp pointer. (tui_on_normal_stop, tui_on_signal_received) (tui_on_end_stepping_range, tui_on_signal_exited, tui_on_exited) (tui_on_no_history, tui_on_user_selected_context_changed): Adjust to use interp::interp_ui_out. (tui_init): Rename to ... (tui_interp::init): ... this. Remove the 'self' parameter, use bool, return void and make extern. Adjust. (tui_resume): Rename to ... (tui_interp::resume): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (tui_suspend): Rename to ... (tui_interp::suspend): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (tui_ui_out): Rename to ... (tui_interp::interp_ui_out): ... this. Remove the 'self' parameter, and make extern. Adjust. (tui_exec): Rename to ... (tui_interp::exec): ... this. Remove the 'data' parameter and make extern. (tui_interp_procs): Delete. (tui_interp_factory): Use "new".
2017-02-03 17:30:04 +01:00
interp_set (interp, true);
Add new command to create extra console/mi UIs With all the previous plumbing in place, it's now easy to add a command that actually creates a new console/mi UI. The intended use case is to make it possible and easy for MI frontends to provide a fully featured GDB console to users, with readline support, command line editing, history, etc., just like if gdb was started on the command line. Currently MI frontends have to try to implement all of that theirselves and make use of "-interpreter-exec console ...", which is far from perfect. If you ever tried Eclipse's gdb console window, you'll know what I mean... Instead of trying to multiplex console through MI, this command let's just leverage all the built in readline/editing support already inside gdb. The plan is for the MI frontend to start GDB in regular console mode, running inside a terminal emulator widget embedded in Eclipse (which already exists, for supporting the shell widget; other frontends have similar widgets), and then tell GDB to run a full MI interpreter on an specified input/output device, independent of the console. My original prototype planned to do things the other way around -- start GDB in MI mode, and then start an extra CLI console on separate tty. I handed over that prototype to Marc Khouzam @ Eclipse CDT, and after experimentation and discussion, we ended up concluding that starting GDB in CLI mode instead was both easier and actually also supported an interesting use case -- connect an Eclipse frontend to a GDB that is already running outside Eclipse. The current usage is "new-ui <interpreter> <tty>". E.g., on a terminal run this scriplet: $ cat gdb-client #!/bin/bash reset tty tail -f /dev/null $ gdb-client /dev/pts/15 Now run gdb on another terminal, and tell it to start a MI interpreter on the tty of the other terminal: ... (gdb) new-ui mi /dev/pts/15 New UI allocated Now back to the the gdb-client terminal, we'll get an MI prompt, ready for MI input: /dev/pts/15 =thread-group-added,id="i1" (gdb) You can also start a new UI running a CLI, with: (gdb) new-ui console /dev/pts/15 Though note that this console won't support readline command editing. It works as if "set editing off" was entered. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * interps.c (set_top_level_interpreter): New function, factored out from captured_main. (interpreter_completer): Make extern. * interps.h (set_top_level_interpreter, interpreter_completer): New declarations. (captured_main): Use set_top_level_interpreter. * top.c [!O_NOCTTY] (O_NOCTTY): Define as 0. (open_terminal_stream, new_ui_command): New functions. (init_main): Install the "new-ui" command.
2016-06-21 02:11:55 +02:00
}
Move "tee" building down to interpreter::set_logging_proc This patch gets rid of this hack in mi_set_logging: /* The tee created already is based on gdb_stdout, which for MI is a console and so we end up in an infinite loop of console writing to ui_file writing to console etc. So discard the existing tee (it hasn't been used yet, and MI won't ever use it), and create one based on raw_stdout instead. */ By pushing down responsibility for the tee creation to the interpreter. I.e., pushing the CLI bits out of handle_redirections down to the CLI interpreter's set_logging_proc method. This fixes a few leaks that I spotted, and then confirmed with "valgrind --leak-check=full": [...] ==21429== 56 (32 direct, 24 indirect) bytes in 1 blocks are definitely lost in loss record 30,243 of 34,980 ==21429== at 0x4C29216: operator new(unsigned long) (vg_replace_malloc.c:334) ==21429== by 0x62D9A9: mi_set_logging(interp*, int, ui_file*, ui_file*) (mi-interp.c:1395) ==21429== by 0x810B8A: current_interp_set_logging(int, ui_file*, ui_file*) (interps.c:360) ==21429== by 0x61C537: handle_redirections(int) (cli-logging.c:162) ==21429== by 0x61C6EC: set_logging_on(char*, int) (cli-logging.c:190) ==21429== by 0x6163BE: do_cfunc(cmd_list_element*, char*, int) (cli-decode.c:105) ==21429== by 0x6193C1: cmd_func(cmd_list_element*, char*, int) (cli-decode.c:1913) ==21429== by 0x8DB790: execute_command(char*, int) (top.c:674) ==21429== by 0x632AE6: mi_execute_cli_command(char const*, int, char const*) (mi-main.c:2343) ==21429== by 0x6329BA: mi_cmd_execute(mi_parse*) (mi-main.c:2306) ==21429== by 0x631E19: captured_mi_execute_command(ui_out*, mi_parse*) (mi-main.c:1998) ==21429== by 0x632389: mi_execute_command(char const*, int) (mi-main.c:2163) ==21429== [...] ==26635== 24 bytes in 1 blocks are definitely lost in loss record 20,740 of 34,995 ==26635== at 0x4C29216: operator new(unsigned long) (vg_replace_malloc.c:334) ==26635== by 0x61C355: handle_redirections(int) (cli-logging.c:131) ==26635== by 0x61C6EC: set_logging_on(char*, int) (cli-logging.c:190) ==26635== by 0x6163BE: do_cfunc(cmd_list_element*, char*, int) (cli-decode.c:105) ==26635== by 0x6193C1: cmd_func(cmd_list_element*, char*, int) (cli-decode.c:1913) ==26635== by 0x8DB7BC: execute_command(char*, int) (top.c:674) ==26635== by 0x7B9132: command_handler(char*) (event-top.c:590) ==26635== by 0x7B94F7: command_line_handler(char*) (event-top.c:780) ==26635== by 0x7B8ABB: gdb_rl_callback_handler(char*) (event-top.c:213) ==26635== by 0x933CE9: rl_callback_read_char (callback.c:220) ==26635== by 0x7B89ED: gdb_rl_callback_read_char_wrapper_noexcept() (event-top.c:175) ==26635== by 0x7B8A49: gdb_rl_callback_read_char_wrapper(void*) (event-top.c:192) One is fixed by transfering ownership of the log file to the tee. In pseudo-patch, since the code was moved at the same time: - out = new tee_file (curr_output, false, logfile.get (), false); + out = new tee_file (curr_output, false, logfile.get (), true); The other is this bit in mi_set_logging: else { + delete mi->raw_stdout; I tried to split the leak fixes to a smaller preparatory patch, but that was difficult exactly because of the tee hack in handle_redirections -> mi_set_logging. gdb/ChangeLog: 2017-02-02 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (struct saved_output_files, saved_output): Moved from cli/cli-logging.c. (cli_set_logging): New function. (cli_interp_procs): Install cli_set_logging. * cli/cli-interp.h (make_logging_output, cli_set_logging): Declare. * cli/cli-logging.c (struct saved_output_files, saved_output): Moved to cli/cli-interp.c. (pop_output_files): Don't save outputs here. (make_logging_output): New function. (handle_redirections): Don't build tee nor save previous outputs here. * interps.c (current_interp_set_logging): Change prototype. Assume there's always a set_logging_proc method installed. * interps.h (interp_set_logging_ftype): Change prototype. (current_interp_set_logging): Change prototype and adjust comment. * mi/mi-interp.c (mi_set_logging): Change protototype. Adjust to use make_logging_output. * tui/tui-interp.c (tui_interp_procs): Install cli_set_logging.
2017-02-02 23:00:43 +01:00
void
2019-05-17 15:15:01 +02:00
current_interp_set_logging (ui_file_up logfile, bool logging_redirect,
bool debug_redirect)
{
Make the interpreters be per UI Make each UI have its own interpreter list, top level interpreter, current interpreter, etc. The "interpreter_async" global is not really specific to an struct interp (it crosses interpreter-exec ...), so I moved it to "struct ui" directly, while the other globals were left hidden in interps.c, opaque to the rest of GDB. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * breakpoint.c (bpstat_do_actions_1): Access the current UI's async field instead of the interpreter_async global. * cli/cli-script.c (execute_user_command, while_command) (if_command, script_from_file): Likewise. * compile/compile.c: Include top.h instead of interps.h. (compile_file_command, compile_code_command) (compile_print_command): Access the current UI's async field instead of the interpreter_async global. * guile/guile.c: Include top.h instead of interps.h. (guile_repl_command, guile_command, gdbscm_execute_gdb_command): Access the current UI's async field instead of the interpreter_async global. * guile/scm-ports.c: Include top.h instead of interps.h. (ioscm_with_output_to_port_worker): Access the current UI's async field instead of the interpreter_async global. * inf-loop.c (inferior_event_handler): Likewise. * infcall.c (run_inferior_call): Likewise. * infrun.c (reinstall_readline_callback_handler_cleanup) (fetch_inferior_event): Likewise. * interps.c (interpreter_async): Delete. (struct ui_interp_info): New. (get_current_interp_info): New function. (interp_list, current_interpreter, top_level_interpreter_ptr): Delete. (interp_add, interp_set, interp_lookup, interp_ui_out) (current_interp_set_logging, interp_set_temp) (current_interp_named_p): Adjust to per-UI interpreters. (command_interpreter): Delete. (command_interp, current_interp_command_loop, interp_quiet_p) (interp_exec, interpreter_exec_cmd, interpreter_completer) (top_level_interpreter, top_level_interpreter_data): Adjust to per-UI interpreters. * interps.h (interpreter_async): Delete. * main.c (captured_command_loop): Access the current UI's async field instead of the interpreter_async global. * python/python.c (python_interactive_command, python_command) (execute_gdb_command): Likewise. * top.c (maybe_wait_sync_command_done, execute_command_to_string): Access the current UI's async field instead of the interpreter_async global. * top.h (struct tl_interp_info): Forward declare. (struct ui) <interp_info, async>: New fields.
2016-06-21 02:11:45 +02:00
struct ui_interp_info *ui_interp = get_current_interp_info ();
struct interp *interp = ui_interp->current_interpreter;
2019-05-17 15:15:01 +02:00
interp->set_logging (std::move (logfile), logging_redirect, debug_redirect);
}
/* Temporarily overrides the current interpreter. */
struct interp *
scoped_restore_interp::set_interp (const char *name)
{
Make the interpreters be per UI Make each UI have its own interpreter list, top level interpreter, current interpreter, etc. The "interpreter_async" global is not really specific to an struct interp (it crosses interpreter-exec ...), so I moved it to "struct ui" directly, while the other globals were left hidden in interps.c, opaque to the rest of GDB. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * breakpoint.c (bpstat_do_actions_1): Access the current UI's async field instead of the interpreter_async global. * cli/cli-script.c (execute_user_command, while_command) (if_command, script_from_file): Likewise. * compile/compile.c: Include top.h instead of interps.h. (compile_file_command, compile_code_command) (compile_print_command): Access the current UI's async field instead of the interpreter_async global. * guile/guile.c: Include top.h instead of interps.h. (guile_repl_command, guile_command, gdbscm_execute_gdb_command): Access the current UI's async field instead of the interpreter_async global. * guile/scm-ports.c: Include top.h instead of interps.h. (ioscm_with_output_to_port_worker): Access the current UI's async field instead of the interpreter_async global. * inf-loop.c (inferior_event_handler): Likewise. * infcall.c (run_inferior_call): Likewise. * infrun.c (reinstall_readline_callback_handler_cleanup) (fetch_inferior_event): Likewise. * interps.c (interpreter_async): Delete. (struct ui_interp_info): New. (get_current_interp_info): New function. (interp_list, current_interpreter, top_level_interpreter_ptr): Delete. (interp_add, interp_set, interp_lookup, interp_ui_out) (current_interp_set_logging, interp_set_temp) (current_interp_named_p): Adjust to per-UI interpreters. (command_interpreter): Delete. (command_interp, current_interp_command_loop, interp_quiet_p) (interp_exec, interpreter_exec_cmd, interpreter_completer) (top_level_interpreter, top_level_interpreter_data): Adjust to per-UI interpreters. * interps.h (interpreter_async): Delete. * main.c (captured_command_loop): Access the current UI's async field instead of the interpreter_async global. * python/python.c (python_interactive_command, python_command) (execute_gdb_command): Likewise. * top.c (maybe_wait_sync_command_done, execute_command_to_string): Access the current UI's async field instead of the interpreter_async global. * top.h (struct tl_interp_info): Forward declare. (struct ui) <interp_info, async>: New fields.
2016-06-21 02:11:45 +02:00
struct ui_interp_info *ui_interp = get_current_interp_info ();
Introduce interpreter factories If every UI instance has its own set of interpreters, then the current scheme of creating the interpreters at GDB initialization time no longer works. We need to create them whenever a new UI instance is created. The scheme implemented here has each interpreter register a factory callback that when called creates a new instance of a specific interpreter type. Then, when some code in gdb looks up an interpreter (always by name), if there's none yet, the factory method is called to construct one. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_uiout): Delete, moved into ... (struct cli_interp): ... this new structure. (cli_on_normal_stop, cli_on_signal_received) (cli_on_end_stepping_range, cli_on_signal_exited, cli_on_exited) (cli_on_no_history): Use interp_ui_out. (cli_interpreter_init): If top level, set the cli_interp global. (cli_interpreter_init): Return the interp's data instead of NULL. (cli_interpreter_resume, cli_interpreter_exec, cli_ui_out): Adjust to cli_uiout being in the interpreter's data. (cli_interp_procs): New, factored out from _initialize_cli_interp. (cli_interp_factory): New function. (_initialize_cli_interp): Call interp_factory_register. * interps.c (get_interp_info): New, factored out from ... (get_current_interp_info): ... this. (interp_new): Add parameter 'data'. Store it. (struct interp_factory): New function. (interp_factory_p): New typedef. Define a VEC_P. (interpreter_factories): New global. (interp_factory_register): New function. (interp_add): Add 'ui' parameter. Use get_interp_info and interp_lookup_existing. (interp_lookup): Rename to ... (interp_lookup_existing): ... this. Add 'ui' parameter. Don't check for NULL or empty name here. (interp_lookup): Add 'ui' parameter and reimplement. (interp_set_temp, interpreter_exec_cmd): Adjust. (interpreter_completer): Complete on registered interpreter factories instead of interpreters. * interps.h (interp_factory_func): New typedef. (interp_factory_register): Declare. (interp_new, interp_add): Adjust. (interp_lookup): Declare. * main.c (captured_main): Adjust. * mi/mi-interp.c (mi_cmd_interpreter_exec): Adjust. (mi_interp_procs): New, factored out from _initialize_mi_interp. (mi_interp_factory): New function. * python/python.c (execute_gdb_command): Adjust. * tui/tui-interp.c (tui_init): If top level, set the tui_interp global. (tui_interp_procs): New. (tui_interp_factory): New function. (_initialize_tui_interp): Call interp_factory_register.
2016-06-21 02:11:45 +02:00
struct interp *interp = interp_lookup (current_ui, name);
Make the interpreters be per UI Make each UI have its own interpreter list, top level interpreter, current interpreter, etc. The "interpreter_async" global is not really specific to an struct interp (it crosses interpreter-exec ...), so I moved it to "struct ui" directly, while the other globals were left hidden in interps.c, opaque to the rest of GDB. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * breakpoint.c (bpstat_do_actions_1): Access the current UI's async field instead of the interpreter_async global. * cli/cli-script.c (execute_user_command, while_command) (if_command, script_from_file): Likewise. * compile/compile.c: Include top.h instead of interps.h. (compile_file_command, compile_code_command) (compile_print_command): Access the current UI's async field instead of the interpreter_async global. * guile/guile.c: Include top.h instead of interps.h. (guile_repl_command, guile_command, gdbscm_execute_gdb_command): Access the current UI's async field instead of the interpreter_async global. * guile/scm-ports.c: Include top.h instead of interps.h. (ioscm_with_output_to_port_worker): Access the current UI's async field instead of the interpreter_async global. * inf-loop.c (inferior_event_handler): Likewise. * infcall.c (run_inferior_call): Likewise. * infrun.c (reinstall_readline_callback_handler_cleanup) (fetch_inferior_event): Likewise. * interps.c (interpreter_async): Delete. (struct ui_interp_info): New. (get_current_interp_info): New function. (interp_list, current_interpreter, top_level_interpreter_ptr): Delete. (interp_add, interp_set, interp_lookup, interp_ui_out) (current_interp_set_logging, interp_set_temp) (current_interp_named_p): Adjust to per-UI interpreters. (command_interpreter): Delete. (command_interp, current_interp_command_loop, interp_quiet_p) (interp_exec, interpreter_exec_cmd, interpreter_completer) (top_level_interpreter, top_level_interpreter_data): Adjust to per-UI interpreters. * interps.h (interpreter_async): Delete. * main.c (captured_command_loop): Access the current UI's async field instead of the interpreter_async global. * python/python.c (python_interactive_command, python_command) (execute_gdb_command): Likewise. * top.c (maybe_wait_sync_command_done, execute_command_to_string): Access the current UI's async field instead of the interpreter_async global. * top.h (struct tl_interp_info): Forward declare. (struct ui) <interp_info, async>: New fields.
2016-06-21 02:11:45 +02:00
struct interp *old_interp = ui_interp->current_interpreter;
if (interp)
Make the interpreters be per UI Make each UI have its own interpreter list, top level interpreter, current interpreter, etc. The "interpreter_async" global is not really specific to an struct interp (it crosses interpreter-exec ...), so I moved it to "struct ui" directly, while the other globals were left hidden in interps.c, opaque to the rest of GDB. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * breakpoint.c (bpstat_do_actions_1): Access the current UI's async field instead of the interpreter_async global. * cli/cli-script.c (execute_user_command, while_command) (if_command, script_from_file): Likewise. * compile/compile.c: Include top.h instead of interps.h. (compile_file_command, compile_code_command) (compile_print_command): Access the current UI's async field instead of the interpreter_async global. * guile/guile.c: Include top.h instead of interps.h. (guile_repl_command, guile_command, gdbscm_execute_gdb_command): Access the current UI's async field instead of the interpreter_async global. * guile/scm-ports.c: Include top.h instead of interps.h. (ioscm_with_output_to_port_worker): Access the current UI's async field instead of the interpreter_async global. * inf-loop.c (inferior_event_handler): Likewise. * infcall.c (run_inferior_call): Likewise. * infrun.c (reinstall_readline_callback_handler_cleanup) (fetch_inferior_event): Likewise. * interps.c (interpreter_async): Delete. (struct ui_interp_info): New. (get_current_interp_info): New function. (interp_list, current_interpreter, top_level_interpreter_ptr): Delete. (interp_add, interp_set, interp_lookup, interp_ui_out) (current_interp_set_logging, interp_set_temp) (current_interp_named_p): Adjust to per-UI interpreters. (command_interpreter): Delete. (command_interp, current_interp_command_loop, interp_quiet_p) (interp_exec, interpreter_exec_cmd, interpreter_completer) (top_level_interpreter, top_level_interpreter_data): Adjust to per-UI interpreters. * interps.h (interpreter_async): Delete. * main.c (captured_command_loop): Access the current UI's async field instead of the interpreter_async global. * python/python.c (python_interactive_command, python_command) (execute_gdb_command): Likewise. * top.c (maybe_wait_sync_command_done, execute_command_to_string): Access the current UI's async field instead of the interpreter_async global. * top.h (struct tl_interp_info): Forward declare. (struct ui) <interp_info, async>: New fields.
2016-06-21 02:11:45 +02:00
ui_interp->current_interpreter = interp;
return old_interp;
}
/* Returns true if the current interp is the passed in name. */
2003-02-06 06:30:17 +01:00
int
current_interp_named_p (const char *interp_name)
{
Make the interpreters be per UI Make each UI have its own interpreter list, top level interpreter, current interpreter, etc. The "interpreter_async" global is not really specific to an struct interp (it crosses interpreter-exec ...), so I moved it to "struct ui" directly, while the other globals were left hidden in interps.c, opaque to the rest of GDB. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * breakpoint.c (bpstat_do_actions_1): Access the current UI's async field instead of the interpreter_async global. * cli/cli-script.c (execute_user_command, while_command) (if_command, script_from_file): Likewise. * compile/compile.c: Include top.h instead of interps.h. (compile_file_command, compile_code_command) (compile_print_command): Access the current UI's async field instead of the interpreter_async global. * guile/guile.c: Include top.h instead of interps.h. (guile_repl_command, guile_command, gdbscm_execute_gdb_command): Access the current UI's async field instead of the interpreter_async global. * guile/scm-ports.c: Include top.h instead of interps.h. (ioscm_with_output_to_port_worker): Access the current UI's async field instead of the interpreter_async global. * inf-loop.c (inferior_event_handler): Likewise. * infcall.c (run_inferior_call): Likewise. * infrun.c (reinstall_readline_callback_handler_cleanup) (fetch_inferior_event): Likewise. * interps.c (interpreter_async): Delete. (struct ui_interp_info): New. (get_current_interp_info): New function. (interp_list, current_interpreter, top_level_interpreter_ptr): Delete. (interp_add, interp_set, interp_lookup, interp_ui_out) (current_interp_set_logging, interp_set_temp) (current_interp_named_p): Adjust to per-UI interpreters. (command_interpreter): Delete. (command_interp, current_interp_command_loop, interp_quiet_p) (interp_exec, interpreter_exec_cmd, interpreter_completer) (top_level_interpreter, top_level_interpreter_data): Adjust to per-UI interpreters. * interps.h (interpreter_async): Delete. * main.c (captured_command_loop): Access the current UI's async field instead of the interpreter_async global. * python/python.c (python_interactive_command, python_command) (execute_gdb_command): Likewise. * top.c (maybe_wait_sync_command_done, execute_command_to_string): Access the current UI's async field instead of the interpreter_async global. * top.h (struct tl_interp_info): Forward declare. (struct ui) <interp_info, async>: New fields.
2016-06-21 02:11:45 +02:00
struct ui_interp_info *ui_interp = get_current_interp_info ();
struct interp *interp = ui_interp->current_interpreter;
if (interp != NULL)
return (strcmp (interp->name (), interp_name) == 0);
2003-02-06 06:30:17 +01:00
return 0;
}
PR gdb/13860: don't lose '-interpreter-exec console EXECUTION_COMMAND''s output in async mode. The other part of PR gdb/13860 is about console execution commands in MI getting their output half lost. E.g., take the finish command, executed on a frontend's GDB console: sync: finish &"finish\n" ~"Run till exit from #0 usleep (useconds=10) at ../sysdeps/unix/sysv/linux/usleep.c:27\n" ^running *running,thread-id="1" (gdb) ~"0x00000000004004d7 in foo () at stepinf.c:6\n" ~"6\t usleep (10);\n" ~"Value returned is $1 = 0\n" *stopped,reason="function-finished",frame={addr="0x00000000004004d7",func="foo",args=[],file="stepinf.c",fullname="/home/pedro/gdb/tests/stepinf.c",line="6"},thread-id="1",stopped-threads="all",core="1" async: finish &"finish\n" ~"Run till exit from #0 usleep (useconds=10) at ../sysdeps/unix/sysv/linux/usleep.c:27\n" ^running *running,thread-id="1" (gdb) *stopped,reason="function-finished",frame={addr="0x00000000004004d7",func="foo",args=[],file="stepinf.c",fullname="/home/pedro/gdb/tests/stepinf.c",line="6"},gdb-result-var="$1",return-value="0",thread-id="1",stopped-threads="all",core="0" Note how all the "Value returned" etc. output is missing in async mode. The same happens with e.g., catchpoints: =breakpoint-modified,bkpt={number="1",type="catchpoint",disp="keep",enabled="y",what="22016",times="1"} ~"\nCatchpoint " ~"1 (forked process 22016), 0x0000003791cbd8a6 in __libc_fork () at ../nptl/sysdeps/unix/sysv/linux/fork.c:131\n" ~"131\t pid = ARCH_FORK ();\n" *stopped,reason="fork",disp="keep",bkptno="1",newpid="22016",frame={addr="0x0000003791cbd8a6",func="__libc_fork",args=[],file="../nptl/sysdeps/unix/sysv/linux/fork.c",fullname="/usr/src/debug/glibc-2.14-394-g8f3b1ff/nptl/sysdeps/unix/sysv/linux/fork.c",line="131"},thread-id="1",stopped-threads="all",core="0" where all those ~ lines are missing in async mode, or just the "step" current line indication: s &"s\n" ^running *running,thread-id="all" (gdb) ~"13\t foo ();\n" *stopped,frame={addr="0x00000000004004ef",func="main",args=[{name="argc",value="1"},{name="argv",value="0x7fffffffdd78"}],file="stepinf.c",fullname="/home/pedro/gdb/tests/stepinf.c",line="13"},thread-id="1",stopped-threads="all",core="3" (gdb) Or in the case of the PRs example, the "Stopped due to shared library event" note: start &"start\n" ~"Temporary breakpoint 1 at 0x400608: file ../../../src/gdb/testsuite/gdb.mi/solib-main.c, line 21.\n" =breakpoint-created,bkpt={number="1",type="breakpoint",disp="del",enabled="y",addr="0x0000000000400608",func="main",file="../../../src/gdb/testsuite/gdb.mi/solib-main.c",fullname="/home/pedro/gdb/mygit/src/gdb/testsuite/gdb.mi/solib-main.c",line="21",times="0",original-location="main"} ~"Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.mi/solib-main \n" =thread-group-started,id="i1",pid="21990" =thread-created,id="1",group-id="i1" ^running *running,thread-id="all" (gdb) =library-loaded,id="/lib64/ld-linux-x86-64.so.2",target-name="/lib64/ld-linux-x86-64.so.2",host-name="/lib64/ld-linux-x86-64.so.2",symbols-loaded="0",thread-group="i1" ~"Stopped due to shared library event (no libraries added or removed)\n" *stopped,reason="solib-event",thread-id="1",stopped-threads="all",core="3" (gdb) IMO, if you're typing execution commands in a frontend's console, you expect to see their output. Indeed it's what you get in sync mode. I think async mode should do the same. Deciding what to mirror to the console wrt to breakpoints and random stops gets messy real fast. E.g., say "s" trips on a breakpoint. We'd clearly want to mirror the event to the console in this case. But what about more complicated cases like "s&; thread n; s&", and one of those steps spawning a new thread, and that thread hitting a breakpoint? It's impossible in general to track whether the thread had any relation to the commands that had been executed. So I think we should just simplify and always mirror breakpoints and random events to the console. Notes: - mi->out is the same as gdb_stdout when MI is the current interpreter. I think that referring to that directly is cleaner. An earlier revision of this patch made the changes that are now done in mi_on_normal_stop directly in infrun.c:normal_stop, and so not having an obvious place to put the new uiout by then, and not wanting to abuse CLI's uiout, I made a temporary uiout when necessary. - Hopefuly the rest of the patch is more or less obvious given the comments added. Tested on x86_64 Fedora 20, no regressions. 2014-05-21 Pedro Alves <palves@redhat.com> PR gdb/13860 * gdbthread.h (struct thread_control_state): New field `command_interp'. * infrun.c (follow_fork): Copy the new thread control field to the child fork thread. (clear_proceed_status_thread): Clear the new thread control field. (proceed): Set the new thread control field. * interps.h (command_interp): Declare. * interps.c (command_interpreter): New global. (command_interp): New function. (interp_exec): Set `command_interpreter' while here. * cli-out.c (cli_uiout_dtor): New function. (cli_ui_out_impl): Install it. * mi/mi-interp.c: Include cli-out.h. (mi_cmd_interpreter_exec): Add comment. (restore_current_uiout_cleanup): New function. (ui_out_free_cleanup): New function. (mi_on_normal_stop): If finishing an execution command started by a CLI command, or any kind of breakpoint-like event triggered, print the stop event to the output (CLI) stream. * mi/mi-out.c (mi_ui_out_impl): Install NULL `dtor' handler. 2014-05-21 Pedro Alves <palves@redhat.com> PR gdb/13860 * gdb.mi/mi-cli.exp (line_callee4_next_step): New global. (top level): Test that output related to execution commands is sent to the console with CLI commands, but not with MI commands. Test that breakpoint events are always mirrored to the console. Also expect the new source line to be output after a "next" in async mode too. Make it a pass/fail test. * gdb.mi/mi-solib.exp: Test that the CLI solib event note is output. * lib/mi-support.exp (mi_gdb_expect_cli_output): New procedure.
2014-03-11 21:31:36 +01:00
/* The interpreter that was active when a command was executed.
Normally that'd always be CURRENT_INTERPRETER, except that MI's
-interpreter-exec command doesn't actually flip the current
interpreter when running its sub-command. The
`command_interpreter' global tracks when interp_exec is called
(IOW, when -interpreter-exec is called). If that is set, it is
INTERP in '-interpreter-exec INTERP "CMD"' or in 'interpreter-exec
INTERP "CMD". Otherwise, interp_exec isn't active, and so the
interpreter running the command is the current interpreter. */
struct interp *
command_interp (void)
{
Make the interpreters be per UI Make each UI have its own interpreter list, top level interpreter, current interpreter, etc. The "interpreter_async" global is not really specific to an struct interp (it crosses interpreter-exec ...), so I moved it to "struct ui" directly, while the other globals were left hidden in interps.c, opaque to the rest of GDB. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * breakpoint.c (bpstat_do_actions_1): Access the current UI's async field instead of the interpreter_async global. * cli/cli-script.c (execute_user_command, while_command) (if_command, script_from_file): Likewise. * compile/compile.c: Include top.h instead of interps.h. (compile_file_command, compile_code_command) (compile_print_command): Access the current UI's async field instead of the interpreter_async global. * guile/guile.c: Include top.h instead of interps.h. (guile_repl_command, guile_command, gdbscm_execute_gdb_command): Access the current UI's async field instead of the interpreter_async global. * guile/scm-ports.c: Include top.h instead of interps.h. (ioscm_with_output_to_port_worker): Access the current UI's async field instead of the interpreter_async global. * inf-loop.c (inferior_event_handler): Likewise. * infcall.c (run_inferior_call): Likewise. * infrun.c (reinstall_readline_callback_handler_cleanup) (fetch_inferior_event): Likewise. * interps.c (interpreter_async): Delete. (struct ui_interp_info): New. (get_current_interp_info): New function. (interp_list, current_interpreter, top_level_interpreter_ptr): Delete. (interp_add, interp_set, interp_lookup, interp_ui_out) (current_interp_set_logging, interp_set_temp) (current_interp_named_p): Adjust to per-UI interpreters. (command_interpreter): Delete. (command_interp, current_interp_command_loop, interp_quiet_p) (interp_exec, interpreter_exec_cmd, interpreter_completer) (top_level_interpreter, top_level_interpreter_data): Adjust to per-UI interpreters. * interps.h (interpreter_async): Delete. * main.c (captured_command_loop): Access the current UI's async field instead of the interpreter_async global. * python/python.c (python_interactive_command, python_command) (execute_gdb_command): Likewise. * top.c (maybe_wait_sync_command_done, execute_command_to_string): Access the current UI's async field instead of the interpreter_async global. * top.h (struct tl_interp_info): Forward declare. (struct ui) <interp_info, async>: New fields.
2016-06-21 02:11:45 +02:00
struct ui_interp_info *ui_interp = get_current_interp_info ();
if (ui_interp->command_interpreter != NULL)
return ui_interp->command_interpreter;
PR gdb/13860: don't lose '-interpreter-exec console EXECUTION_COMMAND''s output in async mode. The other part of PR gdb/13860 is about console execution commands in MI getting their output half lost. E.g., take the finish command, executed on a frontend's GDB console: sync: finish &"finish\n" ~"Run till exit from #0 usleep (useconds=10) at ../sysdeps/unix/sysv/linux/usleep.c:27\n" ^running *running,thread-id="1" (gdb) ~"0x00000000004004d7 in foo () at stepinf.c:6\n" ~"6\t usleep (10);\n" ~"Value returned is $1 = 0\n" *stopped,reason="function-finished",frame={addr="0x00000000004004d7",func="foo",args=[],file="stepinf.c",fullname="/home/pedro/gdb/tests/stepinf.c",line="6"},thread-id="1",stopped-threads="all",core="1" async: finish &"finish\n" ~"Run till exit from #0 usleep (useconds=10) at ../sysdeps/unix/sysv/linux/usleep.c:27\n" ^running *running,thread-id="1" (gdb) *stopped,reason="function-finished",frame={addr="0x00000000004004d7",func="foo",args=[],file="stepinf.c",fullname="/home/pedro/gdb/tests/stepinf.c",line="6"},gdb-result-var="$1",return-value="0",thread-id="1",stopped-threads="all",core="0" Note how all the "Value returned" etc. output is missing in async mode. The same happens with e.g., catchpoints: =breakpoint-modified,bkpt={number="1",type="catchpoint",disp="keep",enabled="y",what="22016",times="1"} ~"\nCatchpoint " ~"1 (forked process 22016), 0x0000003791cbd8a6 in __libc_fork () at ../nptl/sysdeps/unix/sysv/linux/fork.c:131\n" ~"131\t pid = ARCH_FORK ();\n" *stopped,reason="fork",disp="keep",bkptno="1",newpid="22016",frame={addr="0x0000003791cbd8a6",func="__libc_fork",args=[],file="../nptl/sysdeps/unix/sysv/linux/fork.c",fullname="/usr/src/debug/glibc-2.14-394-g8f3b1ff/nptl/sysdeps/unix/sysv/linux/fork.c",line="131"},thread-id="1",stopped-threads="all",core="0" where all those ~ lines are missing in async mode, or just the "step" current line indication: s &"s\n" ^running *running,thread-id="all" (gdb) ~"13\t foo ();\n" *stopped,frame={addr="0x00000000004004ef",func="main",args=[{name="argc",value="1"},{name="argv",value="0x7fffffffdd78"}],file="stepinf.c",fullname="/home/pedro/gdb/tests/stepinf.c",line="13"},thread-id="1",stopped-threads="all",core="3" (gdb) Or in the case of the PRs example, the "Stopped due to shared library event" note: start &"start\n" ~"Temporary breakpoint 1 at 0x400608: file ../../../src/gdb/testsuite/gdb.mi/solib-main.c, line 21.\n" =breakpoint-created,bkpt={number="1",type="breakpoint",disp="del",enabled="y",addr="0x0000000000400608",func="main",file="../../../src/gdb/testsuite/gdb.mi/solib-main.c",fullname="/home/pedro/gdb/mygit/src/gdb/testsuite/gdb.mi/solib-main.c",line="21",times="0",original-location="main"} ~"Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.mi/solib-main \n" =thread-group-started,id="i1",pid="21990" =thread-created,id="1",group-id="i1" ^running *running,thread-id="all" (gdb) =library-loaded,id="/lib64/ld-linux-x86-64.so.2",target-name="/lib64/ld-linux-x86-64.so.2",host-name="/lib64/ld-linux-x86-64.so.2",symbols-loaded="0",thread-group="i1" ~"Stopped due to shared library event (no libraries added or removed)\n" *stopped,reason="solib-event",thread-id="1",stopped-threads="all",core="3" (gdb) IMO, if you're typing execution commands in a frontend's console, you expect to see their output. Indeed it's what you get in sync mode. I think async mode should do the same. Deciding what to mirror to the console wrt to breakpoints and random stops gets messy real fast. E.g., say "s" trips on a breakpoint. We'd clearly want to mirror the event to the console in this case. But what about more complicated cases like "s&; thread n; s&", and one of those steps spawning a new thread, and that thread hitting a breakpoint? It's impossible in general to track whether the thread had any relation to the commands that had been executed. So I think we should just simplify and always mirror breakpoints and random events to the console. Notes: - mi->out is the same as gdb_stdout when MI is the current interpreter. I think that referring to that directly is cleaner. An earlier revision of this patch made the changes that are now done in mi_on_normal_stop directly in infrun.c:normal_stop, and so not having an obvious place to put the new uiout by then, and not wanting to abuse CLI's uiout, I made a temporary uiout when necessary. - Hopefuly the rest of the patch is more or less obvious given the comments added. Tested on x86_64 Fedora 20, no regressions. 2014-05-21 Pedro Alves <palves@redhat.com> PR gdb/13860 * gdbthread.h (struct thread_control_state): New field `command_interp'. * infrun.c (follow_fork): Copy the new thread control field to the child fork thread. (clear_proceed_status_thread): Clear the new thread control field. (proceed): Set the new thread control field. * interps.h (command_interp): Declare. * interps.c (command_interpreter): New global. (command_interp): New function. (interp_exec): Set `command_interpreter' while here. * cli-out.c (cli_uiout_dtor): New function. (cli_ui_out_impl): Install it. * mi/mi-interp.c: Include cli-out.h. (mi_cmd_interpreter_exec): Add comment. (restore_current_uiout_cleanup): New function. (ui_out_free_cleanup): New function. (mi_on_normal_stop): If finishing an execution command started by a CLI command, or any kind of breakpoint-like event triggered, print the stop event to the output (CLI) stream. * mi/mi-out.c (mi_ui_out_impl): Install NULL `dtor' handler. 2014-05-21 Pedro Alves <palves@redhat.com> PR gdb/13860 * gdb.mi/mi-cli.exp (line_callee4_next_step): New global. (top level): Test that output related to execution commands is sent to the console with CLI commands, but not with MI commands. Test that breakpoint events are always mirrored to the console. Also expect the new source line to be output after a "next" in async mode too. Make it a pass/fail test. * gdb.mi/mi-solib.exp: Test that the CLI solib event note is output. * lib/mi-support.exp (mi_gdb_expect_cli_output): New procedure.
2014-03-11 21:31:36 +01:00
else
Make the interpreters be per UI Make each UI have its own interpreter list, top level interpreter, current interpreter, etc. The "interpreter_async" global is not really specific to an struct interp (it crosses interpreter-exec ...), so I moved it to "struct ui" directly, while the other globals were left hidden in interps.c, opaque to the rest of GDB. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * breakpoint.c (bpstat_do_actions_1): Access the current UI's async field instead of the interpreter_async global. * cli/cli-script.c (execute_user_command, while_command) (if_command, script_from_file): Likewise. * compile/compile.c: Include top.h instead of interps.h. (compile_file_command, compile_code_command) (compile_print_command): Access the current UI's async field instead of the interpreter_async global. * guile/guile.c: Include top.h instead of interps.h. (guile_repl_command, guile_command, gdbscm_execute_gdb_command): Access the current UI's async field instead of the interpreter_async global. * guile/scm-ports.c: Include top.h instead of interps.h. (ioscm_with_output_to_port_worker): Access the current UI's async field instead of the interpreter_async global. * inf-loop.c (inferior_event_handler): Likewise. * infcall.c (run_inferior_call): Likewise. * infrun.c (reinstall_readline_callback_handler_cleanup) (fetch_inferior_event): Likewise. * interps.c (interpreter_async): Delete. (struct ui_interp_info): New. (get_current_interp_info): New function. (interp_list, current_interpreter, top_level_interpreter_ptr): Delete. (interp_add, interp_set, interp_lookup, interp_ui_out) (current_interp_set_logging, interp_set_temp) (current_interp_named_p): Adjust to per-UI interpreters. (command_interpreter): Delete. (command_interp, current_interp_command_loop, interp_quiet_p) (interp_exec, interpreter_exec_cmd, interpreter_completer) (top_level_interpreter, top_level_interpreter_data): Adjust to per-UI interpreters. * interps.h (interpreter_async): Delete. * main.c (captured_command_loop): Access the current UI's async field instead of the interpreter_async global. * python/python.c (python_interactive_command, python_command) (execute_gdb_command): Likewise. * top.c (maybe_wait_sync_command_done, execute_command_to_string): Access the current UI's async field instead of the interpreter_async global. * top.h (struct tl_interp_info): Forward declare. (struct ui) <interp_info, async>: New fields.
2016-06-21 02:11:45 +02:00
return ui_interp->current_interpreter;
PR gdb/13860: don't lose '-interpreter-exec console EXECUTION_COMMAND''s output in async mode. The other part of PR gdb/13860 is about console execution commands in MI getting their output half lost. E.g., take the finish command, executed on a frontend's GDB console: sync: finish &"finish\n" ~"Run till exit from #0 usleep (useconds=10) at ../sysdeps/unix/sysv/linux/usleep.c:27\n" ^running *running,thread-id="1" (gdb) ~"0x00000000004004d7 in foo () at stepinf.c:6\n" ~"6\t usleep (10);\n" ~"Value returned is $1 = 0\n" *stopped,reason="function-finished",frame={addr="0x00000000004004d7",func="foo",args=[],file="stepinf.c",fullname="/home/pedro/gdb/tests/stepinf.c",line="6"},thread-id="1",stopped-threads="all",core="1" async: finish &"finish\n" ~"Run till exit from #0 usleep (useconds=10) at ../sysdeps/unix/sysv/linux/usleep.c:27\n" ^running *running,thread-id="1" (gdb) *stopped,reason="function-finished",frame={addr="0x00000000004004d7",func="foo",args=[],file="stepinf.c",fullname="/home/pedro/gdb/tests/stepinf.c",line="6"},gdb-result-var="$1",return-value="0",thread-id="1",stopped-threads="all",core="0" Note how all the "Value returned" etc. output is missing in async mode. The same happens with e.g., catchpoints: =breakpoint-modified,bkpt={number="1",type="catchpoint",disp="keep",enabled="y",what="22016",times="1"} ~"\nCatchpoint " ~"1 (forked process 22016), 0x0000003791cbd8a6 in __libc_fork () at ../nptl/sysdeps/unix/sysv/linux/fork.c:131\n" ~"131\t pid = ARCH_FORK ();\n" *stopped,reason="fork",disp="keep",bkptno="1",newpid="22016",frame={addr="0x0000003791cbd8a6",func="__libc_fork",args=[],file="../nptl/sysdeps/unix/sysv/linux/fork.c",fullname="/usr/src/debug/glibc-2.14-394-g8f3b1ff/nptl/sysdeps/unix/sysv/linux/fork.c",line="131"},thread-id="1",stopped-threads="all",core="0" where all those ~ lines are missing in async mode, or just the "step" current line indication: s &"s\n" ^running *running,thread-id="all" (gdb) ~"13\t foo ();\n" *stopped,frame={addr="0x00000000004004ef",func="main",args=[{name="argc",value="1"},{name="argv",value="0x7fffffffdd78"}],file="stepinf.c",fullname="/home/pedro/gdb/tests/stepinf.c",line="13"},thread-id="1",stopped-threads="all",core="3" (gdb) Or in the case of the PRs example, the "Stopped due to shared library event" note: start &"start\n" ~"Temporary breakpoint 1 at 0x400608: file ../../../src/gdb/testsuite/gdb.mi/solib-main.c, line 21.\n" =breakpoint-created,bkpt={number="1",type="breakpoint",disp="del",enabled="y",addr="0x0000000000400608",func="main",file="../../../src/gdb/testsuite/gdb.mi/solib-main.c",fullname="/home/pedro/gdb/mygit/src/gdb/testsuite/gdb.mi/solib-main.c",line="21",times="0",original-location="main"} ~"Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.mi/solib-main \n" =thread-group-started,id="i1",pid="21990" =thread-created,id="1",group-id="i1" ^running *running,thread-id="all" (gdb) =library-loaded,id="/lib64/ld-linux-x86-64.so.2",target-name="/lib64/ld-linux-x86-64.so.2",host-name="/lib64/ld-linux-x86-64.so.2",symbols-loaded="0",thread-group="i1" ~"Stopped due to shared library event (no libraries added or removed)\n" *stopped,reason="solib-event",thread-id="1",stopped-threads="all",core="3" (gdb) IMO, if you're typing execution commands in a frontend's console, you expect to see their output. Indeed it's what you get in sync mode. I think async mode should do the same. Deciding what to mirror to the console wrt to breakpoints and random stops gets messy real fast. E.g., say "s" trips on a breakpoint. We'd clearly want to mirror the event to the console in this case. But what about more complicated cases like "s&; thread n; s&", and one of those steps spawning a new thread, and that thread hitting a breakpoint? It's impossible in general to track whether the thread had any relation to the commands that had been executed. So I think we should just simplify and always mirror breakpoints and random events to the console. Notes: - mi->out is the same as gdb_stdout when MI is the current interpreter. I think that referring to that directly is cleaner. An earlier revision of this patch made the changes that are now done in mi_on_normal_stop directly in infrun.c:normal_stop, and so not having an obvious place to put the new uiout by then, and not wanting to abuse CLI's uiout, I made a temporary uiout when necessary. - Hopefuly the rest of the patch is more or less obvious given the comments added. Tested on x86_64 Fedora 20, no regressions. 2014-05-21 Pedro Alves <palves@redhat.com> PR gdb/13860 * gdbthread.h (struct thread_control_state): New field `command_interp'. * infrun.c (follow_fork): Copy the new thread control field to the child fork thread. (clear_proceed_status_thread): Clear the new thread control field. (proceed): Set the new thread control field. * interps.h (command_interp): Declare. * interps.c (command_interpreter): New global. (command_interp): New function. (interp_exec): Set `command_interpreter' while here. * cli-out.c (cli_uiout_dtor): New function. (cli_ui_out_impl): Install it. * mi/mi-interp.c: Include cli-out.h. (mi_cmd_interpreter_exec): Add comment. (restore_current_uiout_cleanup): New function. (ui_out_free_cleanup): New function. (mi_on_normal_stop): If finishing an execution command started by a CLI command, or any kind of breakpoint-like event triggered, print the stop event to the output (CLI) stream. * mi/mi-out.c (mi_ui_out_impl): Install NULL `dtor' handler. 2014-05-21 Pedro Alves <palves@redhat.com> PR gdb/13860 * gdb.mi/mi-cli.exp (line_callee4_next_step): New global. (top level): Test that output related to execution commands is sent to the console with CLI commands, but not with MI commands. Test that breakpoint events are always mirrored to the console. Also expect the new source line to be output after a "next" in async mode too. Make it a pass/fail test. * gdb.mi/mi-solib.exp: Test that the CLI solib event note is output. * lib/mi-support.exp (mi_gdb_expect_cli_output): New procedure.
2014-03-11 21:31:36 +01:00
}
Simplify starting the command event loop All interpreter types (CLI/TUI/MI) print the prompt, and then call start_event_loop. Because we'll need an interpreter hook to display the interpreter-specific prompt before going back to the event loop, without actually starting an event loop, this patch moves the start_event_loop call to common code, and replaces the command_loop hook with a pre_command_look hook, that now just prints the prompt. Turns out to be a cleanup on its own right anyway. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_interpreter_pre_command_loop): New function. (cli_interp_procs): Install it instead of cli_command_loop. * cli/cli-interp.h (cli_interpreter_pre_command_loop): Declare. * event-top.c (cli_command_loop): Delete. * interps.c (interp_new): Remove reference to command_loop_proc. (current_interp_command_loop): Delete. (interp_pre_command_loop): New function. (interp_command_loop_ftype): Delete. * interps.h (interp_pre_command_loop_ftype): New typedef. (struct interp_procs) <command_loop_proc>: Delele field. <pre_command_loop_proc>: New field. (current_interp_command_loop): Delete declaration. (interp_pre_command_loop): New declaration. * main.c (captured_command_loop): Call interp_pre_command_loop instead of current_interp_command_loop and start an event loop. * mi/mi-interp.c (mi_command_loop): Delete. (mi_interpreter_pre_command_loop): New. (mi_interp_procs): Update. * tui/tui-interp.c (tui_interp_procs): Install cli_interpreter_pre_command_loop instead of cli_command_loop.
2016-06-21 02:11:51 +02:00
/* See interps.h. */
2003-02-06 06:30:17 +01:00
void
Simplify starting the command event loop All interpreter types (CLI/TUI/MI) print the prompt, and then call start_event_loop. Because we'll need an interpreter hook to display the interpreter-specific prompt before going back to the event loop, without actually starting an event loop, this patch moves the start_event_loop call to common code, and replaces the command_loop hook with a pre_command_look hook, that now just prints the prompt. Turns out to be a cleanup on its own right anyway. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_interpreter_pre_command_loop): New function. (cli_interp_procs): Install it instead of cli_command_loop. * cli/cli-interp.h (cli_interpreter_pre_command_loop): Declare. * event-top.c (cli_command_loop): Delete. * interps.c (interp_new): Remove reference to command_loop_proc. (current_interp_command_loop): Delete. (interp_pre_command_loop): New function. (interp_command_loop_ftype): Delete. * interps.h (interp_pre_command_loop_ftype): New typedef. (struct interp_procs) <command_loop_proc>: Delele field. <pre_command_loop_proc>: New field. (current_interp_command_loop): Delete declaration. (interp_pre_command_loop): New declaration. * main.c (captured_command_loop): Call interp_pre_command_loop instead of current_interp_command_loop and start an event loop. * mi/mi-interp.c (mi_command_loop): Delete. (mi_interpreter_pre_command_loop): New. (mi_interp_procs): Update. * tui/tui-interp.c (tui_interp_procs): Install cli_interpreter_pre_command_loop instead of cli_command_loop.
2016-06-21 02:11:51 +02:00
interp_pre_command_loop (struct interp *interp)
2003-02-06 06:30:17 +01:00
{
Simplify starting the command event loop All interpreter types (CLI/TUI/MI) print the prompt, and then call start_event_loop. Because we'll need an interpreter hook to display the interpreter-specific prompt before going back to the event loop, without actually starting an event loop, this patch moves the start_event_loop call to common code, and replaces the command_loop hook with a pre_command_look hook, that now just prints the prompt. Turns out to be a cleanup on its own right anyway. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_interpreter_pre_command_loop): New function. (cli_interp_procs): Install it instead of cli_command_loop. * cli/cli-interp.h (cli_interpreter_pre_command_loop): Declare. * event-top.c (cli_command_loop): Delete. * interps.c (interp_new): Remove reference to command_loop_proc. (current_interp_command_loop): Delete. (interp_pre_command_loop): New function. (interp_command_loop_ftype): Delete. * interps.h (interp_pre_command_loop_ftype): New typedef. (struct interp_procs) <command_loop_proc>: Delele field. <pre_command_loop_proc>: New field. (current_interp_command_loop): Delete declaration. (interp_pre_command_loop): New declaration. * main.c (captured_command_loop): Call interp_pre_command_loop instead of current_interp_command_loop and start an event loop. * mi/mi-interp.c (mi_command_loop): Delete. (mi_interpreter_pre_command_loop): New. (mi_interp_procs): Update. * tui/tui-interp.c (tui_interp_procs): Install cli_interpreter_pre_command_loop instead of cli_command_loop.
2016-06-21 02:11:51 +02:00
gdb_assert (interp != NULL);
C++-fy struct interp/cli_interp/tui_interp/mi_interp - The interp->data field disappears, since we can put data in the interpreter directly now. The "init" method remains in place, but it now returns void. - A few places check if the interpreter method is NULL before calling it, and also check whether the method returns true/false. For some of those methods, all current implementations always return true. In those cases, this commit makes the C++-fied method return void instead and cleans up the callers. Tested on x86_64 Fedora 23. gdb/ChangeLog: 2017-02-03 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_interp_base::cli_interp_base) (cli_interp_base::~cli_interp_base): New. (cli_interp): New struct. (as_cli_interp): Cast the interp itself to cli_interp. (cli_interpreter_pre_command_loop): Rename to ... (cli_interp_base::pre_command_loop): ... this. Remove 'self' parameter. (cli_interpreter_init): Rename to ... (cli_interp::init): ... this. Remove 'self' parameter. Use boolean. Make extern. (cli_interpreter_resume): Rename to ... (cli_interp::resume): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_suspend): Rename to ... (cli_interp::suspend): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_exec): Rename to ... (cli_interp::exec): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_supports_command_editing): Rename to ... (cli_interp_base::supports_command_editing): ... this. Remove 'interp' parameter. Make extern. (cli_ui_out): Rename to ... (cli_interp::interp_ui_out): ... this. Remove 'interp' parameter. Make extern. (cli_set_logging): Rename to ... (cli_interp_base::set_logging): ... this. Remove 'interp' parameter. Make extern. (cli_interp_procs): Delete. (cli_interp_factory): Adjust to use "new". * cli/cli-interp.h: Include "interps.h". (struct cli_interp_base): New struct. * interps.c (struct interp): Delete. Fields moved to interps.h. (interp_new): Delete. (interp::interp, interp::~interp): New. (interp_set): Use bool, and return void. Assume the interpreter has suspend, init and resume methods, and that the all return void. (set_top_level_interpreter): interp_set returns void. (interp_ui_out): Adapt. (current_interp_set_logging): Adapt. (interp_data): Delete. (interp_pre_command_loop, interp_supports_command_editing): Adapt. (interp_exec): Adapt. (top_level_interpreter_data): Delete. * interps.h (interp_init_ftype, interp_resume_ftype) (interp_suspend_ftype, interp_exec_ftype) (interp_pre_command_loop_ftype, interp_ui_out_ftype): Delete. (class interp): New. (interp_new): Delete. (interp_set): Now returns void. Use bool. (interp_data, top_level_interpreter_data): Delete. * mi/mi-common.h: Include interps.h. (class mi_interp): Inherit from interp. Define a ctor. Declare init, resume, suspect, exec, interp_ui_out, set_logging and pre_command_loop methods. * mi/mi-interp.c (as_mi_interp): Cast the interp itself. (mi_interpreter_init): Rename to ... (mi_interp::init): ... this. Remove the 'interp' parameter, use bool, return void and make extern. Adjust. (mi_interpreter_resume): ... Rename to ... (mi_interp::resume): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (mi_interpreter_suspend): ... Rename to ... (mi_interp::suspend): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (mi_interpreter_exec): ... Rename to ... (mi_interp::exec): ... this. Remove the 'data' parameter and make extern. Adjust. (mi_interpreter_pre_command_loop): ... Rename to ... (mi_interp::pre_command_loop): ... this. Remove the 'self' parameter and make extern. (mi_on_normal_stop_1): Adjust. (mi_ui_out): Rename to ... (mi_interp::interp_ui_out): ... this. Remove the 'interp' parameter and make extern. Adjust. (mi_set_logging): Rename to ... (mi_interp::set_logging): ... this. Remove the 'interp' parameter and make extern. Adjust. (mi_interp_procs): Delete. (mi_interp_factory): Adjust to use 'new'. * mi/mi-main.c (mi_cmd_gdb_exit, captured_mi_execute_command) (mi_print_exception, mi_execute_command, mi_load_progress): Adjust. * tui/tui-interp.c (tui_interp): New class. (as_tui_interp): Return a tui_interp pointer. (tui_on_normal_stop, tui_on_signal_received) (tui_on_end_stepping_range, tui_on_signal_exited, tui_on_exited) (tui_on_no_history, tui_on_user_selected_context_changed): Adjust to use interp::interp_ui_out. (tui_init): Rename to ... (tui_interp::init): ... this. Remove the 'self' parameter, use bool, return void and make extern. Adjust. (tui_resume): Rename to ... (tui_interp::resume): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (tui_suspend): Rename to ... (tui_interp::suspend): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (tui_ui_out): Rename to ... (tui_interp::interp_ui_out): ... this. Remove the 'self' parameter, and make extern. Adjust. (tui_exec): Rename to ... (tui_interp::exec): ... this. Remove the 'data' parameter and make extern. (tui_interp_procs): Delete. (tui_interp_factory): Use "new".
2017-02-03 17:30:04 +01:00
interp->pre_command_loop ();
2003-02-06 06:30:17 +01:00
}
Make command line editing (use of readline) be per UI Due to the way that readline's API works (based on globals), we can only have one instance of readline in a process. So the goal of this patch is to only allow editing in the main UI, and make sure that only one UI calls into readline. Some MI paths touch readline variables currently, which is bad as that is changing variables that matter for the main console UI. This patch fixes those. This actually fixes a nasty bug -- starting gdb in MI mode ("gdb -i=mi"), and then doing "set editing on" crashes GDB, because MI is not prepared to use readline: set editing on &"set editing on\n" =cmd-param-changed,param="editing",value="on" ^done (gdb) p 1 readline: readline_callback_read_char() called with no handler! Aborted (core dumped) The fix for that was to add an interp_proc method to query the interpreter whether it actually supports editing. New test included. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> PR mi/20034 * cli/cli-interp.c: Include cli-interp.h and event-top.h. (cli_interpreter_resume): Pass 1 to gdb_setup_readline. Set the UI's input_handler here. (cli_interpreter_supports_command_editing): New function. (cli_interp_procs): Install it. * cli/cli-interp.h: New file. * event-top.c (async_command_editing_p): Rename to ... (set_editing_cmd_var): ... this. (change_line_handler): Add parameter 'editing', and use it. Bail early if the interpreter doesn't support editing. Don't touch readline state if editing is off. (gdb_rl_callback_handler_remove, gdb_rl_callback_handler_install) (gdb_rl_callback_handler_reinstall): Assert the current UI is the main UI. (display_gdb_prompt): Don't call gdb_rl_callback_handler_remove if not using readline. Check whether the current UI is using command editing instead of checking the async_command_editing_p global. (set_async_editing_command): Delete. (gdb_setup_readline): Add 'editing' parameter. Only allow editing on the main UI. Don't touch readline state if editing is off. (gdb_disable_readline): Don't touch readline state if editing is off. * event-top.h (gdb_setup_readline): Add 'int' parameter. (set_async_editing_command): Delete declaration. (change_line_handler, command_line_handler): Declare. (async_command_editing_p): Rename to ... (set_editing_cmd_var): ... this. * infrun.c (reinstall_readline_callback_handler_cleanup): Check whether the current UI has editing enabled rather than checking the async_command_editing_p global. * interps.c (interp_supports_command_editing): New function. * interps.h (interp_supports_command_editing_ftype): New typedef. (struct interp_procs) <supports_command_editing_proc>: New field. (interp_supports_command_editing): Declare. * mi/mi-interp.c (mi_interpreter_resume): Pass 0 to gdb_setup_readline. Don't clear the async_command_editing_p global. Update comments. * top.c (gdb_readline_wrapper_line, gdb_readline_wrapper): Check whether the current UI has editing enabled rather than checking the async_command_editing_p global. Don't touch readline state if editing is off. (undo_terminal_modifications_before_exit): Switch to the main UI. Unconditionally call gdb_disable_readline. (set_editing): New function. (show_async_command_editing_p): Rename to ... (show_editing): ... this. Show the state of the current UI. (_initialize_top): Adjust. * top.h (struct ui) <command_editing>: New field. * tui/tui-interp.c: Include cli/cli-interp.h. (tui_resume): Pass 1 to gdb_setup_readline. Set the UI's input_handler. (tui_interp_procs): Install cli_interpreter_supports_command_editing. * tui/tui-io.c (tui_getc): Check whether the current UI has editing enabled rather than checking the async_command_editing_p global. gdb/testsuite/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> PR mi/20034 * gdb.mi/mi-editing.exp: New file.
2016-06-21 02:11:48 +02:00
/* See interp.h */
int
interp_supports_command_editing (struct interp *interp)
{
C++-fy struct interp/cli_interp/tui_interp/mi_interp - The interp->data field disappears, since we can put data in the interpreter directly now. The "init" method remains in place, but it now returns void. - A few places check if the interpreter method is NULL before calling it, and also check whether the method returns true/false. For some of those methods, all current implementations always return true. In those cases, this commit makes the C++-fied method return void instead and cleans up the callers. Tested on x86_64 Fedora 23. gdb/ChangeLog: 2017-02-03 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_interp_base::cli_interp_base) (cli_interp_base::~cli_interp_base): New. (cli_interp): New struct. (as_cli_interp): Cast the interp itself to cli_interp. (cli_interpreter_pre_command_loop): Rename to ... (cli_interp_base::pre_command_loop): ... this. Remove 'self' parameter. (cli_interpreter_init): Rename to ... (cli_interp::init): ... this. Remove 'self' parameter. Use boolean. Make extern. (cli_interpreter_resume): Rename to ... (cli_interp::resume): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_suspend): Rename to ... (cli_interp::suspend): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_exec): Rename to ... (cli_interp::exec): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_supports_command_editing): Rename to ... (cli_interp_base::supports_command_editing): ... this. Remove 'interp' parameter. Make extern. (cli_ui_out): Rename to ... (cli_interp::interp_ui_out): ... this. Remove 'interp' parameter. Make extern. (cli_set_logging): Rename to ... (cli_interp_base::set_logging): ... this. Remove 'interp' parameter. Make extern. (cli_interp_procs): Delete. (cli_interp_factory): Adjust to use "new". * cli/cli-interp.h: Include "interps.h". (struct cli_interp_base): New struct. * interps.c (struct interp): Delete. Fields moved to interps.h. (interp_new): Delete. (interp::interp, interp::~interp): New. (interp_set): Use bool, and return void. Assume the interpreter has suspend, init and resume methods, and that the all return void. (set_top_level_interpreter): interp_set returns void. (interp_ui_out): Adapt. (current_interp_set_logging): Adapt. (interp_data): Delete. (interp_pre_command_loop, interp_supports_command_editing): Adapt. (interp_exec): Adapt. (top_level_interpreter_data): Delete. * interps.h (interp_init_ftype, interp_resume_ftype) (interp_suspend_ftype, interp_exec_ftype) (interp_pre_command_loop_ftype, interp_ui_out_ftype): Delete. (class interp): New. (interp_new): Delete. (interp_set): Now returns void. Use bool. (interp_data, top_level_interpreter_data): Delete. * mi/mi-common.h: Include interps.h. (class mi_interp): Inherit from interp. Define a ctor. Declare init, resume, suspect, exec, interp_ui_out, set_logging and pre_command_loop methods. * mi/mi-interp.c (as_mi_interp): Cast the interp itself. (mi_interpreter_init): Rename to ... (mi_interp::init): ... this. Remove the 'interp' parameter, use bool, return void and make extern. Adjust. (mi_interpreter_resume): ... Rename to ... (mi_interp::resume): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (mi_interpreter_suspend): ... Rename to ... (mi_interp::suspend): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (mi_interpreter_exec): ... Rename to ... (mi_interp::exec): ... this. Remove the 'data' parameter and make extern. Adjust. (mi_interpreter_pre_command_loop): ... Rename to ... (mi_interp::pre_command_loop): ... this. Remove the 'self' parameter and make extern. (mi_on_normal_stop_1): Adjust. (mi_ui_out): Rename to ... (mi_interp::interp_ui_out): ... this. Remove the 'interp' parameter and make extern. Adjust. (mi_set_logging): Rename to ... (mi_interp::set_logging): ... this. Remove the 'interp' parameter and make extern. Adjust. (mi_interp_procs): Delete. (mi_interp_factory): Adjust to use 'new'. * mi/mi-main.c (mi_cmd_gdb_exit, captured_mi_execute_command) (mi_print_exception, mi_execute_command, mi_load_progress): Adjust. * tui/tui-interp.c (tui_interp): New class. (as_tui_interp): Return a tui_interp pointer. (tui_on_normal_stop, tui_on_signal_received) (tui_on_end_stepping_range, tui_on_signal_exited, tui_on_exited) (tui_on_no_history, tui_on_user_selected_context_changed): Adjust to use interp::interp_ui_out. (tui_init): Rename to ... (tui_interp::init): ... this. Remove the 'self' parameter, use bool, return void and make extern. Adjust. (tui_resume): Rename to ... (tui_interp::resume): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (tui_suspend): Rename to ... (tui_interp::suspend): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (tui_ui_out): Rename to ... (tui_interp::interp_ui_out): ... this. Remove the 'self' parameter, and make extern. Adjust. (tui_exec): Rename to ... (tui_interp::exec): ... this. Remove the 'data' parameter and make extern. (tui_interp_procs): Delete. (tui_interp_factory): Use "new".
2017-02-03 17:30:04 +01:00
return interp->supports_command_editing ();
Make command line editing (use of readline) be per UI Due to the way that readline's API works (based on globals), we can only have one instance of readline in a process. So the goal of this patch is to only allow editing in the main UI, and make sure that only one UI calls into readline. Some MI paths touch readline variables currently, which is bad as that is changing variables that matter for the main console UI. This patch fixes those. This actually fixes a nasty bug -- starting gdb in MI mode ("gdb -i=mi"), and then doing "set editing on" crashes GDB, because MI is not prepared to use readline: set editing on &"set editing on\n" =cmd-param-changed,param="editing",value="on" ^done (gdb) p 1 readline: readline_callback_read_char() called with no handler! Aborted (core dumped) The fix for that was to add an interp_proc method to query the interpreter whether it actually supports editing. New test included. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> PR mi/20034 * cli/cli-interp.c: Include cli-interp.h and event-top.h. (cli_interpreter_resume): Pass 1 to gdb_setup_readline. Set the UI's input_handler here. (cli_interpreter_supports_command_editing): New function. (cli_interp_procs): Install it. * cli/cli-interp.h: New file. * event-top.c (async_command_editing_p): Rename to ... (set_editing_cmd_var): ... this. (change_line_handler): Add parameter 'editing', and use it. Bail early if the interpreter doesn't support editing. Don't touch readline state if editing is off. (gdb_rl_callback_handler_remove, gdb_rl_callback_handler_install) (gdb_rl_callback_handler_reinstall): Assert the current UI is the main UI. (display_gdb_prompt): Don't call gdb_rl_callback_handler_remove if not using readline. Check whether the current UI is using command editing instead of checking the async_command_editing_p global. (set_async_editing_command): Delete. (gdb_setup_readline): Add 'editing' parameter. Only allow editing on the main UI. Don't touch readline state if editing is off. (gdb_disable_readline): Don't touch readline state if editing is off. * event-top.h (gdb_setup_readline): Add 'int' parameter. (set_async_editing_command): Delete declaration. (change_line_handler, command_line_handler): Declare. (async_command_editing_p): Rename to ... (set_editing_cmd_var): ... this. * infrun.c (reinstall_readline_callback_handler_cleanup): Check whether the current UI has editing enabled rather than checking the async_command_editing_p global. * interps.c (interp_supports_command_editing): New function. * interps.h (interp_supports_command_editing_ftype): New typedef. (struct interp_procs) <supports_command_editing_proc>: New field. (interp_supports_command_editing): Declare. * mi/mi-interp.c (mi_interpreter_resume): Pass 0 to gdb_setup_readline. Don't clear the async_command_editing_p global. Update comments. * top.c (gdb_readline_wrapper_line, gdb_readline_wrapper): Check whether the current UI has editing enabled rather than checking the async_command_editing_p global. Don't touch readline state if editing is off. (undo_terminal_modifications_before_exit): Switch to the main UI. Unconditionally call gdb_disable_readline. (set_editing): New function. (show_async_command_editing_p): Rename to ... (show_editing): ... this. Show the state of the current UI. (_initialize_top): Adjust. * top.h (struct ui) <command_editing>: New field. * tui/tui-interp.c: Include cli/cli-interp.h. (tui_resume): Pass 1 to gdb_setup_readline. Set the UI's input_handler. (tui_interp_procs): Install cli_interpreter_supports_command_editing. * tui/tui-io.c (tui_getc): Check whether the current UI has editing enabled rather than checking the async_command_editing_p global. gdb/testsuite/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> PR mi/20034 * gdb.mi/mi-editing.exp: New file.
2016-06-21 02:11:48 +02:00
}
2003-02-06 06:30:17 +01:00
/* interp_exec - This executes COMMAND_STR in the current
interpreter. */
2003-02-06 06:30:17 +01:00
struct gdb_exception
2003-02-06 06:30:17 +01:00
interp_exec (struct interp *interp, const char *command_str)
{
Make the interpreters be per UI Make each UI have its own interpreter list, top level interpreter, current interpreter, etc. The "interpreter_async" global is not really specific to an struct interp (it crosses interpreter-exec ...), so I moved it to "struct ui" directly, while the other globals were left hidden in interps.c, opaque to the rest of GDB. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * breakpoint.c (bpstat_do_actions_1): Access the current UI's async field instead of the interpreter_async global. * cli/cli-script.c (execute_user_command, while_command) (if_command, script_from_file): Likewise. * compile/compile.c: Include top.h instead of interps.h. (compile_file_command, compile_code_command) (compile_print_command): Access the current UI's async field instead of the interpreter_async global. * guile/guile.c: Include top.h instead of interps.h. (guile_repl_command, guile_command, gdbscm_execute_gdb_command): Access the current UI's async field instead of the interpreter_async global. * guile/scm-ports.c: Include top.h instead of interps.h. (ioscm_with_output_to_port_worker): Access the current UI's async field instead of the interpreter_async global. * inf-loop.c (inferior_event_handler): Likewise. * infcall.c (run_inferior_call): Likewise. * infrun.c (reinstall_readline_callback_handler_cleanup) (fetch_inferior_event): Likewise. * interps.c (interpreter_async): Delete. (struct ui_interp_info): New. (get_current_interp_info): New function. (interp_list, current_interpreter, top_level_interpreter_ptr): Delete. (interp_add, interp_set, interp_lookup, interp_ui_out) (current_interp_set_logging, interp_set_temp) (current_interp_named_p): Adjust to per-UI interpreters. (command_interpreter): Delete. (command_interp, current_interp_command_loop, interp_quiet_p) (interp_exec, interpreter_exec_cmd, interpreter_completer) (top_level_interpreter, top_level_interpreter_data): Adjust to per-UI interpreters. * interps.h (interpreter_async): Delete. * main.c (captured_command_loop): Access the current UI's async field instead of the interpreter_async global. * python/python.c (python_interactive_command, python_command) (execute_gdb_command): Likewise. * top.c (maybe_wait_sync_command_done, execute_command_to_string): Access the current UI's async field instead of the interpreter_async global. * top.h (struct tl_interp_info): Forward declare. (struct ui) <interp_info, async>: New fields.
2016-06-21 02:11:45 +02:00
struct ui_interp_info *ui_interp = get_current_interp_info ();
PR gdb/13860: don't lose '-interpreter-exec console EXECUTION_COMMAND''s output in async mode. The other part of PR gdb/13860 is about console execution commands in MI getting their output half lost. E.g., take the finish command, executed on a frontend's GDB console: sync: finish &"finish\n" ~"Run till exit from #0 usleep (useconds=10) at ../sysdeps/unix/sysv/linux/usleep.c:27\n" ^running *running,thread-id="1" (gdb) ~"0x00000000004004d7 in foo () at stepinf.c:6\n" ~"6\t usleep (10);\n" ~"Value returned is $1 = 0\n" *stopped,reason="function-finished",frame={addr="0x00000000004004d7",func="foo",args=[],file="stepinf.c",fullname="/home/pedro/gdb/tests/stepinf.c",line="6"},thread-id="1",stopped-threads="all",core="1" async: finish &"finish\n" ~"Run till exit from #0 usleep (useconds=10) at ../sysdeps/unix/sysv/linux/usleep.c:27\n" ^running *running,thread-id="1" (gdb) *stopped,reason="function-finished",frame={addr="0x00000000004004d7",func="foo",args=[],file="stepinf.c",fullname="/home/pedro/gdb/tests/stepinf.c",line="6"},gdb-result-var="$1",return-value="0",thread-id="1",stopped-threads="all",core="0" Note how all the "Value returned" etc. output is missing in async mode. The same happens with e.g., catchpoints: =breakpoint-modified,bkpt={number="1",type="catchpoint",disp="keep",enabled="y",what="22016",times="1"} ~"\nCatchpoint " ~"1 (forked process 22016), 0x0000003791cbd8a6 in __libc_fork () at ../nptl/sysdeps/unix/sysv/linux/fork.c:131\n" ~"131\t pid = ARCH_FORK ();\n" *stopped,reason="fork",disp="keep",bkptno="1",newpid="22016",frame={addr="0x0000003791cbd8a6",func="__libc_fork",args=[],file="../nptl/sysdeps/unix/sysv/linux/fork.c",fullname="/usr/src/debug/glibc-2.14-394-g8f3b1ff/nptl/sysdeps/unix/sysv/linux/fork.c",line="131"},thread-id="1",stopped-threads="all",core="0" where all those ~ lines are missing in async mode, or just the "step" current line indication: s &"s\n" ^running *running,thread-id="all" (gdb) ~"13\t foo ();\n" *stopped,frame={addr="0x00000000004004ef",func="main",args=[{name="argc",value="1"},{name="argv",value="0x7fffffffdd78"}],file="stepinf.c",fullname="/home/pedro/gdb/tests/stepinf.c",line="13"},thread-id="1",stopped-threads="all",core="3" (gdb) Or in the case of the PRs example, the "Stopped due to shared library event" note: start &"start\n" ~"Temporary breakpoint 1 at 0x400608: file ../../../src/gdb/testsuite/gdb.mi/solib-main.c, line 21.\n" =breakpoint-created,bkpt={number="1",type="breakpoint",disp="del",enabled="y",addr="0x0000000000400608",func="main",file="../../../src/gdb/testsuite/gdb.mi/solib-main.c",fullname="/home/pedro/gdb/mygit/src/gdb/testsuite/gdb.mi/solib-main.c",line="21",times="0",original-location="main"} ~"Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.mi/solib-main \n" =thread-group-started,id="i1",pid="21990" =thread-created,id="1",group-id="i1" ^running *running,thread-id="all" (gdb) =library-loaded,id="/lib64/ld-linux-x86-64.so.2",target-name="/lib64/ld-linux-x86-64.so.2",host-name="/lib64/ld-linux-x86-64.so.2",symbols-loaded="0",thread-group="i1" ~"Stopped due to shared library event (no libraries added or removed)\n" *stopped,reason="solib-event",thread-id="1",stopped-threads="all",core="3" (gdb) IMO, if you're typing execution commands in a frontend's console, you expect to see their output. Indeed it's what you get in sync mode. I think async mode should do the same. Deciding what to mirror to the console wrt to breakpoints and random stops gets messy real fast. E.g., say "s" trips on a breakpoint. We'd clearly want to mirror the event to the console in this case. But what about more complicated cases like "s&; thread n; s&", and one of those steps spawning a new thread, and that thread hitting a breakpoint? It's impossible in general to track whether the thread had any relation to the commands that had been executed. So I think we should just simplify and always mirror breakpoints and random events to the console. Notes: - mi->out is the same as gdb_stdout when MI is the current interpreter. I think that referring to that directly is cleaner. An earlier revision of this patch made the changes that are now done in mi_on_normal_stop directly in infrun.c:normal_stop, and so not having an obvious place to put the new uiout by then, and not wanting to abuse CLI's uiout, I made a temporary uiout when necessary. - Hopefuly the rest of the patch is more or less obvious given the comments added. Tested on x86_64 Fedora 20, no regressions. 2014-05-21 Pedro Alves <palves@redhat.com> PR gdb/13860 * gdbthread.h (struct thread_control_state): New field `command_interp'. * infrun.c (follow_fork): Copy the new thread control field to the child fork thread. (clear_proceed_status_thread): Clear the new thread control field. (proceed): Set the new thread control field. * interps.h (command_interp): Declare. * interps.c (command_interpreter): New global. (command_interp): New function. (interp_exec): Set `command_interpreter' while here. * cli-out.c (cli_uiout_dtor): New function. (cli_ui_out_impl): Install it. * mi/mi-interp.c: Include cli-out.h. (mi_cmd_interpreter_exec): Add comment. (restore_current_uiout_cleanup): New function. (ui_out_free_cleanup): New function. (mi_on_normal_stop): If finishing an execution command started by a CLI command, or any kind of breakpoint-like event triggered, print the stop event to the output (CLI) stream. * mi/mi-out.c (mi_ui_out_impl): Install NULL `dtor' handler. 2014-05-21 Pedro Alves <palves@redhat.com> PR gdb/13860 * gdb.mi/mi-cli.exp (line_callee4_next_step): New global. (top level): Test that output related to execution commands is sent to the console with CLI commands, but not with MI commands. Test that breakpoint events are always mirrored to the console. Also expect the new source line to be output after a "next" in async mode too. Make it a pass/fail test. * gdb.mi/mi-solib.exp: Test that the CLI solib event note is output. * lib/mi-support.exp (mi_gdb_expect_cli_output): New procedure.
2014-03-11 21:31:36 +01:00
/* See `command_interp' for why we do this. */
scoped_restore save_command_interp
= make_scoped_restore (&ui_interp->command_interpreter, interp);
PR gdb/13860: don't lose '-interpreter-exec console EXECUTION_COMMAND''s output in async mode. The other part of PR gdb/13860 is about console execution commands in MI getting their output half lost. E.g., take the finish command, executed on a frontend's GDB console: sync: finish &"finish\n" ~"Run till exit from #0 usleep (useconds=10) at ../sysdeps/unix/sysv/linux/usleep.c:27\n" ^running *running,thread-id="1" (gdb) ~"0x00000000004004d7 in foo () at stepinf.c:6\n" ~"6\t usleep (10);\n" ~"Value returned is $1 = 0\n" *stopped,reason="function-finished",frame={addr="0x00000000004004d7",func="foo",args=[],file="stepinf.c",fullname="/home/pedro/gdb/tests/stepinf.c",line="6"},thread-id="1",stopped-threads="all",core="1" async: finish &"finish\n" ~"Run till exit from #0 usleep (useconds=10) at ../sysdeps/unix/sysv/linux/usleep.c:27\n" ^running *running,thread-id="1" (gdb) *stopped,reason="function-finished",frame={addr="0x00000000004004d7",func="foo",args=[],file="stepinf.c",fullname="/home/pedro/gdb/tests/stepinf.c",line="6"},gdb-result-var="$1",return-value="0",thread-id="1",stopped-threads="all",core="0" Note how all the "Value returned" etc. output is missing in async mode. The same happens with e.g., catchpoints: =breakpoint-modified,bkpt={number="1",type="catchpoint",disp="keep",enabled="y",what="22016",times="1"} ~"\nCatchpoint " ~"1 (forked process 22016), 0x0000003791cbd8a6 in __libc_fork () at ../nptl/sysdeps/unix/sysv/linux/fork.c:131\n" ~"131\t pid = ARCH_FORK ();\n" *stopped,reason="fork",disp="keep",bkptno="1",newpid="22016",frame={addr="0x0000003791cbd8a6",func="__libc_fork",args=[],file="../nptl/sysdeps/unix/sysv/linux/fork.c",fullname="/usr/src/debug/glibc-2.14-394-g8f3b1ff/nptl/sysdeps/unix/sysv/linux/fork.c",line="131"},thread-id="1",stopped-threads="all",core="0" where all those ~ lines are missing in async mode, or just the "step" current line indication: s &"s\n" ^running *running,thread-id="all" (gdb) ~"13\t foo ();\n" *stopped,frame={addr="0x00000000004004ef",func="main",args=[{name="argc",value="1"},{name="argv",value="0x7fffffffdd78"}],file="stepinf.c",fullname="/home/pedro/gdb/tests/stepinf.c",line="13"},thread-id="1",stopped-threads="all",core="3" (gdb) Or in the case of the PRs example, the "Stopped due to shared library event" note: start &"start\n" ~"Temporary breakpoint 1 at 0x400608: file ../../../src/gdb/testsuite/gdb.mi/solib-main.c, line 21.\n" =breakpoint-created,bkpt={number="1",type="breakpoint",disp="del",enabled="y",addr="0x0000000000400608",func="main",file="../../../src/gdb/testsuite/gdb.mi/solib-main.c",fullname="/home/pedro/gdb/mygit/src/gdb/testsuite/gdb.mi/solib-main.c",line="21",times="0",original-location="main"} ~"Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.mi/solib-main \n" =thread-group-started,id="i1",pid="21990" =thread-created,id="1",group-id="i1" ^running *running,thread-id="all" (gdb) =library-loaded,id="/lib64/ld-linux-x86-64.so.2",target-name="/lib64/ld-linux-x86-64.so.2",host-name="/lib64/ld-linux-x86-64.so.2",symbols-loaded="0",thread-group="i1" ~"Stopped due to shared library event (no libraries added or removed)\n" *stopped,reason="solib-event",thread-id="1",stopped-threads="all",core="3" (gdb) IMO, if you're typing execution commands in a frontend's console, you expect to see their output. Indeed it's what you get in sync mode. I think async mode should do the same. Deciding what to mirror to the console wrt to breakpoints and random stops gets messy real fast. E.g., say "s" trips on a breakpoint. We'd clearly want to mirror the event to the console in this case. But what about more complicated cases like "s&; thread n; s&", and one of those steps spawning a new thread, and that thread hitting a breakpoint? It's impossible in general to track whether the thread had any relation to the commands that had been executed. So I think we should just simplify and always mirror breakpoints and random events to the console. Notes: - mi->out is the same as gdb_stdout when MI is the current interpreter. I think that referring to that directly is cleaner. An earlier revision of this patch made the changes that are now done in mi_on_normal_stop directly in infrun.c:normal_stop, and so not having an obvious place to put the new uiout by then, and not wanting to abuse CLI's uiout, I made a temporary uiout when necessary. - Hopefuly the rest of the patch is more or less obvious given the comments added. Tested on x86_64 Fedora 20, no regressions. 2014-05-21 Pedro Alves <palves@redhat.com> PR gdb/13860 * gdbthread.h (struct thread_control_state): New field `command_interp'. * infrun.c (follow_fork): Copy the new thread control field to the child fork thread. (clear_proceed_status_thread): Clear the new thread control field. (proceed): Set the new thread control field. * interps.h (command_interp): Declare. * interps.c (command_interpreter): New global. (command_interp): New function. (interp_exec): Set `command_interpreter' while here. * cli-out.c (cli_uiout_dtor): New function. (cli_ui_out_impl): Install it. * mi/mi-interp.c: Include cli-out.h. (mi_cmd_interpreter_exec): Add comment. (restore_current_uiout_cleanup): New function. (ui_out_free_cleanup): New function. (mi_on_normal_stop): If finishing an execution command started by a CLI command, or any kind of breakpoint-like event triggered, print the stop event to the output (CLI) stream. * mi/mi-out.c (mi_ui_out_impl): Install NULL `dtor' handler. 2014-05-21 Pedro Alves <palves@redhat.com> PR gdb/13860 * gdb.mi/mi-cli.exp (line_callee4_next_step): New global. (top level): Test that output related to execution commands is sent to the console with CLI commands, but not with MI commands. Test that breakpoint events are always mirrored to the console. Also expect the new source line to be output after a "next" in async mode too. Make it a pass/fail test. * gdb.mi/mi-solib.exp: Test that the CLI solib event note is output. * lib/mi-support.exp (mi_gdb_expect_cli_output): New procedure.
2014-03-11 21:31:36 +01:00
return interp->exec (command_str);
2003-02-06 06:30:17 +01:00
}
/* A convenience routine that nulls out all the common command hooks.
Use it when removing your interpreter in its suspend proc. */
2003-02-06 06:30:17 +01:00
void
clear_interpreter_hooks (void)
2003-02-06 06:30:17 +01: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 01:52:21 +02:00
deprecated_print_frame_info_listing_hook = 0;
2003-02-06 06:30:17 +01:00
/*print_frame_more_info_hook = 0; */
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 01:52:21 +02:00
deprecated_query_hook = 0;
deprecated_warning_hook = 0;
deprecated_readline_begin_hook = 0;
deprecated_readline_hook = 0;
deprecated_readline_end_hook = 0;
deprecated_context_hook = 0;
deprecated_target_wait_hook = 0;
deprecated_call_command_hook = 0;
deprecated_error_begin_hook = 0;
2003-02-06 06:30:17 +01:00
}
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
static void
interpreter_exec_cmd (const char *args, int from_tty)
2003-02-06 06:30:17 +01:00
{
Make the interpreters be per UI Make each UI have its own interpreter list, top level interpreter, current interpreter, etc. The "interpreter_async" global is not really specific to an struct interp (it crosses interpreter-exec ...), so I moved it to "struct ui" directly, while the other globals were left hidden in interps.c, opaque to the rest of GDB. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * breakpoint.c (bpstat_do_actions_1): Access the current UI's async field instead of the interpreter_async global. * cli/cli-script.c (execute_user_command, while_command) (if_command, script_from_file): Likewise. * compile/compile.c: Include top.h instead of interps.h. (compile_file_command, compile_code_command) (compile_print_command): Access the current UI's async field instead of the interpreter_async global. * guile/guile.c: Include top.h instead of interps.h. (guile_repl_command, guile_command, gdbscm_execute_gdb_command): Access the current UI's async field instead of the interpreter_async global. * guile/scm-ports.c: Include top.h instead of interps.h. (ioscm_with_output_to_port_worker): Access the current UI's async field instead of the interpreter_async global. * inf-loop.c (inferior_event_handler): Likewise. * infcall.c (run_inferior_call): Likewise. * infrun.c (reinstall_readline_callback_handler_cleanup) (fetch_inferior_event): Likewise. * interps.c (interpreter_async): Delete. (struct ui_interp_info): New. (get_current_interp_info): New function. (interp_list, current_interpreter, top_level_interpreter_ptr): Delete. (interp_add, interp_set, interp_lookup, interp_ui_out) (current_interp_set_logging, interp_set_temp) (current_interp_named_p): Adjust to per-UI interpreters. (command_interpreter): Delete. (command_interp, current_interp_command_loop, interp_quiet_p) (interp_exec, interpreter_exec_cmd, interpreter_completer) (top_level_interpreter, top_level_interpreter_data): Adjust to per-UI interpreters. * interps.h (interpreter_async): Delete. * main.c (captured_command_loop): Access the current UI's async field instead of the interpreter_async global. * python/python.c (python_interactive_command, python_command) (execute_gdb_command): Likewise. * top.c (maybe_wait_sync_command_done, execute_command_to_string): Access the current UI's async field instead of the interpreter_async global. * top.h (struct tl_interp_info): Forward declare. (struct ui) <interp_info, async>: New fields.
2016-06-21 02:11:45 +02:00
struct ui_interp_info *ui_interp = get_current_interp_info ();
2003-02-06 06:30:17 +01:00
struct interp *old_interp, *interp_to_use;
unsigned int nrules;
unsigned int i;
if (args == NULL)
error_no_arg (_("interpreter-exec command"));
Introduce gdb_argv, a class wrapper for buildargv This introduces gdb_argv, a class wrapping an "argv" pointer; that is, a pointer to a NULL-terminated array of char*, where both the array and each non-NULL element in the array are xmalloc'd. This patch then changes most users of gdb_buildargv to use gdb_argv instead. ChangeLog 2017-08-03 Tom Tromey <tom@tromey.com> * utils.h (struct gdb_argv_deleter): New. (gdb_argv): New class. * utils.c (gdb_argv::reset): New method. * tracepoint.c (delete_trace_variable_command): Use gdb_argv. * tracefile.c (tsave_command): Use gdb_argv. * top.c (new_ui_command): Use gdb_argv. * symmisc.c (maintenance_print_symbols) (maintenance_print_msymbols, maintenance_expand_symtabs): Use gdb_argv. * symfile.c (symbol_file_command, generic_load) (remove_symbol_file_command): Use gdb_argv. * stack.c (backtrace_command): Use gdb_argv. * source.c (add_path, show_substitute_path_command) (unset_substitute_path_command, set_substitute_path_command): Use gdb_argv. * skip.c (skip_command): Use gdb_argv. Use gdb_buildargv. * ser-mingw.c (pipe_windows_open): Use gdb_argv. * remote.c (extended_remote_run, remote_put_command) (remote_get_command, remote_delete_command): Use gdb_argv. * remote-sim.c (gdbsim_load, gdbsim_create_inferior) (gdbsim_open): Use gdb_argv. * python/py-cmd.c (gdbpy_string_to_argv): Use gdb_argv. * psymtab.c (maintenance_print_psymbols): Use gdb_argv. * procfs.c (procfs_info_proc): Use gdb_argv. * interps.c (interpreter_exec_cmd): Use gdb_argv. * infrun.c (handle_command): Use gdb_argv. * inferior.c (add_inferior_command, clone_inferior_command): Use gdb_argv. * guile/scm-string.c (gdbscm_string_to_argv): Use gdb_argv. * exec.c (exec_file_command): Use gdb_argv. * cli/cli-cmds.c (alias_command): Use gdb_argv. * compile/compile.c (build_argc_argv): Use gdb_argv.
2017-05-01 07:02:30 +02:00
gdb_argv prules (args);
nrules = prules.count ();
2003-02-06 06:30:17 +01:00
if (nrules < 2)
Make first and last lines of 'command help documentation' consistent. With this patch, the help docs now respect 2 invariants: * The first line of a command help is terminated by a '.' character. * The last character of a command help is not a newline character. Note that the changes for the last invariant were done by Tom, as part of : [PATCH] Remove trailing newlines from help text https://sourceware.org/ml/gdb-patches/2019-06/msg00050.html but some occurrences have been re-introduced since then. Some help docs had to be rephrased/restructured to respect the above invariants. Before this patch, print_doc_line was printing the first line of a command help documentation, but stopping at the first '.' or ',' character. This was giving inconsistent results : * The first line of command helps was sometimes '.' terminated, sometimes not. * The first line of command helps was not always designed to be readable/understandable/unambiguous when stopping at the first '.' or ',' character. This e.g. created the following inconsistencies/problems: < catch exception -- Catch Ada exceptions < catch handlers -- Catch Ada exceptions < catch syscall -- Catch system calls by their names < down-silently -- Same as the `down' command while the new help is: > catch exception -- Catch Ada exceptions, when raised. > catch handlers -- Catch Ada exceptions, when handled. > catch syscall -- Catch system calls by their names, groups and/or numbers. > down-silently -- Same as the `down' command, but does not print anything. Also, the command help doc should not be terminated by a newline character, but this was not respected by all commands. The cli-option -OPT framework re-introduced some occurences. So, the -OPT build help framework was changed to not output newlines at the end of %OPTIONS% replacement. This patch changes the help documentations to ensure the 2 invariants given above. It implied to slightly rephrase or restructure some help docs. Based on the above invariants, print_doc_line (called by 'apropos' and 'help' commands to print the first line of a command help) now outputs the full first line of a command help. This all results in a lot of small changes in the produced help docs. There are less code changes than changes in the help docs, as a lot of docs are produced by some code (e.g. the remote packet usage settings). gdb/ChangeLog 2019-08-07 Philippe Waroquiers <philippe.waroquiers@skynet.be> * cli/cli-decode.h (print_doc_line): Add for_value_prefix argument. * cli/cli-decode.c (print_doc_line): Likewise. It now prints the full first line, except when FOR_VALUE_PREFIX. In this case, the trailing '.' is not output, and the first character is uppercased. (print_help_for_command): Update call to print_doc_line. (print_doc_of_command): Likewise. * cli/cli-setshow.c (deprecated_show_value_hack): Likewise. * cli/cli-option.c (append_indented_doc): Do not append newline. (build_help_option): Append newline after first appended_indented_doc only if a second call is done. (build_help): Append 2 new lines before each option, except the first one. * compile/compile.c (_initialize_compile): Add new lines after %OPTIONS%, when not at the end of the help. Change help doc or code producing the help doc to respect the invariants. * maint-test-options.c (_initialize_maint_test_options): Likewise. Also removed the new line after 'Options:', as all other commands do not put an empty line between 'Options:' and the first option. * printcmd.c (_initialize_printcmd): Likewise. * stack.c (_initialize_stack): Likewise. * interps.c (interpreter_exec_cmd): Fix "Usage:" line that was incorrectly telling COMMAND is optional. * ada-lang.c (_initialize_ada_language): Change help doc or code producing the help doc to respect the invariants. * ada-tasks.c (_initialize_ada_tasks): Likewise. * breakpoint.c (_initialize_breakpoint): Likewise. * cli/cli-cmds.c (_initialize_cli_cmds): Likewise. * cli/cli-logging.c (_initialize_cli_logging): Likewise. * cli/cli-setshow.c (_initialize_cli_setshow): Likewise. * cli/cli-style.c (cli_style_option::add_setshow_commands, _initialize_cli_style): Likewise. * corelow.c (core_target_info): Likewise. * dwarf-index-cache.c (_initialize_index_cache): Likewise. * dwarf2read.c (_initialize_dwarf2_read): Likewise. * filesystem.c (_initialize_filesystem): Likewise. * frame.c (_initialize_frame): Likewise. * gnu-nat.c (add_task_commands): Likewise. * infcall.c (_initialize_infcall): Likewise. * infcmd.c (_initialize_infcmd): Likewise. * interps.c (_initialize_interpreter): Likewise. * language.c (_initialize_language): Likewise. * linux-fork.c (_initialize_linux_fork): Likewise. * maint-test-settings.c (_initialize_maint_test_settings): Likewise. * maint.c (_initialize_maint_cmds): Likewise. * memattr.c (_initialize_mem): Likewise. * printcmd.c (_initialize_printcmd): Likewise. * python/lib/gdb/function/strfns.py (_MemEq, _StrLen, _StrEq, _RegEx): Likewise. * ravenscar-thread.c (_initialize_ravenscar): Likewise. * record-btrace.c (_initialize_record_btrace): Likewise. * record-full.c (_initialize_record_full): Likewise. * record.c (_initialize_record): Likewise. * regcache-dump.c (_initialize_regcache_dump): Likewise. * regcache.c (_initialize_regcache): Likewise. * remote.c (add_packet_config_cmd, init_remote_threadtests, _initialize_remote): Likewise. * ser-tcp.c (_initialize_ser_tcp): Likewise. * serial.c (_initialize_serial): Likewise. * skip.c (_initialize_step_skip): Likewise. * source.c (_initialize_source): Likewise. * stack.c (_initialize_stack): Likewise. * symfile.c (_initialize_symfile): Likewise. * symtab.c (_initialize_symtab): Likewise. * target-descriptions.c (_initialize_target_descriptions): Likewise. * top.c (init_main): Likewise. * tracefile-tfile.c (tfile_target_info): Likewise. * tracepoint.c (_initialize_tracepoint): Likewise. * tui/tui-win.c (_initialize_tui_win): Likewise. * utils.c (add_internal_problem_command): Likewise. * valprint.c (value_print_option_defs): Likewise. gdb/testsuite/ChangeLog 2019-08-07 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/style.exp: Update tests for help doc new invariants. * gdb.base/help.exp: Likewise.
2019-06-09 11:16:20 +02:00
error (_("Usage: interpreter-exec INTERPRETER COMMAND..."));
2003-02-06 06:30:17 +01:00
Make the interpreters be per UI Make each UI have its own interpreter list, top level interpreter, current interpreter, etc. The "interpreter_async" global is not really specific to an struct interp (it crosses interpreter-exec ...), so I moved it to "struct ui" directly, while the other globals were left hidden in interps.c, opaque to the rest of GDB. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * breakpoint.c (bpstat_do_actions_1): Access the current UI's async field instead of the interpreter_async global. * cli/cli-script.c (execute_user_command, while_command) (if_command, script_from_file): Likewise. * compile/compile.c: Include top.h instead of interps.h. (compile_file_command, compile_code_command) (compile_print_command): Access the current UI's async field instead of the interpreter_async global. * guile/guile.c: Include top.h instead of interps.h. (guile_repl_command, guile_command, gdbscm_execute_gdb_command): Access the current UI's async field instead of the interpreter_async global. * guile/scm-ports.c: Include top.h instead of interps.h. (ioscm_with_output_to_port_worker): Access the current UI's async field instead of the interpreter_async global. * inf-loop.c (inferior_event_handler): Likewise. * infcall.c (run_inferior_call): Likewise. * infrun.c (reinstall_readline_callback_handler_cleanup) (fetch_inferior_event): Likewise. * interps.c (interpreter_async): Delete. (struct ui_interp_info): New. (get_current_interp_info): New function. (interp_list, current_interpreter, top_level_interpreter_ptr): Delete. (interp_add, interp_set, interp_lookup, interp_ui_out) (current_interp_set_logging, interp_set_temp) (current_interp_named_p): Adjust to per-UI interpreters. (command_interpreter): Delete. (command_interp, current_interp_command_loop, interp_quiet_p) (interp_exec, interpreter_exec_cmd, interpreter_completer) (top_level_interpreter, top_level_interpreter_data): Adjust to per-UI interpreters. * interps.h (interpreter_async): Delete. * main.c (captured_command_loop): Access the current UI's async field instead of the interpreter_async global. * python/python.c (python_interactive_command, python_command) (execute_gdb_command): Likewise. * top.c (maybe_wait_sync_command_done, execute_command_to_string): Access the current UI's async field instead of the interpreter_async global. * top.h (struct tl_interp_info): Forward declare. (struct ui) <interp_info, async>: New fields.
2016-06-21 02:11:45 +02:00
old_interp = ui_interp->current_interpreter;
2003-02-06 06:30:17 +01:00
Introduce interpreter factories If every UI instance has its own set of interpreters, then the current scheme of creating the interpreters at GDB initialization time no longer works. We need to create them whenever a new UI instance is created. The scheme implemented here has each interpreter register a factory callback that when called creates a new instance of a specific interpreter type. Then, when some code in gdb looks up an interpreter (always by name), if there's none yet, the factory method is called to construct one. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_uiout): Delete, moved into ... (struct cli_interp): ... this new structure. (cli_on_normal_stop, cli_on_signal_received) (cli_on_end_stepping_range, cli_on_signal_exited, cli_on_exited) (cli_on_no_history): Use interp_ui_out. (cli_interpreter_init): If top level, set the cli_interp global. (cli_interpreter_init): Return the interp's data instead of NULL. (cli_interpreter_resume, cli_interpreter_exec, cli_ui_out): Adjust to cli_uiout being in the interpreter's data. (cli_interp_procs): New, factored out from _initialize_cli_interp. (cli_interp_factory): New function. (_initialize_cli_interp): Call interp_factory_register. * interps.c (get_interp_info): New, factored out from ... (get_current_interp_info): ... this. (interp_new): Add parameter 'data'. Store it. (struct interp_factory): New function. (interp_factory_p): New typedef. Define a VEC_P. (interpreter_factories): New global. (interp_factory_register): New function. (interp_add): Add 'ui' parameter. Use get_interp_info and interp_lookup_existing. (interp_lookup): Rename to ... (interp_lookup_existing): ... this. Add 'ui' parameter. Don't check for NULL or empty name here. (interp_lookup): Add 'ui' parameter and reimplement. (interp_set_temp, interpreter_exec_cmd): Adjust. (interpreter_completer): Complete on registered interpreter factories instead of interpreters. * interps.h (interp_factory_func): New typedef. (interp_factory_register): Declare. (interp_new, interp_add): Adjust. (interp_lookup): Declare. * main.c (captured_main): Adjust. * mi/mi-interp.c (mi_cmd_interpreter_exec): Adjust. (mi_interp_procs): New, factored out from _initialize_mi_interp. (mi_interp_factory): New function. * python/python.c (execute_gdb_command): Adjust. * tui/tui-interp.c (tui_init): If top level, set the tui_interp global. (tui_interp_procs): New. (tui_interp_factory): New function. (_initialize_tui_interp): Call interp_factory_register.
2016-06-21 02:11:45 +02:00
interp_to_use = interp_lookup (current_ui, prules[0]);
2003-02-06 06:30:17 +01:00
if (interp_to_use == NULL)
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
error (_("Could not find interpreter \"%s\"."), prules[0]);
2003-02-06 06:30:17 +01:00
C++-fy struct interp/cli_interp/tui_interp/mi_interp - The interp->data field disappears, since we can put data in the interpreter directly now. The "init" method remains in place, but it now returns void. - A few places check if the interpreter method is NULL before calling it, and also check whether the method returns true/false. For some of those methods, all current implementations always return true. In those cases, this commit makes the C++-fied method return void instead and cleans up the callers. Tested on x86_64 Fedora 23. gdb/ChangeLog: 2017-02-03 Pedro Alves <palves@redhat.com> * cli/cli-interp.c (cli_interp_base::cli_interp_base) (cli_interp_base::~cli_interp_base): New. (cli_interp): New struct. (as_cli_interp): Cast the interp itself to cli_interp. (cli_interpreter_pre_command_loop): Rename to ... (cli_interp_base::pre_command_loop): ... this. Remove 'self' parameter. (cli_interpreter_init): Rename to ... (cli_interp::init): ... this. Remove 'self' parameter. Use boolean. Make extern. (cli_interpreter_resume): Rename to ... (cli_interp::resume): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_suspend): Rename to ... (cli_interp::suspend): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_exec): Rename to ... (cli_interp::exec): ... this. Remove 'data' parameter. Make extern. (cli_interpreter_supports_command_editing): Rename to ... (cli_interp_base::supports_command_editing): ... this. Remove 'interp' parameter. Make extern. (cli_ui_out): Rename to ... (cli_interp::interp_ui_out): ... this. Remove 'interp' parameter. Make extern. (cli_set_logging): Rename to ... (cli_interp_base::set_logging): ... this. Remove 'interp' parameter. Make extern. (cli_interp_procs): Delete. (cli_interp_factory): Adjust to use "new". * cli/cli-interp.h: Include "interps.h". (struct cli_interp_base): New struct. * interps.c (struct interp): Delete. Fields moved to interps.h. (interp_new): Delete. (interp::interp, interp::~interp): New. (interp_set): Use bool, and return void. Assume the interpreter has suspend, init and resume methods, and that the all return void. (set_top_level_interpreter): interp_set returns void. (interp_ui_out): Adapt. (current_interp_set_logging): Adapt. (interp_data): Delete. (interp_pre_command_loop, interp_supports_command_editing): Adapt. (interp_exec): Adapt. (top_level_interpreter_data): Delete. * interps.h (interp_init_ftype, interp_resume_ftype) (interp_suspend_ftype, interp_exec_ftype) (interp_pre_command_loop_ftype, interp_ui_out_ftype): Delete. (class interp): New. (interp_new): Delete. (interp_set): Now returns void. Use bool. (interp_data, top_level_interpreter_data): Delete. * mi/mi-common.h: Include interps.h. (class mi_interp): Inherit from interp. Define a ctor. Declare init, resume, suspect, exec, interp_ui_out, set_logging and pre_command_loop methods. * mi/mi-interp.c (as_mi_interp): Cast the interp itself. (mi_interpreter_init): Rename to ... (mi_interp::init): ... this. Remove the 'interp' parameter, use bool, return void and make extern. Adjust. (mi_interpreter_resume): ... Rename to ... (mi_interp::resume): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (mi_interpreter_suspend): ... Rename to ... (mi_interp::suspend): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (mi_interpreter_exec): ... Rename to ... (mi_interp::exec): ... this. Remove the 'data' parameter and make extern. Adjust. (mi_interpreter_pre_command_loop): ... Rename to ... (mi_interp::pre_command_loop): ... this. Remove the 'self' parameter and make extern. (mi_on_normal_stop_1): Adjust. (mi_ui_out): Rename to ... (mi_interp::interp_ui_out): ... this. Remove the 'interp' parameter and make extern. Adjust. (mi_set_logging): Rename to ... (mi_interp::set_logging): ... this. Remove the 'interp' parameter and make extern. Adjust. (mi_interp_procs): Delete. (mi_interp_factory): Adjust to use 'new'. * mi/mi-main.c (mi_cmd_gdb_exit, captured_mi_execute_command) (mi_print_exception, mi_execute_command, mi_load_progress): Adjust. * tui/tui-interp.c (tui_interp): New class. (as_tui_interp): Return a tui_interp pointer. (tui_on_normal_stop, tui_on_signal_received) (tui_on_end_stepping_range, tui_on_signal_exited, tui_on_exited) (tui_on_no_history, tui_on_user_selected_context_changed): Adjust to use interp::interp_ui_out. (tui_init): Rename to ... (tui_interp::init): ... this. Remove the 'self' parameter, use bool, return void and make extern. Adjust. (tui_resume): Rename to ... (tui_interp::resume): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (tui_suspend): Rename to ... (tui_interp::suspend): ... this. Remove the 'data' parameter, return void and make extern. Adjust. (tui_ui_out): Rename to ... (tui_interp::interp_ui_out): ... this. Remove the 'self' parameter, and make extern. Adjust. (tui_exec): Rename to ... (tui_interp::exec): ... this. Remove the 'data' parameter and make extern. (tui_interp_procs): Delete. (tui_interp_factory): Use "new".
2017-02-03 17:30:04 +01:00
interp_set (interp_to_use, false);
2003-02-06 06:30:17 +01:00
for (i = 1; i < nrules; i++)
{
struct gdb_exception e = interp_exec (interp_to_use, prules[i]);
if (e.reason < 0)
2003-02-06 06:30:17 +01:00
{
interp_set (old_interp, 0);
2005-02-10 Andrew Cagney <cagney@gnu.org> Mark up all error and warning messages. * ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update. * bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update. * core-aout.c, core-regset.c, corefile.c, corelow.c: Update. * cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update. * dbxread.c, demangle.c, doublest.c, dsrec.c: Update. * dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update. * dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update. * event-top.c, exec.c, expprint.c, f-lang.c: Update. * f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update. * frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update. * gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update. * hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update. * hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update. * hpread.c, hpux-thread.c, i386-linux-nat.c: Update. * i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update. * i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update. * ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update. * infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update. * inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update. * kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update. * linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update. * m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update. * m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update. * maint.c, mdebugread.c, mem-break.c, memattr.c: Update. * mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update. * nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update. * observer.c, ocd.c, p-lang.c, p-typeprint.c: Update. * p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update. * ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update. * remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update. * remote-rdp.c, remote-sim.c, remote-st.c: Update. * remote-utils.c, remote-utils.h, remote.c: Update. * rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update. * ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update. * sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update. * solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update. * solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update. * somread.c, somsolib.c, source.c, stabsread.c: Update. * stack.c, std-regs.c, symfile-mem.c, symfile.c: Update. * symmisc.c, symtab.c, target.c, thread.c, top.c: Update. * tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update. * uw-thread.c, valarith.c, valops.c, valprint.c: Update. * value.c, varobj.c, version.in, win32-nat.c, wince.c: Update. * xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update. * cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update. * cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update. * mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update. * mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update. * mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update. * tui/tui-win.c: Update.
2005-02-11 05:06:14 +01:00
error (_("error in command: \"%s\"."), prules[i]);
2003-02-06 06:30:17 +01:00
}
}
interp_set (old_interp, 0);
2003-02-06 06:30:17 +01:00
}
Add new command to create extra console/mi UIs With all the previous plumbing in place, it's now easy to add a command that actually creates a new console/mi UI. The intended use case is to make it possible and easy for MI frontends to provide a fully featured GDB console to users, with readline support, command line editing, history, etc., just like if gdb was started on the command line. Currently MI frontends have to try to implement all of that theirselves and make use of "-interpreter-exec console ...", which is far from perfect. If you ever tried Eclipse's gdb console window, you'll know what I mean... Instead of trying to multiplex console through MI, this command let's just leverage all the built in readline/editing support already inside gdb. The plan is for the MI frontend to start GDB in regular console mode, running inside a terminal emulator widget embedded in Eclipse (which already exists, for supporting the shell widget; other frontends have similar widgets), and then tell GDB to run a full MI interpreter on an specified input/output device, independent of the console. My original prototype planned to do things the other way around -- start GDB in MI mode, and then start an extra CLI console on separate tty. I handed over that prototype to Marc Khouzam @ Eclipse CDT, and after experimentation and discussion, we ended up concluding that starting GDB in CLI mode instead was both easier and actually also supported an interesting use case -- connect an Eclipse frontend to a GDB that is already running outside Eclipse. The current usage is "new-ui <interpreter> <tty>". E.g., on a terminal run this scriplet: $ cat gdb-client #!/bin/bash reset tty tail -f /dev/null $ gdb-client /dev/pts/15 Now run gdb on another terminal, and tell it to start a MI interpreter on the tty of the other terminal: ... (gdb) new-ui mi /dev/pts/15 New UI allocated Now back to the the gdb-client terminal, we'll get an MI prompt, ready for MI input: /dev/pts/15 =thread-group-added,id="i1" (gdb) You can also start a new UI running a CLI, with: (gdb) new-ui console /dev/pts/15 Though note that this console won't support readline command editing. It works as if "set editing off" was entered. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * interps.c (set_top_level_interpreter): New function, factored out from captured_main. (interpreter_completer): Make extern. * interps.h (set_top_level_interpreter, interpreter_completer): New declarations. (captured_main): Use set_top_level_interpreter. * top.c [!O_NOCTTY] (O_NOCTTY): Define as 0. (open_terminal_stream, new_ui_command): New functions. (init_main): Install the "new-ui" command.
2016-06-21 02:11:55 +02:00
/* See interps.h. */
Introduce class completion_tracker & rewrite completion<->readline interaction This patch reworks the whole completion machinery, and prepares it for later enhancements. Adds a new "completion_tracker" class that is meant to hold everything about the state of the current completion operation. This class now has the responsibility of tracking the list of completion matches, and checking whether the max completions limit has been reached. You can look at this as this patch starting out by C++fying the existing "completion_tracker" in symtab.c (it's just an htab_t typedef currently), moving it to completer.h/c, and then making it a class/generalizing/enhancing it. Unlike with the current tracking, completion_tracker now checks whether the limit has been reached on each completion match list insertion. This both simplifies the max-completions handling code (maybe_add_completion_enum is gone, for example), and is a prerequisite for follow up patches. The current completion_tracker is only used for symbol completions, and the symbol code gets at the current instance via globals. This patch cleans that up by adding a completion_tracker reference to the signature of the completion functions, and passing the tracker around everywhere necessary. Then, the patch changes how the completion match list is handed over to readline. Currently, we're using the rl_completion_entry_function readline entry point, and the patch switches to rl_attempted_completion_function. A following patch will want to let GDB itself decide the common completion prefix between all matches (what readline calls the "lowest common denominator"), instead of having readline compute it, and that's not possible with the rl_completion_entry_function entry point. Also, rl_attempted_completion_function lets GDB hand over the match list to readline as an array in one go instead of passing down matches one by one, so from that angle it's a nicer entry point anyway. Lastly, the patch catches exceptions around the readline entry points, because we can't let C++ exceptions cross readline. We handle that in the readline input entry point, but the completion entry point isn't guarded, so GDB can abort if completion throws. E.g., in current master: (gdb) b -function "fun<tab> terminate called after throwing an instance of 'gdb_exception_RETURN_MASK_ERROR' Aborted (core dumped) This patch fixes that. This will be exercised in the new tests added later on in the series. gdb/ChangeLog: 2017-07-17 Pedro Alves <palves@redhat.com> * ada-lang.c (symbol_completion_match): Adjust comments. (symbol_completion_add): Replace vector parameter with completion_tracker parameter. Use it. (ada_make_symbol_completion_list): Rename to... (ada_collect_symbol_completion_matches): ... this. Add completion_tracker parameter and use it. (ada_language_defn): Adjust. * break-catch-syscall.c (catch_syscall_completer): Adjust prototype and work with completion_tracker instead of VEC. * breakpoint.c (condition_completer): Adjust prototype and work with completion_tracker instead of VEC. * c-lang.c (c_language_defn, cplus_language_defn) (asm_language_defn, minimal_language_defn): Adjust to renames. * cli/cli-cmds.c (complete_command): Rework using completion_tracker. Catch exceptions when completing. * cli/cli-decode.c (integer_unlimited_completer) (complete_on_cmdlist, complete_on_enum): Adjust prototype and work with completion_tracker instead of VEC. * command.h (struct completion_tracker): Forward declare. (completer_ftype, completer_handle_brkchars_ftype): Change types. (complete_on_cmdlist, complete_on_enum): Adjust. * completer.c: Include <algorithm>. (struct gdb_completer_state): New. (current_completion): New global. (readline_line_completion_function): Delete. (noop_completer, filename_completer) (filename_completer_handle_brkchars, complete_files_symbols) (linespec_location_completer): Adjust to work with a completion_tracker instead of a VEC. (string_or_empty): New. (collect_explicit_location_matches): Adjust to work with a completion_tracker instead of a VEC. (explicit_location_completer): Rename to ... (complete_explicit_location): ... this and adjust to work with a completion_tracker instead of a VEC. (location_completer): Adjust to work with a completion_tracker instead of a VEC. (add_struct_fields): Adjust to work with a completion_list instead of VEC. (expression_completer): Rename to ... (complete_expression): ... this and adjust to work with a completion_tracker instead of a VEC. Use complete_files_symbols. (expression_completer): Reimplement on top of complete_expression. (symbol_completer): Adjust to work with a completion_tracker instead of a VEC. (enum complete_line_internal_reason): Add describing comments. (complete_line_internal_normal_command): Adjust to work with a completion_tracker instead of a VEC. (complete_line_internal): Rename to ... (complete_line_internal_1): ... this and adjust to work with a completion_tracker instead of a VEC. Assert TEXT is NULL in the handle_brkchars phase. (new_completion_tracker): Delete. (complete_line_internal): Reimplement as TRY/CATCH wrapper around complete_line_internal_1. (free_completion_tracker): Delete. (INITIAL_COMPLETION_HTAB_SIZE): New. (completion_tracker::completion_tracker) (completion_tracker::~completion_tracker): New. (maybe_add_completion): Delete. (completion_tracker::maybe_add_completion) (completion_tracker::add_completion) (completion_tracker::add_completions): New. (throw_max_completions_reached_error): Delete. (complete_line): Adjust to work with a completion_tracker instead of a VEC. Don't create a completion_tracker_t or check for max completions here. (command_completer, command_completer_handle_brkchars) (signal_completer, reg_or_group_completer_1) (reg_or_group_completer, default_completer_handle_brkchars): Adjust to work with a completion_tracker. (gdb_completion_word_break_characters_throw): New. (gdb_completion_word_break_characters): Reimplement. (line_completion_function): Delete. (completion_tracker::recompute_lowest_common_denominator) (expand_preserving_ws) (completion_tracker::build_completion_result) (completion_result::completion_result) (completion_result::completion_result) (completion_result::~completion_result) (completion_result::completion_result) (completion_result::release_match_list, compare_cstrings) (completion_result::sort_match_list) (completion_result::reset_match_list) (gdb_rl_attempted_completion_function_throw) (gdb_rl_attempted_completion_function): New. * completer.h (completion_list, struct completion_result) (class completion_tracker): New. (complete_line): Add completion_tracker parameter. (readline_line_completion_function): Delete. (gdb_rl_attempted_completion_function): New. (noop_completer, filename_completer, expression_completer) (location_completer, symbol_completer, command_completer) (signal_completer, reg_or_group_completer): Update prototypes. (completion_tracker_t, new_completion_tracker) (make_cleanup_free_completion_tracker): Delete. (enum maybe_add_completion_enum): Delete. (maybe_add_completion): Delete. (throw_max_completions_reached_error): Delete. * corefile.c (complete_set_gnutarget): Adjust to work with a completion_tracker instead of a VEC. * cp-abi.c (cp_abi_completer): Adjust to work with a completion_tracker instead of a VEC. * d-lang.c (d_language_defn): Adjust. * disasm.c (disassembler_options_completer): Adjust to work with a completion_tracker instead of a VEC. * f-lang.c (f_make_symbol_completion_list): Rename to ... (f_collect_symbol_completion_matches): ... this. Adjust to work with a completion_tracker instead of a VEC. (f_language_defn): Adjust. * go-lang.c (go_language_defn): Adjust. * guile/scm-cmd.c (cmdscm_add_completion, cmdscm_completer): Adjust to work with a completion_tracker instead of a VEC. * infrun.c (handle_completer): Likewise. * interps.c (interpreter_completer): Likewise. * interps.h (interpreter_completer): Likewise. * language.c (unknown_language_defn, auto_language_defn) (local_language_defn): Adjust. * language.h (language_defn::la_make_symbol_completion_list): Rename to ... (language_defn::la_collect_symbol_completion_matches): ... this and adjust to work with a completion_tracker instead of a VEC. * m2-lang.c (m2_language_defn): Adjust. * objc-lang.c (objc_language_defn): Adjust. * opencl-lang.c (opencl_language_defn): Adjust. * p-lang.c (pascal_language_defn): Adjust. * python/py-cmd.c (cmdpy_completer_helper): Handle NULL word. (cmdpy_completer_handle_brkchars, cmdpy_completer): Adjust to work with a completion_tracker. * rust-lang.c (rust_language_defn): Adjust. * symtab.c (free_completion_list, do_free_completion_list) (return_val, completion_tracker): Delete. (completion_list_add_name, completion_list_add_symbol) (completion_list_add_msymbol, completion_list_objc_symbol) (completion_list_add_fields, add_symtab_completions): Add completion_tracker parameter and use it. (default_make_symbol_completion_list_break_on_1): Rename to... (default_collect_symbol_completion_matches_break_on): ... this. Add completion_tracker parameter and use it instead of allocating a completion tracker here. (default_make_symbol_completion_list_break_on): Delete old implementation. (default_make_symbol_completion_list): Delete. (default_collect_symbol_completion_matches): New. (make_symbol_completion_list): Delete. (collect_symbol_completion_matches): New. (make_symbol_completion_type): Rename to ... (collect_symbol_completion_matches_type): ... this. Add completion_tracker parameter and use it instead of VEC. (make_file_symbol_completion_list_1): Rename to... (collect_file_symbol_completion_matches): ... this. Add completion_tracker parameter and use it instead of VEC. (make_file_symbol_completion_list): Delete. (add_filename_to_list): Use completion_list instead of a VEC. (add_partial_filename_data::list): Now a completion_list. (make_source_files_completion_list): Work with a completion_list instead of a VEC. * symtab.h: Include "completer.h". (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_type, make_file_symbol_completion_list) (make_source_files_completion_list): Delete. (default_collect_symbol_completion_matches_break_on) (default_collect_symbol_completion_matches) (collect_symbol_completion_matches) (collect_symbol_completion_matches_type) (collect_file_symbol_completion_matches) (make_source_files_completion_list): New. * top.c (init_main): Don't install a rl_completion_entry_function hook. Install a rl_attempted_completion_function hook instead. * tui/tui-layout.c (layout_completer): Adjust to work with a completion_tracker. * tui/tui-regs.c (tui_reggroup_completer): * tui/tui-win.c (window_name_completer, focus_completer) (winheight_completer): Adjust to work with a completion_tracker. * value.c: Include "completer.h". (complete_internalvar): Adjust to work with a completion_tracker. * value.h (complete_internalvar): Likewise.
2017-07-17 15:45:59 +02:00
void
Constify strings in tracepoint.c, lookup_cmd and the completers. This is sort of a continuation of Keith's parse_exp_1 constification patch. It started out by undoing these bits: @@ -754,9 +754,12 @@ validate_actionline (char **line, struct tmp_p = p; for (loc = t->base.loc; loc; loc = loc->next) { - p = tmp_p; - exp = parse_exp_1 (&p, loc->address, + const char *q; + + q = tmp_p; + exp = parse_exp_1 (&q, loc->address, block_for_pc (loc->address), 1); + p = (char *) q; and progressively making more things const upwards, fixing fallout, rinse repeat, until GDB built again (--enable-targets=all). That ended up constifying lookup_cmd/add_cmd and (lots of) friends, and the completers. I didn't try to constify the command hooks themselves, because I know upfront there are commands that write to the command string argument, and I think I managed to stop at a nice non-hacky split point already. I think the only non-really-super-obvious changes are tracepoint.c:validate_actionline, and tracepoint.c:trace_dump_actions. The rest is just mostly about 'char *' => 'const char *', 'char **'=> 'const char **', and the occasional (e.g., deprecated_cmd_warning) case of 'char **'=> 'const char *', where/when I noticed that nothing actually cares about the pointer to pointer output. Tested on x86_64 Fedora 17, native and gdbserver. gdb/ 2013-03-13 Pedro Alves <palves@redhat.com> * ada-lang.c (struct add_partial_datum) <text, text0, word>: Make fields const. (ada_make_symbol_completion_list): Make "text0" parameter const. * ax-gdb.c (agent_eval_command_one): Make "exp" parameter const. * breakpoint.c (condition_completer): Make "text" and "word" parameters const. Adjust. (check_tracepoint_command): Adjust to validate_actionline prototype change. (catch_syscall_completer): Make "text" and "word" parameters const. * cli/cli-cmds.c (show_user): Make "comname" local const. (valid_command_p): Make "command" parameter const. (alias_command): Make "alias_prefix" and "command_prefix" locals const. * cli/cli-decode.c (add_cmd): Make "name" parameter const. (add_alias_cmd): Make "name" and "oldname" parameters const. Adjust. No longer make copy of OLDNAME. (add_prefix_cmd, add_abbrev_prefix_cmd, add_set_or_show_cmd) (add_setshow_cmd_full, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd) (delete_cmd, add_info, add_info_alias, add_com, add_com_alias): Make "name" parameter const. (help_cmd): Rename "command" parameter to "arg". New const local "command". (find_cmd): Make "command" parameter const. (lookup_cmd_1): Make "text" parameter pointer to const. Adjust to deprecated_cmd_warning prototype change. (undef_cmd_error): Make "cmdtype" parameter const. (lookup_cmd): Make "line" parameter const. (deprecated_cmd_warning): Change type of "text" parameter to pointer to const char, from pointer to pointer to char. Adjust. (lookup_cmd_composition): Make "text" parameter const. (complete_on_cmdlist, complete_on_enum): Make "text" and "word" parameters const. * cli/cli-decode.h (struct cmd_list_element) <name>: Make field const. * cli/cli-script.c (validate_comname): Make "tem" local const. (define_command): New const local "tem_c". Use it in calls to lookup_cmd. (document_command): Make "tem" and "comfull" locals const. (show_user_1): Make "prefix" and "name" parameters const. * cli-script.h (show_user_1): Make "prefix" and "name" parameters const. * command.h (add_cmd, add_alias_cmd, add_prefix_cmd) (add_abbrev_prefix_cmd, completer_ftype, lookup_cmd, lookup_cmd_1) (deprecated_cmd_warning, lookup_cmd_composition, add_com) (add_com_alias, add_info, add_info_alias, complete_on_cmdlist) (complete_on_enum, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Change prototypes, constifying strings. * completer.c (noop_completer, filename_completer): Make "text" and "prefix" parameters const. (location_completer, expression_completer) (complete_line_internal): Make "text" and "prefix" parameters const and adjust. (command_completer, signal_completer): Make "text" and "prefix" parameters const. * completer.h (noop_completer, filename_completer) (expression_completer, location_completer, command_completer) (signal_completer): Change prototypes. * corefile.c (complete_set_gnutarget): Make "text" and "word" parameters const. * cp-abi.c (cp_abi_completer): Likewise. * expression.h (parse_expression_for_completion): Change prototype. * f-lang.c (f_make_symbol_completion_list): Make "text" and "word" parameters const. * infcmd.c (_initialize_infcmd): Make "cmd_name" local const. * infrun.c (handle_completer): Make "text" and "word" parameters const. * interps.c (interpreter_completer): Make "text" and "word" parameters const. * language.h (struct language_defn) <la_make_symbol_completion_list>: Make "text" and "word" parameters const. * parse.c (parse_exp_1): Move const hack to parse_exp_in_context. (parse_exp_in_context): Rename to ... (parse_exp_in_context_1): ... this. (parse_exp_in_context): Reimplement, with const hack from parse_exp_1. (parse_expression_for_completion): Make "string" parameter const. * printcmd.c (decode_format): Make "string_ptr" parameter pointer to pointer to const char. Adjust. (print_command_1): Make "exp" parameter const. (output_command): Rename to ... (output_command_const): ... this. Make "exp" parameter const. (output_command): Reimplement. (x_command): Adjust. (display_command): Rename "exp" parameter to "arg". New "exp" local, const version of "arg". * python/py-auto-load.c (gdbpy_initialize_auto_load): Make "cmd_name" local const. * python/py-cmd.c (cmdpy_destroyer): Cast const away in xfree call. (cmdpy_completer): Make "text" and "word" parameters const. (gdbpy_parse_command_name): Make "prefix_text2" local const. * python/py-param.c (add_setshow_generic): Make "tmp_name" local const. * remote.c (_initialize_remote): Make "cmd_name" local const. * symtab.c (language_search_unquoted_string): Make "text" and "p" parameters const. Adjust. (completion_list_add_fields): Make "sym_text", "text" and "word" parameters const. (struct add_name_data) <sym_text, text, word>: Make fields const. (default_make_symbol_completion_list_break_on): Make "text" and "word" parameters const. Adjust locals. (default_make_symbol_completion_list) (make_symbol_completion_list, make_symbol_completion_type) (make_symbol_completion_list_fn): Make "text" and "word" parameters const. (make_file_symbol_completion_list): Make "text", "word" and "srcfile" parameters const. Adjust locals. (add_filename_to_list): Make "text" and "word" parameters const. (struct add_partial_filename_data) <text, word>: Make fields const. (make_source_files_completion_list): Make "text" and "word" parameters const. * symtab.h (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_type enum type_code) (make_symbol_completion_list_fn make_file_symbol_completion_list) (make_source_files_completion_list): Change prototype. * top.c (execute_command): Adjust to pass pointer to pointer to const char to lookup_cmd, and to deprecated_cmd_warning prototype change. (set_verbose): Make "cmdname" local const. * tracepoint.c (decode_agent_options): Make "exp" parameter const, and adjust. (validate_actionline): Make "line" parameter a pointer to const char, and adjust. (encode_actions_1): Make "action_exp" local const, and adjust. (encode_actions): Adjust. (replace_comma): Delete. (trace_dump_actions): Make "action_exp" and "next_comma" locals const, and adjust. Don't frob the action string while splitting it at commas. Instead, make a copy of each split substring in turn. (trace_dump_command): Adjust to validate_actionline prototype change. * tracepoint.h (decode_agent_options, decode_agent_options) (encode_actions, validate_actionline): Change prototypes. * valprint.h (output_command): Delete declaration. (output_command_const): Declare. * value.c (function_destroyer): Cast const away in xfree call.
2013-03-13 19:34:55 +01:00
interpreter_completer (struct cmd_list_element *ignore,
Introduce class completion_tracker & rewrite completion<->readline interaction This patch reworks the whole completion machinery, and prepares it for later enhancements. Adds a new "completion_tracker" class that is meant to hold everything about the state of the current completion operation. This class now has the responsibility of tracking the list of completion matches, and checking whether the max completions limit has been reached. You can look at this as this patch starting out by C++fying the existing "completion_tracker" in symtab.c (it's just an htab_t typedef currently), moving it to completer.h/c, and then making it a class/generalizing/enhancing it. Unlike with the current tracking, completion_tracker now checks whether the limit has been reached on each completion match list insertion. This both simplifies the max-completions handling code (maybe_add_completion_enum is gone, for example), and is a prerequisite for follow up patches. The current completion_tracker is only used for symbol completions, and the symbol code gets at the current instance via globals. This patch cleans that up by adding a completion_tracker reference to the signature of the completion functions, and passing the tracker around everywhere necessary. Then, the patch changes how the completion match list is handed over to readline. Currently, we're using the rl_completion_entry_function readline entry point, and the patch switches to rl_attempted_completion_function. A following patch will want to let GDB itself decide the common completion prefix between all matches (what readline calls the "lowest common denominator"), instead of having readline compute it, and that's not possible with the rl_completion_entry_function entry point. Also, rl_attempted_completion_function lets GDB hand over the match list to readline as an array in one go instead of passing down matches one by one, so from that angle it's a nicer entry point anyway. Lastly, the patch catches exceptions around the readline entry points, because we can't let C++ exceptions cross readline. We handle that in the readline input entry point, but the completion entry point isn't guarded, so GDB can abort if completion throws. E.g., in current master: (gdb) b -function "fun<tab> terminate called after throwing an instance of 'gdb_exception_RETURN_MASK_ERROR' Aborted (core dumped) This patch fixes that. This will be exercised in the new tests added later on in the series. gdb/ChangeLog: 2017-07-17 Pedro Alves <palves@redhat.com> * ada-lang.c (symbol_completion_match): Adjust comments. (symbol_completion_add): Replace vector parameter with completion_tracker parameter. Use it. (ada_make_symbol_completion_list): Rename to... (ada_collect_symbol_completion_matches): ... this. Add completion_tracker parameter and use it. (ada_language_defn): Adjust. * break-catch-syscall.c (catch_syscall_completer): Adjust prototype and work with completion_tracker instead of VEC. * breakpoint.c (condition_completer): Adjust prototype and work with completion_tracker instead of VEC. * c-lang.c (c_language_defn, cplus_language_defn) (asm_language_defn, minimal_language_defn): Adjust to renames. * cli/cli-cmds.c (complete_command): Rework using completion_tracker. Catch exceptions when completing. * cli/cli-decode.c (integer_unlimited_completer) (complete_on_cmdlist, complete_on_enum): Adjust prototype and work with completion_tracker instead of VEC. * command.h (struct completion_tracker): Forward declare. (completer_ftype, completer_handle_brkchars_ftype): Change types. (complete_on_cmdlist, complete_on_enum): Adjust. * completer.c: Include <algorithm>. (struct gdb_completer_state): New. (current_completion): New global. (readline_line_completion_function): Delete. (noop_completer, filename_completer) (filename_completer_handle_brkchars, complete_files_symbols) (linespec_location_completer): Adjust to work with a completion_tracker instead of a VEC. (string_or_empty): New. (collect_explicit_location_matches): Adjust to work with a completion_tracker instead of a VEC. (explicit_location_completer): Rename to ... (complete_explicit_location): ... this and adjust to work with a completion_tracker instead of a VEC. (location_completer): Adjust to work with a completion_tracker instead of a VEC. (add_struct_fields): Adjust to work with a completion_list instead of VEC. (expression_completer): Rename to ... (complete_expression): ... this and adjust to work with a completion_tracker instead of a VEC. Use complete_files_symbols. (expression_completer): Reimplement on top of complete_expression. (symbol_completer): Adjust to work with a completion_tracker instead of a VEC. (enum complete_line_internal_reason): Add describing comments. (complete_line_internal_normal_command): Adjust to work with a completion_tracker instead of a VEC. (complete_line_internal): Rename to ... (complete_line_internal_1): ... this and adjust to work with a completion_tracker instead of a VEC. Assert TEXT is NULL in the handle_brkchars phase. (new_completion_tracker): Delete. (complete_line_internal): Reimplement as TRY/CATCH wrapper around complete_line_internal_1. (free_completion_tracker): Delete. (INITIAL_COMPLETION_HTAB_SIZE): New. (completion_tracker::completion_tracker) (completion_tracker::~completion_tracker): New. (maybe_add_completion): Delete. (completion_tracker::maybe_add_completion) (completion_tracker::add_completion) (completion_tracker::add_completions): New. (throw_max_completions_reached_error): Delete. (complete_line): Adjust to work with a completion_tracker instead of a VEC. Don't create a completion_tracker_t or check for max completions here. (command_completer, command_completer_handle_brkchars) (signal_completer, reg_or_group_completer_1) (reg_or_group_completer, default_completer_handle_brkchars): Adjust to work with a completion_tracker. (gdb_completion_word_break_characters_throw): New. (gdb_completion_word_break_characters): Reimplement. (line_completion_function): Delete. (completion_tracker::recompute_lowest_common_denominator) (expand_preserving_ws) (completion_tracker::build_completion_result) (completion_result::completion_result) (completion_result::completion_result) (completion_result::~completion_result) (completion_result::completion_result) (completion_result::release_match_list, compare_cstrings) (completion_result::sort_match_list) (completion_result::reset_match_list) (gdb_rl_attempted_completion_function_throw) (gdb_rl_attempted_completion_function): New. * completer.h (completion_list, struct completion_result) (class completion_tracker): New. (complete_line): Add completion_tracker parameter. (readline_line_completion_function): Delete. (gdb_rl_attempted_completion_function): New. (noop_completer, filename_completer, expression_completer) (location_completer, symbol_completer, command_completer) (signal_completer, reg_or_group_completer): Update prototypes. (completion_tracker_t, new_completion_tracker) (make_cleanup_free_completion_tracker): Delete. (enum maybe_add_completion_enum): Delete. (maybe_add_completion): Delete. (throw_max_completions_reached_error): Delete. * corefile.c (complete_set_gnutarget): Adjust to work with a completion_tracker instead of a VEC. * cp-abi.c (cp_abi_completer): Adjust to work with a completion_tracker instead of a VEC. * d-lang.c (d_language_defn): Adjust. * disasm.c (disassembler_options_completer): Adjust to work with a completion_tracker instead of a VEC. * f-lang.c (f_make_symbol_completion_list): Rename to ... (f_collect_symbol_completion_matches): ... this. Adjust to work with a completion_tracker instead of a VEC. (f_language_defn): Adjust. * go-lang.c (go_language_defn): Adjust. * guile/scm-cmd.c (cmdscm_add_completion, cmdscm_completer): Adjust to work with a completion_tracker instead of a VEC. * infrun.c (handle_completer): Likewise. * interps.c (interpreter_completer): Likewise. * interps.h (interpreter_completer): Likewise. * language.c (unknown_language_defn, auto_language_defn) (local_language_defn): Adjust. * language.h (language_defn::la_make_symbol_completion_list): Rename to ... (language_defn::la_collect_symbol_completion_matches): ... this and adjust to work with a completion_tracker instead of a VEC. * m2-lang.c (m2_language_defn): Adjust. * objc-lang.c (objc_language_defn): Adjust. * opencl-lang.c (opencl_language_defn): Adjust. * p-lang.c (pascal_language_defn): Adjust. * python/py-cmd.c (cmdpy_completer_helper): Handle NULL word. (cmdpy_completer_handle_brkchars, cmdpy_completer): Adjust to work with a completion_tracker. * rust-lang.c (rust_language_defn): Adjust. * symtab.c (free_completion_list, do_free_completion_list) (return_val, completion_tracker): Delete. (completion_list_add_name, completion_list_add_symbol) (completion_list_add_msymbol, completion_list_objc_symbol) (completion_list_add_fields, add_symtab_completions): Add completion_tracker parameter and use it. (default_make_symbol_completion_list_break_on_1): Rename to... (default_collect_symbol_completion_matches_break_on): ... this. Add completion_tracker parameter and use it instead of allocating a completion tracker here. (default_make_symbol_completion_list_break_on): Delete old implementation. (default_make_symbol_completion_list): Delete. (default_collect_symbol_completion_matches): New. (make_symbol_completion_list): Delete. (collect_symbol_completion_matches): New. (make_symbol_completion_type): Rename to ... (collect_symbol_completion_matches_type): ... this. Add completion_tracker parameter and use it instead of VEC. (make_file_symbol_completion_list_1): Rename to... (collect_file_symbol_completion_matches): ... this. Add completion_tracker parameter and use it instead of VEC. (make_file_symbol_completion_list): Delete. (add_filename_to_list): Use completion_list instead of a VEC. (add_partial_filename_data::list): Now a completion_list. (make_source_files_completion_list): Work with a completion_list instead of a VEC. * symtab.h: Include "completer.h". (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_type, make_file_symbol_completion_list) (make_source_files_completion_list): Delete. (default_collect_symbol_completion_matches_break_on) (default_collect_symbol_completion_matches) (collect_symbol_completion_matches) (collect_symbol_completion_matches_type) (collect_file_symbol_completion_matches) (make_source_files_completion_list): New. * top.c (init_main): Don't install a rl_completion_entry_function hook. Install a rl_attempted_completion_function hook instead. * tui/tui-layout.c (layout_completer): Adjust to work with a completion_tracker. * tui/tui-regs.c (tui_reggroup_completer): * tui/tui-win.c (window_name_completer, focus_completer) (winheight_completer): Adjust to work with a completion_tracker. * value.c: Include "completer.h". (complete_internalvar): Adjust to work with a completion_tracker. * value.h (complete_internalvar): Likewise.
2017-07-17 15:45:59 +02:00
completion_tracker &tracker,
Constify strings in tracepoint.c, lookup_cmd and the completers. This is sort of a continuation of Keith's parse_exp_1 constification patch. It started out by undoing these bits: @@ -754,9 +754,12 @@ validate_actionline (char **line, struct tmp_p = p; for (loc = t->base.loc; loc; loc = loc->next) { - p = tmp_p; - exp = parse_exp_1 (&p, loc->address, + const char *q; + + q = tmp_p; + exp = parse_exp_1 (&q, loc->address, block_for_pc (loc->address), 1); + p = (char *) q; and progressively making more things const upwards, fixing fallout, rinse repeat, until GDB built again (--enable-targets=all). That ended up constifying lookup_cmd/add_cmd and (lots of) friends, and the completers. I didn't try to constify the command hooks themselves, because I know upfront there are commands that write to the command string argument, and I think I managed to stop at a nice non-hacky split point already. I think the only non-really-super-obvious changes are tracepoint.c:validate_actionline, and tracepoint.c:trace_dump_actions. The rest is just mostly about 'char *' => 'const char *', 'char **'=> 'const char **', and the occasional (e.g., deprecated_cmd_warning) case of 'char **'=> 'const char *', where/when I noticed that nothing actually cares about the pointer to pointer output. Tested on x86_64 Fedora 17, native and gdbserver. gdb/ 2013-03-13 Pedro Alves <palves@redhat.com> * ada-lang.c (struct add_partial_datum) <text, text0, word>: Make fields const. (ada_make_symbol_completion_list): Make "text0" parameter const. * ax-gdb.c (agent_eval_command_one): Make "exp" parameter const. * breakpoint.c (condition_completer): Make "text" and "word" parameters const. Adjust. (check_tracepoint_command): Adjust to validate_actionline prototype change. (catch_syscall_completer): Make "text" and "word" parameters const. * cli/cli-cmds.c (show_user): Make "comname" local const. (valid_command_p): Make "command" parameter const. (alias_command): Make "alias_prefix" and "command_prefix" locals const. * cli/cli-decode.c (add_cmd): Make "name" parameter const. (add_alias_cmd): Make "name" and "oldname" parameters const. Adjust. No longer make copy of OLDNAME. (add_prefix_cmd, add_abbrev_prefix_cmd, add_set_or_show_cmd) (add_setshow_cmd_full, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_unlimited_cmd, add_setshow_zuinteger_cmd) (delete_cmd, add_info, add_info_alias, add_com, add_com_alias): Make "name" parameter const. (help_cmd): Rename "command" parameter to "arg". New const local "command". (find_cmd): Make "command" parameter const. (lookup_cmd_1): Make "text" parameter pointer to const. Adjust to deprecated_cmd_warning prototype change. (undef_cmd_error): Make "cmdtype" parameter const. (lookup_cmd): Make "line" parameter const. (deprecated_cmd_warning): Change type of "text" parameter to pointer to const char, from pointer to pointer to char. Adjust. (lookup_cmd_composition): Make "text" parameter const. (complete_on_cmdlist, complete_on_enum): Make "text" and "word" parameters const. * cli/cli-decode.h (struct cmd_list_element) <name>: Make field const. * cli/cli-script.c (validate_comname): Make "tem" local const. (define_command): New const local "tem_c". Use it in calls to lookup_cmd. (document_command): Make "tem" and "comfull" locals const. (show_user_1): Make "prefix" and "name" parameters const. * cli-script.h (show_user_1): Make "prefix" and "name" parameters const. * command.h (add_cmd, add_alias_cmd, add_prefix_cmd) (add_abbrev_prefix_cmd, completer_ftype, lookup_cmd, lookup_cmd_1) (deprecated_cmd_warning, lookup_cmd_composition, add_com) (add_com_alias, add_info, add_info_alias, complete_on_cmdlist) (complete_on_enum, add_setshow_enum_cmd) (add_setshow_auto_boolean_cmd, add_setshow_boolean_cmd) (add_setshow_filename_cmd, add_setshow_string_cmd) (add_setshow_string_noescape_cmd) (add_setshow_optional_filename_cmd, add_setshow_integer_cmd) (add_setshow_uinteger_cmd, add_setshow_zinteger_cmd) (add_setshow_zuinteger_cmd, add_setshow_zuinteger_unlimited_cmd): Change prototypes, constifying strings. * completer.c (noop_completer, filename_completer): Make "text" and "prefix" parameters const. (location_completer, expression_completer) (complete_line_internal): Make "text" and "prefix" parameters const and adjust. (command_completer, signal_completer): Make "text" and "prefix" parameters const. * completer.h (noop_completer, filename_completer) (expression_completer, location_completer, command_completer) (signal_completer): Change prototypes. * corefile.c (complete_set_gnutarget): Make "text" and "word" parameters const. * cp-abi.c (cp_abi_completer): Likewise. * expression.h (parse_expression_for_completion): Change prototype. * f-lang.c (f_make_symbol_completion_list): Make "text" and "word" parameters const. * infcmd.c (_initialize_infcmd): Make "cmd_name" local const. * infrun.c (handle_completer): Make "text" and "word" parameters const. * interps.c (interpreter_completer): Make "text" and "word" parameters const. * language.h (struct language_defn) <la_make_symbol_completion_list>: Make "text" and "word" parameters const. * parse.c (parse_exp_1): Move const hack to parse_exp_in_context. (parse_exp_in_context): Rename to ... (parse_exp_in_context_1): ... this. (parse_exp_in_context): Reimplement, with const hack from parse_exp_1. (parse_expression_for_completion): Make "string" parameter const. * printcmd.c (decode_format): Make "string_ptr" parameter pointer to pointer to const char. Adjust. (print_command_1): Make "exp" parameter const. (output_command): Rename to ... (output_command_const): ... this. Make "exp" parameter const. (output_command): Reimplement. (x_command): Adjust. (display_command): Rename "exp" parameter to "arg". New "exp" local, const version of "arg". * python/py-auto-load.c (gdbpy_initialize_auto_load): Make "cmd_name" local const. * python/py-cmd.c (cmdpy_destroyer): Cast const away in xfree call. (cmdpy_completer): Make "text" and "word" parameters const. (gdbpy_parse_command_name): Make "prefix_text2" local const. * python/py-param.c (add_setshow_generic): Make "tmp_name" local const. * remote.c (_initialize_remote): Make "cmd_name" local const. * symtab.c (language_search_unquoted_string): Make "text" and "p" parameters const. Adjust. (completion_list_add_fields): Make "sym_text", "text" and "word" parameters const. (struct add_name_data) <sym_text, text, word>: Make fields const. (default_make_symbol_completion_list_break_on): Make "text" and "word" parameters const. Adjust locals. (default_make_symbol_completion_list) (make_symbol_completion_list, make_symbol_completion_type) (make_symbol_completion_list_fn): Make "text" and "word" parameters const. (make_file_symbol_completion_list): Make "text", "word" and "srcfile" parameters const. Adjust locals. (add_filename_to_list): Make "text" and "word" parameters const. (struct add_partial_filename_data) <text, word>: Make fields const. (make_source_files_completion_list): Make "text" and "word" parameters const. * symtab.h (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list, make_symbol_completion_list) (make_symbol_completion_type enum type_code) (make_symbol_completion_list_fn make_file_symbol_completion_list) (make_source_files_completion_list): Change prototype. * top.c (execute_command): Adjust to pass pointer to pointer to const char to lookup_cmd, and to deprecated_cmd_warning prototype change. (set_verbose): Make "cmdname" local const. * tracepoint.c (decode_agent_options): Make "exp" parameter const, and adjust. (validate_actionline): Make "line" parameter a pointer to const char, and adjust. (encode_actions_1): Make "action_exp" local const, and adjust. (encode_actions): Adjust. (replace_comma): Delete. (trace_dump_actions): Make "action_exp" and "next_comma" locals const, and adjust. Don't frob the action string while splitting it at commas. Instead, make a copy of each split substring in turn. (trace_dump_command): Adjust to validate_actionline prototype change. * tracepoint.h (decode_agent_options, decode_agent_options) (encode_actions, validate_actionline): Change prototypes. * valprint.h (output_command): Delete declaration. (output_command_const): Declare. * value.c (function_destroyer): Cast const away in xfree call.
2013-03-13 19:34:55 +01:00
const char *text, const char *word)
2003-02-06 06:30:17 +01:00
{
int textlen = strlen (text);
for (const interp_factory &interp : interpreter_factories)
2003-02-06 06:30:17 +01:00
{
if (strncmp (interp.name, text, textlen) == 0)
2003-02-06 06:30:17 +01:00
{
Factor out final completion match string building We have several places doing essentially the same thing; factor them out to a central place. Some of the places overallocate for no good reason, or use strcat unnecessarily. The centralized version is more precise and to the point. (I considered making the gdb::unique_xmalloc_ptr overload version of make_completer_match_str try to realloc (not xrealloc) probably avoiding an allocation in most cases, but that'd be probably overdoing it, and also, now that I'm writing this I thought I'd try to see how could we ever get to filename_completer with "text != word", but I couldn't figure it out. Running the testsuite with 'gdb_assert (text == word);' never tripped on the assertion either. So post gdb 8.1, I'll probably propose a patch to simplify filename_completer a bit, and the gdb::unique_xmalloc_str overload can be removed then.) gdb/ChangeLog: 2017-12-13 Pedro Alves <palves@redhat.com> * cli/cli-decode.c (complete_on_cmdlist, complete_on_enum): Use make_completion_match_str. * completer.c: Use gdb::unique_xmalloc_ptr and make_completion_match_str. (make_completion_match_str_1): New. (make_completion_match_str(const char *, const char *, const char *)): New. (make_completion_match_str(gdb::unique_xmalloc_ptr<char> &&, const char *, const char *)): New. * completer.h (make_completion_match_str(const char *, const char *, const char *)): New. (make_completion_match_str(gdb::unique_xmalloc_ptr<char> &&, const char *, const char *)): New. * interps.c (interpreter_completer): Use make_completion_match_str. * symtab.c (completion_list_add_name, add_filename_to_list): Use make_completion_match_str.
2017-12-13 17:38:49 +01:00
tracker.add_completion
(make_completion_match_str (interp.name, text, word));
2003-02-06 06:30:17 +01:00
}
}
}
struct interp *
top_level_interpreter (void)
{
Make the interpreters be per UI Make each UI have its own interpreter list, top level interpreter, current interpreter, etc. The "interpreter_async" global is not really specific to an struct interp (it crosses interpreter-exec ...), so I moved it to "struct ui" directly, while the other globals were left hidden in interps.c, opaque to the rest of GDB. gdb/ChangeLog: 2016-06-21 Pedro Alves <palves@redhat.com> * breakpoint.c (bpstat_do_actions_1): Access the current UI's async field instead of the interpreter_async global. * cli/cli-script.c (execute_user_command, while_command) (if_command, script_from_file): Likewise. * compile/compile.c: Include top.h instead of interps.h. (compile_file_command, compile_code_command) (compile_print_command): Access the current UI's async field instead of the interpreter_async global. * guile/guile.c: Include top.h instead of interps.h. (guile_repl_command, guile_command, gdbscm_execute_gdb_command): Access the current UI's async field instead of the interpreter_async global. * guile/scm-ports.c: Include top.h instead of interps.h. (ioscm_with_output_to_port_worker): Access the current UI's async field instead of the interpreter_async global. * inf-loop.c (inferior_event_handler): Likewise. * infcall.c (run_inferior_call): Likewise. * infrun.c (reinstall_readline_callback_handler_cleanup) (fetch_inferior_event): Likewise. * interps.c (interpreter_async): Delete. (struct ui_interp_info): New. (get_current_interp_info): New function. (interp_list, current_interpreter, top_level_interpreter_ptr): Delete. (interp_add, interp_set, interp_lookup, interp_ui_out) (current_interp_set_logging, interp_set_temp) (current_interp_named_p): Adjust to per-UI interpreters. (command_interpreter): Delete. (command_interp, current_interp_command_loop, interp_quiet_p) (interp_exec, interpreter_exec_cmd, interpreter_completer) (top_level_interpreter, top_level_interpreter_data): Adjust to per-UI interpreters. * interps.h (interpreter_async): Delete. * main.c (captured_command_loop): Access the current UI's async field instead of the interpreter_async global. * python/python.c (python_interactive_command, python_command) (execute_gdb_command): Likewise. * top.c (maybe_wait_sync_command_done, execute_command_to_string): Access the current UI's async field instead of the interpreter_async global. * top.h (struct tl_interp_info): Forward declare. (struct ui) <interp_info, async>: New fields.
2016-06-21 02:11:45 +02:00
struct ui_interp_info *ui_interp = get_current_interp_info ();
return ui_interp->top_level_interpreter;
}
/* See interps.h. */
struct interp *
current_interpreter (void)
{
struct ui_interp_info *ui_interp = get_interp_info (current_ui);
return ui_interp->current_interpreter;
}
2003-02-06 06:30:17 +01:00
/* This just adds the "interpreter-exec" command. */
gdb: add back declarations for _initialize functions I'd like to enable the -Wmissing-declarations warning. However, it warns for every _initialize function, for example: CXX dcache.o /home/smarchi/src/binutils-gdb/gdb/dcache.c: In function ‘void _initialize_dcache()’: /home/smarchi/src/binutils-gdb/gdb/dcache.c:688:1: error: no previous declaration for ‘void _initialize_dcache()’ [-Werror=missing-declarations] _initialize_dcache (void) ^~~~~~~~~~~~~~~~~~ The only practical way forward I found is to add back the declarations, which were removed by this commit: commit 481695ed5f6e0a8a9c9c50bfac1cdd2b3151e6c9 Author: John Baldwin <jhb@FreeBSD.org> Date: Sat Sep 9 11:02:37 2017 -0700 Remove unnecessary function prototypes. I don't think it's a big problem to have the declarations for these functions, but if anybody has a better solution for this, I'll be happy to use it. gdb/ChangeLog: * aarch64-fbsd-nat.c (_initialize_aarch64_fbsd_nat): Add declaration. * aarch64-fbsd-tdep.c (_initialize_aarch64_fbsd_tdep): Add declaration. * aarch64-linux-nat.c (_initialize_aarch64_linux_nat): Add declaration. * aarch64-linux-tdep.c (_initialize_aarch64_linux_tdep): Add declaration. * aarch64-newlib-tdep.c (_initialize_aarch64_newlib_tdep): Add declaration. * aarch64-tdep.c (_initialize_aarch64_tdep): Add declaration. * ada-exp.y (_initialize_ada_exp): Add declaration. * ada-lang.c (_initialize_ada_language): Add declaration. * ada-tasks.c (_initialize_tasks): Add declaration. * agent.c (_initialize_agent): Add declaration. * aix-thread.c (_initialize_aix_thread): Add declaration. * alpha-bsd-nat.c (_initialize_alphabsd_nat): Add declaration. * alpha-linux-nat.c (_initialize_alpha_linux_nat): Add declaration. * alpha-linux-tdep.c (_initialize_alpha_linux_tdep): Add declaration. * alpha-nbsd-tdep.c (_initialize_alphanbsd_tdep): Add declaration. * alpha-obsd-tdep.c (_initialize_alphaobsd_tdep): Add declaration. * alpha-tdep.c (_initialize_alpha_tdep): Add declaration. * amd64-darwin-tdep.c (_initialize_amd64_darwin_tdep): Add declaration. * amd64-dicos-tdep.c (_initialize_amd64_dicos_tdep): Add declaration. * amd64-fbsd-nat.c (_initialize_amd64fbsd_nat): Add declaration. * amd64-fbsd-tdep.c (_initialize_amd64fbsd_tdep): Add declaration. * amd64-linux-nat.c (_initialize_amd64_linux_nat): Add declaration. * amd64-linux-tdep.c (_initialize_amd64_linux_tdep): Add declaration. * amd64-nbsd-nat.c (_initialize_amd64nbsd_nat): Add declaration. * amd64-nbsd-tdep.c (_initialize_amd64nbsd_tdep): Add declaration. * amd64-obsd-nat.c (_initialize_amd64obsd_nat): Add declaration. * amd64-obsd-tdep.c (_initialize_amd64obsd_tdep): Add declaration. * amd64-sol2-tdep.c (_initialize_amd64_sol2_tdep): Add declaration. * amd64-tdep.c (_initialize_amd64_tdep): Add declaration. * amd64-windows-nat.c (_initialize_amd64_windows_nat): Add declaration. * amd64-windows-tdep.c (_initialize_amd64_windows_tdep): Add declaration. * annotate.c (_initialize_annotate): Add declaration. * arc-newlib-tdep.c (_initialize_arc_newlib_tdep): Add declaration. * arc-tdep.c (_initialize_arc_tdep): Add declaration. * arch-utils.c (_initialize_gdbarch_utils): Add declaration. * arm-fbsd-nat.c (_initialize_arm_fbsd_nat): Add declaration. * arm-fbsd-tdep.c (_initialize_arm_fbsd_tdep): Add declaration. * arm-linux-nat.c (_initialize_arm_linux_nat): Add declaration. * arm-linux-tdep.c (_initialize_arm_linux_tdep): Add declaration. * arm-nbsd-nat.c (_initialize_arm_netbsd_nat): Add declaration. * arm-nbsd-tdep.c (_initialize_arm_netbsd_tdep): Add declaration. * arm-obsd-tdep.c (_initialize_armobsd_tdep): Add declaration. * arm-pikeos-tdep.c (_initialize_arm_pikeos_tdep): Add declaration. * arm-symbian-tdep.c (_initialize_arm_symbian_tdep): Add declaration. * arm-tdep.c (_initialize_arm_tdep): Add declaration. * arm-wince-tdep.c (_initialize_arm_wince_tdep): Add declaration. * auto-load.c (_initialize_auto_load): Add declaration. * auxv.c (_initialize_auxv): Add declaration. * avr-tdep.c (_initialize_avr_tdep): Add declaration. * ax-gdb.c (_initialize_ax_gdb): Add declaration. * bfin-linux-tdep.c (_initialize_bfin_linux_tdep): Add declaration. * bfin-tdep.c (_initialize_bfin_tdep): Add declaration. * break-catch-sig.c (_initialize_break_catch_sig): Add declaration. * break-catch-syscall.c (_initialize_break_catch_syscall): Add declaration. * break-catch-throw.c (_initialize_break_catch_throw): Add declaration. * breakpoint.c (_initialize_breakpoint): Add declaration. * bsd-uthread.c (_initialize_bsd_uthread): Add declaration. * btrace.c (_initialize_btrace): Add declaration. * charset.c (_initialize_charset): Add declaration. * cli/cli-cmds.c (_initialize_cli_cmds): Add declaration. * cli/cli-dump.c (_initialize_cli_dump): Add declaration. * cli/cli-interp.c (_initialize_cli_interp): Add declaration. * cli/cli-logging.c (_initialize_cli_logging): Add declaration. * cli/cli-script.c (_initialize_cli_script): Add declaration. * cli/cli-style.c (_initialize_cli_style): Add declaration. * coff-pe-read.c (_initialize_coff_pe_read): Add declaration. * coffread.c (_initialize_coffread): Add declaration. * compile/compile-cplus-types.c (_initialize_compile_cplus_types): Add declaration. * compile/compile.c (_initialize_compile): Add declaration. * complaints.c (_initialize_complaints): Add declaration. * completer.c (_initialize_completer): Add declaration. * copying.c (_initialize_copying): Add declaration. * corefile.c (_initialize_core): Add declaration. * corelow.c (_initialize_corelow): Add declaration. * cp-abi.c (_initialize_cp_abi): Add declaration. * cp-namespace.c (_initialize_cp_namespace): Add declaration. * cp-support.c (_initialize_cp_support): Add declaration. * cp-valprint.c (_initialize_cp_valprint): Add declaration. * cris-linux-tdep.c (_initialize_cris_linux_tdep): Add declaration. * cris-tdep.c (_initialize_cris_tdep): Add declaration. * csky-linux-tdep.c (_initialize_csky_linux_tdep): Add declaration. * csky-tdep.c (_initialize_csky_tdep): Add declaration. * ctfread.c (_initialize_ctfread): Add declaration. * d-lang.c (_initialize_d_language): Add declaration. * darwin-nat-info.c (_initialize_darwin_info_commands): Add declaration. * darwin-nat.c (_initialize_darwin_nat): Add declaration. * dbxread.c (_initialize_dbxread): Add declaration. * dcache.c (_initialize_dcache): Add declaration. * disasm-selftests.c (_initialize_disasm_selftests): Add declaration. * disasm.c (_initialize_disasm): Add declaration. * dtrace-probe.c (_initialize_dtrace_probe): Add declaration. * dummy-frame.c (_initialize_dummy_frame): Add declaration. * dwarf-index-cache.c (_initialize_index_cache): Add declaration. * dwarf-index-write.c (_initialize_dwarf_index_write): Add declaration. * dwarf2-frame-tailcall.c (_initialize_tailcall_frame): Add declaration. * dwarf2-frame.c (_initialize_dwarf2_frame): Add declaration. * dwarf2expr.c (_initialize_dwarf2expr): Add declaration. * dwarf2loc.c (_initialize_dwarf2loc): Add declaration. * dwarf2read.c (_initialize_dwarf2_read): Add declaration. * elfread.c (_initialize_elfread): Add declaration. * exec.c (_initialize_exec): Add declaration. * extension.c (_initialize_extension): Add declaration. * f-lang.c (_initialize_f_language): Add declaration. * f-valprint.c (_initialize_f_valprint): Add declaration. * fbsd-nat.c (_initialize_fbsd_nat): Add declaration. * fbsd-tdep.c (_initialize_fbsd_tdep): Add declaration. * filesystem.c (_initialize_filesystem): Add declaration. * findcmd.c (_initialize_mem_search): Add declaration. * findvar.c (_initialize_findvar): Add declaration. * fork-child.c (_initialize_fork_child): Add declaration. * frame-base.c (_initialize_frame_base): Add declaration. * frame-unwind.c (_initialize_frame_unwind): Add declaration. * frame.c (_initialize_frame): Add declaration. * frv-linux-tdep.c (_initialize_frv_linux_tdep): Add declaration. * frv-tdep.c (_initialize_frv_tdep): Add declaration. * ft32-tdep.c (_initialize_ft32_tdep): Add declaration. * gcore.c (_initialize_gcore): Add declaration. * gdb-demangle.c (_initialize_gdb_demangle): Add declaration. * gdb_bfd.c (_initialize_gdb_bfd): Add declaration. * gdbarch-selftests.c (_initialize_gdbarch_selftests): Add declaration. * gdbarch.c (_initialize_gdbarch): Add declaration. * gdbtypes.c (_initialize_gdbtypes): Add declaration. * gnu-nat.c (_initialize_gnu_nat): Add declaration. * gnu-v2-abi.c (_initialize_gnu_v2_abi): Add declaration. * gnu-v3-abi.c (_initialize_gnu_v3_abi): Add declaration. * go-lang.c (_initialize_go_language): Add declaration. * go32-nat.c (_initialize_go32_nat): Add declaration. * guile/guile.c (_initialize_guile): Add declaration. * h8300-tdep.c (_initialize_h8300_tdep): Add declaration. * hppa-linux-nat.c (_initialize_hppa_linux_nat): Add declaration. * hppa-linux-tdep.c (_initialize_hppa_linux_tdep): Add declaration. * hppa-nbsd-nat.c (_initialize_hppanbsd_nat): Add declaration. * hppa-nbsd-tdep.c (_initialize_hppanbsd_tdep): Add declaration. * hppa-obsd-nat.c (_initialize_hppaobsd_nat): Add declaration. * hppa-obsd-tdep.c (_initialize_hppabsd_tdep): Add declaration. * hppa-tdep.c (_initialize_hppa_tdep): Add declaration. * i386-bsd-nat.c (_initialize_i386bsd_nat): Add declaration. * i386-cygwin-tdep.c (_initialize_i386_cygwin_tdep): Add declaration. * i386-darwin-nat.c (_initialize_i386_darwin_nat): Add declaration. * i386-darwin-tdep.c (_initialize_i386_darwin_tdep): Add declaration. * i386-dicos-tdep.c (_initialize_i386_dicos_tdep): Add declaration. * i386-fbsd-nat.c (_initialize_i386fbsd_nat): Add declaration. * i386-fbsd-tdep.c (_initialize_i386fbsd_tdep): Add declaration. * i386-gnu-nat.c (_initialize_i386gnu_nat): Add declaration. * i386-gnu-tdep.c (_initialize_i386gnu_tdep): Add declaration. * i386-go32-tdep.c (_initialize_i386_go32_tdep): Add declaration. * i386-linux-nat.c (_initialize_i386_linux_nat): Add declaration. * i386-linux-tdep.c (_initialize_i386_linux_tdep): Add declaration. * i386-nbsd-nat.c (_initialize_i386nbsd_nat): Add declaration. * i386-nbsd-tdep.c (_initialize_i386nbsd_tdep): Add declaration. * i386-nto-tdep.c (_initialize_i386nto_tdep): Add declaration. * i386-obsd-nat.c (_initialize_i386obsd_nat): Add declaration. * i386-obsd-tdep.c (_initialize_i386obsd_tdep): Add declaration. * i386-sol2-nat.c (_initialize_amd64_sol2_nat): Add declaration. * i386-sol2-tdep.c (_initialize_i386_sol2_tdep): Add declaration. * i386-tdep.c (_initialize_i386_tdep): Add declaration. * i386-windows-nat.c (_initialize_i386_windows_nat): Add declaration. * ia64-libunwind-tdep.c (_initialize_libunwind_frame): Add declaration. * ia64-linux-nat.c (_initialize_ia64_linux_nat): Add declaration. * ia64-linux-tdep.c (_initialize_ia64_linux_tdep): Add declaration. * ia64-tdep.c (_initialize_ia64_tdep): Add declaration. * ia64-vms-tdep.c (_initialize_ia64_vms_tdep): Add declaration. * infcall.c (_initialize_infcall): Add declaration. * infcmd.c (_initialize_infcmd): Add declaration. * inflow.c (_initialize_inflow): Add declaration. * infrun.c (_initialize_infrun): Add declaration. * interps.c (_initialize_interpreter): Add declaration. * iq2000-tdep.c (_initialize_iq2000_tdep): Add declaration. * jit.c (_initialize_jit): Add declaration. * language.c (_initialize_language): Add declaration. * linux-fork.c (_initialize_linux_fork): Add declaration. * linux-nat.c (_initialize_linux_nat): Add declaration. * linux-tdep.c (_initialize_linux_tdep): Add declaration. * linux-thread-db.c (_initialize_thread_db): Add declaration. * lm32-tdep.c (_initialize_lm32_tdep): Add declaration. * m2-lang.c (_initialize_m2_language): Add declaration. * m32c-tdep.c (_initialize_m32c_tdep): Add declaration. * m32r-linux-nat.c (_initialize_m32r_linux_nat): Add declaration. * m32r-linux-tdep.c (_initialize_m32r_linux_tdep): Add declaration. * m32r-tdep.c (_initialize_m32r_tdep): Add declaration. * m68hc11-tdep.c (_initialize_m68hc11_tdep): Add declaration. * m68k-bsd-nat.c (_initialize_m68kbsd_nat): Add declaration. * m68k-bsd-tdep.c (_initialize_m68kbsd_tdep): Add declaration. * m68k-linux-nat.c (_initialize_m68k_linux_nat): Add declaration. * m68k-linux-tdep.c (_initialize_m68k_linux_tdep): Add declaration. * m68k-tdep.c (_initialize_m68k_tdep): Add declaration. * machoread.c (_initialize_machoread): Add declaration. * macrocmd.c (_initialize_macrocmd): Add declaration. * macroscope.c (_initialize_macroscope): Add declaration. * maint-test-options.c (_initialize_maint_test_options): Add declaration. * maint-test-settings.c (_initialize_maint_test_settings): Add declaration. * maint.c (_initialize_maint_cmds): Add declaration. * mdebugread.c (_initialize_mdebugread): Add declaration. * memattr.c (_initialize_mem): Add declaration. * mep-tdep.c (_initialize_mep_tdep): Add declaration. * mi/mi-cmd-env.c (_initialize_mi_cmd_env): Add declaration. * mi/mi-cmds.c (_initialize_mi_cmds): Add declaration. * mi/mi-interp.c (_initialize_mi_interp): Add declaration. * mi/mi-main.c (_initialize_mi_main): Add declaration. * microblaze-linux-tdep.c (_initialize_microblaze_linux_tdep): Add declaration. * microblaze-tdep.c (_initialize_microblaze_tdep): Add declaration. * mips-fbsd-nat.c (_initialize_mips_fbsd_nat): Add declaration. * mips-fbsd-tdep.c (_initialize_mips_fbsd_tdep): Add declaration. * mips-linux-nat.c (_initialize_mips_linux_nat): Add declaration. * mips-linux-tdep.c (_initialize_mips_linux_tdep): Add declaration. * mips-nbsd-nat.c (_initialize_mipsnbsd_nat): Add declaration. * mips-nbsd-tdep.c (_initialize_mipsnbsd_tdep): Add declaration. * mips-sde-tdep.c (_initialize_mips_sde_tdep): Add declaration. * mips-tdep.c (_initialize_mips_tdep): Add declaration. * mips64-obsd-nat.c (_initialize_mips64obsd_nat): Add declaration. * mips64-obsd-tdep.c (_initialize_mips64obsd_tdep): Add declaration. * mipsread.c (_initialize_mipsread): Add declaration. * mn10300-linux-tdep.c (_initialize_mn10300_linux_tdep): Add declaration. * mn10300-tdep.c (_initialize_mn10300_tdep): Add declaration. * moxie-tdep.c (_initialize_moxie_tdep): Add declaration. * msp430-tdep.c (_initialize_msp430_tdep): Add declaration. * nds32-tdep.c (_initialize_nds32_tdep): Add declaration. * nios2-linux-tdep.c (_initialize_nios2_linux_tdep): Add declaration. * nios2-tdep.c (_initialize_nios2_tdep): Add declaration. * nto-procfs.c (_initialize_procfs): Add declaration. * objc-lang.c (_initialize_objc_language): Add declaration. * observable.c (_initialize_observer): Add declaration. * opencl-lang.c (_initialize_opencl_language): Add declaration. * or1k-linux-tdep.c (_initialize_or1k_linux_tdep): Add declaration. * or1k-tdep.c (_initialize_or1k_tdep): Add declaration. * osabi.c (_initialize_gdb_osabi): Add declaration. * osdata.c (_initialize_osdata): Add declaration. * p-valprint.c (_initialize_pascal_valprint): Add declaration. * parse.c (_initialize_parse): Add declaration. * ppc-fbsd-nat.c (_initialize_ppcfbsd_nat): Add declaration. * ppc-fbsd-tdep.c (_initialize_ppcfbsd_tdep): Add declaration. * ppc-linux-nat.c (_initialize_ppc_linux_nat): Add declaration. * ppc-linux-tdep.c (_initialize_ppc_linux_tdep): Add declaration. * ppc-nbsd-nat.c (_initialize_ppcnbsd_nat): Add declaration. * ppc-nbsd-tdep.c (_initialize_ppcnbsd_tdep): Add declaration. * ppc-obsd-nat.c (_initialize_ppcobsd_nat): Add declaration. * ppc-obsd-tdep.c (_initialize_ppcobsd_tdep): Add declaration. * printcmd.c (_initialize_printcmd): Add declaration. * probe.c (_initialize_probe): Add declaration. * proc-api.c (_initialize_proc_api): Add declaration. * proc-events.c (_initialize_proc_events): Add declaration. * proc-service.c (_initialize_proc_service): Add declaration. * procfs.c (_initialize_procfs): Add declaration. * producer.c (_initialize_producer): Add declaration. * psymtab.c (_initialize_psymtab): Add declaration. * python/python.c (_initialize_python): Add declaration. * ravenscar-thread.c (_initialize_ravenscar): Add declaration. * record-btrace.c (_initialize_record_btrace): Add declaration. * record-full.c (_initialize_record_full): Add declaration. * record.c (_initialize_record): Add declaration. * regcache-dump.c (_initialize_regcache_dump): Add declaration. * regcache.c (_initialize_regcache): Add declaration. * reggroups.c (_initialize_reggroup): Add declaration. * remote-notif.c (_initialize_notif): Add declaration. * remote-sim.c (_initialize_remote_sim): Add declaration. * remote.c (_initialize_remote): Add declaration. * reverse.c (_initialize_reverse): Add declaration. * riscv-fbsd-nat.c (_initialize_riscv_fbsd_nat): Add declaration. * riscv-fbsd-tdep.c (_initialize_riscv_fbsd_tdep): Add declaration. * riscv-linux-nat.c (_initialize_riscv_linux_nat): Add declaration. * riscv-linux-tdep.c (_initialize_riscv_linux_tdep): Add declaration. * riscv-tdep.c (_initialize_riscv_tdep): Add declaration. * rl78-tdep.c (_initialize_rl78_tdep): Add declaration. * rs6000-aix-tdep.c (_initialize_rs6000_aix_tdep): Add declaration. * rs6000-lynx178-tdep.c (_initialize_rs6000_lynx178_tdep): Add declaration. * rs6000-nat.c (_initialize_rs6000_nat): Add declaration. * rs6000-tdep.c (_initialize_rs6000_tdep): Add declaration. * run-on-main-thread.c (_initialize_run_on_main_thread): Add declaration. * rust-exp.y (_initialize_rust_exp): Add declaration. * rx-tdep.c (_initialize_rx_tdep): Add declaration. * s12z-tdep.c (_initialize_s12z_tdep): Add declaration. * s390-linux-nat.c (_initialize_s390_nat): Add declaration. * s390-linux-tdep.c (_initialize_s390_linux_tdep): Add declaration. * s390-tdep.c (_initialize_s390_tdep): Add declaration. * score-tdep.c (_initialize_score_tdep): Add declaration. * ser-go32.c (_initialize_ser_dos): Add declaration. * ser-mingw.c (_initialize_ser_windows): Add declaration. * ser-pipe.c (_initialize_ser_pipe): Add declaration. * ser-tcp.c (_initialize_ser_tcp): Add declaration. * ser-uds.c (_initialize_ser_socket): Add declaration. * ser-unix.c (_initialize_ser_hardwire): Add declaration. * serial.c (_initialize_serial): Add declaration. * sh-linux-tdep.c (_initialize_sh_linux_tdep): Add declaration. * sh-nbsd-nat.c (_initialize_shnbsd_nat): Add declaration. * sh-nbsd-tdep.c (_initialize_shnbsd_tdep): Add declaration. * sh-tdep.c (_initialize_sh_tdep): Add declaration. * skip.c (_initialize_step_skip): Add declaration. * sol-thread.c (_initialize_sol_thread): Add declaration. * solib-aix.c (_initialize_solib_aix): Add declaration. * solib-darwin.c (_initialize_darwin_solib): Add declaration. * solib-dsbt.c (_initialize_dsbt_solib): Add declaration. * solib-frv.c (_initialize_frv_solib): Add declaration. * solib-svr4.c (_initialize_svr4_solib): Add declaration. * solib-target.c (_initialize_solib_target): Add declaration. * solib.c (_initialize_solib): Add declaration. * source-cache.c (_initialize_source_cache): Add declaration. * source.c (_initialize_source): Add declaration. * sparc-linux-nat.c (_initialize_sparc_linux_nat): Add declaration. * sparc-linux-tdep.c (_initialize_sparc_linux_tdep): Add declaration. * sparc-nat.c (_initialize_sparc_nat): Add declaration. * sparc-nbsd-nat.c (_initialize_sparcnbsd_nat): Add declaration. * sparc-nbsd-tdep.c (_initialize_sparcnbsd_tdep): Add declaration. * sparc-obsd-tdep.c (_initialize_sparc32obsd_tdep): Add declaration. * sparc-sol2-tdep.c (_initialize_sparc_sol2_tdep): Add declaration. * sparc-tdep.c (_initialize_sparc_tdep): Add declaration. * sparc64-fbsd-nat.c (_initialize_sparc64fbsd_nat): Add declaration. * sparc64-fbsd-tdep.c (_initialize_sparc64fbsd_tdep): Add declaration. * sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Add declaration. * sparc64-linux-tdep.c (_initialize_sparc64_linux_tdep): Add declaration. * sparc64-nat.c (_initialize_sparc64_nat): Add declaration. * sparc64-nbsd-nat.c (_initialize_sparc64nbsd_nat): Add declaration. * sparc64-nbsd-tdep.c (_initialize_sparc64nbsd_tdep): Add declaration. * sparc64-obsd-nat.c (_initialize_sparc64obsd_nat): Add declaration. * sparc64-obsd-tdep.c (_initialize_sparc64obsd_tdep): Add declaration. * sparc64-sol2-tdep.c (_initialize_sparc64_sol2_tdep): Add declaration. * sparc64-tdep.c (_initialize_sparc64_adi_tdep): Add declaration. * stabsread.c (_initialize_stabsread): Add declaration. * stack.c (_initialize_stack): Add declaration. * stap-probe.c (_initialize_stap_probe): Add declaration. * std-regs.c (_initialize_frame_reg): Add declaration. * symfile-debug.c (_initialize_symfile_debug): Add declaration. * symfile-mem.c (_initialize_symfile_mem): Add declaration. * symfile.c (_initialize_symfile): Add declaration. * symmisc.c (_initialize_symmisc): Add declaration. * symtab.c (_initialize_symtab): Add declaration. * target.c (_initialize_target): Add declaration. * target-connection.c (_initialize_target_connection): Add declaration. * target-dcache.c (_initialize_target_dcache): Add declaration. * target-descriptions.c (_initialize_target_descriptions): Add declaration. * thread.c (_initialize_thread): Add declaration. * tic6x-linux-tdep.c (_initialize_tic6x_linux_tdep): Add declaration. * tic6x-tdep.c (_initialize_tic6x_tdep): Add declaration. * tilegx-linux-nat.c (_initialize_tile_linux_nat): Add declaration. * tilegx-linux-tdep.c (_initialize_tilegx_linux_tdep): Add declaration. * tilegx-tdep.c (_initialize_tilegx_tdep): Add declaration. * tracectf.c (_initialize_ctf): Add declaration. * tracefile-tfile.c (_initialize_tracefile_tfile): Add declaration. * tracefile.c (_initialize_tracefile): Add declaration. * tracepoint.c (_initialize_tracepoint): Add declaration. * tui/tui-hooks.c (_initialize_tui_hooks): Add declaration. * tui/tui-interp.c (_initialize_tui_interp): Add declaration. * tui/tui-layout.c (_initialize_tui_layout): Add declaration. * tui/tui-regs.c (_initialize_tui_regs): Add declaration. * tui/tui-stack.c (_initialize_tui_stack): Add declaration. * tui/tui-win.c (_initialize_tui_win): Add declaration. * tui/tui.c (_initialize_tui): Add declaration. * typeprint.c (_initialize_typeprint): Add declaration. * ui-style.c (_initialize_ui_style): Add declaration. * unittests/array-view-selftests.c (_initialize_array_view_selftests): Add declaration. * unittests/child-path-selftests.c (_initialize_child_path_selftests): Add declaration. * unittests/cli-utils-selftests.c (_initialize_cli_utils_selftests): Add declaration. * unittests/common-utils-selftests.c (_initialize_common_utils_selftests): Add declaration. * unittests/copy_bitwise-selftests.c (_initialize_copy_bitwise_utils_selftests): Add declaration. * unittests/environ-selftests.c (_initialize_environ_selftests): Add declaration. * unittests/filtered_iterator-selftests.c (_initialize_filtered_iterator_selftests): Add declaration. * unittests/format_pieces-selftests.c (_initialize_format_pieces_selftests): Add declaration. * unittests/function-view-selftests.c (_initialize_function_view_selftests): Add declaration. * unittests/help-doc-selftests.c (_initialize_help_doc_selftests): Add declaration. * unittests/lookup_name_info-selftests.c (_initialize_lookup_name_info_selftests): Add declaration. * unittests/main-thread-selftests.c (_initialize_main_thread_selftests): Add declaration. * unittests/memory-map-selftests.c (_initialize_memory_map_selftests): Add declaration. * unittests/memrange-selftests.c (_initialize_memrange_selftests): Add declaration. * unittests/mkdir-recursive-selftests.c (_initialize_mkdir_recursive_selftests): Add declaration. * unittests/observable-selftests.c (_initialize_observer_selftest): Add declaration. * unittests/offset-type-selftests.c (_initialize_offset_type_selftests): Add declaration. * unittests/optional-selftests.c (_initialize_optional_selftests): Add declaration. * unittests/parse-connection-spec-selftests.c (_initialize_parse_connection_spec_selftests): Add declaration. * unittests/rsp-low-selftests.c (_initialize_rsp_low_selftests): Add declaration. * unittests/scoped_fd-selftests.c (_initialize_scoped_fd_selftests): Add declaration. * unittests/scoped_mmap-selftests.c (_initialize_scoped_mmap_selftests): Add declaration. * unittests/scoped_restore-selftests.c (_initialize_scoped_restore_selftests): Add declaration. * unittests/string_view-selftests.c (_initialize_string_view_selftests): Add declaration. * unittests/style-selftests.c (_initialize_style_selftest): Add declaration. * unittests/tracepoint-selftests.c (_initialize_tracepoint_selftests): Add declaration. * unittests/tui-selftests.c (_initialize_tui_selftest): Add declaration. * unittests/unpack-selftests.c (_initialize_unpack_selftests): Add declaration. * unittests/utils-selftests.c (_initialize_utils_selftests): Add declaration. * unittests/vec-utils-selftests.c (_initialize_vec_utils_selftests): Add declaration. * unittests/xml-utils-selftests.c (_initialize_xml_utils): Add declaration. * user-regs.c (_initialize_user_regs): Add declaration. * utils.c (_initialize_utils): Add declaration. * v850-tdep.c (_initialize_v850_tdep): Add declaration. * valops.c (_initialize_valops): Add declaration. * valprint.c (_initialize_valprint): Add declaration. * value.c (_initialize_values): Add declaration. * varobj.c (_initialize_varobj): Add declaration. * vax-bsd-nat.c (_initialize_vaxbsd_nat): Add declaration. * vax-nbsd-tdep.c (_initialize_vaxnbsd_tdep): Add declaration. * vax-tdep.c (_initialize_vax_tdep): Add declaration. * windows-nat.c (_initialize_windows_nat): Add declaration. (_initialize_check_for_gdb_ini): Add declaration. (_initialize_loadable): Add declaration. * windows-tdep.c (_initialize_windows_tdep): Add declaration. * x86-bsd-nat.c (_initialize_x86_bsd_nat): Add declaration. * x86-linux-nat.c (_initialize_x86_linux_nat): Add declaration. * xcoffread.c (_initialize_xcoffread): Add declaration. * xml-support.c (_initialize_xml_support): Add declaration. * xstormy16-tdep.c (_initialize_xstormy16_tdep): Add declaration. * xtensa-linux-nat.c (_initialize_xtensa_linux_nat): Add declaration. * xtensa-linux-tdep.c (_initialize_xtensa_linux_tdep): Add declaration. * xtensa-tdep.c (_initialize_xtensa_tdep): Add declaration. Change-Id: I13eec7e0ed2b3c427377a7bdb055cf46da64def9
2020-01-13 20:01:38 +01:00
void _initialize_interpreter ();
2003-02-06 06:30:17 +01:00
void
gdb: add back declarations for _initialize functions I'd like to enable the -Wmissing-declarations warning. However, it warns for every _initialize function, for example: CXX dcache.o /home/smarchi/src/binutils-gdb/gdb/dcache.c: In function ‘void _initialize_dcache()’: /home/smarchi/src/binutils-gdb/gdb/dcache.c:688:1: error: no previous declaration for ‘void _initialize_dcache()’ [-Werror=missing-declarations] _initialize_dcache (void) ^~~~~~~~~~~~~~~~~~ The only practical way forward I found is to add back the declarations, which were removed by this commit: commit 481695ed5f6e0a8a9c9c50bfac1cdd2b3151e6c9 Author: John Baldwin <jhb@FreeBSD.org> Date: Sat Sep 9 11:02:37 2017 -0700 Remove unnecessary function prototypes. I don't think it's a big problem to have the declarations for these functions, but if anybody has a better solution for this, I'll be happy to use it. gdb/ChangeLog: * aarch64-fbsd-nat.c (_initialize_aarch64_fbsd_nat): Add declaration. * aarch64-fbsd-tdep.c (_initialize_aarch64_fbsd_tdep): Add declaration. * aarch64-linux-nat.c (_initialize_aarch64_linux_nat): Add declaration. * aarch64-linux-tdep.c (_initialize_aarch64_linux_tdep): Add declaration. * aarch64-newlib-tdep.c (_initialize_aarch64_newlib_tdep): Add declaration. * aarch64-tdep.c (_initialize_aarch64_tdep): Add declaration. * ada-exp.y (_initialize_ada_exp): Add declaration. * ada-lang.c (_initialize_ada_language): Add declaration. * ada-tasks.c (_initialize_tasks): Add declaration. * agent.c (_initialize_agent): Add declaration. * aix-thread.c (_initialize_aix_thread): Add declaration. * alpha-bsd-nat.c (_initialize_alphabsd_nat): Add declaration. * alpha-linux-nat.c (_initialize_alpha_linux_nat): Add declaration. * alpha-linux-tdep.c (_initialize_alpha_linux_tdep): Add declaration. * alpha-nbsd-tdep.c (_initialize_alphanbsd_tdep): Add declaration. * alpha-obsd-tdep.c (_initialize_alphaobsd_tdep): Add declaration. * alpha-tdep.c (_initialize_alpha_tdep): Add declaration. * amd64-darwin-tdep.c (_initialize_amd64_darwin_tdep): Add declaration. * amd64-dicos-tdep.c (_initialize_amd64_dicos_tdep): Add declaration. * amd64-fbsd-nat.c (_initialize_amd64fbsd_nat): Add declaration. * amd64-fbsd-tdep.c (_initialize_amd64fbsd_tdep): Add declaration. * amd64-linux-nat.c (_initialize_amd64_linux_nat): Add declaration. * amd64-linux-tdep.c (_initialize_amd64_linux_tdep): Add declaration. * amd64-nbsd-nat.c (_initialize_amd64nbsd_nat): Add declaration. * amd64-nbsd-tdep.c (_initialize_amd64nbsd_tdep): Add declaration. * amd64-obsd-nat.c (_initialize_amd64obsd_nat): Add declaration. * amd64-obsd-tdep.c (_initialize_amd64obsd_tdep): Add declaration. * amd64-sol2-tdep.c (_initialize_amd64_sol2_tdep): Add declaration. * amd64-tdep.c (_initialize_amd64_tdep): Add declaration. * amd64-windows-nat.c (_initialize_amd64_windows_nat): Add declaration. * amd64-windows-tdep.c (_initialize_amd64_windows_tdep): Add declaration. * annotate.c (_initialize_annotate): Add declaration. * arc-newlib-tdep.c (_initialize_arc_newlib_tdep): Add declaration. * arc-tdep.c (_initialize_arc_tdep): Add declaration. * arch-utils.c (_initialize_gdbarch_utils): Add declaration. * arm-fbsd-nat.c (_initialize_arm_fbsd_nat): Add declaration. * arm-fbsd-tdep.c (_initialize_arm_fbsd_tdep): Add declaration. * arm-linux-nat.c (_initialize_arm_linux_nat): Add declaration. * arm-linux-tdep.c (_initialize_arm_linux_tdep): Add declaration. * arm-nbsd-nat.c (_initialize_arm_netbsd_nat): Add declaration. * arm-nbsd-tdep.c (_initialize_arm_netbsd_tdep): Add declaration. * arm-obsd-tdep.c (_initialize_armobsd_tdep): Add declaration. * arm-pikeos-tdep.c (_initialize_arm_pikeos_tdep): Add declaration. * arm-symbian-tdep.c (_initialize_arm_symbian_tdep): Add declaration. * arm-tdep.c (_initialize_arm_tdep): Add declaration. * arm-wince-tdep.c (_initialize_arm_wince_tdep): Add declaration. * auto-load.c (_initialize_auto_load): Add declaration. * auxv.c (_initialize_auxv): Add declaration. * avr-tdep.c (_initialize_avr_tdep): Add declaration. * ax-gdb.c (_initialize_ax_gdb): Add declaration. * bfin-linux-tdep.c (_initialize_bfin_linux_tdep): Add declaration. * bfin-tdep.c (_initialize_bfin_tdep): Add declaration. * break-catch-sig.c (_initialize_break_catch_sig): Add declaration. * break-catch-syscall.c (_initialize_break_catch_syscall): Add declaration. * break-catch-throw.c (_initialize_break_catch_throw): Add declaration. * breakpoint.c (_initialize_breakpoint): Add declaration. * bsd-uthread.c (_initialize_bsd_uthread): Add declaration. * btrace.c (_initialize_btrace): Add declaration. * charset.c (_initialize_charset): Add declaration. * cli/cli-cmds.c (_initialize_cli_cmds): Add declaration. * cli/cli-dump.c (_initialize_cli_dump): Add declaration. * cli/cli-interp.c (_initialize_cli_interp): Add declaration. * cli/cli-logging.c (_initialize_cli_logging): Add declaration. * cli/cli-script.c (_initialize_cli_script): Add declaration. * cli/cli-style.c (_initialize_cli_style): Add declaration. * coff-pe-read.c (_initialize_coff_pe_read): Add declaration. * coffread.c (_initialize_coffread): Add declaration. * compile/compile-cplus-types.c (_initialize_compile_cplus_types): Add declaration. * compile/compile.c (_initialize_compile): Add declaration. * complaints.c (_initialize_complaints): Add declaration. * completer.c (_initialize_completer): Add declaration. * copying.c (_initialize_copying): Add declaration. * corefile.c (_initialize_core): Add declaration. * corelow.c (_initialize_corelow): Add declaration. * cp-abi.c (_initialize_cp_abi): Add declaration. * cp-namespace.c (_initialize_cp_namespace): Add declaration. * cp-support.c (_initialize_cp_support): Add declaration. * cp-valprint.c (_initialize_cp_valprint): Add declaration. * cris-linux-tdep.c (_initialize_cris_linux_tdep): Add declaration. * cris-tdep.c (_initialize_cris_tdep): Add declaration. * csky-linux-tdep.c (_initialize_csky_linux_tdep): Add declaration. * csky-tdep.c (_initialize_csky_tdep): Add declaration. * ctfread.c (_initialize_ctfread): Add declaration. * d-lang.c (_initialize_d_language): Add declaration. * darwin-nat-info.c (_initialize_darwin_info_commands): Add declaration. * darwin-nat.c (_initialize_darwin_nat): Add declaration. * dbxread.c (_initialize_dbxread): Add declaration. * dcache.c (_initialize_dcache): Add declaration. * disasm-selftests.c (_initialize_disasm_selftests): Add declaration. * disasm.c (_initialize_disasm): Add declaration. * dtrace-probe.c (_initialize_dtrace_probe): Add declaration. * dummy-frame.c (_initialize_dummy_frame): Add declaration. * dwarf-index-cache.c (_initialize_index_cache): Add declaration. * dwarf-index-write.c (_initialize_dwarf_index_write): Add declaration. * dwarf2-frame-tailcall.c (_initialize_tailcall_frame): Add declaration. * dwarf2-frame.c (_initialize_dwarf2_frame): Add declaration. * dwarf2expr.c (_initialize_dwarf2expr): Add declaration. * dwarf2loc.c (_initialize_dwarf2loc): Add declaration. * dwarf2read.c (_initialize_dwarf2_read): Add declaration. * elfread.c (_initialize_elfread): Add declaration. * exec.c (_initialize_exec): Add declaration. * extension.c (_initialize_extension): Add declaration. * f-lang.c (_initialize_f_language): Add declaration. * f-valprint.c (_initialize_f_valprint): Add declaration. * fbsd-nat.c (_initialize_fbsd_nat): Add declaration. * fbsd-tdep.c (_initialize_fbsd_tdep): Add declaration. * filesystem.c (_initialize_filesystem): Add declaration. * findcmd.c (_initialize_mem_search): Add declaration. * findvar.c (_initialize_findvar): Add declaration. * fork-child.c (_initialize_fork_child): Add declaration. * frame-base.c (_initialize_frame_base): Add declaration. * frame-unwind.c (_initialize_frame_unwind): Add declaration. * frame.c (_initialize_frame): Add declaration. * frv-linux-tdep.c (_initialize_frv_linux_tdep): Add declaration. * frv-tdep.c (_initialize_frv_tdep): Add declaration. * ft32-tdep.c (_initialize_ft32_tdep): Add declaration. * gcore.c (_initialize_gcore): Add declaration. * gdb-demangle.c (_initialize_gdb_demangle): Add declaration. * gdb_bfd.c (_initialize_gdb_bfd): Add declaration. * gdbarch-selftests.c (_initialize_gdbarch_selftests): Add declaration. * gdbarch.c (_initialize_gdbarch): Add declaration. * gdbtypes.c (_initialize_gdbtypes): Add declaration. * gnu-nat.c (_initialize_gnu_nat): Add declaration. * gnu-v2-abi.c (_initialize_gnu_v2_abi): Add declaration. * gnu-v3-abi.c (_initialize_gnu_v3_abi): Add declaration. * go-lang.c (_initialize_go_language): Add declaration. * go32-nat.c (_initialize_go32_nat): Add declaration. * guile/guile.c (_initialize_guile): Add declaration. * h8300-tdep.c (_initialize_h8300_tdep): Add declaration. * hppa-linux-nat.c (_initialize_hppa_linux_nat): Add declaration. * hppa-linux-tdep.c (_initialize_hppa_linux_tdep): Add declaration. * hppa-nbsd-nat.c (_initialize_hppanbsd_nat): Add declaration. * hppa-nbsd-tdep.c (_initialize_hppanbsd_tdep): Add declaration. * hppa-obsd-nat.c (_initialize_hppaobsd_nat): Add declaration. * hppa-obsd-tdep.c (_initialize_hppabsd_tdep): Add declaration. * hppa-tdep.c (_initialize_hppa_tdep): Add declaration. * i386-bsd-nat.c (_initialize_i386bsd_nat): Add declaration. * i386-cygwin-tdep.c (_initialize_i386_cygwin_tdep): Add declaration. * i386-darwin-nat.c (_initialize_i386_darwin_nat): Add declaration. * i386-darwin-tdep.c (_initialize_i386_darwin_tdep): Add declaration. * i386-dicos-tdep.c (_initialize_i386_dicos_tdep): Add declaration. * i386-fbsd-nat.c (_initialize_i386fbsd_nat): Add declaration. * i386-fbsd-tdep.c (_initialize_i386fbsd_tdep): Add declaration. * i386-gnu-nat.c (_initialize_i386gnu_nat): Add declaration. * i386-gnu-tdep.c (_initialize_i386gnu_tdep): Add declaration. * i386-go32-tdep.c (_initialize_i386_go32_tdep): Add declaration. * i386-linux-nat.c (_initialize_i386_linux_nat): Add declaration. * i386-linux-tdep.c (_initialize_i386_linux_tdep): Add declaration. * i386-nbsd-nat.c (_initialize_i386nbsd_nat): Add declaration. * i386-nbsd-tdep.c (_initialize_i386nbsd_tdep): Add declaration. * i386-nto-tdep.c (_initialize_i386nto_tdep): Add declaration. * i386-obsd-nat.c (_initialize_i386obsd_nat): Add declaration. * i386-obsd-tdep.c (_initialize_i386obsd_tdep): Add declaration. * i386-sol2-nat.c (_initialize_amd64_sol2_nat): Add declaration. * i386-sol2-tdep.c (_initialize_i386_sol2_tdep): Add declaration. * i386-tdep.c (_initialize_i386_tdep): Add declaration. * i386-windows-nat.c (_initialize_i386_windows_nat): Add declaration. * ia64-libunwind-tdep.c (_initialize_libunwind_frame): Add declaration. * ia64-linux-nat.c (_initialize_ia64_linux_nat): Add declaration. * ia64-linux-tdep.c (_initialize_ia64_linux_tdep): Add declaration. * ia64-tdep.c (_initialize_ia64_tdep): Add declaration. * ia64-vms-tdep.c (_initialize_ia64_vms_tdep): Add declaration. * infcall.c (_initialize_infcall): Add declaration. * infcmd.c (_initialize_infcmd): Add declaration. * inflow.c (_initialize_inflow): Add declaration. * infrun.c (_initialize_infrun): Add declaration. * interps.c (_initialize_interpreter): Add declaration. * iq2000-tdep.c (_initialize_iq2000_tdep): Add declaration. * jit.c (_initialize_jit): Add declaration. * language.c (_initialize_language): Add declaration. * linux-fork.c (_initialize_linux_fork): Add declaration. * linux-nat.c (_initialize_linux_nat): Add declaration. * linux-tdep.c (_initialize_linux_tdep): Add declaration. * linux-thread-db.c (_initialize_thread_db): Add declaration. * lm32-tdep.c (_initialize_lm32_tdep): Add declaration. * m2-lang.c (_initialize_m2_language): Add declaration. * m32c-tdep.c (_initialize_m32c_tdep): Add declaration. * m32r-linux-nat.c (_initialize_m32r_linux_nat): Add declaration. * m32r-linux-tdep.c (_initialize_m32r_linux_tdep): Add declaration. * m32r-tdep.c (_initialize_m32r_tdep): Add declaration. * m68hc11-tdep.c (_initialize_m68hc11_tdep): Add declaration. * m68k-bsd-nat.c (_initialize_m68kbsd_nat): Add declaration. * m68k-bsd-tdep.c (_initialize_m68kbsd_tdep): Add declaration. * m68k-linux-nat.c (_initialize_m68k_linux_nat): Add declaration. * m68k-linux-tdep.c (_initialize_m68k_linux_tdep): Add declaration. * m68k-tdep.c (_initialize_m68k_tdep): Add declaration. * machoread.c (_initialize_machoread): Add declaration. * macrocmd.c (_initialize_macrocmd): Add declaration. * macroscope.c (_initialize_macroscope): Add declaration. * maint-test-options.c (_initialize_maint_test_options): Add declaration. * maint-test-settings.c (_initialize_maint_test_settings): Add declaration. * maint.c (_initialize_maint_cmds): Add declaration. * mdebugread.c (_initialize_mdebugread): Add declaration. * memattr.c (_initialize_mem): Add declaration. * mep-tdep.c (_initialize_mep_tdep): Add declaration. * mi/mi-cmd-env.c (_initialize_mi_cmd_env): Add declaration. * mi/mi-cmds.c (_initialize_mi_cmds): Add declaration. * mi/mi-interp.c (_initialize_mi_interp): Add declaration. * mi/mi-main.c (_initialize_mi_main): Add declaration. * microblaze-linux-tdep.c (_initialize_microblaze_linux_tdep): Add declaration. * microblaze-tdep.c (_initialize_microblaze_tdep): Add declaration. * mips-fbsd-nat.c (_initialize_mips_fbsd_nat): Add declaration. * mips-fbsd-tdep.c (_initialize_mips_fbsd_tdep): Add declaration. * mips-linux-nat.c (_initialize_mips_linux_nat): Add declaration. * mips-linux-tdep.c (_initialize_mips_linux_tdep): Add declaration. * mips-nbsd-nat.c (_initialize_mipsnbsd_nat): Add declaration. * mips-nbsd-tdep.c (_initialize_mipsnbsd_tdep): Add declaration. * mips-sde-tdep.c (_initialize_mips_sde_tdep): Add declaration. * mips-tdep.c (_initialize_mips_tdep): Add declaration. * mips64-obsd-nat.c (_initialize_mips64obsd_nat): Add declaration. * mips64-obsd-tdep.c (_initialize_mips64obsd_tdep): Add declaration. * mipsread.c (_initialize_mipsread): Add declaration. * mn10300-linux-tdep.c (_initialize_mn10300_linux_tdep): Add declaration. * mn10300-tdep.c (_initialize_mn10300_tdep): Add declaration. * moxie-tdep.c (_initialize_moxie_tdep): Add declaration. * msp430-tdep.c (_initialize_msp430_tdep): Add declaration. * nds32-tdep.c (_initialize_nds32_tdep): Add declaration. * nios2-linux-tdep.c (_initialize_nios2_linux_tdep): Add declaration. * nios2-tdep.c (_initialize_nios2_tdep): Add declaration. * nto-procfs.c (_initialize_procfs): Add declaration. * objc-lang.c (_initialize_objc_language): Add declaration. * observable.c (_initialize_observer): Add declaration. * opencl-lang.c (_initialize_opencl_language): Add declaration. * or1k-linux-tdep.c (_initialize_or1k_linux_tdep): Add declaration. * or1k-tdep.c (_initialize_or1k_tdep): Add declaration. * osabi.c (_initialize_gdb_osabi): Add declaration. * osdata.c (_initialize_osdata): Add declaration. * p-valprint.c (_initialize_pascal_valprint): Add declaration. * parse.c (_initialize_parse): Add declaration. * ppc-fbsd-nat.c (_initialize_ppcfbsd_nat): Add declaration. * ppc-fbsd-tdep.c (_initialize_ppcfbsd_tdep): Add declaration. * ppc-linux-nat.c (_initialize_ppc_linux_nat): Add declaration. * ppc-linux-tdep.c (_initialize_ppc_linux_tdep): Add declaration. * ppc-nbsd-nat.c (_initialize_ppcnbsd_nat): Add declaration. * ppc-nbsd-tdep.c (_initialize_ppcnbsd_tdep): Add declaration. * ppc-obsd-nat.c (_initialize_ppcobsd_nat): Add declaration. * ppc-obsd-tdep.c (_initialize_ppcobsd_tdep): Add declaration. * printcmd.c (_initialize_printcmd): Add declaration. * probe.c (_initialize_probe): Add declaration. * proc-api.c (_initialize_proc_api): Add declaration. * proc-events.c (_initialize_proc_events): Add declaration. * proc-service.c (_initialize_proc_service): Add declaration. * procfs.c (_initialize_procfs): Add declaration. * producer.c (_initialize_producer): Add declaration. * psymtab.c (_initialize_psymtab): Add declaration. * python/python.c (_initialize_python): Add declaration. * ravenscar-thread.c (_initialize_ravenscar): Add declaration. * record-btrace.c (_initialize_record_btrace): Add declaration. * record-full.c (_initialize_record_full): Add declaration. * record.c (_initialize_record): Add declaration. * regcache-dump.c (_initialize_regcache_dump): Add declaration. * regcache.c (_initialize_regcache): Add declaration. * reggroups.c (_initialize_reggroup): Add declaration. * remote-notif.c (_initialize_notif): Add declaration. * remote-sim.c (_initialize_remote_sim): Add declaration. * remote.c (_initialize_remote): Add declaration. * reverse.c (_initialize_reverse): Add declaration. * riscv-fbsd-nat.c (_initialize_riscv_fbsd_nat): Add declaration. * riscv-fbsd-tdep.c (_initialize_riscv_fbsd_tdep): Add declaration. * riscv-linux-nat.c (_initialize_riscv_linux_nat): Add declaration. * riscv-linux-tdep.c (_initialize_riscv_linux_tdep): Add declaration. * riscv-tdep.c (_initialize_riscv_tdep): Add declaration. * rl78-tdep.c (_initialize_rl78_tdep): Add declaration. * rs6000-aix-tdep.c (_initialize_rs6000_aix_tdep): Add declaration. * rs6000-lynx178-tdep.c (_initialize_rs6000_lynx178_tdep): Add declaration. * rs6000-nat.c (_initialize_rs6000_nat): Add declaration. * rs6000-tdep.c (_initialize_rs6000_tdep): Add declaration. * run-on-main-thread.c (_initialize_run_on_main_thread): Add declaration. * rust-exp.y (_initialize_rust_exp): Add declaration. * rx-tdep.c (_initialize_rx_tdep): Add declaration. * s12z-tdep.c (_initialize_s12z_tdep): Add declaration. * s390-linux-nat.c (_initialize_s390_nat): Add declaration. * s390-linux-tdep.c (_initialize_s390_linux_tdep): Add declaration. * s390-tdep.c (_initialize_s390_tdep): Add declaration. * score-tdep.c (_initialize_score_tdep): Add declaration. * ser-go32.c (_initialize_ser_dos): Add declaration. * ser-mingw.c (_initialize_ser_windows): Add declaration. * ser-pipe.c (_initialize_ser_pipe): Add declaration. * ser-tcp.c (_initialize_ser_tcp): Add declaration. * ser-uds.c (_initialize_ser_socket): Add declaration. * ser-unix.c (_initialize_ser_hardwire): Add declaration. * serial.c (_initialize_serial): Add declaration. * sh-linux-tdep.c (_initialize_sh_linux_tdep): Add declaration. * sh-nbsd-nat.c (_initialize_shnbsd_nat): Add declaration. * sh-nbsd-tdep.c (_initialize_shnbsd_tdep): Add declaration. * sh-tdep.c (_initialize_sh_tdep): Add declaration. * skip.c (_initialize_step_skip): Add declaration. * sol-thread.c (_initialize_sol_thread): Add declaration. * solib-aix.c (_initialize_solib_aix): Add declaration. * solib-darwin.c (_initialize_darwin_solib): Add declaration. * solib-dsbt.c (_initialize_dsbt_solib): Add declaration. * solib-frv.c (_initialize_frv_solib): Add declaration. * solib-svr4.c (_initialize_svr4_solib): Add declaration. * solib-target.c (_initialize_solib_target): Add declaration. * solib.c (_initialize_solib): Add declaration. * source-cache.c (_initialize_source_cache): Add declaration. * source.c (_initialize_source): Add declaration. * sparc-linux-nat.c (_initialize_sparc_linux_nat): Add declaration. * sparc-linux-tdep.c (_initialize_sparc_linux_tdep): Add declaration. * sparc-nat.c (_initialize_sparc_nat): Add declaration. * sparc-nbsd-nat.c (_initialize_sparcnbsd_nat): Add declaration. * sparc-nbsd-tdep.c (_initialize_sparcnbsd_tdep): Add declaration. * sparc-obsd-tdep.c (_initialize_sparc32obsd_tdep): Add declaration. * sparc-sol2-tdep.c (_initialize_sparc_sol2_tdep): Add declaration. * sparc-tdep.c (_initialize_sparc_tdep): Add declaration. * sparc64-fbsd-nat.c (_initialize_sparc64fbsd_nat): Add declaration. * sparc64-fbsd-tdep.c (_initialize_sparc64fbsd_tdep): Add declaration. * sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Add declaration. * sparc64-linux-tdep.c (_initialize_sparc64_linux_tdep): Add declaration. * sparc64-nat.c (_initialize_sparc64_nat): Add declaration. * sparc64-nbsd-nat.c (_initialize_sparc64nbsd_nat): Add declaration. * sparc64-nbsd-tdep.c (_initialize_sparc64nbsd_tdep): Add declaration. * sparc64-obsd-nat.c (_initialize_sparc64obsd_nat): Add declaration. * sparc64-obsd-tdep.c (_initialize_sparc64obsd_tdep): Add declaration. * sparc64-sol2-tdep.c (_initialize_sparc64_sol2_tdep): Add declaration. * sparc64-tdep.c (_initialize_sparc64_adi_tdep): Add declaration. * stabsread.c (_initialize_stabsread): Add declaration. * stack.c (_initialize_stack): Add declaration. * stap-probe.c (_initialize_stap_probe): Add declaration. * std-regs.c (_initialize_frame_reg): Add declaration. * symfile-debug.c (_initialize_symfile_debug): Add declaration. * symfile-mem.c (_initialize_symfile_mem): Add declaration. * symfile.c (_initialize_symfile): Add declaration. * symmisc.c (_initialize_symmisc): Add declaration. * symtab.c (_initialize_symtab): Add declaration. * target.c (_initialize_target): Add declaration. * target-connection.c (_initialize_target_connection): Add declaration. * target-dcache.c (_initialize_target_dcache): Add declaration. * target-descriptions.c (_initialize_target_descriptions): Add declaration. * thread.c (_initialize_thread): Add declaration. * tic6x-linux-tdep.c (_initialize_tic6x_linux_tdep): Add declaration. * tic6x-tdep.c (_initialize_tic6x_tdep): Add declaration. * tilegx-linux-nat.c (_initialize_tile_linux_nat): Add declaration. * tilegx-linux-tdep.c (_initialize_tilegx_linux_tdep): Add declaration. * tilegx-tdep.c (_initialize_tilegx_tdep): Add declaration. * tracectf.c (_initialize_ctf): Add declaration. * tracefile-tfile.c (_initialize_tracefile_tfile): Add declaration. * tracefile.c (_initialize_tracefile): Add declaration. * tracepoint.c (_initialize_tracepoint): Add declaration. * tui/tui-hooks.c (_initialize_tui_hooks): Add declaration. * tui/tui-interp.c (_initialize_tui_interp): Add declaration. * tui/tui-layout.c (_initialize_tui_layout): Add declaration. * tui/tui-regs.c (_initialize_tui_regs): Add declaration. * tui/tui-stack.c (_initialize_tui_stack): Add declaration. * tui/tui-win.c (_initialize_tui_win): Add declaration. * tui/tui.c (_initialize_tui): Add declaration. * typeprint.c (_initialize_typeprint): Add declaration. * ui-style.c (_initialize_ui_style): Add declaration. * unittests/array-view-selftests.c (_initialize_array_view_selftests): Add declaration. * unittests/child-path-selftests.c (_initialize_child_path_selftests): Add declaration. * unittests/cli-utils-selftests.c (_initialize_cli_utils_selftests): Add declaration. * unittests/common-utils-selftests.c (_initialize_common_utils_selftests): Add declaration. * unittests/copy_bitwise-selftests.c (_initialize_copy_bitwise_utils_selftests): Add declaration. * unittests/environ-selftests.c (_initialize_environ_selftests): Add declaration. * unittests/filtered_iterator-selftests.c (_initialize_filtered_iterator_selftests): Add declaration. * unittests/format_pieces-selftests.c (_initialize_format_pieces_selftests): Add declaration. * unittests/function-view-selftests.c (_initialize_function_view_selftests): Add declaration. * unittests/help-doc-selftests.c (_initialize_help_doc_selftests): Add declaration. * unittests/lookup_name_info-selftests.c (_initialize_lookup_name_info_selftests): Add declaration. * unittests/main-thread-selftests.c (_initialize_main_thread_selftests): Add declaration. * unittests/memory-map-selftests.c (_initialize_memory_map_selftests): Add declaration. * unittests/memrange-selftests.c (_initialize_memrange_selftests): Add declaration. * unittests/mkdir-recursive-selftests.c (_initialize_mkdir_recursive_selftests): Add declaration. * unittests/observable-selftests.c (_initialize_observer_selftest): Add declaration. * unittests/offset-type-selftests.c (_initialize_offset_type_selftests): Add declaration. * unittests/optional-selftests.c (_initialize_optional_selftests): Add declaration. * unittests/parse-connection-spec-selftests.c (_initialize_parse_connection_spec_selftests): Add declaration. * unittests/rsp-low-selftests.c (_initialize_rsp_low_selftests): Add declaration. * unittests/scoped_fd-selftests.c (_initialize_scoped_fd_selftests): Add declaration. * unittests/scoped_mmap-selftests.c (_initialize_scoped_mmap_selftests): Add declaration. * unittests/scoped_restore-selftests.c (_initialize_scoped_restore_selftests): Add declaration. * unittests/string_view-selftests.c (_initialize_string_view_selftests): Add declaration. * unittests/style-selftests.c (_initialize_style_selftest): Add declaration. * unittests/tracepoint-selftests.c (_initialize_tracepoint_selftests): Add declaration. * unittests/tui-selftests.c (_initialize_tui_selftest): Add declaration. * unittests/unpack-selftests.c (_initialize_unpack_selftests): Add declaration. * unittests/utils-selftests.c (_initialize_utils_selftests): Add declaration. * unittests/vec-utils-selftests.c (_initialize_vec_utils_selftests): Add declaration. * unittests/xml-utils-selftests.c (_initialize_xml_utils): Add declaration. * user-regs.c (_initialize_user_regs): Add declaration. * utils.c (_initialize_utils): Add declaration. * v850-tdep.c (_initialize_v850_tdep): Add declaration. * valops.c (_initialize_valops): Add declaration. * valprint.c (_initialize_valprint): Add declaration. * value.c (_initialize_values): Add declaration. * varobj.c (_initialize_varobj): Add declaration. * vax-bsd-nat.c (_initialize_vaxbsd_nat): Add declaration. * vax-nbsd-tdep.c (_initialize_vaxnbsd_tdep): Add declaration. * vax-tdep.c (_initialize_vax_tdep): Add declaration. * windows-nat.c (_initialize_windows_nat): Add declaration. (_initialize_check_for_gdb_ini): Add declaration. (_initialize_loadable): Add declaration. * windows-tdep.c (_initialize_windows_tdep): Add declaration. * x86-bsd-nat.c (_initialize_x86_bsd_nat): Add declaration. * x86-linux-nat.c (_initialize_x86_linux_nat): Add declaration. * xcoffread.c (_initialize_xcoffread): Add declaration. * xml-support.c (_initialize_xml_support): Add declaration. * xstormy16-tdep.c (_initialize_xstormy16_tdep): Add declaration. * xtensa-linux-nat.c (_initialize_xtensa_linux_nat): Add declaration. * xtensa-linux-tdep.c (_initialize_xtensa_linux_tdep): Add declaration. * xtensa-tdep.c (_initialize_xtensa_tdep): Add declaration. Change-Id: I13eec7e0ed2b3c427377a7bdb055cf46da64def9
2020-01-13 20:01:38 +01:00
_initialize_interpreter ()
2003-02-06 06:30:17 +01:00
{
struct cmd_list_element *c;
c = add_cmd ("interpreter-exec", class_support,
interpreter_exec_cmd, _("\
Remove trailing newlines from help text I noticed recently that some command had a trailing newline in its "help" output. So, I temporarily hacked cli-decode.c to print something when a new command was installed that had a trailing newline in its help message, and wrote this patch, which removes all the ones I could find this way. (There could still be a few more in *-nat files.) Tested on x86-64 Fedora 29. gdb/ChangeLog 2019-06-11 Tom Tromey <tromey@adacore.com> * infcall.c (_initialize_infcall): Remove trailing newline from help. * user-regs.c (_initialize_user_regs): Remove trailing newline from help. * typeprint.c (_initialize_typeprint): Remove trailing newline from help. * reverse.c (_initialize_reverse): Remove trailing newlines from help. * tracepoint.c (_initialize_tracepoint): Remove trailing newlines from help. * language.c (add_set_language_command): Remove trailing newline from help. * infcmd.c (_initialize_infcmd): Remove trailing newlines from help. * disasm.c (_initialize_disasm): Remove trailing newline from help. * top.c (init_main): Remove trailing newline from help. * interps.c (_initialize_interpreter): Remove trailing newline from help. * btrace.c (_initialize_btrace): Remove trailing newlines from help. * breakpoint.c (_initialize_breakpoint): Remove trailing newline from help. * python/python.c (_initialize_python): Remove trailing newline from help. * spu-tdep.c (_initialize_spu_tdep): Remove trailing newlines from help. * tui/tui-win.c (_initialize_tui_win): Remove trailing newlines from help. Reformat some text. * tui/tui-stack.c (_initialize_tui_stack): Remove trailing newline from help. * tui/tui-layout.c (_initialize_tui_layout): Remove trailing newline from help.
2019-06-04 14:17:09 +02:00
Execute a command in an interpreter.\n\
Make first and last lines of 'command help documentation' consistent. With this patch, the help docs now respect 2 invariants: * The first line of a command help is terminated by a '.' character. * The last character of a command help is not a newline character. Note that the changes for the last invariant were done by Tom, as part of : [PATCH] Remove trailing newlines from help text https://sourceware.org/ml/gdb-patches/2019-06/msg00050.html but some occurrences have been re-introduced since then. Some help docs had to be rephrased/restructured to respect the above invariants. Before this patch, print_doc_line was printing the first line of a command help documentation, but stopping at the first '.' or ',' character. This was giving inconsistent results : * The first line of command helps was sometimes '.' terminated, sometimes not. * The first line of command helps was not always designed to be readable/understandable/unambiguous when stopping at the first '.' or ',' character. This e.g. created the following inconsistencies/problems: < catch exception -- Catch Ada exceptions < catch handlers -- Catch Ada exceptions < catch syscall -- Catch system calls by their names < down-silently -- Same as the `down' command while the new help is: > catch exception -- Catch Ada exceptions, when raised. > catch handlers -- Catch Ada exceptions, when handled. > catch syscall -- Catch system calls by their names, groups and/or numbers. > down-silently -- Same as the `down' command, but does not print anything. Also, the command help doc should not be terminated by a newline character, but this was not respected by all commands. The cli-option -OPT framework re-introduced some occurences. So, the -OPT build help framework was changed to not output newlines at the end of %OPTIONS% replacement. This patch changes the help documentations to ensure the 2 invariants given above. It implied to slightly rephrase or restructure some help docs. Based on the above invariants, print_doc_line (called by 'apropos' and 'help' commands to print the first line of a command help) now outputs the full first line of a command help. This all results in a lot of small changes in the produced help docs. There are less code changes than changes in the help docs, as a lot of docs are produced by some code (e.g. the remote packet usage settings). gdb/ChangeLog 2019-08-07 Philippe Waroquiers <philippe.waroquiers@skynet.be> * cli/cli-decode.h (print_doc_line): Add for_value_prefix argument. * cli/cli-decode.c (print_doc_line): Likewise. It now prints the full first line, except when FOR_VALUE_PREFIX. In this case, the trailing '.' is not output, and the first character is uppercased. (print_help_for_command): Update call to print_doc_line. (print_doc_of_command): Likewise. * cli/cli-setshow.c (deprecated_show_value_hack): Likewise. * cli/cli-option.c (append_indented_doc): Do not append newline. (build_help_option): Append newline after first appended_indented_doc only if a second call is done. (build_help): Append 2 new lines before each option, except the first one. * compile/compile.c (_initialize_compile): Add new lines after %OPTIONS%, when not at the end of the help. Change help doc or code producing the help doc to respect the invariants. * maint-test-options.c (_initialize_maint_test_options): Likewise. Also removed the new line after 'Options:', as all other commands do not put an empty line between 'Options:' and the first option. * printcmd.c (_initialize_printcmd): Likewise. * stack.c (_initialize_stack): Likewise. * interps.c (interpreter_exec_cmd): Fix "Usage:" line that was incorrectly telling COMMAND is optional. * ada-lang.c (_initialize_ada_language): Change help doc or code producing the help doc to respect the invariants. * ada-tasks.c (_initialize_ada_tasks): Likewise. * breakpoint.c (_initialize_breakpoint): Likewise. * cli/cli-cmds.c (_initialize_cli_cmds): Likewise. * cli/cli-logging.c (_initialize_cli_logging): Likewise. * cli/cli-setshow.c (_initialize_cli_setshow): Likewise. * cli/cli-style.c (cli_style_option::add_setshow_commands, _initialize_cli_style): Likewise. * corelow.c (core_target_info): Likewise. * dwarf-index-cache.c (_initialize_index_cache): Likewise. * dwarf2read.c (_initialize_dwarf2_read): Likewise. * filesystem.c (_initialize_filesystem): Likewise. * frame.c (_initialize_frame): Likewise. * gnu-nat.c (add_task_commands): Likewise. * infcall.c (_initialize_infcall): Likewise. * infcmd.c (_initialize_infcmd): Likewise. * interps.c (_initialize_interpreter): Likewise. * language.c (_initialize_language): Likewise. * linux-fork.c (_initialize_linux_fork): Likewise. * maint-test-settings.c (_initialize_maint_test_settings): Likewise. * maint.c (_initialize_maint_cmds): Likewise. * memattr.c (_initialize_mem): Likewise. * printcmd.c (_initialize_printcmd): Likewise. * python/lib/gdb/function/strfns.py (_MemEq, _StrLen, _StrEq, _RegEx): Likewise. * ravenscar-thread.c (_initialize_ravenscar): Likewise. * record-btrace.c (_initialize_record_btrace): Likewise. * record-full.c (_initialize_record_full): Likewise. * record.c (_initialize_record): Likewise. * regcache-dump.c (_initialize_regcache_dump): Likewise. * regcache.c (_initialize_regcache): Likewise. * remote.c (add_packet_config_cmd, init_remote_threadtests, _initialize_remote): Likewise. * ser-tcp.c (_initialize_ser_tcp): Likewise. * serial.c (_initialize_serial): Likewise. * skip.c (_initialize_step_skip): Likewise. * source.c (_initialize_source): Likewise. * stack.c (_initialize_stack): Likewise. * symfile.c (_initialize_symfile): Likewise. * symtab.c (_initialize_symtab): Likewise. * target-descriptions.c (_initialize_target_descriptions): Likewise. * top.c (init_main): Likewise. * tracefile-tfile.c (tfile_target_info): Likewise. * tracepoint.c (_initialize_tracepoint): Likewise. * tui/tui-win.c (_initialize_tui_win): Likewise. * utils.c (add_internal_problem_command): Likewise. * valprint.c (value_print_option_defs): Likewise. gdb/testsuite/ChangeLog 2019-08-07 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/style.exp: Update tests for help doc new invariants. * gdb.base/help.exp: Likewise.
2019-06-09 11:16:20 +02:00
Usage: interpreter-exec INTERPRETER COMMAND...\n\
2003-02-06 06:30:17 +01:00
The first argument is the name of the interpreter to use.\n\
Make first and last lines of 'command help documentation' consistent. With this patch, the help docs now respect 2 invariants: * The first line of a command help is terminated by a '.' character. * The last character of a command help is not a newline character. Note that the changes for the last invariant were done by Tom, as part of : [PATCH] Remove trailing newlines from help text https://sourceware.org/ml/gdb-patches/2019-06/msg00050.html but some occurrences have been re-introduced since then. Some help docs had to be rephrased/restructured to respect the above invariants. Before this patch, print_doc_line was printing the first line of a command help documentation, but stopping at the first '.' or ',' character. This was giving inconsistent results : * The first line of command helps was sometimes '.' terminated, sometimes not. * The first line of command helps was not always designed to be readable/understandable/unambiguous when stopping at the first '.' or ',' character. This e.g. created the following inconsistencies/problems: < catch exception -- Catch Ada exceptions < catch handlers -- Catch Ada exceptions < catch syscall -- Catch system calls by their names < down-silently -- Same as the `down' command while the new help is: > catch exception -- Catch Ada exceptions, when raised. > catch handlers -- Catch Ada exceptions, when handled. > catch syscall -- Catch system calls by their names, groups and/or numbers. > down-silently -- Same as the `down' command, but does not print anything. Also, the command help doc should not be terminated by a newline character, but this was not respected by all commands. The cli-option -OPT framework re-introduced some occurences. So, the -OPT build help framework was changed to not output newlines at the end of %OPTIONS% replacement. This patch changes the help documentations to ensure the 2 invariants given above. It implied to slightly rephrase or restructure some help docs. Based on the above invariants, print_doc_line (called by 'apropos' and 'help' commands to print the first line of a command help) now outputs the full first line of a command help. This all results in a lot of small changes in the produced help docs. There are less code changes than changes in the help docs, as a lot of docs are produced by some code (e.g. the remote packet usage settings). gdb/ChangeLog 2019-08-07 Philippe Waroquiers <philippe.waroquiers@skynet.be> * cli/cli-decode.h (print_doc_line): Add for_value_prefix argument. * cli/cli-decode.c (print_doc_line): Likewise. It now prints the full first line, except when FOR_VALUE_PREFIX. In this case, the trailing '.' is not output, and the first character is uppercased. (print_help_for_command): Update call to print_doc_line. (print_doc_of_command): Likewise. * cli/cli-setshow.c (deprecated_show_value_hack): Likewise. * cli/cli-option.c (append_indented_doc): Do not append newline. (build_help_option): Append newline after first appended_indented_doc only if a second call is done. (build_help): Append 2 new lines before each option, except the first one. * compile/compile.c (_initialize_compile): Add new lines after %OPTIONS%, when not at the end of the help. Change help doc or code producing the help doc to respect the invariants. * maint-test-options.c (_initialize_maint_test_options): Likewise. Also removed the new line after 'Options:', as all other commands do not put an empty line between 'Options:' and the first option. * printcmd.c (_initialize_printcmd): Likewise. * stack.c (_initialize_stack): Likewise. * interps.c (interpreter_exec_cmd): Fix "Usage:" line that was incorrectly telling COMMAND is optional. * ada-lang.c (_initialize_ada_language): Change help doc or code producing the help doc to respect the invariants. * ada-tasks.c (_initialize_ada_tasks): Likewise. * breakpoint.c (_initialize_breakpoint): Likewise. * cli/cli-cmds.c (_initialize_cli_cmds): Likewise. * cli/cli-logging.c (_initialize_cli_logging): Likewise. * cli/cli-setshow.c (_initialize_cli_setshow): Likewise. * cli/cli-style.c (cli_style_option::add_setshow_commands, _initialize_cli_style): Likewise. * corelow.c (core_target_info): Likewise. * dwarf-index-cache.c (_initialize_index_cache): Likewise. * dwarf2read.c (_initialize_dwarf2_read): Likewise. * filesystem.c (_initialize_filesystem): Likewise. * frame.c (_initialize_frame): Likewise. * gnu-nat.c (add_task_commands): Likewise. * infcall.c (_initialize_infcall): Likewise. * infcmd.c (_initialize_infcmd): Likewise. * interps.c (_initialize_interpreter): Likewise. * language.c (_initialize_language): Likewise. * linux-fork.c (_initialize_linux_fork): Likewise. * maint-test-settings.c (_initialize_maint_test_settings): Likewise. * maint.c (_initialize_maint_cmds): Likewise. * memattr.c (_initialize_mem): Likewise. * printcmd.c (_initialize_printcmd): Likewise. * python/lib/gdb/function/strfns.py (_MemEq, _StrLen, _StrEq, _RegEx): Likewise. * ravenscar-thread.c (_initialize_ravenscar): Likewise. * record-btrace.c (_initialize_record_btrace): Likewise. * record-full.c (_initialize_record_full): Likewise. * record.c (_initialize_record): Likewise. * regcache-dump.c (_initialize_regcache_dump): Likewise. * regcache.c (_initialize_regcache): Likewise. * remote.c (add_packet_config_cmd, init_remote_threadtests, _initialize_remote): Likewise. * ser-tcp.c (_initialize_ser_tcp): Likewise. * serial.c (_initialize_serial): Likewise. * skip.c (_initialize_step_skip): Likewise. * source.c (_initialize_source): Likewise. * stack.c (_initialize_stack): Likewise. * symfile.c (_initialize_symfile): Likewise. * symtab.c (_initialize_symtab): Likewise. * target-descriptions.c (_initialize_target_descriptions): Likewise. * top.c (init_main): Likewise. * tracefile-tfile.c (tfile_target_info): Likewise. * tracepoint.c (_initialize_tracepoint): Likewise. * tui/tui-win.c (_initialize_tui_win): Likewise. * utils.c (add_internal_problem_command): Likewise. * valprint.c (value_print_option_defs): Likewise. gdb/testsuite/ChangeLog 2019-08-07 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/style.exp: Update tests for help doc new invariants. * gdb.base/help.exp: Likewise.
2019-06-09 11:16:20 +02:00
The following arguments are the commands to execute.\n\
A command can have arguments, separated by spaces.\n\
These spaces must be escaped using \\ or the command\n\
and its arguments must be enclosed in double quotes."), &cmdlist);
2003-02-06 06:30:17 +01:00
set_cmd_completer (c, interpreter_completer);
}