1999-04-16 09:35:26 +08:00
|
|
|
/* Top level stuff for GDB, the GNU debugger.
|
2003-02-05 Jim Ingham <jingham@apple.com>
Keith Seitz <keiths@redhat.com>
Elena Zannoni <ezannoni@redhat.com>
Andrew Cagney <ac131313@redhat.com>
* Makefile.in (SUBDIR_CLI_OBS): Add "cli-interp.o".
(SUBDIR_CLI_SRCS): Add "cli/cli-interp.c".
(SUBDIR_MI_OBS): Add "mi-interp.o".
(SUBDIR_MI_SRCS): Add "mi/mi-interp.c".
(SFILES): Add "interps.c".
(COMMON_OBS): Add "interps.o".
(interps_h, mi_main_h): Define.
(interps.o, cli-interp.o, mi-interp.o): Add dependencies.
(mi-main.o, main.o, event-top.o): Update dependencies.
* cli/cli-interp.c: New file.
* interps.h, interps.c: New files.
* top.c: (gdb_init): Don't install the default interpreter, handed
by captured_main.
* main.c: Include "interps.h".
(interpreter_p): Note that it should malloc'ed.
(captured_command_loop): Call current_interp_command_loop.
(captured_main): Initialize interpreter_p to INTERP_CONSOLE. Use
xfree and xstrdup when updating interpreter_p. Install the
default interpreter. Add hack to stop mi1's copyright notice
being encoded.
* event-top.h (gdb_setup_readline): Declare.
(gdb_disable_readline): Declare.
* event-top.c: Include "interps.h".
(display_gdb_prompt): Call current_interp_display_prompt_p.
(gdb_setup_readline): Initialize gdb_stdout, gdb_stderr,
gdb_stdlog, and gdb_stdtarg.
(_initialize_event_loop): Don't call gdb_setup_readline.
* cli-out.c (cli_out_set_stream): New function.
* cli-out.h (cli_out_set_stream): Declare.
2003-02-06 09:19:12 +08:00
|
|
|
|
2017-01-01 14:50:51 +08:00
|
|
|
Copyright (C) 1986-2017 Free Software Foundation, Inc.
|
1999-04-16 09:35:26 +08:00
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
This file is part of GDB.
|
1999-04-16 09:35:26 +08:00
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-08-24 02:08:50 +08:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
1999-07-08 04:19:36 +08:00
|
|
|
(at your option) any later version.
|
1999-04-16 09:35:26 +08:00
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
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.
|
1999-04-16 09:35:26 +08:00
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
You should have received a copy of the GNU General Public License
|
2007-08-24 02:08:50 +08:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
#include "top.h"
|
|
|
|
#include "target.h"
|
|
|
|
#include "inferior.h"
|
2001-01-27 08:43:26 +08:00
|
|
|
#include "symfile.h"
|
|
|
|
#include "gdbcore.h"
|
1999-04-16 09:35:26 +08:00
|
|
|
#include "getopt.h"
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
remove gdb_stat.h
This patch is purely mechanical. It removes gdb_stat.h and changes
the code to use sys/stat.h.
2013-11-18 Tom Tromey <tromey@redhat.com>
* common/gdb_stat.h: Remove.
* ada-lang.c: Use sys/stat.h, not gdb_stat.h.
* common/filestuff.c: Use sys/stat.h, not gdb_stat.h.
* common/linux-osdata.c: Use sys/stat.h, not gdb_stat.h.
* corefile.c: Use sys/stat.h, not gdb_stat.h.
* ctf.c: Use sys/stat.h, not gdb_stat.h.
* darwin-nat.c: Use sys/stat.h, not gdb_stat.h.
* dbxread.c: Use sys/stat.h, not gdb_stat.h.
* dwarf2read.c: Use sys/stat.h, not gdb_stat.h.
* exec.c: Use sys/stat.h, not gdb_stat.h.
* gdbserver/linux-low.c: Use sys/stat.h, not gdb_stat.h.
* gdbserver/remote-utils.c: Use sys/stat.h, not gdb_stat.h.
* inf-child.c: Use sys/stat.h, not gdb_stat.h.
* jit.c: Use sys/stat.h, not gdb_stat.h.
* linux-nat.c: Use sys/stat.h, not gdb_stat.h.
* m68klinux-nat.c: Use sys/stat.h, not gdb_stat.h.
* main.c: Use sys/stat.h, not gdb_stat.h.
* mdebugread.c: Use sys/stat.h, not gdb_stat.h.
* mi/mi-cmd-env.c: Use sys/stat.h, not gdb_stat.h.
* nto-tdep.c: Use sys/stat.h, not gdb_stat.h.
* objfiles.c: Use sys/stat.h, not gdb_stat.h.
* procfs.c: Use sys/stat.h, not gdb_stat.h.
* remote-fileio.c: Use sys/stat.h, not gdb_stat.h.
* remote-mips.c: Use sys/stat.h, not gdb_stat.h.
* remote.c: Use sys/stat.h, not gdb_stat.h.
* rs6000-nat.c: Use sys/stat.h, not gdb_stat.h.
* sol-thread.c: Use sys/stat.h, not gdb_stat.h.
* solib-spu.c: Use sys/stat.h, not gdb_stat.h.
* source.c: Use sys/stat.h, not gdb_stat.h.
* symfile.c: Use sys/stat.h, not gdb_stat.h.
* symmisc.c: Use sys/stat.h, not gdb_stat.h.
* symtab.c: Use sys/stat.h, not gdb_stat.h.
* top.c: Use sys/stat.h, not gdb_stat.h.
* xcoffread.c: Use sys/stat.h, not gdb_stat.h.
2013-11-06 22:55:51 +08:00
|
|
|
#include <sys/stat.h>
|
1999-04-16 09:35:26 +08:00
|
|
|
#include <ctype.h>
|
1999-06-21 21:27:42 +08:00
|
|
|
#include "event-loop.h"
|
2000-02-03 12:14:45 +08:00
|
|
|
#include "ui-out.h"
|
2001-04-05 08:04:45 +08:00
|
|
|
|
2003-02-05 Jim Ingham <jingham@apple.com>
Keith Seitz <keiths@redhat.com>
Elena Zannoni <ezannoni@redhat.com>
Andrew Cagney <ac131313@redhat.com>
* Makefile.in (SUBDIR_CLI_OBS): Add "cli-interp.o".
(SUBDIR_CLI_SRCS): Add "cli/cli-interp.c".
(SUBDIR_MI_OBS): Add "mi-interp.o".
(SUBDIR_MI_SRCS): Add "mi/mi-interp.c".
(SFILES): Add "interps.c".
(COMMON_OBS): Add "interps.o".
(interps_h, mi_main_h): Define.
(interps.o, cli-interp.o, mi-interp.o): Add dependencies.
(mi-main.o, main.o, event-top.o): Update dependencies.
* cli/cli-interp.c: New file.
* interps.h, interps.c: New files.
* top.c: (gdb_init): Don't install the default interpreter, handed
by captured_main.
* main.c: Include "interps.h".
(interpreter_p): Note that it should malloc'ed.
(captured_command_loop): Call current_interp_command_loop.
(captured_main): Initialize interpreter_p to INTERP_CONSOLE. Use
xfree and xstrdup when updating interpreter_p. Install the
default interpreter. Add hack to stop mi1's copyright notice
being encoded.
* event-top.h (gdb_setup_readline): Declare.
(gdb_disable_readline): Declare.
* event-top.c: Include "interps.h".
(display_gdb_prompt): Call current_interp_display_prompt_p.
(gdb_setup_readline): Initialize gdb_stdout, gdb_stderr,
gdb_stdlog, and gdb_stdtarg.
(_initialize_event_loop): Don't call gdb_setup_readline.
* cli-out.c (cli_out_set_stream): New function.
* cli-out.h (cli_out_set_stream): Declare.
2003-02-06 09:19:12 +08:00
|
|
|
#include "interps.h"
|
2002-09-27 01:46:04 +08:00
|
|
|
#include "main.h"
|
2009-04-21 18:13:05 +08:00
|
|
|
#include "source.h"
|
2010-04-07 00:51:18 +08:00
|
|
|
#include "cli/cli-cmds.h"
|
2010-09-23 03:59:15 +08:00
|
|
|
#include "objfiles.h"
|
gdb/
auto-load: Move files.
* Makefile.in (SFILES): Add auto-load.c.
(HFILES_NO_SRCDIR): Add auto-load.h.
(COMMON_OBS): Add auto-load.o.
(distclean): Change .gdbinit for gdb-gdb.gdb.
* auto-load.c: New file, with parts from python/py-auto-load.c.
* auto-load.h: New file, with parts from python/python.h.
* configure: Regenerate.
* configure.ac (AC_OUTPUT): Change .gdbinit for gdb-gdb.gdb.
* gdb-gdb.gdb.in: New file, renamed from gdbinit.in.
* gdbinit.in: Remove file, rename it to gdb-gdb.gdb.in.
* main.c: Include auto-load.h.
* python/py-auto-load.c: Move include filenames.h, gdb_regex.h,
command.h, observer.h and progspace.h to auto-load.c. Add include
auto-load.h.
(gdbpy_global_auto_load, struct auto_load_pspace_info)
(struct loaded_script, auto_load_pspace_data)
(auto_load_pspace_data_cleanup, get_auto_load_pspace_data)
(hash_loaded_script_entry, eq_loaded_script_entry)
(init_loaded_scripts_info, get_auto_load_pspace_data_for_loading)
(maybe_add_script): Move to auto-load.c.
(source_section_scripts): Change maybe_add_script parameters passing,
use script_not_found_warning_print.
(clear_section_scripts, auto_load_objfile_script)
(auto_load_new_objfile, loaded_script_ptr)
(DEF_VEC_P (loaded_script_ptr), collect_matching_scripts, print_script)
(sort_scripts_by_name, info_auto_load_scripts): Move to auto-load.c.
(gdbpy_initialize_auto_load): Move auto_load_pspace_data,
auto_load_new_objfile and info_auto_load_scripts initizations to
auto-load.c.
* python/python.h (gdbpy_global_auto_load): Move to auto-load.h.
2012-04-17 23:49:16 +08:00
|
|
|
#include "auto-load.h"
|
New commands "mt set per-command {space,time,symtab} {on,off}".
* NEWS: Add entry.
* event-top.c: #include "maint.h".
* main.c: #include "maint.h".
* maint.c: #include <sys/time.h>, <time.h>, block.h, top.h,
timeval-utils.h, maint.h, cli/cli-setshow.h.
(per_command_time, per_command_space): New static globals.
(per_command_symtab): New static global.
(per_command_setlist, per_command_showlist): New static globals.
(struct cmd_stats): Move here from utils.c.
(set_per_command_time): Renamed from set_display_time in utils.c
and moved here. All callers updated.
(set_per_command_space): Renamed from set_display_space in utils.c
and moved here. All callers updated.
(count_symtabs_and_blocks): New function.
(report_command_stats): Moved here from utils.c. Add support for
printing symtab stats. Only print data if enabled before command
executed.
(make_command_stats_cleanup): Ditto.
(sert_per_command_cmd, show_per_command_cmd): New functions.
(_initialize_maint_cmds): Add new commands
mt set per-command {space,time,symtab} {on,off}.
* maint.h: New file.
* top.c: #include "maint.h".
* utils.c (reset_prompt_for_continue_wait_time): New function.
(get_prompt_for_continue_wait_time): New function.
* utils.h (reset_prompt_for_continue_wait_time): Declare
(get_prompt_for_continue_wait_time): Declare.
(make_command_stats_cleanup): Moved to maint.h.
(set_display_time, set_display_space): Moved to maint.h and renamed
to set_per_command_time, set_per_command_space.
* cli/cli-setshow.c (parse_cli_boolean_value): Renamed from
parse_binary_operation and made non-static. Don't call error,
just return an error marker. All callers updated.
* cli/cli-setshow.h (parse_cli_boolean_value): Declare.
doc/
* gdb.texinfo (Maintenance Commands): Add docs for
"mt set per-command {space,time,symtab} {on,off}".
testsuite/
* gdb.base/maint.exp: Update tests for per-command stats.
2013-03-22 01:37:30 +08:00
|
|
|
#include "maint.h"
|
2009-04-21 18:13:05 +08:00
|
|
|
|
2013-03-23 18:48:23 +08:00
|
|
|
#include "filenames.h"
|
PR gdb/7912:
* Makefile.in (SFILES): Add filestuff.c
(COMMON_OBS): Add filestuff.o.
(filestuff.o): New target.
* auto-load.c (auto_load_objfile_script_1): Use
gdb_fopen_cloexec.
* auxv.c (procfs_xfer_auxv): Use gdb_open_cloexec.
* cli/cli-cmds.c (shell_escape): Call close_most_fds.
* cli/cli-dump.c (fopen_with_cleanup): Use gdb_fopen_cloexec.
* common/agent.c (gdb_connect_sync_socket): Use
gdb_socket_cloexec.
* common/filestuff.c: New file.
* common/filestuff.h: New file.
* common/linux-osdata.c (linux_common_core_of_thread)
(command_from_pid, commandline_from_pid, print_source_lines)
(linux_xfer_osdata_shm, linux_xfer_osdata_sem)
(linux_xfer_osdata_msg, linux_xfer_osdata_modules): Use
gdb_fopen_cloexec.
* common/linux-procfs.c (linux_proc_get_int)
(linux_proc_pid_has_state): Use gdb_fopen_cloexec.
* config.in, configure: Rebuild.
* configure.ac: Don't check for sys/socket.h. Check for
fdwalk, pipe2.
* corelow.c (core_open): Use gdb_open_cloexec.
* dwarf2read.c (write_psymtabs_to_index): Use gdb_fopen_cloexec.
* fork-child.c (fork_inferior): Call close_most_fds.
* gdb_bfd.c (gdb_bfd_open): Use gdb_open_cloexec.
* inf-child.c (inf_child_fileio_readlink): Use gdb_open_cloexec.
* linux-nat.c (linux_nat_thread_name, linux_proc_pending_signals):
Use gdb_fopen_cloexec.
(linux_proc_xfer_partial, linux_proc_xfer_spu): Use
gdb_open_cloexec.
(linux_async_pipe): Use gdb_pipe_cloexec.
* remote-fileio.c (remote_fileio_func_open): Use
gdb_open_cloexec.
* remote.c (remote_file_put, remote_file_get): Use
gdb_fopen_cloexec.
* ser-pipe.c (pipe_open): Use gdb_socketpair_cloexec,
close_most_fds.
* ser-tcp.c (net_open): Use gdb_socket_cloexec.
* ser-unix.c (hardwire_open): Use gdb_open_cloexec.
* solib.c (solib_find): Use gdb_open_cloexec.
* source.c (openp, find_and_open_source): Use gdb_open_cloexec.
* tracepoint.c (tfile_start): Use gdb_fopen_cloexec.
(tfile_open): Use gdb_open_cloexec.
* tui/tui-io.c (tui_initialize_io): Use gdb_pipe_cloexec.
* ui-file.c (gdb_fopen): Use gdb_fopen_cloexec.
* xml-support.c (xml_fetch_content_from_file): Use
gdb_fopen_cloexec.
* main.c (captured_main): Call notice_open_fds.
gdbserver
* Makefile.in (SFILES): Add filestuff.c.
(OBS): Add filestuff.o.
(filestuff.o): New target.
* config.in, configure: Rebuild.
* configure.ac: Check for fdwalk, pipe2.
2013-04-23 00:46:15 +08:00
|
|
|
#include "filestuff.h"
|
2014-06-19 16:13:57 +08:00
|
|
|
#include <signal.h>
|
Canceling pagination caused by execution command from command line aborts readline/gdb
This fixes:
$ ./gdb program -ex "set height 2" -ex "start"
...
Reading symbols from /home/pedro/gdb/tests/threads...done.
---Type <return> to continue, or q <return> to quit---^CQuit << ctrl-c triggers a Quit
*type something*
readline: readline_callback_read_char() called with no handler!
Aborted
$
Usually, if an error propagates all the way to the top level, we'll
re-enable stdin, in case the command that was running was a
synchronous command. That's done in the event loop's actual loop
(event-loop.c:start_event_loop). However, if a foreground execution
command is run before the event loop starts and throws, nothing is
presently reenabling stdin, which leaves sync_execution set.
When we do start the event loop, because sync_execution is still
(mistakenly) set, display_gdb_prompt removes the readline input
callback, even though stdin is registered in the event loop. Any
input from here on results in readline aborting.
Such commands are run through catch_command_errors,
catch_command_errors_const, so add the tweak there.
gdb/
2014-07-14 Pedro Alves <palves@redhat.com>
PR gdb/17072
* main.c: Include event-top.h.
(handle_command_errors): New function.
(catch_command_errors, catch_command_errors_const): Use it.
gdb/testsuite/
2014-07-14 Pedro Alves <palves@redhat.com>
PR gdb/17072
* gdb.base/paginate-execution-startup.c: New file.
* gdb.base/paginate-execution-startup.exp: New file.
* lib/gdb.exp (pagination_prompt): New global.
(default_gdb_spawn): New procedure, factored out from
default_gdb_spawn.
(default_gdb_start): Adjust to call default_gdb_spawn.
(gdb_spawn): New procedure.
2014-07-15 02:55:31 +08:00
|
|
|
#include "event-top.h"
|
gdb/17347 - Regression: GDB stopped on run with attached process
Doing:
gdb --pid=PID -ex run
Results in GDB getting a SIGTTIN, and thus ending stopped. That's
usually indicative of a missing target_terminal_ours call.
E.g., from the PR:
$ sleep 1h & p=$!; sleep 0.1; gdb -batch sleep $p -ex run
[1] 28263
[1] Killed sleep 1h
[2]+ Stopped gdb -batch sleep $p -ex run
The workaround is doing:
gdb -ex "attach $PID" -ex "run"
instead of
gdb [-p] $PID -ex "run"
With the former, gdb waits for the attach command to complete before
moving on to the "run" command, because the interpreter is in sync
mode at this point, within execute_command. But for the latter,
attach_command is called directly from captured_main, and thus misses
that waiting. IOW, "run" is running before the attach continuation
has run, before the program stops and attach completes. The broken
terminal settings are just one symptom of that. Any command that
queries or requires input results in the same.
The fix is to wait in catch_command_errors (which is specific to
main.c nowadays), just like we wait in execute_command.
gdb/ChangeLog:
2014-09-11 Pedro Alves <palves@redhat.com>
PR gdb/17347
* main.c: Include "infrun.h".
(catch_command_errors, catch_command_errors_const): Wait for the
foreground command to complete.
* top.c (maybe_wait_sync_command_done): New function, factored out
from ...
(maybe_wait_sync_command_done): ... here.
* top.h (maybe_wait_sync_command_done): New declaration.
gdb/testsuite/ChangeLog:
2014-09-11 Pedro Alves <palves@redhat.com>
PR gdb/17347
* lib/gdb.exp (gdb_spawn_with_cmdline_opts): New procedure.
* gdb.base/attach.exp (test_command_line_attach_run): New
procedure.
(top level): Call it.
2014-09-11 20:04:15 +08:00
|
|
|
#include "infrun.h"
|
2016-08-10 03:16:20 +08:00
|
|
|
#include "signals-state-save-restore.h"
|
2016-10-12 10:02:23 +08:00
|
|
|
#include <vector>
|
2013-03-23 18:48:23 +08:00
|
|
|
|
2003-02-05 Jim Ingham <jingham@apple.com>
Keith Seitz <keiths@redhat.com>
Elena Zannoni <ezannoni@redhat.com>
Andrew Cagney <ac131313@redhat.com>
* Makefile.in (SUBDIR_CLI_OBS): Add "cli-interp.o".
(SUBDIR_CLI_SRCS): Add "cli/cli-interp.c".
(SUBDIR_MI_OBS): Add "mi-interp.o".
(SUBDIR_MI_SRCS): Add "mi/mi-interp.c".
(SFILES): Add "interps.c".
(COMMON_OBS): Add "interps.o".
(interps_h, mi_main_h): Define.
(interps.o, cli-interp.o, mi-interp.o): Add dependencies.
(mi-main.o, main.o, event-top.o): Update dependencies.
* cli/cli-interp.c: New file.
* interps.h, interps.c: New files.
* top.c: (gdb_init): Don't install the default interpreter, handed
by captured_main.
* main.c: Include "interps.h".
(interpreter_p): Note that it should malloc'ed.
(captured_command_loop): Call current_interp_command_loop.
(captured_main): Initialize interpreter_p to INTERP_CONSOLE. Use
xfree and xstrdup when updating interpreter_p. Install the
default interpreter. Add hack to stop mi1's copyright notice
being encoded.
* event-top.h (gdb_setup_readline): Declare.
(gdb_disable_readline): Declare.
* event-top.c: Include "interps.h".
(display_gdb_prompt): Call current_interp_display_prompt_p.
(gdb_setup_readline): Initialize gdb_stdout, gdb_stderr,
gdb_stdlog, and gdb_stdtarg.
(_initialize_event_loop): Don't call gdb_setup_readline.
* cli-out.c (cli_out_set_stream): New function.
* cli-out.h (cli_out_set_stream): Declare.
2003-02-06 09:19:12 +08:00
|
|
|
/* The selected interpreter. This will be used as a set command
|
|
|
|
variable, so it should always be malloc'ed - since
|
2010-12-29 08:58:14 +08:00
|
|
|
do_setshow_command will free it. */
|
2000-02-23 08:25:43 +08:00
|
|
|
char *interpreter_p;
|
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
/* Whether dbx commands will be handled. */
|
1999-04-16 09:35:26 +08:00
|
|
|
int dbx_commands = 0;
|
|
|
|
|
2003-01-14 02:00:16 +08:00
|
|
|
/* System root path, used to find libraries etc. */
|
|
|
|
char *gdb_sysroot = 0;
|
|
|
|
|
2009-04-24 05:28:20 +08:00
|
|
|
/* GDB datadir, used to store data files. */
|
|
|
|
char *gdb_datadir = 0;
|
|
|
|
|
2012-11-17 03:43:39 +08:00
|
|
|
/* Non-zero if GDB_DATADIR was provided on the command line.
|
|
|
|
This doesn't track whether data-directory is set later from the
|
|
|
|
command line, but we don't reread system.gdbinit when that happens. */
|
|
|
|
static int gdb_datadir_provided = 0;
|
|
|
|
|
2010-05-27 11:40:45 +08:00
|
|
|
/* If gdb was configured with --with-python=/path,
|
|
|
|
the possibly relocated path to python's lib directory. */
|
|
|
|
char *python_libdir = 0;
|
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
/* Target IO streams. */
|
2003-06-10 22:37:04 +08:00
|
|
|
struct ui_file *gdb_stdtargin;
|
2004-02-03 00:12:49 +08:00
|
|
|
struct ui_file *gdb_stdtarg;
|
2003-06-10 22:37:04 +08:00
|
|
|
struct ui_file *gdb_stdtargerr;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2010-03-09 03:20:38 +08:00
|
|
|
/* True if --batch or --batch-silent was seen. */
|
|
|
|
int batch_flag = 0;
|
|
|
|
|
2005-11-01 19:09:18 +08:00
|
|
|
/* Support for the --batch-silent option. */
|
|
|
|
int batch_silent = 0;
|
|
|
|
|
2005-11-04 19:49:12 +08:00
|
|
|
/* Support for --return-child-result option.
|
|
|
|
Set the default to -1 to return error in the case
|
|
|
|
that the program does not run or does not complete. */
|
|
|
|
int return_child_result = 0;
|
|
|
|
int return_child_result_value = -1;
|
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2009-01-28 23:01:00 +08:00
|
|
|
/* GDB as it has been invoked from the command line (i.e. argv[0]). */
|
|
|
|
static char *gdb_program_name;
|
|
|
|
|
2013-09-18 19:41:38 +08:00
|
|
|
/* Return read only pointer to GDB_PROGRAM_NAME. */
|
|
|
|
const char *
|
|
|
|
get_gdb_program_name (void)
|
|
|
|
{
|
|
|
|
return gdb_program_name;
|
|
|
|
}
|
|
|
|
|
2000-02-02 08:21:19 +08:00
|
|
|
static void print_gdb_help (struct ui_file *);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2014-05-17 03:15:10 +08:00
|
|
|
/* Set the data-directory parameter to NEW_DATADIR.
|
|
|
|
If NEW_DATADIR is not a directory then a warning is printed.
|
|
|
|
We don't signal an error for backward compatibility. */
|
|
|
|
|
|
|
|
void
|
|
|
|
set_gdb_data_directory (const char *new_datadir)
|
|
|
|
{
|
|
|
|
struct stat st;
|
|
|
|
|
|
|
|
if (stat (new_datadir, &st) < 0)
|
|
|
|
{
|
|
|
|
int save_errno = errno;
|
|
|
|
|
|
|
|
fprintf_unfiltered (gdb_stderr, "Warning: ");
|
|
|
|
print_sys_errmsg (new_datadir, save_errno);
|
|
|
|
}
|
|
|
|
else if (!S_ISDIR (st.st_mode))
|
|
|
|
warning (_("%s is not a directory."), new_datadir);
|
|
|
|
|
|
|
|
xfree (gdb_datadir);
|
2017-08-04 06:53:22 +08:00
|
|
|
gdb_datadir = gdb_realpath (new_datadir).release ();
|
2014-05-17 03:15:10 +08:00
|
|
|
|
|
|
|
/* gdb_realpath won't return an absolute path if the path doesn't exist,
|
|
|
|
but we still want to record an absolute path here. If the user entered
|
|
|
|
"../foo" and "../foo" doesn't exist then we'll record $(pwd)/../foo which
|
|
|
|
isn't canonical, but that's ok. */
|
|
|
|
if (!IS_ABSOLUTE_PATH (gdb_datadir))
|
|
|
|
{
|
2017-08-04 06:32:14 +08:00
|
|
|
gdb::unique_xmalloc_ptr<char> abs_datadir = gdb_abspath (gdb_datadir);
|
2014-05-17 03:15:10 +08:00
|
|
|
|
|
|
|
xfree (gdb_datadir);
|
2017-08-04 06:32:14 +08:00
|
|
|
gdb_datadir = abs_datadir.release ();
|
2014-05-17 03:15:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-24 05:28:20 +08:00
|
|
|
/* Relocate a file or directory. PROGNAME is the name by which gdb
|
|
|
|
was invoked (i.e., argv[0]). INITIAL is the default value for the
|
|
|
|
file or directory. FLAG is true if the value is relocatable, false
|
|
|
|
otherwise. Returns a newly allocated string; this may return NULL
|
|
|
|
under the same conditions as make_relative_prefix. */
|
2011-05-10 05:49:57 +08:00
|
|
|
|
2009-04-24 05:28:20 +08:00
|
|
|
static char *
|
|
|
|
relocate_path (const char *progname, const char *initial, int flag)
|
|
|
|
{
|
|
|
|
if (flag)
|
|
|
|
return make_relative_prefix (progname, BINDIR, initial);
|
|
|
|
return xstrdup (initial);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Like relocate_path, but specifically checks for a directory.
|
|
|
|
INITIAL is relocated according to the rules of relocate_path. If
|
|
|
|
the result is a directory, it is used; otherwise, INITIAL is used.
|
|
|
|
The chosen directory is then canonicalized using lrealpath. This
|
|
|
|
function always returns a newly-allocated string. */
|
2011-05-10 05:49:57 +08:00
|
|
|
|
|
|
|
char *
|
|
|
|
relocate_gdb_directory (const char *initial, int flag)
|
2009-04-24 05:28:20 +08:00
|
|
|
{
|
|
|
|
char *dir;
|
|
|
|
|
2011-05-10 05:49:57 +08:00
|
|
|
dir = relocate_path (gdb_program_name, initial, flag);
|
2009-04-24 05:28:20 +08:00
|
|
|
if (dir)
|
|
|
|
{
|
|
|
|
struct stat s;
|
|
|
|
|
2013-01-04 06:18:35 +08:00
|
|
|
if (*dir == '\0' || stat (dir, &s) != 0 || !S_ISDIR (s.st_mode))
|
2009-04-24 05:28:20 +08:00
|
|
|
{
|
|
|
|
xfree (dir);
|
|
|
|
dir = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!dir)
|
|
|
|
dir = xstrdup (initial);
|
|
|
|
|
|
|
|
/* Canonicalize the directory. */
|
|
|
|
if (*dir)
|
|
|
|
{
|
|
|
|
char *canon_sysroot = lrealpath (dir);
|
2010-05-16 08:18:02 +08:00
|
|
|
|
2009-04-24 05:28:20 +08:00
|
|
|
if (canon_sysroot)
|
|
|
|
{
|
|
|
|
xfree (dir);
|
|
|
|
dir = canon_sysroot;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return dir;
|
|
|
|
}
|
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
/* Compute the locations of init files that GDB should source and
|
|
|
|
return them in SYSTEM_GDBINIT, HOME_GDBINIT, LOCAL_GDBINIT. If
|
|
|
|
there is no system gdbinit (resp. home gdbinit and local gdbinit)
|
|
|
|
to be loaded, then SYSTEM_GDBINIT (resp. HOME_GDBINIT and
|
|
|
|
LOCAL_GDBINIT) is set to NULL. */
|
2009-01-28 23:01:00 +08:00
|
|
|
static void
|
2013-07-01 19:22:12 +08:00
|
|
|
get_init_files (const char **system_gdbinit,
|
|
|
|
const char **home_gdbinit,
|
|
|
|
const char **local_gdbinit)
|
2009-01-28 23:01:00 +08:00
|
|
|
{
|
2013-07-01 19:22:12 +08:00
|
|
|
static const char *sysgdbinit = NULL;
|
2009-01-28 23:01:00 +08:00
|
|
|
static char *homeinit = NULL;
|
2013-07-01 19:22:12 +08:00
|
|
|
static const char *localinit = NULL;
|
2009-01-28 23:01:00 +08:00
|
|
|
static int initialized = 0;
|
|
|
|
|
|
|
|
if (!initialized)
|
|
|
|
{
|
|
|
|
struct stat homebuf, cwdbuf, s;
|
2012-11-17 03:43:39 +08:00
|
|
|
char *homedir;
|
2009-01-28 23:01:00 +08:00
|
|
|
|
2009-04-24 05:28:20 +08:00
|
|
|
if (SYSTEM_GDBINIT[0])
|
2009-01-28 23:01:00 +08:00
|
|
|
{
|
2012-11-17 03:43:39 +08:00
|
|
|
int datadir_len = strlen (GDB_DATADIR);
|
|
|
|
int sys_gdbinit_len = strlen (SYSTEM_GDBINIT);
|
|
|
|
char *relocated_sysgdbinit;
|
|
|
|
|
|
|
|
/* If SYSTEM_GDBINIT lives in data-directory, and data-directory
|
|
|
|
has been provided, search for SYSTEM_GDBINIT there. */
|
|
|
|
if (gdb_datadir_provided
|
|
|
|
&& datadir_len < sys_gdbinit_len
|
2013-03-23 18:48:23 +08:00
|
|
|
&& filename_ncmp (SYSTEM_GDBINIT, GDB_DATADIR, datadir_len) == 0
|
|
|
|
&& IS_DIR_SEPARATOR (SYSTEM_GDBINIT[datadir_len]))
|
2012-11-17 03:43:39 +08:00
|
|
|
{
|
|
|
|
/* Append the part of SYSTEM_GDBINIT that follows GDB_DATADIR
|
|
|
|
to gdb_datadir. */
|
2017-06-25 18:57:13 +08:00
|
|
|
char *tmp_sys_gdbinit = xstrdup (&SYSTEM_GDBINIT[datadir_len]);
|
2012-11-17 03:43:39 +08:00
|
|
|
char *p;
|
|
|
|
|
2013-03-23 18:48:23 +08:00
|
|
|
for (p = tmp_sys_gdbinit; IS_DIR_SEPARATOR (*p); ++p)
|
2012-11-17 03:43:39 +08:00
|
|
|
continue;
|
|
|
|
relocated_sysgdbinit = concat (gdb_datadir, SLASH_STRING, p,
|
2016-04-21 18:34:18 +08:00
|
|
|
(char *) NULL);
|
2012-11-17 03:43:39 +08:00
|
|
|
xfree (tmp_sys_gdbinit);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
relocated_sysgdbinit = relocate_path (gdb_program_name,
|
|
|
|
SYSTEM_GDBINIT,
|
|
|
|
SYSTEM_GDBINIT_RELOCATABLE);
|
|
|
|
}
|
2009-04-24 05:28:20 +08:00
|
|
|
if (relocated_sysgdbinit && stat (relocated_sysgdbinit, &s) == 0)
|
2009-01-28 23:01:00 +08:00
|
|
|
sysgdbinit = relocated_sysgdbinit;
|
|
|
|
else
|
|
|
|
xfree (relocated_sysgdbinit);
|
|
|
|
}
|
|
|
|
|
|
|
|
homedir = getenv ("HOME");
|
|
|
|
|
|
|
|
/* If the .gdbinit file in the current directory is the same as
|
|
|
|
the $HOME/.gdbinit file, it should not be sourced. homebuf
|
2011-01-09 11:20:33 +08:00
|
|
|
and cwdbuf are used in that purpose. Make sure that the stats
|
2009-01-28 23:01:00 +08:00
|
|
|
are zero in case one of them fails (this guarantees that they
|
|
|
|
won't match if either exists). */
|
|
|
|
|
|
|
|
memset (&homebuf, 0, sizeof (struct stat));
|
|
|
|
memset (&cwdbuf, 0, sizeof (struct stat));
|
|
|
|
|
|
|
|
if (homedir)
|
|
|
|
{
|
|
|
|
homeinit = xstrprintf ("%s/%s", homedir, gdbinit);
|
|
|
|
if (stat (homeinit, &homebuf) != 0)
|
|
|
|
{
|
|
|
|
xfree (homeinit);
|
|
|
|
homeinit = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (stat (gdbinit, &cwdbuf) == 0)
|
|
|
|
{
|
|
|
|
if (!homeinit
|
|
|
|
|| memcmp ((char *) &homebuf, (char *) &cwdbuf,
|
|
|
|
sizeof (struct stat)))
|
|
|
|
localinit = gdbinit;
|
|
|
|
}
|
|
|
|
|
|
|
|
initialized = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
*system_gdbinit = sysgdbinit;
|
|
|
|
*home_gdbinit = homeinit;
|
|
|
|
*local_gdbinit = localinit;
|
|
|
|
}
|
|
|
|
|
2014-06-19 16:13:57 +08:00
|
|
|
/* Try to set up an alternate signal stack for SIGSEGV handlers.
|
|
|
|
This allows us to handle SIGSEGV signals generated when the
|
|
|
|
normal process stack is exhausted. If this stack is not set
|
|
|
|
up (sigaltstack is unavailable or fails) and a SIGSEGV is
|
|
|
|
generated when the normal stack is exhausted then the program
|
|
|
|
will behave as though no SIGSEGV handler was installed. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
setup_alternate_signal_stack (void)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_SIGALTSTACK
|
|
|
|
stack_t ss;
|
|
|
|
|
2016-04-20 04:51:05 +08:00
|
|
|
/* FreeBSD versions older than 11.0 use char * for ss_sp instead of
|
|
|
|
void *. This cast works with both types. */
|
|
|
|
ss.ss_sp = (char *) xmalloc (SIGSTKSZ);
|
2014-06-19 16:13:57 +08:00
|
|
|
ss.ss_size = SIGSTKSZ;
|
|
|
|
ss.ss_flags = 0;
|
|
|
|
|
|
|
|
sigaltstack(&ss, NULL);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
Eliminate catch_errors
If you want to use catch_errors with a function with parameters, then
currently you have to manually write a "capture" struct wrapping the
arguments and marshall/unmarshall that.
https://sourceware.org/ml/gdb-patches/2017-09/msg00834.html proposed
adjusting catch_errors to use gdb::function_view, which would allow
passing lambdas with automatic captures. However, it seems like using
TRY/CATCH directly instead ends up producing clearer and easier to
debug code. This is what this commit does.
Note that removing catch_errors exposes further cleanup opportunities
around no longer having to follow catch_errors callback type, and also
removes a few cleanups.
I didn't do anything to save/restore current_uiout because I think
that should be the responsibility of the code that changes
current_uiout in the first place.
(Another approach could be to make catch_errors a variadic template
like:
template<typename Function, typename... Args>
int catch_errors (const char *errstring, return_mask mask,
Function &&func, Args... args);
and then with:
extern void function_with_args (int, int);
extern void function_with_no_args ();
calls to the above functions would be wrapped like this:
catch_errors ("some error happened", RETURN_MASK_ERROR,
function_with_args, arg1, arg2);
catch_errors ("some error happened", RETURN_MASK_ERROR,
function_with_no_args);
but I'm thinking that that doesn't improve much if at all either.)
gdb/ChangeLog
2017-10-10 Pedro Alves <palves@redhat.com>
Tom Tromey <tom@tromey.com>
* breakpoint.c (breakpoint_cond_eval): Change return type to bool
and reverse logic.
(WP_DELETED, WP_VALUE_CHANGED, WP_VALUE_NOT_CHANGED, WP_IGNORE):
No longer macros. Instead ...
(enum wp_check_result): They're now values of this new
enumeration.
(watchpoint_check): Change return type to wp_check_result and
parameter type to bpstat.
(bpstat_check_watchpoint): Use TRY/CATCH instead of catch_errors.
(bpstat_check_breakpoint_conditions): Use TRY/CATCH instead of
catch_errors. Reverse logic of watchpoint_check call.
(breakpoint_re_set_one): Now returns void and takes a breakpoint
pointer as parameter.
(breakpoint_re_set): Use TRY/CATCH instead of catch_errors.
* common/common-exceptions.c (throw_exception_sjlj): Update
comments to avoid mentioning catch_errors.
* exceptions.c (catch_errors): Delete.
* exceptions.h: Update comments to avoid mentioning catch_errors.
(catch_errors_ftype, catch_errors): Delete.
* infrun.c (normal_stop): Use TRY/CATCH instead of catch_errors.
(hook_stop_stub): Delete.
(restore_selected_frame): Change return type to void, and
parameter type to const frame_id &.
(restore_infcall_control_state): Use TRY/CATCH instead of
catch_errors.
* main.c (captured_command_loop): Return void and remove
parameter. Remove references to catch_errors.
(captured_main): Use TRY/CATCH instead of catch_errors.
* objc-lang.c (objc_submethod_helper_data)
(find_objc_msgcall_submethod_helper): Delete.
(find_objc_msgcall_submethod): Use TRY/CATCH instead of
catch_errors.
* record-full.c (record_full_message): Return void.
(record_full_message_args, record_full_message_wrapper): Delete.
(record_full_message_wrapper_safe): Return bool and use TRY/CATCH
instead of catch_errors.
* solib-aix.c (solib_aix_open_symbol_file_object): Change
parameter type to int.
* solib-darwin.c (open_symbol_file_object): Ditto.
* solib-dsbt.c (open_symbol_file_object): Ditto.
* solib-frv.c (open_symbol_file_object): Ditto.
* solib-svr4.c (open_symbol_file_object): Ditto.
* solib-target.c (solib_target_open_symbol_file_object): Ditto.
* solib.c (update_solib_list): Use TRY/CATCH instead of
catch_errors.
* solist.h (struct target_so_ops) <open_symbol_file_object>:
Change type.
* symmisc.c (struct print_symbol_args): Remove.
(dump_symtab_1): Use TRY/CATCH instead of catch_errors.
(print_symbol): Change type.
* windows-nat.c (handle_load_dll, handle_unload_dll): Return void
and remove parameters.
(catch_errors): New.
(get_windows_debug_event): Adjust.
gdb/testsuite/ChangeLog:
2017-10-10 Pedro Alves <palves@redhat.com>
* lib/selftest-support.exp (selftest_setup): Update for
captured_command_loop's prototype change.
2017-10-10 23:45:50 +08:00
|
|
|
/* Call command_loop. */
|
1999-11-09 09:23:30 +08:00
|
|
|
|
2017-10-20 21:47:24 +08:00
|
|
|
/* Prevent inlining this function for the benefit of GDB's selftests
|
|
|
|
in the testsuite. Those tests want to run GDB under GDB and stop
|
|
|
|
here. */
|
|
|
|
static void captured_command_loop () __attribute__((noinline));
|
|
|
|
|
Eliminate catch_errors
If you want to use catch_errors with a function with parameters, then
currently you have to manually write a "capture" struct wrapping the
arguments and marshall/unmarshall that.
https://sourceware.org/ml/gdb-patches/2017-09/msg00834.html proposed
adjusting catch_errors to use gdb::function_view, which would allow
passing lambdas with automatic captures. However, it seems like using
TRY/CATCH directly instead ends up producing clearer and easier to
debug code. This is what this commit does.
Note that removing catch_errors exposes further cleanup opportunities
around no longer having to follow catch_errors callback type, and also
removes a few cleanups.
I didn't do anything to save/restore current_uiout because I think
that should be the responsibility of the code that changes
current_uiout in the first place.
(Another approach could be to make catch_errors a variadic template
like:
template<typename Function, typename... Args>
int catch_errors (const char *errstring, return_mask mask,
Function &&func, Args... args);
and then with:
extern void function_with_args (int, int);
extern void function_with_no_args ();
calls to the above functions would be wrapped like this:
catch_errors ("some error happened", RETURN_MASK_ERROR,
function_with_args, arg1, arg2);
catch_errors ("some error happened", RETURN_MASK_ERROR,
function_with_no_args);
but I'm thinking that that doesn't improve much if at all either.)
gdb/ChangeLog
2017-10-10 Pedro Alves <palves@redhat.com>
Tom Tromey <tom@tromey.com>
* breakpoint.c (breakpoint_cond_eval): Change return type to bool
and reverse logic.
(WP_DELETED, WP_VALUE_CHANGED, WP_VALUE_NOT_CHANGED, WP_IGNORE):
No longer macros. Instead ...
(enum wp_check_result): They're now values of this new
enumeration.
(watchpoint_check): Change return type to wp_check_result and
parameter type to bpstat.
(bpstat_check_watchpoint): Use TRY/CATCH instead of catch_errors.
(bpstat_check_breakpoint_conditions): Use TRY/CATCH instead of
catch_errors. Reverse logic of watchpoint_check call.
(breakpoint_re_set_one): Now returns void and takes a breakpoint
pointer as parameter.
(breakpoint_re_set): Use TRY/CATCH instead of catch_errors.
* common/common-exceptions.c (throw_exception_sjlj): Update
comments to avoid mentioning catch_errors.
* exceptions.c (catch_errors): Delete.
* exceptions.h: Update comments to avoid mentioning catch_errors.
(catch_errors_ftype, catch_errors): Delete.
* infrun.c (normal_stop): Use TRY/CATCH instead of catch_errors.
(hook_stop_stub): Delete.
(restore_selected_frame): Change return type to void, and
parameter type to const frame_id &.
(restore_infcall_control_state): Use TRY/CATCH instead of
catch_errors.
* main.c (captured_command_loop): Return void and remove
parameter. Remove references to catch_errors.
(captured_main): Use TRY/CATCH instead of catch_errors.
* objc-lang.c (objc_submethod_helper_data)
(find_objc_msgcall_submethod_helper): Delete.
(find_objc_msgcall_submethod): Use TRY/CATCH instead of
catch_errors.
* record-full.c (record_full_message): Return void.
(record_full_message_args, record_full_message_wrapper): Delete.
(record_full_message_wrapper_safe): Return bool and use TRY/CATCH
instead of catch_errors.
* solib-aix.c (solib_aix_open_symbol_file_object): Change
parameter type to int.
* solib-darwin.c (open_symbol_file_object): Ditto.
* solib-dsbt.c (open_symbol_file_object): Ditto.
* solib-frv.c (open_symbol_file_object): Ditto.
* solib-svr4.c (open_symbol_file_object): Ditto.
* solib-target.c (solib_target_open_symbol_file_object): Ditto.
* solib.c (update_solib_list): Use TRY/CATCH instead of
catch_errors.
* solist.h (struct target_so_ops) <open_symbol_file_object>:
Change type.
* symmisc.c (struct print_symbol_args): Remove.
(dump_symtab_1): Use TRY/CATCH instead of catch_errors.
(print_symbol): Change type.
* windows-nat.c (handle_load_dll, handle_unload_dll): Return void
and remove parameters.
(catch_errors): New.
(get_windows_debug_event): Adjust.
gdb/testsuite/ChangeLog:
2017-10-10 Pedro Alves <palves@redhat.com>
* lib/selftest-support.exp (selftest_setup): Update for
captured_command_loop's prototype change.
2017-10-10 23:45:50 +08:00
|
|
|
static void
|
|
|
|
captured_command_loop ()
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
Make instream be per UI
gdb/ChangeLog:
2016-06-21 Pedro Alves <palves@redhat.com>
* cli/cli-script.c (execute_user_command, read_next_line)
(read_next_line): Adjust to per-UI instream.
* event-top.c (stdin_event_handler, command_handler)
(handle_line_of_input, command_line_handler)
(gdb_readline_no_editing_callback, async_sigterm_handler)
(gdb_setup_readline): Likewise.
* inflow.c: Include top.h.
(gdb_has_a_terminal, child_terminal_init_with_pgrp)
(gdb_save_tty_state, child_terminal_inferior)
(child_terminal_ours_1, copy_terminal_info): Use the main UI.
(initialize_stdin_serial): Adjust to per-UI instream.
* main.c (captured_command_loop, captured_main): Adjust to per-UI
instream.
* mi/mi-interp.c (mi_execute_command_wrapper): Likewise.
* python/python.c (python_interactive_command): Likewise.
* terminal.h (struct ui): Forward declare.
(initialize_stdin_serial): Add struct ui parameter.
* top.c (instream): Delete.
(do_restore_instream_cleanup, read_command_file, dont_repeat)
(gdb_readline_no_editing, command_line_input)
(input_from_terminal_p, gdb_init): Adjust to per-UI instream.
* top.h (struct ui) <instream>: New field.
(instream): Delete declaration.
(quit): Adjust to per-UI instream.
gdb/testsuite/ChangeLog:
2016-06-21 Pedro Alves <palves@redhat.com>
* gdb.gdb/selftest.exp (do_steps_and_nexts): Add new regexp.
2016-06-21 08:11:46 +08:00
|
|
|
struct ui *ui = current_ui;
|
|
|
|
|
2013-07-30 05:41:30 +08:00
|
|
|
/* Top-level execution commands can be run in the background from
|
2011-09-03 00:56:30 +08:00
|
|
|
here on. */
|
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 08:11:45 +08:00
|
|
|
current_ui->async = 1;
|
2011-09-03 00:56:30 +08:00
|
|
|
|
Replace the sync_execution global with a new enum prompt_state tristate
When sync_execution (a boolean) is true, it means we're running a
foreground command -- we hide the prompt stop listening to input, give
the inferior the terminal, then go to the event loop waiting for the
target to stop.
With multiple independent UIs, we need to track whether each UI is
synchronously blocked waiting for the target. IOW, if you do
"continue" in one console, that console stops accepting commands, but
you should still be free to type other commands in the others
consoles.
Just simply making sync_execution be per-UI alone not sufficient,
because of this in fetch_inferior_event:
/* If the inferior was in sync execution mode, and now isn't,
restore the prompt (a synchronous execution command has finished,
and we're ready for input). */
if (current_ui->async && was_sync && !sync_execution)
observer_notify_sync_execution_done ();
We'd have to record at entry the "was_sync" state for each UI, not
just of the current UI.
This patch instead replaces the sync_execution flag by a per-UI
tristate flag indicating the command line prompt state:
enum prompt_state
{
/* The command line is blocked simulating synchronous execution.
This is used to implement the foreground execution commands
('run', 'continue', etc.). We won't display the prompt and
accept further commands until the execution is actually over. */
PROMPT_BLOCKED,
/* The command finished; display the prompt before returning back to
the top level. */
PROMPT_NEEDED,
/* We've displayed the prompt already, ready for input. */
PROMPTED,
;
I think the end result is _much_ clearer than the current code, and,
it addresses the original motivation too.
gdb/ChangeLog:
2016-06-21 Pedro Alves <palves@redhat.com>
* annotate.c: Include top.h.
(async_background_execution_p): Delete.
(print_value_flags): Check the UI's prompt state rather then
async_background_execution_p.
* event-loop.c (start_event_loop): Set the prompt state to
PROMPT_NEEDED.
* event-top.c (display_gdb_prompt, async_enable_stdin)
(async_disable_stdin): Check the current UI's prompt state instead
of the sync_execution global.
(command_line_handler): Set the prompt state to PROMPT_NEEDED
before running a command, and display the prompt if still needed
afterwards.
* infcall.c (struct call_thread_fsm) <waiting_ui>: New field.
(new_call_thread_fsm): New parameter 'waiting_ui'. Store it.
(call_thread_fsm_should_stop): Set the prompt state to
PROMPT_NEEDED.
(run_inferior_call): Adjust to temporarily set the prompt state to
PROMPT_BLOCKED instead of using the sync_execution global.
(call_function_by_hand_dummy): Pass the current UI to
new_call_thread_fsm.
* infcmd.c: Include top.h.
(continue_1): Check the current UI's prompt state instead of the
sync_execution global.
(continue_command): Validate global execution state before calling
prepare_execution_command.
(step_1): Call all_uis_check_sync_execution_done.
(attach_post_wait): Don't call async_enable_stdin here. Remove
reference to sync_execution.
* infrun.c (sync_execution): Delete global.
(follow_fork_inferior)
(reinstall_readline_callback_handler_cleanup): Check the current
UI's prompt state instead of the sync_execution global.
(check_curr_ui_sync_execution_done)
(all_uis_check_sync_execution_done): New functions.
(fetch_inferior_event): Call all_uis_check_sync_execution_done
instead of trying to determine whether the global sync execution
changed.
(handle_no_resumed): Check the prompt state of all UIs.
(normal_stop): Emit the no unwait-for even to all PROMPT_BLOCKED
UIs. Emit the "Switching to" notification to all UIs. Enable
stdin in all UIs.
* infrun.h (sync_execution): Delete.
(all_uis_check_sync_execution_done): Declare.
* main.c (captured_command_loop): Don't call
interp_pre_command_loop if the prompt is blocked.
(catch_command_errors, catch_command_errors_const): Adjust.
(captured_main): Set the initial prompt state to PROMPT_NEEDED.
* mi/mi-interp.c (display_mi_prompt): Set the prompt state to
PROMPTED.
(mi_interpreter_resume): Don't clear sync_execution. Remove hack
comment.
(mi_execute_command_input_handler): Set the prompt state to
PROMPT_NEEDED before executing the command, and only display the
prompt if the prompt state is PROMPT_NEEDED afterwards.
(mi_on_resume_1): Adjust to check the prompt state.
* target.c (target_terminal_inferior): Adjust to check the prompt
state.
* top.c (wait_sync_command_done, maybe_wait_sync_command_done)
(execute_command): Check the current UI's prompt state instead of
sync_execution.
* top.h (enum prompt_state): New.
(struct ui) <prompt_state>: New field.
(ALL_UIS): New macro.
2016-06-21 08:11:51 +08:00
|
|
|
/* Give the interpreter a chance to print a prompt, if necessary */
|
|
|
|
if (ui->prompt_state != PROMPT_BLOCKED)
|
|
|
|
interp_pre_command_loop (top_level_interpreter ());
|
2016-06-21 08:11:51 +08:00
|
|
|
|
|
|
|
/* Now it's time to start the event loop. */
|
|
|
|
start_event_loop ();
|
|
|
|
|
1999-11-09 09:23:30 +08:00
|
|
|
/* FIXME: cagney/1999-11-05: A correct command_loop() implementaton
|
|
|
|
would clean things up (restoring the cleanup chain) to the state
|
|
|
|
they were just prior to the call. Technically, this means that
|
2000-10-24 06:49:29 +08:00
|
|
|
the do_cleanups() below is redundant. Unfortunately, many FUNCs
|
1999-11-09 09:23:30 +08:00
|
|
|
are not that well behaved. do_cleanups should either be replaced
|
|
|
|
with a do_cleanups call (to cover the problem) or an assertion
|
2010-12-29 08:58:14 +08:00
|
|
|
check to detect bad FUNCs code. */
|
2012-04-20 04:18:26 +08:00
|
|
|
do_cleanups (all_cleanups ());
|
1999-11-09 09:23:30 +08:00
|
|
|
/* If the command_loop returned, normally (rather than threw an
|
Eliminate catch_errors
If you want to use catch_errors with a function with parameters, then
currently you have to manually write a "capture" struct wrapping the
arguments and marshall/unmarshall that.
https://sourceware.org/ml/gdb-patches/2017-09/msg00834.html proposed
adjusting catch_errors to use gdb::function_view, which would allow
passing lambdas with automatic captures. However, it seems like using
TRY/CATCH directly instead ends up producing clearer and easier to
debug code. This is what this commit does.
Note that removing catch_errors exposes further cleanup opportunities
around no longer having to follow catch_errors callback type, and also
removes a few cleanups.
I didn't do anything to save/restore current_uiout because I think
that should be the responsibility of the code that changes
current_uiout in the first place.
(Another approach could be to make catch_errors a variadic template
like:
template<typename Function, typename... Args>
int catch_errors (const char *errstring, return_mask mask,
Function &&func, Args... args);
and then with:
extern void function_with_args (int, int);
extern void function_with_no_args ();
calls to the above functions would be wrapped like this:
catch_errors ("some error happened", RETURN_MASK_ERROR,
function_with_args, arg1, arg2);
catch_errors ("some error happened", RETURN_MASK_ERROR,
function_with_no_args);
but I'm thinking that that doesn't improve much if at all either.)
gdb/ChangeLog
2017-10-10 Pedro Alves <palves@redhat.com>
Tom Tromey <tom@tromey.com>
* breakpoint.c (breakpoint_cond_eval): Change return type to bool
and reverse logic.
(WP_DELETED, WP_VALUE_CHANGED, WP_VALUE_NOT_CHANGED, WP_IGNORE):
No longer macros. Instead ...
(enum wp_check_result): They're now values of this new
enumeration.
(watchpoint_check): Change return type to wp_check_result and
parameter type to bpstat.
(bpstat_check_watchpoint): Use TRY/CATCH instead of catch_errors.
(bpstat_check_breakpoint_conditions): Use TRY/CATCH instead of
catch_errors. Reverse logic of watchpoint_check call.
(breakpoint_re_set_one): Now returns void and takes a breakpoint
pointer as parameter.
(breakpoint_re_set): Use TRY/CATCH instead of catch_errors.
* common/common-exceptions.c (throw_exception_sjlj): Update
comments to avoid mentioning catch_errors.
* exceptions.c (catch_errors): Delete.
* exceptions.h: Update comments to avoid mentioning catch_errors.
(catch_errors_ftype, catch_errors): Delete.
* infrun.c (normal_stop): Use TRY/CATCH instead of catch_errors.
(hook_stop_stub): Delete.
(restore_selected_frame): Change return type to void, and
parameter type to const frame_id &.
(restore_infcall_control_state): Use TRY/CATCH instead of
catch_errors.
* main.c (captured_command_loop): Return void and remove
parameter. Remove references to catch_errors.
(captured_main): Use TRY/CATCH instead of catch_errors.
* objc-lang.c (objc_submethod_helper_data)
(find_objc_msgcall_submethod_helper): Delete.
(find_objc_msgcall_submethod): Use TRY/CATCH instead of
catch_errors.
* record-full.c (record_full_message): Return void.
(record_full_message_args, record_full_message_wrapper): Delete.
(record_full_message_wrapper_safe): Return bool and use TRY/CATCH
instead of catch_errors.
* solib-aix.c (solib_aix_open_symbol_file_object): Change
parameter type to int.
* solib-darwin.c (open_symbol_file_object): Ditto.
* solib-dsbt.c (open_symbol_file_object): Ditto.
* solib-frv.c (open_symbol_file_object): Ditto.
* solib-svr4.c (open_symbol_file_object): Ditto.
* solib-target.c (solib_target_open_symbol_file_object): Ditto.
* solib.c (update_solib_list): Use TRY/CATCH instead of
catch_errors.
* solist.h (struct target_so_ops) <open_symbol_file_object>:
Change type.
* symmisc.c (struct print_symbol_args): Remove.
(dump_symtab_1): Use TRY/CATCH instead of catch_errors.
(print_symbol): Change type.
* windows-nat.c (handle_load_dll, handle_unload_dll): Return void
and remove parameters.
(catch_errors): New.
(get_windows_debug_event): Adjust.
gdb/testsuite/ChangeLog:
2017-10-10 Pedro Alves <palves@redhat.com>
* lib/selftest-support.exp (selftest_setup): Update for
captured_command_loop's prototype change.
2017-10-10 23:45:50 +08:00
|
|
|
error) we try to quit. If the quit is aborted, our caller
|
|
|
|
catches the signal and restarts the command loop. */
|
Make stdin be per UI
This commit makes each UI have its own "stdin" stream pointer. This
is used to determine whether the "from_tty" argument to
execute_command, etc. should be true.
Related, this commit makes input_from_terminal_p take an UI parameter,
and then avoids the gdb_has_a_terminal in it. gdb_has_a_terminal only
returns info on gdb's own main/primary terminal (the real stdin).
However, the places that call input_from_terminal_p really want to
know is whether the command came from an interactive tty. This patch
thus renames input_from_terminal_p to input_interactive_p for clarity,
and then makes input_interactive_p check for "set interactive" itself,
along with ISATTY, instead of calling gdb_has_a_terminal. Actually,
quit_force wants to call input_interactive_p _after_ stdin is closed,
we can't call ISATTY that late. So instead we save the result of
ISATTY in a field of the UI.
gdb/ChangeLog:
2016-06-21 Pedro Alves <palves@redhat.com>
* cli/cli-script.c (read_next_line): Adjust to per-UI stdin.
(read_command_lines): Use input_interactive_p instead of
input_from_terminal_p.
* defs.h (struct ui): Forward declare.
(input_from_terminal_p): Rename to ...
(input_interactive_p): ... this.
* event-top.c (stdin_event_handler): Pass 0 as from_tty argument
to quit_command.
(command_handler): Adjust to per-UI stdin.
(handle_line_of_input): Adjust to per-UI stdin and use
input_interactive_p instead of ISATTY and input_from_terminal_p.
(gdb_readline_no_editing_callback): Adjust to per-UI stdin.
(command_line_handler): Always pass true as "from_tty" parameter
of handle_line_of_input and execute_command.
(async_sigterm_handler): Pass 0 as from_tty argument to
quit_command.
* inflow.c (interactive_mode, show_interactive_mode): Moved to ...
(gdb_has_a_terminal): Don't check interactive_mode here.
(_initialize_inflow): Don't install "set interactive-mode" here.
* main.c (captured_command_loop): Adjust to per-UI stdin.
* mi/mi-interp.c (mi_execute_command_wrapper): Adjust to per-UI
stdin.
* top.c (new_ui): Save the stdin stream and whether it's a tty.
(dont_repeat): Adjust to per-UI stdin.
(command_line_input): Adjust to per-UI stdin and to use
input_interactive_p.
(quit_force): Write history if any UI supports interactive input.
(interactive_mode, show_interactive_mode): Move here, from
inflow.c.
(input_from_terminal_p): Rename to ...
(input_interactive_p): ... this, and check the "interactive_mode"
global instead of calling gdb_has_a_terminal.
(_initialize_top): Install "set interactive-mode" here.
* top.h (struct ui) <stdin_stream, input_interactive_p>: New
fields.
* utils.c (quit): Pass 0 as from_tty argument to quit_force.
(defaulted_query): Adjust to per-UI stdin and to use
input_interactive_p.
2016-06-21 08:11:54 +08:00
|
|
|
quit_command (NULL, ui->instream == ui->stdin_stream);
|
1999-11-09 09:23:30 +08:00
|
|
|
}
|
|
|
|
|
2017-09-13 04:14:33 +08:00
|
|
|
/* Handle command errors thrown from within catch_command_errors. */
|
Canceling pagination caused by execution command from command line aborts readline/gdb
This fixes:
$ ./gdb program -ex "set height 2" -ex "start"
...
Reading symbols from /home/pedro/gdb/tests/threads...done.
---Type <return> to continue, or q <return> to quit---^CQuit << ctrl-c triggers a Quit
*type something*
readline: readline_callback_read_char() called with no handler!
Aborted
$
Usually, if an error propagates all the way to the top level, we'll
re-enable stdin, in case the command that was running was a
synchronous command. That's done in the event loop's actual loop
(event-loop.c:start_event_loop). However, if a foreground execution
command is run before the event loop starts and throws, nothing is
presently reenabling stdin, which leaves sync_execution set.
When we do start the event loop, because sync_execution is still
(mistakenly) set, display_gdb_prompt removes the readline input
callback, even though stdin is registered in the event loop. Any
input from here on results in readline aborting.
Such commands are run through catch_command_errors,
catch_command_errors_const, so add the tweak there.
gdb/
2014-07-14 Pedro Alves <palves@redhat.com>
PR gdb/17072
* main.c: Include event-top.h.
(handle_command_errors): New function.
(catch_command_errors, catch_command_errors_const): Use it.
gdb/testsuite/
2014-07-14 Pedro Alves <palves@redhat.com>
PR gdb/17072
* gdb.base/paginate-execution-startup.c: New file.
* gdb.base/paginate-execution-startup.exp: New file.
* lib/gdb.exp (pagination_prompt): New global.
(default_gdb_spawn): New procedure, factored out from
default_gdb_spawn.
(default_gdb_start): Adjust to call default_gdb_spawn.
(gdb_spawn): New procedure.
2014-07-15 02:55:31 +08:00
|
|
|
|
|
|
|
static int
|
2015-03-07 22:50:03 +08:00
|
|
|
handle_command_errors (struct gdb_exception e)
|
Canceling pagination caused by execution command from command line aborts readline/gdb
This fixes:
$ ./gdb program -ex "set height 2" -ex "start"
...
Reading symbols from /home/pedro/gdb/tests/threads...done.
---Type <return> to continue, or q <return> to quit---^CQuit << ctrl-c triggers a Quit
*type something*
readline: readline_callback_read_char() called with no handler!
Aborted
$
Usually, if an error propagates all the way to the top level, we'll
re-enable stdin, in case the command that was running was a
synchronous command. That's done in the event loop's actual loop
(event-loop.c:start_event_loop). However, if a foreground execution
command is run before the event loop starts and throws, nothing is
presently reenabling stdin, which leaves sync_execution set.
When we do start the event loop, because sync_execution is still
(mistakenly) set, display_gdb_prompt removes the readline input
callback, even though stdin is registered in the event loop. Any
input from here on results in readline aborting.
Such commands are run through catch_command_errors,
catch_command_errors_const, so add the tweak there.
gdb/
2014-07-14 Pedro Alves <palves@redhat.com>
PR gdb/17072
* main.c: Include event-top.h.
(handle_command_errors): New function.
(catch_command_errors, catch_command_errors_const): Use it.
gdb/testsuite/
2014-07-14 Pedro Alves <palves@redhat.com>
PR gdb/17072
* gdb.base/paginate-execution-startup.c: New file.
* gdb.base/paginate-execution-startup.exp: New file.
* lib/gdb.exp (pagination_prompt): New global.
(default_gdb_spawn): New procedure, factored out from
default_gdb_spawn.
(default_gdb_start): Adjust to call default_gdb_spawn.
(gdb_spawn): New procedure.
2014-07-15 02:55:31 +08:00
|
|
|
{
|
|
|
|
if (e.reason < 0)
|
|
|
|
{
|
|
|
|
exception_print (gdb_stderr, e);
|
|
|
|
|
|
|
|
/* If any exception escaped to here, we better enable stdin.
|
|
|
|
Otherwise, any command that calls async_disable_stdin, and
|
|
|
|
then throws, will leave stdin inoperable. */
|
|
|
|
async_enable_stdin ();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2017-09-13 04:14:33 +08:00
|
|
|
/* Type of the command callback passed to the const
|
|
|
|
catch_command_errors. */
|
2014-07-15 02:55:31 +08:00
|
|
|
|
|
|
|
typedef void (catch_command_errors_const_ftype) (const char *, int);
|
|
|
|
|
2017-10-15 22:36:51 +08:00
|
|
|
/* Wrap calls to commands run before the event loop is started. */
|
2014-07-15 02:55:31 +08:00
|
|
|
|
|
|
|
static int
|
2017-09-13 04:14:33 +08:00
|
|
|
catch_command_errors (catch_command_errors_const_ftype command,
|
|
|
|
const char *arg, int from_tty)
|
2014-07-15 02:55:31 +08:00
|
|
|
{
|
Split TRY_CATCH into TRY + CATCH
This patch splits the TRY_CATCH macro into three, so that we go from
this:
~~~
volatile gdb_exception ex;
TRY_CATCH (ex, RETURN_MASK_ERROR)
{
}
if (ex.reason < 0)
{
}
~~~
to this:
~~~
TRY
{
}
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
~~~
Thus, we'll be getting rid of the local volatile exception object, and
declaring the caught exception in the catch block.
This allows reimplementing TRY/CATCH in terms of C++ exceptions when
building in C++ mode, while still allowing to build GDB in C mode
(using setjmp/longjmp), as a transition step.
TBC, after this patch, is it _not_ valid to have code between the TRY
and the CATCH blocks, like:
TRY
{
}
// some code here.
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
Just like it isn't valid to do that with C++'s native try/catch.
By switching to creating the exception object inside the CATCH block
scope, we can get rid of all the explicitly allocated volatile
exception objects all over the tree, and map the CATCH block more
directly to C++'s catch blocks.
The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was
done with a script, rerun from scratch at every rebase, no manual
editing involved. After the mechanical conversion, a few places
needed manual intervention, to fix preexisting cases where we were
using the exception object outside of the TRY_CATCH block, and cases
where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH
after this patch]. The result was folded into this patch so that GDB
still builds at each incremental step.
END_CATCH is necessary for two reasons:
First, because we name the exception object in the CATCH block, which
requires creating a scope, which in turn must be closed somewhere.
Declaring the exception variable in the initializer field of a for
block, like:
#define CATCH(EXCEPTION, mask) \
for (struct gdb_exception EXCEPTION; \
exceptions_state_mc_catch (&EXCEPTION, MASK); \
EXCEPTION = exception_none)
would avoid needing END_CATCH, but alas, in C mode, we build with C90,
which doesn't allow mixed declarations and code.
Second, because when TRY/CATCH are wired to real C++ try/catch, as
long as we need to handle cleanup chains, even if there's no CATCH
block that wants to catch the exception, we need for stop at every
frame in the unwind chain and run cleanups, then rethrow. That will
be done in END_CATCH.
After we require C++, we'll still need TRY/CATCH/END_CATCH until
cleanups are completely phased out -- TRY/CATCH in C++ mode will
save/restore the current cleanup chain, like in C mode, and END_CATCH
catches otherwise uncaugh exceptions, runs cleanups and rethrows, so
that C++ cleanups and exceptions can coexist.
IMO, this still makes the TRY/CATCH code look a bit more like a
newcomer would expect, so IMO worth it even if we weren't considering
C++.
gdb/ChangeLog.
2015-03-07 Pedro Alves <palves@redhat.com>
* common/common-exceptions.c (struct catcher) <exception>: No
longer a pointer to volatile exception. Now an exception value.
<mask>: Delete field.
(exceptions_state_mc_init): Remove all parameters. Adjust.
(exceptions_state_mc): No longer pop the catcher here.
(exceptions_state_mc_catch): New function.
(throw_exception): Adjust.
* common/common-exceptions.h (exceptions_state_mc_init): Remove
all parameters.
(exceptions_state_mc_catch): Declare.
(TRY_CATCH): Rename to ...
(TRY): ... this. Remove EXCEPTION and MASK parameters.
(CATCH, END_CATCH): New.
All callers adjusted.
gdb/gdbserver/ChangeLog:
2015-03-07 Pedro Alves <palves@redhat.com>
Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH
instead.
2015-03-07 23:14:14 +08:00
|
|
|
TRY
|
2014-07-15 02:55:31 +08:00
|
|
|
{
|
Replace the sync_execution global with a new enum prompt_state tristate
When sync_execution (a boolean) is true, it means we're running a
foreground command -- we hide the prompt stop listening to input, give
the inferior the terminal, then go to the event loop waiting for the
target to stop.
With multiple independent UIs, we need to track whether each UI is
synchronously blocked waiting for the target. IOW, if you do
"continue" in one console, that console stops accepting commands, but
you should still be free to type other commands in the others
consoles.
Just simply making sync_execution be per-UI alone not sufficient,
because of this in fetch_inferior_event:
/* If the inferior was in sync execution mode, and now isn't,
restore the prompt (a synchronous execution command has finished,
and we're ready for input). */
if (current_ui->async && was_sync && !sync_execution)
observer_notify_sync_execution_done ();
We'd have to record at entry the "was_sync" state for each UI, not
just of the current UI.
This patch instead replaces the sync_execution flag by a per-UI
tristate flag indicating the command line prompt state:
enum prompt_state
{
/* The command line is blocked simulating synchronous execution.
This is used to implement the foreground execution commands
('run', 'continue', etc.). We won't display the prompt and
accept further commands until the execution is actually over. */
PROMPT_BLOCKED,
/* The command finished; display the prompt before returning back to
the top level. */
PROMPT_NEEDED,
/* We've displayed the prompt already, ready for input. */
PROMPTED,
;
I think the end result is _much_ clearer than the current code, and,
it addresses the original motivation too.
gdb/ChangeLog:
2016-06-21 Pedro Alves <palves@redhat.com>
* annotate.c: Include top.h.
(async_background_execution_p): Delete.
(print_value_flags): Check the UI's prompt state rather then
async_background_execution_p.
* event-loop.c (start_event_loop): Set the prompt state to
PROMPT_NEEDED.
* event-top.c (display_gdb_prompt, async_enable_stdin)
(async_disable_stdin): Check the current UI's prompt state instead
of the sync_execution global.
(command_line_handler): Set the prompt state to PROMPT_NEEDED
before running a command, and display the prompt if still needed
afterwards.
* infcall.c (struct call_thread_fsm) <waiting_ui>: New field.
(new_call_thread_fsm): New parameter 'waiting_ui'. Store it.
(call_thread_fsm_should_stop): Set the prompt state to
PROMPT_NEEDED.
(run_inferior_call): Adjust to temporarily set the prompt state to
PROMPT_BLOCKED instead of using the sync_execution global.
(call_function_by_hand_dummy): Pass the current UI to
new_call_thread_fsm.
* infcmd.c: Include top.h.
(continue_1): Check the current UI's prompt state instead of the
sync_execution global.
(continue_command): Validate global execution state before calling
prepare_execution_command.
(step_1): Call all_uis_check_sync_execution_done.
(attach_post_wait): Don't call async_enable_stdin here. Remove
reference to sync_execution.
* infrun.c (sync_execution): Delete global.
(follow_fork_inferior)
(reinstall_readline_callback_handler_cleanup): Check the current
UI's prompt state instead of the sync_execution global.
(check_curr_ui_sync_execution_done)
(all_uis_check_sync_execution_done): New functions.
(fetch_inferior_event): Call all_uis_check_sync_execution_done
instead of trying to determine whether the global sync execution
changed.
(handle_no_resumed): Check the prompt state of all UIs.
(normal_stop): Emit the no unwait-for even to all PROMPT_BLOCKED
UIs. Emit the "Switching to" notification to all UIs. Enable
stdin in all UIs.
* infrun.h (sync_execution): Delete.
(all_uis_check_sync_execution_done): Declare.
* main.c (captured_command_loop): Don't call
interp_pre_command_loop if the prompt is blocked.
(catch_command_errors, catch_command_errors_const): Adjust.
(captured_main): Set the initial prompt state to PROMPT_NEEDED.
* mi/mi-interp.c (display_mi_prompt): Set the prompt state to
PROMPTED.
(mi_interpreter_resume): Don't clear sync_execution. Remove hack
comment.
(mi_execute_command_input_handler): Set the prompt state to
PROMPT_NEEDED before executing the command, and only display the
prompt if the prompt state is PROMPT_NEEDED afterwards.
(mi_on_resume_1): Adjust to check the prompt state.
* target.c (target_terminal_inferior): Adjust to check the prompt
state.
* top.c (wait_sync_command_done, maybe_wait_sync_command_done)
(execute_command): Check the current UI's prompt state instead of
sync_execution.
* top.h (enum prompt_state): New.
(struct ui) <prompt_state>: New field.
(ALL_UIS): New macro.
2016-06-21 08:11:51 +08:00
|
|
|
int was_sync = current_ui->prompt_state == PROMPT_BLOCKED;
|
gdb/17347 - Regression: GDB stopped on run with attached process
Doing:
gdb --pid=PID -ex run
Results in GDB getting a SIGTTIN, and thus ending stopped. That's
usually indicative of a missing target_terminal_ours call.
E.g., from the PR:
$ sleep 1h & p=$!; sleep 0.1; gdb -batch sleep $p -ex run
[1] 28263
[1] Killed sleep 1h
[2]+ Stopped gdb -batch sleep $p -ex run
The workaround is doing:
gdb -ex "attach $PID" -ex "run"
instead of
gdb [-p] $PID -ex "run"
With the former, gdb waits for the attach command to complete before
moving on to the "run" command, because the interpreter is in sync
mode at this point, within execute_command. But for the latter,
attach_command is called directly from captured_main, and thus misses
that waiting. IOW, "run" is running before the attach continuation
has run, before the program stops and attach completes. The broken
terminal settings are just one symptom of that. Any command that
queries or requires input results in the same.
The fix is to wait in catch_command_errors (which is specific to
main.c nowadays), just like we wait in execute_command.
gdb/ChangeLog:
2014-09-11 Pedro Alves <palves@redhat.com>
PR gdb/17347
* main.c: Include "infrun.h".
(catch_command_errors, catch_command_errors_const): Wait for the
foreground command to complete.
* top.c (maybe_wait_sync_command_done): New function, factored out
from ...
(maybe_wait_sync_command_done): ... here.
* top.h (maybe_wait_sync_command_done): New declaration.
gdb/testsuite/ChangeLog:
2014-09-11 Pedro Alves <palves@redhat.com>
PR gdb/17347
* lib/gdb.exp (gdb_spawn_with_cmdline_opts): New procedure.
* gdb.base/attach.exp (test_command_line_attach_run): New
procedure.
(top level): Call it.
2014-09-11 20:04:15 +08:00
|
|
|
|
2014-07-15 02:55:31 +08:00
|
|
|
command (arg, from_tty);
|
gdb/17347 - Regression: GDB stopped on run with attached process
Doing:
gdb --pid=PID -ex run
Results in GDB getting a SIGTTIN, and thus ending stopped. That's
usually indicative of a missing target_terminal_ours call.
E.g., from the PR:
$ sleep 1h & p=$!; sleep 0.1; gdb -batch sleep $p -ex run
[1] 28263
[1] Killed sleep 1h
[2]+ Stopped gdb -batch sleep $p -ex run
The workaround is doing:
gdb -ex "attach $PID" -ex "run"
instead of
gdb [-p] $PID -ex "run"
With the former, gdb waits for the attach command to complete before
moving on to the "run" command, because the interpreter is in sync
mode at this point, within execute_command. But for the latter,
attach_command is called directly from captured_main, and thus misses
that waiting. IOW, "run" is running before the attach continuation
has run, before the program stops and attach completes. The broken
terminal settings are just one symptom of that. Any command that
queries or requires input results in the same.
The fix is to wait in catch_command_errors (which is specific to
main.c nowadays), just like we wait in execute_command.
gdb/ChangeLog:
2014-09-11 Pedro Alves <palves@redhat.com>
PR gdb/17347
* main.c: Include "infrun.h".
(catch_command_errors, catch_command_errors_const): Wait for the
foreground command to complete.
* top.c (maybe_wait_sync_command_done): New function, factored out
from ...
(maybe_wait_sync_command_done): ... here.
* top.h (maybe_wait_sync_command_done): New declaration.
gdb/testsuite/ChangeLog:
2014-09-11 Pedro Alves <palves@redhat.com>
PR gdb/17347
* lib/gdb.exp (gdb_spawn_with_cmdline_opts): New procedure.
* gdb.base/attach.exp (test_command_line_attach_run): New
procedure.
(top level): Call it.
2014-09-11 20:04:15 +08:00
|
|
|
|
|
|
|
maybe_wait_sync_command_done (was_sync);
|
2014-07-15 02:55:31 +08:00
|
|
|
}
|
Split TRY_CATCH into TRY + CATCH
This patch splits the TRY_CATCH macro into three, so that we go from
this:
~~~
volatile gdb_exception ex;
TRY_CATCH (ex, RETURN_MASK_ERROR)
{
}
if (ex.reason < 0)
{
}
~~~
to this:
~~~
TRY
{
}
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
~~~
Thus, we'll be getting rid of the local volatile exception object, and
declaring the caught exception in the catch block.
This allows reimplementing TRY/CATCH in terms of C++ exceptions when
building in C++ mode, while still allowing to build GDB in C mode
(using setjmp/longjmp), as a transition step.
TBC, after this patch, is it _not_ valid to have code between the TRY
and the CATCH blocks, like:
TRY
{
}
// some code here.
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
Just like it isn't valid to do that with C++'s native try/catch.
By switching to creating the exception object inside the CATCH block
scope, we can get rid of all the explicitly allocated volatile
exception objects all over the tree, and map the CATCH block more
directly to C++'s catch blocks.
The majority of the TRY_CATCH -> TRY+CATCH+END_CATCH conversion was
done with a script, rerun from scratch at every rebase, no manual
editing involved. After the mechanical conversion, a few places
needed manual intervention, to fix preexisting cases where we were
using the exception object outside of the TRY_CATCH block, and cases
where we were using "else" after a 'if (ex.reason) < 0)' [a CATCH
after this patch]. The result was folded into this patch so that GDB
still builds at each incremental step.
END_CATCH is necessary for two reasons:
First, because we name the exception object in the CATCH block, which
requires creating a scope, which in turn must be closed somewhere.
Declaring the exception variable in the initializer field of a for
block, like:
#define CATCH(EXCEPTION, mask) \
for (struct gdb_exception EXCEPTION; \
exceptions_state_mc_catch (&EXCEPTION, MASK); \
EXCEPTION = exception_none)
would avoid needing END_CATCH, but alas, in C mode, we build with C90,
which doesn't allow mixed declarations and code.
Second, because when TRY/CATCH are wired to real C++ try/catch, as
long as we need to handle cleanup chains, even if there's no CATCH
block that wants to catch the exception, we need for stop at every
frame in the unwind chain and run cleanups, then rethrow. That will
be done in END_CATCH.
After we require C++, we'll still need TRY/CATCH/END_CATCH until
cleanups are completely phased out -- TRY/CATCH in C++ mode will
save/restore the current cleanup chain, like in C mode, and END_CATCH
catches otherwise uncaugh exceptions, runs cleanups and rethrows, so
that C++ cleanups and exceptions can coexist.
IMO, this still makes the TRY/CATCH code look a bit more like a
newcomer would expect, so IMO worth it even if we weren't considering
C++.
gdb/ChangeLog.
2015-03-07 Pedro Alves <palves@redhat.com>
* common/common-exceptions.c (struct catcher) <exception>: No
longer a pointer to volatile exception. Now an exception value.
<mask>: Delete field.
(exceptions_state_mc_init): Remove all parameters. Adjust.
(exceptions_state_mc): No longer pop the catcher here.
(exceptions_state_mc_catch): New function.
(throw_exception): Adjust.
* common/common-exceptions.h (exceptions_state_mc_init): Remove
all parameters.
(exceptions_state_mc_catch): Declare.
(TRY_CATCH): Rename to ...
(TRY): ... this. Remove EXCEPTION and MASK parameters.
(CATCH, END_CATCH): New.
All callers adjusted.
gdb/gdbserver/ChangeLog:
2015-03-07 Pedro Alves <palves@redhat.com>
Adjust all callers of TRY_CATCH to use TRY/CATCH/END_CATCH
instead.
2015-03-07 23:14:14 +08:00
|
|
|
CATCH (e, RETURN_MASK_ALL)
|
|
|
|
{
|
|
|
|
return handle_command_errors (e);
|
|
|
|
}
|
|
|
|
END_CATCH
|
|
|
|
|
|
|
|
return 1;
|
2014-07-15 02:55:31 +08:00
|
|
|
}
|
|
|
|
|
2016-10-27 01:12:01 +08:00
|
|
|
/* Adapter for symbol_file_add_main that translates 'from_tty' to a
|
|
|
|
symfile_add_flags. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
symbol_file_add_main_adapter (const char *arg, int from_tty)
|
|
|
|
{
|
|
|
|
symfile_add_flags add_flags = 0;
|
|
|
|
|
|
|
|
if (from_tty)
|
|
|
|
add_flags |= SYMFILE_VERBOSE;
|
|
|
|
|
|
|
|
symbol_file_add_main (arg, add_flags);
|
|
|
|
}
|
|
|
|
|
Add support for the readnever concept
The purpose of this concept is to turn the load of debugging
information off, either globally (via the '--readnever' option), or
objfile-specific. The implementation proposed here is an extension of
the patch distributed with Fedora GDB; looking at the Fedora patch
itself and the history, one can see some reasons why it was never
resubmitted:
- The patch appears to have been introduced as a workaround, at
least initially;
- The patch is far from perfect, as it simply shunts the load of
DWARF debugging information, without really worrying about the
other debug format.
- Who really does non-symbolic debugging anyways?
One use of this feature is when a user simply wants to do the
following sequence: attach, dump core, detach. Loading the debugging
information in this case is an unnecessary cause of delay.
This patch expands the version shipped with Fedora GDB in order to
make the feature available for all the debuginfo backends, not only
for DWARF. It also implements a per-objfile flag which can be
activated by using the "-readnever" command when using the
'add-symbol-file' or 'symbol-file' commands.
It's also worth mentioning that this patch tests whether GDB correctly
fails to initialize if both '--readnow' and '--readnever' options are
passed.
Tested on the BuildBot.
gdb/ChangeLog:
2017-12-01 Andrew Cagney <cagney@redhat.com>
Joel Brobecker <brobecker@adacore.com>
Sergio Durigan Junior <sergiodj@redhat.com>
* NEWS (Changes since GDB 8.0: Mention new '--readnever'
feature.
* coffread.c (coff_symfile_read): Do not map over sections with
'coff_locate_sections' if readnever is on.
* dwarf2read.c (dwarf2_has_info): Return 0 if
readnever is on.
* elfread.c (elf_symfile_read): Do not map over sections with
'elf_locate_sections' if readnever is on.
* main.c (validate_readnow_readnever): New function.
(captured_main_1): Add support for --readnever.
(print_gdb_help): Document --readnever.
* objfile-flags.h (enum objfile_flag) <OBJF_READNEVER>: New
flag.
* symfile.c (readnever_symbol_files): New global.
(symbol_file_add_with_addrs): Set 'OBJF_READNEVER' when
'READNEVER_SYMBOL_FILES' is set.
(validate_readnow_readnever): New function.
(symbol_file_command): Handle '-readnever' option.
Call 'validate_readnow_readnever'.
(add_symbol_file_command): Handle '-readnever' option.
Call 'validate_readnow_readnever'.
(_initialize_symfile): Document new '-readnever' option for
both 'symbol-file' and 'add-symbol-file' commands.
* top.h (readnever_symbol_files): New extern global.
* xcoffread.c (xcoff_initial_scan): Do not read debug
information if readnever is on.
gdb/doc/ChangeLog:
2017-12-01 Andrew Cagney <cagney@redhat.com>
Joel Brobecker <brobecker@adacore.com>
Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.texinfo (File Options): Document --readnever.
(Commands to Specify Files): Likewise, for 'symbol-file' and
'add-symbol-file'.
gdb/testsuite/ChangeLog:
2017-12-01 Joel Brobecker <brobecker@adacore.com>
Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
* gdb.base/readnever.c, gdb.base/readnever.exp: New files.
2017-11-25 05:56:08 +08:00
|
|
|
/* Perform validation of the '--readnow' and '--readnever' flags. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
validate_readnow_readnever ()
|
|
|
|
{
|
|
|
|
if (readnever_symbol_files && readnow_symbol_files)
|
|
|
|
{
|
|
|
|
error (_("%s: '--readnow' and '--readnever' cannot be "
|
|
|
|
"specified simultaneously"),
|
|
|
|
gdb_program_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global
scope just like it had been defined outside the struct in the first
place. However, in C++, such a nested structure is given a name that
is nested inside the structure. This patch moves such affected
structures/enums out to global scope, so that code using them works
the same in C++ as it works today in C.
gdb/ChangeLog:
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* dwarf2-frame.c (enum cfa_how_kind, struct
dwarf2_frame_state_reg_info): Move out of struct
dwarf2_frame_state.
* dwarf2read.c (struct tu_stats): Move out of struct
dwarf2_per_objfile.
(struct file_entry): Move out of struct line_header.
(struct nextfield, struct nextfnfield, struct fnfieldlist, struct
typedef_field_list): Move out of struct field_info.
* gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data):
Move out of struct dynamic_prop.
(union type_owner, union field_location, struct field, struct
range_bounds, union type_specific): Move out of struct main_type.
(struct fn_fieldlist, struct fn_field, struct typedef_field)
(VOFFSET_STATIC): Move out of struct cplus_struct_type.
(struct call_site_target, union call_site_parameter_u, struct
call_site_parameter): Move out of struct call_site.
* m32c-tdep.c (enum m32c_prologue_kind): Move out of struct
m32c_prologue.
(enum srcdest_kind): Move out of struct srcdest.
* main.c (enum cmdarg_kind): Move out of struct cmdarg.
* prologue-value.h (enum prologue_value_kind): Move out of struct
prologue_value.
* s390-linux-tdep.c (enum s390_abi_kind): Move out of struct
gdbarch_tdep.
* stabsread.c (struct nextfield, struct next_fnfieldlist): Move
out of struct field_info.
* symfile.h (struct other_sections): Move out of struct
section_addr_info.
* symtab.c (struct symbol_cache_slot): Move out struct
block_symbol_cache.
* target-descriptions.c (enum tdesc_type_kind): Move out of
typedef struct tdesc_type.
* tui/tui-data.h (enum tui_line_or_address_kind): Move out of
struct tui_line_or_address.
* value.c (enum internalvar_kind, union internalvar_data): Move
out of struct internalvar.
* xtensa-tdep.h (struct ctype_cache): Move out of struct
gdbarch_tdep.
2015-02-09 22:59:05 +08:00
|
|
|
/* Type of this option. */
|
|
|
|
enum cmdarg_kind
|
|
|
|
{
|
|
|
|
/* Option type -x. */
|
|
|
|
CMDARG_FILE,
|
2012-03-20 02:16:18 +08:00
|
|
|
|
Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global
scope just like it had been defined outside the struct in the first
place. However, in C++, such a nested structure is given a name that
is nested inside the structure. This patch moves such affected
structures/enums out to global scope, so that code using them works
the same in C++ as it works today in C.
gdb/ChangeLog:
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* dwarf2-frame.c (enum cfa_how_kind, struct
dwarf2_frame_state_reg_info): Move out of struct
dwarf2_frame_state.
* dwarf2read.c (struct tu_stats): Move out of struct
dwarf2_per_objfile.
(struct file_entry): Move out of struct line_header.
(struct nextfield, struct nextfnfield, struct fnfieldlist, struct
typedef_field_list): Move out of struct field_info.
* gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data):
Move out of struct dynamic_prop.
(union type_owner, union field_location, struct field, struct
range_bounds, union type_specific): Move out of struct main_type.
(struct fn_fieldlist, struct fn_field, struct typedef_field)
(VOFFSET_STATIC): Move out of struct cplus_struct_type.
(struct call_site_target, union call_site_parameter_u, struct
call_site_parameter): Move out of struct call_site.
* m32c-tdep.c (enum m32c_prologue_kind): Move out of struct
m32c_prologue.
(enum srcdest_kind): Move out of struct srcdest.
* main.c (enum cmdarg_kind): Move out of struct cmdarg.
* prologue-value.h (enum prologue_value_kind): Move out of struct
prologue_value.
* s390-linux-tdep.c (enum s390_abi_kind): Move out of struct
gdbarch_tdep.
* stabsread.c (struct nextfield, struct next_fnfieldlist): Move
out of struct field_info.
* symfile.h (struct other_sections): Move out of struct
section_addr_info.
* symtab.c (struct symbol_cache_slot): Move out struct
block_symbol_cache.
* target-descriptions.c (enum tdesc_type_kind): Move out of
typedef struct tdesc_type.
* tui/tui-data.h (enum tui_line_or_address_kind): Move out of
struct tui_line_or_address.
* value.c (enum internalvar_kind, union internalvar_data): Move
out of struct internalvar.
* xtensa-tdep.h (struct ctype_cache): Move out of struct
gdbarch_tdep.
2015-02-09 22:59:05 +08:00
|
|
|
/* Option type -ex. */
|
|
|
|
CMDARG_COMMAND,
|
2012-03-20 02:19:26 +08:00
|
|
|
|
Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global
scope just like it had been defined outside the struct in the first
place. However, in C++, such a nested structure is given a name that
is nested inside the structure. This patch moves such affected
structures/enums out to global scope, so that code using them works
the same in C++ as it works today in C.
gdb/ChangeLog:
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* dwarf2-frame.c (enum cfa_how_kind, struct
dwarf2_frame_state_reg_info): Move out of struct
dwarf2_frame_state.
* dwarf2read.c (struct tu_stats): Move out of struct
dwarf2_per_objfile.
(struct file_entry): Move out of struct line_header.
(struct nextfield, struct nextfnfield, struct fnfieldlist, struct
typedef_field_list): Move out of struct field_info.
* gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data):
Move out of struct dynamic_prop.
(union type_owner, union field_location, struct field, struct
range_bounds, union type_specific): Move out of struct main_type.
(struct fn_fieldlist, struct fn_field, struct typedef_field)
(VOFFSET_STATIC): Move out of struct cplus_struct_type.
(struct call_site_target, union call_site_parameter_u, struct
call_site_parameter): Move out of struct call_site.
* m32c-tdep.c (enum m32c_prologue_kind): Move out of struct
m32c_prologue.
(enum srcdest_kind): Move out of struct srcdest.
* main.c (enum cmdarg_kind): Move out of struct cmdarg.
* prologue-value.h (enum prologue_value_kind): Move out of struct
prologue_value.
* s390-linux-tdep.c (enum s390_abi_kind): Move out of struct
gdbarch_tdep.
* stabsread.c (struct nextfield, struct next_fnfieldlist): Move
out of struct field_info.
* symfile.h (struct other_sections): Move out of struct
section_addr_info.
* symtab.c (struct symbol_cache_slot): Move out struct
block_symbol_cache.
* target-descriptions.c (enum tdesc_type_kind): Move out of
typedef struct tdesc_type.
* tui/tui-data.h (enum tui_line_or_address_kind): Move out of
struct tui_line_or_address.
* value.c (enum internalvar_kind, union internalvar_data): Move
out of struct internalvar.
* xtensa-tdep.h (struct ctype_cache): Move out of struct
gdbarch_tdep.
2015-02-09 22:59:05 +08:00
|
|
|
/* Option type -ix. */
|
|
|
|
CMDARG_INIT_FILE,
|
2012-03-20 02:19:26 +08:00
|
|
|
|
Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global
scope just like it had been defined outside the struct in the first
place. However, in C++, such a nested structure is given a name that
is nested inside the structure. This patch moves such affected
structures/enums out to global scope, so that code using them works
the same in C++ as it works today in C.
gdb/ChangeLog:
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* dwarf2-frame.c (enum cfa_how_kind, struct
dwarf2_frame_state_reg_info): Move out of struct
dwarf2_frame_state.
* dwarf2read.c (struct tu_stats): Move out of struct
dwarf2_per_objfile.
(struct file_entry): Move out of struct line_header.
(struct nextfield, struct nextfnfield, struct fnfieldlist, struct
typedef_field_list): Move out of struct field_info.
* gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data):
Move out of struct dynamic_prop.
(union type_owner, union field_location, struct field, struct
range_bounds, union type_specific): Move out of struct main_type.
(struct fn_fieldlist, struct fn_field, struct typedef_field)
(VOFFSET_STATIC): Move out of struct cplus_struct_type.
(struct call_site_target, union call_site_parameter_u, struct
call_site_parameter): Move out of struct call_site.
* m32c-tdep.c (enum m32c_prologue_kind): Move out of struct
m32c_prologue.
(enum srcdest_kind): Move out of struct srcdest.
* main.c (enum cmdarg_kind): Move out of struct cmdarg.
* prologue-value.h (enum prologue_value_kind): Move out of struct
prologue_value.
* s390-linux-tdep.c (enum s390_abi_kind): Move out of struct
gdbarch_tdep.
* stabsread.c (struct nextfield, struct next_fnfieldlist): Move
out of struct field_info.
* symfile.h (struct other_sections): Move out of struct
section_addr_info.
* symtab.c (struct symbol_cache_slot): Move out struct
block_symbol_cache.
* target-descriptions.c (enum tdesc_type_kind): Move out of
typedef struct tdesc_type.
* tui/tui-data.h (enum tui_line_or_address_kind): Move out of
struct tui_line_or_address.
* value.c (enum internalvar_kind, union internalvar_data): Move
out of struct internalvar.
* xtensa-tdep.h (struct ctype_cache): Move out of struct
gdbarch_tdep.
2015-02-09 22:59:05 +08:00
|
|
|
/* Option type -iex. */
|
|
|
|
CMDARG_INIT_COMMAND
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Arguments of --command option and its counterpart. */
|
2016-11-09 22:53:58 +08:00
|
|
|
struct cmdarg
|
|
|
|
{
|
|
|
|
cmdarg (cmdarg_kind type_, char *string_)
|
|
|
|
: type (type_), string (string_)
|
|
|
|
{}
|
|
|
|
|
Fix struct, union, and enum nesting in C++
In C, an enum or structure defined inside other structure has global
scope just like it had been defined outside the struct in the first
place. However, in C++, such a nested structure is given a name that
is nested inside the structure. This patch moves such affected
structures/enums out to global scope, so that code using them works
the same in C++ as it works today in C.
gdb/ChangeLog:
2015-02-27 Tom Tromey <tromey@redhat.com>
Pedro Alves <palves@redhat.com>
* dwarf2-frame.c (enum cfa_how_kind, struct
dwarf2_frame_state_reg_info): Move out of struct
dwarf2_frame_state.
* dwarf2read.c (struct tu_stats): Move out of struct
dwarf2_per_objfile.
(struct file_entry): Move out of struct line_header.
(struct nextfield, struct nextfnfield, struct fnfieldlist, struct
typedef_field_list): Move out of struct field_info.
* gdbtypes.h (enum dynamic_prop_kind, union dynamic_prop_data):
Move out of struct dynamic_prop.
(union type_owner, union field_location, struct field, struct
range_bounds, union type_specific): Move out of struct main_type.
(struct fn_fieldlist, struct fn_field, struct typedef_field)
(VOFFSET_STATIC): Move out of struct cplus_struct_type.
(struct call_site_target, union call_site_parameter_u, struct
call_site_parameter): Move out of struct call_site.
* m32c-tdep.c (enum m32c_prologue_kind): Move out of struct
m32c_prologue.
(enum srcdest_kind): Move out of struct srcdest.
* main.c (enum cmdarg_kind): Move out of struct cmdarg.
* prologue-value.h (enum prologue_value_kind): Move out of struct
prologue_value.
* s390-linux-tdep.c (enum s390_abi_kind): Move out of struct
gdbarch_tdep.
* stabsread.c (struct nextfield, struct next_fnfieldlist): Move
out of struct field_info.
* symfile.h (struct other_sections): Move out of struct
section_addr_info.
* symtab.c (struct symbol_cache_slot): Move out struct
block_symbol_cache.
* target-descriptions.c (enum tdesc_type_kind): Move out of
typedef struct tdesc_type.
* tui/tui-data.h (enum tui_line_or_address_kind): Move out of
struct tui_line_or_address.
* value.c (enum internalvar_kind, union internalvar_data): Move
out of struct internalvar.
* xtensa-tdep.h (struct ctype_cache): Move out of struct
gdbarch_tdep.
2015-02-09 22:59:05 +08:00
|
|
|
/* Type of this option. */
|
|
|
|
enum cmdarg_kind type;
|
2012-03-20 02:16:18 +08:00
|
|
|
|
|
|
|
/* Value of this option - filename or the GDB command itself. String memory
|
|
|
|
is not owned by this structure despite it is 'const'. */
|
|
|
|
char *string;
|
2016-10-12 10:02:23 +08:00
|
|
|
};
|
2012-03-20 02:16:18 +08:00
|
|
|
|
2016-09-25 11:10:45 +08:00
|
|
|
static void
|
|
|
|
captured_main_1 (struct captured_main_args *context)
|
1999-11-09 09:23:30 +08:00
|
|
|
{
|
|
|
|
int argc = context->argc;
|
|
|
|
char **argv = context->argv;
|
2016-09-25 11:10:45 +08:00
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
static int quiet = 0;
|
2001-11-22 08:23:13 +08:00
|
|
|
static int set_args = 0;
|
2012-10-16 05:45:04 +08:00
|
|
|
static int inhibit_home_gdbinit = 0;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
/* Pointers to various arguments from command line. */
|
|
|
|
char *symarg = NULL;
|
|
|
|
char *execarg = NULL;
|
2008-01-06 00:49:53 +08:00
|
|
|
char *pidarg = NULL;
|
1999-04-16 09:35:26 +08:00
|
|
|
char *corearg = NULL;
|
2008-01-06 00:49:53 +08:00
|
|
|
char *pid_or_core_arg = NULL;
|
1999-04-16 09:35:26 +08:00
|
|
|
char *cdarg = NULL;
|
|
|
|
char *ttyarg = NULL;
|
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
/* These are static so that we can take their address in an
|
|
|
|
initializer. */
|
1999-04-16 09:35:26 +08:00
|
|
|
static int print_help;
|
|
|
|
static int print_version;
|
2013-04-12 16:57:07 +08:00
|
|
|
static int print_configuration;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
/* Pointers to all arguments of --command option. */
|
2016-10-12 10:02:23 +08:00
|
|
|
std::vector<struct cmdarg> cmdarg_vec;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2016-10-12 10:02:23 +08:00
|
|
|
/* All arguments of --directory option. */
|
|
|
|
std::vector<char *> dirarg;
|
1999-07-08 04:19:36 +08:00
|
|
|
|
2009-01-28 23:01:00 +08:00
|
|
|
/* gdb init files. */
|
2013-07-01 19:22:12 +08:00
|
|
|
const char *system_gdbinit;
|
|
|
|
const char *home_gdbinit;
|
|
|
|
const char *local_gdbinit;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2003-09-14 Andrew Cagney <cagney@redhat.com>
* alpha-nat.c: Remove some occurances of "register".
* alpha-tdep.c, arm-tdep.c, blockframe.c, breakpoint.c: Ditto.
* buildsym.c, c-typeprint.c, c-valprint.c, coffread.c: Ditto.
* corefile.c, cp-support.c, cp-valprint.c, cris-tdep.c: Ditto.
* dbxread.c, dcache.c, dwarf2read.c, elfread.c: Ditto.
* environ.c, eval.c, event-top.c, f-typeprint.c: Ditto.
* f-valprint.c, findvar.c, frame.c, gdbtypes.c: Ditto.
* h8300-tdep.c, hppa-tdep.c, hppab-nat.c, hppah-nat.c: Ditto.
* hppam3-nat.c, hpread.c, ia64-aix-nat.c, ia64-linux-nat.c: Ditto.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Ditto.
* infttrace.c, irix5-nat.c, jv-typeprint.c: Ditto.
* jv-valprint.c, m68k-tdep.c, m68klinux-nat.c, main.c: Ditto.
* mdebugread.c, minsyms.c, mips-linux-tdep.c: Ditto.
* mips-nat.c, mips-tdep.c, mipsread.c, mipsv4-nat.c: Ditto.
* ns32k-tdep.c, objfiles.c, p-typeprint.c: Ditto.
* p-valprint.c, ppc-linux-nat.c, printcmd.c: Ditto.
* remote-mips.c, remote-vx.c, rs6000-nat.c: Ditto.
* rs6000-tdep.c, scm-exp.c, sh-tdep.c, sh64-tdep.c: Ditto.
* solib.c, somread.c, source.c, sparc-tdep.c: Ditto.
* stabsread.c, stack.c, standalone.c, symfile.c: Ditto.
* symmisc.c, symtab.c, top.c, tracepoint.c: Ditto.
* typeprint.c, utils.c, valarith.c, valops.c: Ditto.
* values.c, vax-tdep.c, xcoffread.c: Ditto.
2003-09-15 00:32:14 +08:00
|
|
|
int i;
|
2010-04-24 02:09:16 +08:00
|
|
|
int save_auto_load;
|
2010-09-23 03:59:15 +08:00
|
|
|
struct objfile *objfile;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2011-11-06 01:08:30 +08:00
|
|
|
#ifdef HAVE_SBRK
|
2016-09-25 11:10:45 +08:00
|
|
|
/* Set this before constructing scoped_command_stats. */
|
2011-11-06 01:08:30 +08:00
|
|
|
lim_at_start = (char *) sbrk (0);
|
|
|
|
#endif
|
|
|
|
|
2016-09-25 11:10:45 +08:00
|
|
|
scoped_command_stats stat_reporter (false);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2002-06-22 07:48:41 +08:00
|
|
|
#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
|
|
|
|
setlocale (LC_MESSAGES, "");
|
|
|
|
#endif
|
|
|
|
#if defined (HAVE_SETLOCALE)
|
|
|
|
setlocale (LC_CTYPE, "");
|
|
|
|
#endif
|
gdb: Fix build breakage with GCC 4.1 and --disable-nls
Ref: https://sourceware.org/ml/gdb-patches/2016-09/msg00203.html
The std::{min,max} patch caused build failures when configuring GDB
with with --disable-nls and using GCC 4.1.
The reason is this bit in common/gdb_locale.h:
#ifdef ENABLE_NLS
...
#else
# define gettext(Msgid) (Msgid)
...
#endif
This causes problems if the <libintl.h> header is first included at
any point after "gdb_locale.h".
Specifically, the gettext&co declarations in libintl.h:
extern char *gettext (__const char *__msgid)
__THROW __attribute_format_arg__ (1);
end up broken after preprocessing:
extern char *(__const char *__msgid)
throw () __attribute__ ((__format_arg__ (1)));
After the std::min/std::max change to include <algorithm>, this now
happens with at least the GCC 4.1 copy of <algorithm>, which includes
<libintl.h> via <bits/stl_algobase.h>, <iosfwd>, and
<bits/c++locale.h>.
The fix is to simply remove the troublesome *gettext and *textdomain
macros, leaving only the _ and N_ ones.
gdb/ChangeLog:
2016-09-19 Pedro Alves <palves@redhat.com>
* common/gdb_locale.h [!ENABLE_NLS] (gettext, dgettext, dcgettext,
textdomain, bindtextdomain): Delete macros.
* main.c (captured_main) [!ENABLE_NLS]: Skip bintextdomain and
textdomain calls.
2016-09-19 23:55:35 +08:00
|
|
|
#ifdef ENABLE_NLS
|
2002-06-22 07:48:41 +08:00
|
|
|
bindtextdomain (PACKAGE, LOCALEDIR);
|
|
|
|
textdomain (PACKAGE);
|
gdb: Fix build breakage with GCC 4.1 and --disable-nls
Ref: https://sourceware.org/ml/gdb-patches/2016-09/msg00203.html
The std::{min,max} patch caused build failures when configuring GDB
with with --disable-nls and using GCC 4.1.
The reason is this bit in common/gdb_locale.h:
#ifdef ENABLE_NLS
...
#else
# define gettext(Msgid) (Msgid)
...
#endif
This causes problems if the <libintl.h> header is first included at
any point after "gdb_locale.h".
Specifically, the gettext&co declarations in libintl.h:
extern char *gettext (__const char *__msgid)
__THROW __attribute_format_arg__ (1);
end up broken after preprocessing:
extern char *(__const char *__msgid)
throw () __attribute__ ((__format_arg__ (1)));
After the std::min/std::max change to include <algorithm>, this now
happens with at least the GCC 4.1 copy of <algorithm>, which includes
<libintl.h> via <bits/stl_algobase.h>, <iosfwd>, and
<bits/c++locale.h>.
The fix is to simply remove the troublesome *gettext and *textdomain
macros, leaving only the _ and N_ ones.
gdb/ChangeLog:
2016-09-19 Pedro Alves <palves@redhat.com>
* common/gdb_locale.h [!ENABLE_NLS] (gettext, dgettext, dcgettext,
textdomain, bindtextdomain): Delete macros.
* main.c (captured_main) [!ENABLE_NLS]: Skip bintextdomain and
textdomain calls.
2016-09-19 23:55:35 +08:00
|
|
|
#endif
|
2002-06-22 07:48:41 +08:00
|
|
|
|
2013-01-22 01:32:10 +08:00
|
|
|
bfd_init ();
|
PR gdb/7912:
* Makefile.in (SFILES): Add filestuff.c
(COMMON_OBS): Add filestuff.o.
(filestuff.o): New target.
* auto-load.c (auto_load_objfile_script_1): Use
gdb_fopen_cloexec.
* auxv.c (procfs_xfer_auxv): Use gdb_open_cloexec.
* cli/cli-cmds.c (shell_escape): Call close_most_fds.
* cli/cli-dump.c (fopen_with_cleanup): Use gdb_fopen_cloexec.
* common/agent.c (gdb_connect_sync_socket): Use
gdb_socket_cloexec.
* common/filestuff.c: New file.
* common/filestuff.h: New file.
* common/linux-osdata.c (linux_common_core_of_thread)
(command_from_pid, commandline_from_pid, print_source_lines)
(linux_xfer_osdata_shm, linux_xfer_osdata_sem)
(linux_xfer_osdata_msg, linux_xfer_osdata_modules): Use
gdb_fopen_cloexec.
* common/linux-procfs.c (linux_proc_get_int)
(linux_proc_pid_has_state): Use gdb_fopen_cloexec.
* config.in, configure: Rebuild.
* configure.ac: Don't check for sys/socket.h. Check for
fdwalk, pipe2.
* corelow.c (core_open): Use gdb_open_cloexec.
* dwarf2read.c (write_psymtabs_to_index): Use gdb_fopen_cloexec.
* fork-child.c (fork_inferior): Call close_most_fds.
* gdb_bfd.c (gdb_bfd_open): Use gdb_open_cloexec.
* inf-child.c (inf_child_fileio_readlink): Use gdb_open_cloexec.
* linux-nat.c (linux_nat_thread_name, linux_proc_pending_signals):
Use gdb_fopen_cloexec.
(linux_proc_xfer_partial, linux_proc_xfer_spu): Use
gdb_open_cloexec.
(linux_async_pipe): Use gdb_pipe_cloexec.
* remote-fileio.c (remote_fileio_func_open): Use
gdb_open_cloexec.
* remote.c (remote_file_put, remote_file_get): Use
gdb_fopen_cloexec.
* ser-pipe.c (pipe_open): Use gdb_socketpair_cloexec,
close_most_fds.
* ser-tcp.c (net_open): Use gdb_socket_cloexec.
* ser-unix.c (hardwire_open): Use gdb_open_cloexec.
* solib.c (solib_find): Use gdb_open_cloexec.
* source.c (openp, find_and_open_source): Use gdb_open_cloexec.
* tracepoint.c (tfile_start): Use gdb_fopen_cloexec.
(tfile_open): Use gdb_open_cloexec.
* tui/tui-io.c (tui_initialize_io): Use gdb_pipe_cloexec.
* ui-file.c (gdb_fopen): Use gdb_fopen_cloexec.
* xml-support.c (xml_fetch_content_from_file): Use
gdb_fopen_cloexec.
* main.c (captured_main): Call notice_open_fds.
gdbserver
* Makefile.in (SFILES): Add filestuff.c.
(OBS): Add filestuff.o.
(filestuff.o): New target.
* config.in, configure: Rebuild.
* configure.ac: Check for fdwalk, pipe2.
2013-04-23 00:46:15 +08:00
|
|
|
notice_open_fds ();
|
2016-08-10 03:16:20 +08:00
|
|
|
save_original_signals_state ();
|
2013-01-22 01:32:10 +08:00
|
|
|
|
2016-03-10 02:25:00 +08:00
|
|
|
saved_command_line = (char *) xstrdup ("");
|
2016-06-21 08:11:47 +08:00
|
|
|
|
2013-08-28 20:25:05 +08:00
|
|
|
#ifdef __MINGW32__
|
|
|
|
/* Ensure stderr is unbuffered. A Cygwin pty or pipe is implemented
|
|
|
|
as a Windows pipe, and Windows buffers on pipes. */
|
|
|
|
setvbuf (stderr, NULL, _IONBF, BUFSIZ);
|
|
|
|
#endif
|
|
|
|
|
2017-09-30 12:35:58 +08:00
|
|
|
main_ui = new ui (stdin, stdout, stderr);
|
2016-06-21 08:11:53 +08:00
|
|
|
current_ui = main_ui;
|
2013-08-28 20:25:05 +08:00
|
|
|
|
2003-06-10 22:37:04 +08:00
|
|
|
gdb_stdtargerr = gdb_stderr; /* for moment */
|
|
|
|
gdb_stdtargin = gdb_stdin; /* for moment */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2013-03-23 18:48:23 +08:00
|
|
|
#ifdef __MINGW32__
|
|
|
|
/* On Windows, argv[0] is not necessarily set to absolute form when
|
|
|
|
GDB is found along PATH, without which relocation doesn't work. */
|
|
|
|
gdb_program_name = windows_get_absolute_argv0 (argv[0]);
|
|
|
|
#else
|
2009-01-28 23:01:00 +08:00
|
|
|
gdb_program_name = xstrdup (argv[0]);
|
2013-03-23 18:48:23 +08:00
|
|
|
#endif
|
2009-01-28 23:01:00 +08:00
|
|
|
|
2014-08-05 23:18:51 +08:00
|
|
|
/* Prefix warning messages with the command name. */
|
2017-04-06 02:21:34 +08:00
|
|
|
gdb::unique_xmalloc_ptr<char> tmp_warn_preprint
|
|
|
|
(xstrprintf ("%s: warning: ", gdb_program_name));
|
|
|
|
warning_pre_print = tmp_warn_preprint.get ();
|
2014-08-05 23:18:51 +08:00
|
|
|
|
2017-09-11 12:54:33 +08:00
|
|
|
current_directory = getcwd (NULL, 0);
|
|
|
|
if (current_directory == NULL)
|
2014-08-05 23:18:51 +08:00
|
|
|
perror_warning_with_name (_("error finding working directory"));
|
|
|
|
|
2003-01-14 02:00:16 +08:00
|
|
|
/* Set the sysroot path. */
|
2011-05-10 05:49:57 +08:00
|
|
|
gdb_sysroot = relocate_gdb_directory (TARGET_SYSTEM_ROOT,
|
|
|
|
TARGET_SYSTEM_ROOT_RELOCATABLE);
|
2003-01-14 02:00:16 +08:00
|
|
|
|
2015-04-02 20:38:29 +08:00
|
|
|
if (gdb_sysroot == NULL || *gdb_sysroot == '\0')
|
|
|
|
{
|
|
|
|
xfree (gdb_sysroot);
|
|
|
|
gdb_sysroot = xstrdup (TARGET_SYSROOT_PREFIX);
|
|
|
|
}
|
|
|
|
|
2011-05-10 05:49:57 +08:00
|
|
|
debug_file_directory = relocate_gdb_directory (DEBUGDIR,
|
|
|
|
DEBUGDIR_RELOCATABLE);
|
2003-01-14 02:00:16 +08:00
|
|
|
|
2011-05-10 05:49:57 +08:00
|
|
|
gdb_datadir = relocate_gdb_directory (GDB_DATADIR,
|
|
|
|
GDB_DATADIR_RELOCATABLE);
|
2007-01-10 05:34:30 +08:00
|
|
|
|
2010-05-27 11:40:45 +08:00
|
|
|
#ifdef WITH_PYTHON_PATH
|
2011-03-08 02:34:31 +08:00
|
|
|
{
|
|
|
|
/* For later use in helping Python find itself. */
|
2016-04-21 18:34:18 +08:00
|
|
|
char *tmp = concat (WITH_PYTHON_PATH, SLASH_STRING, "lib", (char *) NULL);
|
2011-03-08 02:34:31 +08:00
|
|
|
|
2011-05-10 05:49:57 +08:00
|
|
|
python_libdir = relocate_gdb_directory (tmp, PYTHON_PATH_RELOCATABLE);
|
2011-03-08 02:34:31 +08:00
|
|
|
xfree (tmp);
|
|
|
|
}
|
2010-05-27 11:40:45 +08:00
|
|
|
#endif
|
|
|
|
|
2009-04-21 18:13:05 +08:00
|
|
|
#ifdef RELOC_SRCDIR
|
|
|
|
add_substitute_path_rule (RELOC_SRCDIR,
|
2013-03-23 18:48:23 +08:00
|
|
|
make_relative_prefix (gdb_program_name, BINDIR,
|
2009-04-21 18:13:05 +08:00
|
|
|
RELOC_SRCDIR));
|
|
|
|
#endif
|
|
|
|
|
2003-02-05 Jim Ingham <jingham@apple.com>
Keith Seitz <keiths@redhat.com>
Elena Zannoni <ezannoni@redhat.com>
Andrew Cagney <ac131313@redhat.com>
* Makefile.in (SUBDIR_CLI_OBS): Add "cli-interp.o".
(SUBDIR_CLI_SRCS): Add "cli/cli-interp.c".
(SUBDIR_MI_OBS): Add "mi-interp.o".
(SUBDIR_MI_SRCS): Add "mi/mi-interp.c".
(SFILES): Add "interps.c".
(COMMON_OBS): Add "interps.o".
(interps_h, mi_main_h): Define.
(interps.o, cli-interp.o, mi-interp.o): Add dependencies.
(mi-main.o, main.o, event-top.o): Update dependencies.
* cli/cli-interp.c: New file.
* interps.h, interps.c: New files.
* top.c: (gdb_init): Don't install the default interpreter, handed
by captured_main.
* main.c: Include "interps.h".
(interpreter_p): Note that it should malloc'ed.
(captured_command_loop): Call current_interp_command_loop.
(captured_main): Initialize interpreter_p to INTERP_CONSOLE. Use
xfree and xstrdup when updating interpreter_p. Install the
default interpreter. Add hack to stop mi1's copyright notice
being encoded.
* event-top.h (gdb_setup_readline): Declare.
(gdb_disable_readline): Declare.
* event-top.c: Include "interps.h".
(display_gdb_prompt): Call current_interp_display_prompt_p.
(gdb_setup_readline): Initialize gdb_stdout, gdb_stderr,
gdb_stdlog, and gdb_stdtarg.
(_initialize_event_loop): Don't call gdb_setup_readline.
* cli-out.c (cli_out_set_stream): New function.
* cli-out.h (cli_out_set_stream): Declare.
2003-02-06 09:19:12 +08:00
|
|
|
/* There will always be an interpreter. Either the one passed into
|
2003-02-14 02:07:24 +08:00
|
|
|
this captured main, or one specified by the user at start up, or
|
|
|
|
the console. Initialize the interpreter to the one requested by
|
|
|
|
the application. */
|
2012-01-02 21:29:57 +08:00
|
|
|
interpreter_p = xstrdup (context->interpreter_p);
|
2003-02-05 Jim Ingham <jingham@apple.com>
Keith Seitz <keiths@redhat.com>
Elena Zannoni <ezannoni@redhat.com>
Andrew Cagney <ac131313@redhat.com>
* Makefile.in (SUBDIR_CLI_OBS): Add "cli-interp.o".
(SUBDIR_CLI_SRCS): Add "cli/cli-interp.c".
(SUBDIR_MI_OBS): Add "mi-interp.o".
(SUBDIR_MI_SRCS): Add "mi/mi-interp.c".
(SFILES): Add "interps.c".
(COMMON_OBS): Add "interps.o".
(interps_h, mi_main_h): Define.
(interps.o, cli-interp.o, mi-interp.o): Add dependencies.
(mi-main.o, main.o, event-top.o): Update dependencies.
* cli/cli-interp.c: New file.
* interps.h, interps.c: New files.
* top.c: (gdb_init): Don't install the default interpreter, handed
by captured_main.
* main.c: Include "interps.h".
(interpreter_p): Note that it should malloc'ed.
(captured_command_loop): Call current_interp_command_loop.
(captured_main): Initialize interpreter_p to INTERP_CONSOLE. Use
xfree and xstrdup when updating interpreter_p. Install the
default interpreter. Add hack to stop mi1's copyright notice
being encoded.
* event-top.h (gdb_setup_readline): Declare.
(gdb_disable_readline): Declare.
* event-top.c: Include "interps.h".
(display_gdb_prompt): Call current_interp_display_prompt_p.
(gdb_setup_readline): Initialize gdb_stdout, gdb_stderr,
gdb_stdlog, and gdb_stdtarg.
(_initialize_event_loop): Don't call gdb_setup_readline.
* cli-out.c (cli_out_set_stream): New function.
* cli-out.h (cli_out_set_stream): Declare.
2003-02-06 09:19:12 +08:00
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
/* Parse arguments and options. */
|
|
|
|
{
|
|
|
|
int c;
|
|
|
|
/* When var field is 0, use flag field to record the equivalent
|
|
|
|
short option (or arbitrary numbers starting at 10 for those
|
|
|
|
with no equivalent). */
|
2003-03-02 09:22:18 +08:00
|
|
|
enum {
|
|
|
|
OPT_SE = 10,
|
|
|
|
OPT_CD,
|
|
|
|
OPT_ANNOTATE,
|
|
|
|
OPT_STATISTICS,
|
2003-03-02 10:07:12 +08:00
|
|
|
OPT_TUI,
|
|
|
|
OPT_NOWINDOWS,
|
2012-03-20 02:19:26 +08:00
|
|
|
OPT_WINDOWS,
|
|
|
|
OPT_IX,
|
Add support for the readnever concept
The purpose of this concept is to turn the load of debugging
information off, either globally (via the '--readnever' option), or
objfile-specific. The implementation proposed here is an extension of
the patch distributed with Fedora GDB; looking at the Fedora patch
itself and the history, one can see some reasons why it was never
resubmitted:
- The patch appears to have been introduced as a workaround, at
least initially;
- The patch is far from perfect, as it simply shunts the load of
DWARF debugging information, without really worrying about the
other debug format.
- Who really does non-symbolic debugging anyways?
One use of this feature is when a user simply wants to do the
following sequence: attach, dump core, detach. Loading the debugging
information in this case is an unnecessary cause of delay.
This patch expands the version shipped with Fedora GDB in order to
make the feature available for all the debuginfo backends, not only
for DWARF. It also implements a per-objfile flag which can be
activated by using the "-readnever" command when using the
'add-symbol-file' or 'symbol-file' commands.
It's also worth mentioning that this patch tests whether GDB correctly
fails to initialize if both '--readnow' and '--readnever' options are
passed.
Tested on the BuildBot.
gdb/ChangeLog:
2017-12-01 Andrew Cagney <cagney@redhat.com>
Joel Brobecker <brobecker@adacore.com>
Sergio Durigan Junior <sergiodj@redhat.com>
* NEWS (Changes since GDB 8.0: Mention new '--readnever'
feature.
* coffread.c (coff_symfile_read): Do not map over sections with
'coff_locate_sections' if readnever is on.
* dwarf2read.c (dwarf2_has_info): Return 0 if
readnever is on.
* elfread.c (elf_symfile_read): Do not map over sections with
'elf_locate_sections' if readnever is on.
* main.c (validate_readnow_readnever): New function.
(captured_main_1): Add support for --readnever.
(print_gdb_help): Document --readnever.
* objfile-flags.h (enum objfile_flag) <OBJF_READNEVER>: New
flag.
* symfile.c (readnever_symbol_files): New global.
(symbol_file_add_with_addrs): Set 'OBJF_READNEVER' when
'READNEVER_SYMBOL_FILES' is set.
(validate_readnow_readnever): New function.
(symbol_file_command): Handle '-readnever' option.
Call 'validate_readnow_readnever'.
(add_symbol_file_command): Handle '-readnever' option.
Call 'validate_readnow_readnever'.
(_initialize_symfile): Document new '-readnever' option for
both 'symbol-file' and 'add-symbol-file' commands.
* top.h (readnever_symbol_files): New extern global.
* xcoffread.c (xcoff_initial_scan): Do not read debug
information if readnever is on.
gdb/doc/ChangeLog:
2017-12-01 Andrew Cagney <cagney@redhat.com>
Joel Brobecker <brobecker@adacore.com>
Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.texinfo (File Options): Document --readnever.
(Commands to Specify Files): Likewise, for 'symbol-file' and
'add-symbol-file'.
gdb/testsuite/ChangeLog:
2017-12-01 Joel Brobecker <brobecker@adacore.com>
Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
* gdb.base/readnever.c, gdb.base/readnever.exp: New files.
2017-11-25 05:56:08 +08:00
|
|
|
OPT_IEX,
|
|
|
|
OPT_READNOW,
|
|
|
|
OPT_READNEVER
|
2003-03-02 09:22:18 +08:00
|
|
|
};
|
1999-04-16 09:35:26 +08:00
|
|
|
static struct option long_options[] =
|
1999-07-08 04:19:36 +08:00
|
|
|
{
|
2003-03-02 09:22:18 +08:00
|
|
|
{"tui", no_argument, 0, OPT_TUI},
|
1999-07-08 04:19:36 +08:00
|
|
|
{"dbx", no_argument, &dbx_commands, 1},
|
Add support for the readnever concept
The purpose of this concept is to turn the load of debugging
information off, either globally (via the '--readnever' option), or
objfile-specific. The implementation proposed here is an extension of
the patch distributed with Fedora GDB; looking at the Fedora patch
itself and the history, one can see some reasons why it was never
resubmitted:
- The patch appears to have been introduced as a workaround, at
least initially;
- The patch is far from perfect, as it simply shunts the load of
DWARF debugging information, without really worrying about the
other debug format.
- Who really does non-symbolic debugging anyways?
One use of this feature is when a user simply wants to do the
following sequence: attach, dump core, detach. Loading the debugging
information in this case is an unnecessary cause of delay.
This patch expands the version shipped with Fedora GDB in order to
make the feature available for all the debuginfo backends, not only
for DWARF. It also implements a per-objfile flag which can be
activated by using the "-readnever" command when using the
'add-symbol-file' or 'symbol-file' commands.
It's also worth mentioning that this patch tests whether GDB correctly
fails to initialize if both '--readnow' and '--readnever' options are
passed.
Tested on the BuildBot.
gdb/ChangeLog:
2017-12-01 Andrew Cagney <cagney@redhat.com>
Joel Brobecker <brobecker@adacore.com>
Sergio Durigan Junior <sergiodj@redhat.com>
* NEWS (Changes since GDB 8.0: Mention new '--readnever'
feature.
* coffread.c (coff_symfile_read): Do not map over sections with
'coff_locate_sections' if readnever is on.
* dwarf2read.c (dwarf2_has_info): Return 0 if
readnever is on.
* elfread.c (elf_symfile_read): Do not map over sections with
'elf_locate_sections' if readnever is on.
* main.c (validate_readnow_readnever): New function.
(captured_main_1): Add support for --readnever.
(print_gdb_help): Document --readnever.
* objfile-flags.h (enum objfile_flag) <OBJF_READNEVER>: New
flag.
* symfile.c (readnever_symbol_files): New global.
(symbol_file_add_with_addrs): Set 'OBJF_READNEVER' when
'READNEVER_SYMBOL_FILES' is set.
(validate_readnow_readnever): New function.
(symbol_file_command): Handle '-readnever' option.
Call 'validate_readnow_readnever'.
(add_symbol_file_command): Handle '-readnever' option.
Call 'validate_readnow_readnever'.
(_initialize_symfile): Document new '-readnever' option for
both 'symbol-file' and 'add-symbol-file' commands.
* top.h (readnever_symbol_files): New extern global.
* xcoffread.c (xcoff_initial_scan): Do not read debug
information if readnever is on.
gdb/doc/ChangeLog:
2017-12-01 Andrew Cagney <cagney@redhat.com>
Joel Brobecker <brobecker@adacore.com>
Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.texinfo (File Options): Document --readnever.
(Commands to Specify Files): Likewise, for 'symbol-file' and
'add-symbol-file'.
gdb/testsuite/ChangeLog:
2017-12-01 Joel Brobecker <brobecker@adacore.com>
Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
* gdb.base/readnever.c, gdb.base/readnever.exp: New files.
2017-11-25 05:56:08 +08:00
|
|
|
{"readnow", no_argument, NULL, OPT_READNOW},
|
|
|
|
{"readnever", no_argument, NULL, OPT_READNEVER},
|
|
|
|
{"r", no_argument, NULL, OPT_READNOW},
|
1999-07-08 04:19:36 +08:00
|
|
|
{"quiet", no_argument, &quiet, 1},
|
|
|
|
{"q", no_argument, &quiet, 1},
|
|
|
|
{"silent", no_argument, &quiet, 1},
|
2012-10-16 05:45:04 +08:00
|
|
|
{"nh", no_argument, &inhibit_home_gdbinit, 1},
|
1999-07-08 04:19:36 +08:00
|
|
|
{"nx", no_argument, &inhibit_gdbinit, 1},
|
|
|
|
{"n", no_argument, &inhibit_gdbinit, 1},
|
2005-11-01 19:09:18 +08:00
|
|
|
{"batch-silent", no_argument, 0, 'B'},
|
2010-03-09 03:20:38 +08:00
|
|
|
{"batch", no_argument, &batch_flag, 1},
|
1999-07-08 04:19:36 +08:00
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
/* This is a synonym for "--annotate=1". --annotate is now
|
|
|
|
preferred, but keep this here for a long time because people
|
|
|
|
will be running emacses which use --fullname. */
|
1999-07-08 04:19:36 +08:00
|
|
|
{"fullname", no_argument, 0, 'f'},
|
|
|
|
{"f", no_argument, 0, 'f'},
|
|
|
|
|
2003-03-02 09:22:18 +08:00
|
|
|
{"annotate", required_argument, 0, OPT_ANNOTATE},
|
1999-07-08 04:19:36 +08:00
|
|
|
{"help", no_argument, &print_help, 1},
|
2003-03-02 09:22:18 +08:00
|
|
|
{"se", required_argument, 0, OPT_SE},
|
1999-07-08 04:19:36 +08:00
|
|
|
{"symbols", required_argument, 0, 's'},
|
|
|
|
{"s", required_argument, 0, 's'},
|
|
|
|
{"exec", required_argument, 0, 'e'},
|
|
|
|
{"e", required_argument, 0, 'e'},
|
|
|
|
{"core", required_argument, 0, 'c'},
|
|
|
|
{"c", required_argument, 0, 'c'},
|
2002-01-11 07:03:08 +08:00
|
|
|
{"pid", required_argument, 0, 'p'},
|
|
|
|
{"p", required_argument, 0, 'p'},
|
1999-07-08 04:19:36 +08:00
|
|
|
{"command", required_argument, 0, 'x'},
|
2005-11-07 21:56:48 +08:00
|
|
|
{"eval-command", required_argument, 0, 'X'},
|
1999-07-08 04:19:36 +08:00
|
|
|
{"version", no_argument, &print_version, 1},
|
2013-04-12 16:57:07 +08:00
|
|
|
{"configuration", no_argument, &print_configuration, 1},
|
1999-07-08 04:19:36 +08:00
|
|
|
{"x", required_argument, 0, 'x'},
|
2005-11-07 21:56:48 +08:00
|
|
|
{"ex", required_argument, 0, 'X'},
|
2012-03-20 02:19:26 +08:00
|
|
|
{"init-command", required_argument, 0, OPT_IX},
|
|
|
|
{"init-eval-command", required_argument, 0, OPT_IEX},
|
|
|
|
{"ix", required_argument, 0, OPT_IX},
|
|
|
|
{"iex", required_argument, 0, OPT_IEX},
|
2000-02-07 08:19:45 +08:00
|
|
|
#ifdef GDBTK
|
|
|
|
{"tclcommand", required_argument, 0, 'z'},
|
|
|
|
{"enable-external-editor", no_argument, 0, 'y'},
|
|
|
|
{"editor-command", required_argument, 0, 'w'},
|
|
|
|
#endif
|
2000-02-03 12:14:45 +08:00
|
|
|
{"ui", required_argument, 0, 'i'},
|
|
|
|
{"interpreter", required_argument, 0, 'i'},
|
|
|
|
{"i", required_argument, 0, 'i'},
|
1999-07-08 04:19:36 +08:00
|
|
|
{"directory", required_argument, 0, 'd'},
|
1999-12-14 09:06:04 +08:00
|
|
|
{"d", required_argument, 0, 'd'},
|
2010-12-08 01:26:06 +08:00
|
|
|
{"data-directory", required_argument, 0, 'D'},
|
2014-05-17 03:15:10 +08:00
|
|
|
{"D", required_argument, 0, 'D'},
|
2003-03-02 09:22:18 +08:00
|
|
|
{"cd", required_argument, 0, OPT_CD},
|
1999-07-08 04:19:36 +08:00
|
|
|
{"tty", required_argument, 0, 't'},
|
|
|
|
{"baud", required_argument, 0, 'b'},
|
|
|
|
{"b", required_argument, 0, 'b'},
|
2003-03-02 10:07:12 +08:00
|
|
|
{"nw", no_argument, NULL, OPT_NOWINDOWS},
|
|
|
|
{"nowindows", no_argument, NULL, OPT_NOWINDOWS},
|
|
|
|
{"w", no_argument, NULL, OPT_WINDOWS},
|
|
|
|
{"windows", no_argument, NULL, OPT_WINDOWS},
|
2003-03-02 09:22:18 +08:00
|
|
|
{"statistics", no_argument, 0, OPT_STATISTICS},
|
1999-07-08 04:19:36 +08:00
|
|
|
{"write", no_argument, &write_files, 1},
|
2001-11-22 08:23:13 +08:00
|
|
|
{"args", no_argument, &set_args, 1},
|
2009-12-12 07:43:42 +08:00
|
|
|
{"l", required_argument, 0, 'l'},
|
2005-11-04 19:49:12 +08:00
|
|
|
{"return-child-result", no_argument, &return_child_result, 1},
|
1999-07-08 04:19:36 +08:00
|
|
|
{0, no_argument, 0, 0}
|
|
|
|
};
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
int option_index;
|
|
|
|
|
|
|
|
c = getopt_long_only (argc, argv, "",
|
|
|
|
long_options, &option_index);
|
2001-11-22 08:23:13 +08:00
|
|
|
if (c == EOF || set_args)
|
1999-04-16 09:35:26 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* Long option that takes an argument. */
|
|
|
|
if (c == 0 && long_options[option_index].flag == 0)
|
|
|
|
c = long_options[option_index].val;
|
|
|
|
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
/* Long option that just sets a flag. */
|
|
|
|
break;
|
2003-03-02 09:22:18 +08:00
|
|
|
case OPT_SE:
|
1999-04-16 09:35:26 +08:00
|
|
|
symarg = optarg;
|
|
|
|
execarg = optarg;
|
|
|
|
break;
|
2003-03-02 09:22:18 +08:00
|
|
|
case OPT_CD:
|
1999-04-16 09:35:26 +08:00
|
|
|
cdarg = optarg;
|
|
|
|
break;
|
2003-03-02 09:22:18 +08:00
|
|
|
case OPT_ANNOTATE:
|
1999-04-16 09:35:26 +08:00
|
|
|
/* FIXME: what if the syntax is wrong (e.g. not digits)? */
|
|
|
|
annotation_level = atoi (optarg);
|
|
|
|
break;
|
2003-03-02 09:22:18 +08:00
|
|
|
case OPT_STATISTICS:
|
1999-04-16 09:35:26 +08:00
|
|
|
/* Enable the display of both time and space usage. */
|
New commands "mt set per-command {space,time,symtab} {on,off}".
* NEWS: Add entry.
* event-top.c: #include "maint.h".
* main.c: #include "maint.h".
* maint.c: #include <sys/time.h>, <time.h>, block.h, top.h,
timeval-utils.h, maint.h, cli/cli-setshow.h.
(per_command_time, per_command_space): New static globals.
(per_command_symtab): New static global.
(per_command_setlist, per_command_showlist): New static globals.
(struct cmd_stats): Move here from utils.c.
(set_per_command_time): Renamed from set_display_time in utils.c
and moved here. All callers updated.
(set_per_command_space): Renamed from set_display_space in utils.c
and moved here. All callers updated.
(count_symtabs_and_blocks): New function.
(report_command_stats): Moved here from utils.c. Add support for
printing symtab stats. Only print data if enabled before command
executed.
(make_command_stats_cleanup): Ditto.
(sert_per_command_cmd, show_per_command_cmd): New functions.
(_initialize_maint_cmds): Add new commands
mt set per-command {space,time,symtab} {on,off}.
* maint.h: New file.
* top.c: #include "maint.h".
* utils.c (reset_prompt_for_continue_wait_time): New function.
(get_prompt_for_continue_wait_time): New function.
* utils.h (reset_prompt_for_continue_wait_time): Declare
(get_prompt_for_continue_wait_time): Declare.
(make_command_stats_cleanup): Moved to maint.h.
(set_display_time, set_display_space): Moved to maint.h and renamed
to set_per_command_time, set_per_command_space.
* cli/cli-setshow.c (parse_cli_boolean_value): Renamed from
parse_binary_operation and made non-static. Don't call error,
just return an error marker. All callers updated.
* cli/cli-setshow.h (parse_cli_boolean_value): Declare.
doc/
* gdb.texinfo (Maintenance Commands): Add docs for
"mt set per-command {space,time,symtab} {on,off}".
testsuite/
* gdb.base/maint.exp: Update tests for per-command stats.
2013-03-22 01:37:30 +08:00
|
|
|
set_per_command_time (1);
|
|
|
|
set_per_command_space (1);
|
1999-04-16 09:35:26 +08:00
|
|
|
break;
|
2003-03-02 09:22:18 +08:00
|
|
|
case OPT_TUI:
|
2003-02-14 21:58:06 +08:00
|
|
|
/* --tui is equivalent to -i=tui. */
|
2007-05-10 05:46:52 +08:00
|
|
|
#ifdef TUI
|
2003-02-14 21:58:06 +08:00
|
|
|
xfree (interpreter_p);
|
2005-11-07 20:46:38 +08:00
|
|
|
interpreter_p = xstrdup (INTERP_TUI);
|
2007-05-10 05:46:52 +08:00
|
|
|
#else
|
2014-08-05 23:12:01 +08:00
|
|
|
error (_("%s: TUI mode is not supported"), gdb_program_name);
|
2007-05-10 05:46:52 +08:00
|
|
|
#endif
|
2003-02-14 21:58:06 +08:00
|
|
|
break;
|
2003-03-02 10:07:12 +08:00
|
|
|
case OPT_WINDOWS:
|
|
|
|
/* FIXME: cagney/2003-03-01: Not sure if this option is
|
|
|
|
actually useful, and if it is, what it should do. */
|
2005-11-07 20:46:38 +08:00
|
|
|
#ifdef GDBTK
|
|
|
|
/* --windows is equivalent to -i=insight. */
|
|
|
|
xfree (interpreter_p);
|
|
|
|
interpreter_p = xstrdup (INTERP_INSIGHT);
|
|
|
|
#endif
|
2003-03-02 10:07:12 +08:00
|
|
|
break;
|
|
|
|
case OPT_NOWINDOWS:
|
|
|
|
/* -nw is equivalent to -i=console. */
|
|
|
|
xfree (interpreter_p);
|
|
|
|
interpreter_p = xstrdup (INTERP_CONSOLE);
|
|
|
|
break;
|
1999-04-16 09:35:26 +08:00
|
|
|
case 'f':
|
|
|
|
annotation_level = 1;
|
|
|
|
break;
|
|
|
|
case 's':
|
|
|
|
symarg = optarg;
|
|
|
|
break;
|
|
|
|
case 'e':
|
|
|
|
execarg = optarg;
|
|
|
|
break;
|
|
|
|
case 'c':
|
|
|
|
corearg = optarg;
|
|
|
|
break;
|
2002-01-11 07:03:08 +08:00
|
|
|
case 'p':
|
2008-01-06 00:49:53 +08:00
|
|
|
pidarg = optarg;
|
2002-01-11 07:03:08 +08:00
|
|
|
break;
|
1999-04-16 09:35:26 +08:00
|
|
|
case 'x':
|
2016-11-09 22:53:58 +08:00
|
|
|
cmdarg_vec.emplace_back (CMDARG_FILE, optarg);
|
2005-11-07 21:56:48 +08:00
|
|
|
break;
|
|
|
|
case 'X':
|
2016-11-09 22:53:58 +08:00
|
|
|
cmdarg_vec.emplace_back (CMDARG_COMMAND, optarg);
|
2012-03-20 02:16:18 +08:00
|
|
|
break;
|
2012-03-20 02:19:26 +08:00
|
|
|
case OPT_IX:
|
2016-11-09 22:53:58 +08:00
|
|
|
cmdarg_vec.emplace_back (CMDARG_INIT_FILE, optarg);
|
2012-03-20 02:19:26 +08:00
|
|
|
break;
|
|
|
|
case OPT_IEX:
|
2016-11-09 22:53:58 +08:00
|
|
|
cmdarg_vec.emplace_back (CMDARG_INIT_COMMAND, optarg);
|
1999-04-16 09:35:26 +08:00
|
|
|
break;
|
2005-11-01 19:09:18 +08:00
|
|
|
case 'B':
|
2010-03-09 03:20:38 +08:00
|
|
|
batch_flag = batch_silent = 1;
|
Eliminate make_cleanup_ui_file_delete / make ui_file a class hierarchy
This patch starts from the desire to eliminate
make_cleanup_ui_file_delete, but then goes beyond. It makes ui_file &
friends a real C++ class hierarchy, and switches temporary
ui_file-like objects to stack-based allocation.
- mem_fileopen -> string_file
mem_fileopen is replaced with a new string_file class that is treated
as a value class created on the stack. This alone eliminates most
make_cleanup_ui_file_delete calls, and, simplifies code a whole lot
(diffstat shows around 1k loc dropped.)
string_file's internal buffer is a std::string, thus the "string" in
the name. This simplifies the implementation much, compared to
mem_fileopen, which managed growing its internal buffer manually.
- ui_file_as_string, ui_file_strdup, ui_file_obsavestring all gone
The new string_file class has a string() method that provides direct
writable access to the internal std::string buffer. This replaced
ui_file_as_string, which forced a copy of the same data the stream had
inside. With direct access via a writable reference, we can instead
move the string out of the string_stream, avoiding deep string
copying.
Related, ui_file_xstrdup calls are replaced with xstrdup'ping the
stream's string, and ui_file_obsavestring is replaced by
obstack_copy0.
With all those out of the way, getting rid of the weird ui_file_put
mechanism was possible.
- New ui_file::printf, ui_file::puts, etc. methods
These simplify / clarify client code. I considered splitting
client-code changes, like these, e.g.:
- stb = mem_fileopen ();
- fprintf_unfiltered (stb, "%s%s%s",
- _("The valid values are:\n"),
- regdesc,
- _("The default is \"std\"."));
+ string_file stb;
+ stb.printf ("%s%s%s",
+ _("The valid values are:\n"),
+ regdesc,
+ _("The default is \"std\"."));
In two steps, with the first step leaving fprintf_unfiltered (etc.)
calls in place, and only afterwards do a pass to change all those to
call stb.printf etc.. I didn't do that split, because (when I tried),
it turned out to be pointless make-work: the first pass would have to
touch the fprintf_unfiltered line anyway, to replace "stb" with
"&stb".
- gdb_fopen replaced with stack-based objects
This avoids the need for cleanups or unique_ptr's. I.e., this:
struct ui_file *file = gdb_fopen (filename, "w");
if (filename == NULL)
perror_with_name (filename);
cleanups = make_cleanup_ui_file_delete (file);
// use file.
do_cleanups (cleanups);
is replaced with this:
stdio_file file;
if (!file.open (filename, "w"))
perror_with_name (filename);
// use file.
- odd contorsions in null_file_write / null_file_fputs around when to
call to_fputs / to_write eliminated.
- Global null_stream object
A few places that were allocating a ui_file in order to print to
"nowhere" are adjusted to instead refer to a new 'null_stream' global
stream.
- TUI's tui_sfileopen eliminated. TUI's ui_file much simplified
The TUI's ui_file was serving a dual purpose. It supported being used
as string buffer, and supported being backed by a stdio FILE. The
string buffer part is gone, replaced by using of string_file. The
'FILE *' support is now much simplified, by making the TUI's ui_file
inherit from stdio_file.
gdb/ChangeLog:
2017-02-02 Pedro Alves <palves@redhat.com>
* ada-lang.c (type_as_string): Use string_file.
* ada-valprint.c (ada_print_floating): Use string_file.
* ada-varobj.c (ada_varobj_scalar_image)
(ada_varobj_get_value_image): Use string_file.
* aix-thread.c (aix_thread_extra_thread_info): Use string_file.
* arm-tdep.c (_initialize_arm_tdep): Use string_printf.
* breakpoint.c (update_inserted_breakpoint_locations)
(insert_breakpoint_locations, reattach_breakpoints)
(print_breakpoint_location, print_one_detail_ranged_breakpoint)
(print_it_watchpoint): Use string_file.
(save_breakpoints): Use stdio_file.
* c-exp.y (oper): Use string_file.
* cli/cli-logging.c (set_logging_redirect): Use ui_file_up and
tee_file.
(pop_output_files): Use delete.
(handle_redirections): Use stdio_file and tee_file.
* cli/cli-setshow.c (do_show_command): Use string_file.
* compile/compile-c-support.c (c_compute_program): Use
string_file.
* compile/compile-c-symbols.c (generate_vla_size): Take a
'string_file &' instead of a 'ui_file *'.
(generate_c_for_for_one_variable): Take a 'string_file &' instead
of a 'ui_file *'. Use string_file.
(generate_c_for_variable_locations): Take a 'string_file &'
instead of a 'ui_file *'.
* compile/compile-internal.h (generate_c_for_for_one_variable):
Take a 'string_file &' instead of a 'ui_file *'.
* compile/compile-loc2c.c (push, pushf, unary, binary)
(print_label, pushf_register_address, pushf_register)
(do_compile_dwarf_expr_to_c): Take a 'string_file &' instead of a
'ui_file *'. Adjust.
* compile/compile.c (compile_to_object): Use string_file.
* compile/compile.h (compile_dwarf_expr_to_c)
(compile_dwarf_bounds_to_c): Take a 'string_file &' instead of a
'ui_file *'.
* cp-support.c (inspect_type): Use string_file and obstack_copy0.
(replace_typedefs_qualified_name): Use string_file and
obstack_copy0.
* disasm.c (gdb_pretty_print_insn): Use string_file.
(gdb_disassembly): Adjust reference the null_stream global.
(do_ui_file_delete): Delete.
(gdb_insn_length): Use null_stream.
* dummy-frame.c (maintenance_print_dummy_frames): Use stdio_file.
* dwarf2loc.c (dwarf2_compile_property_to_c)
(locexpr_generate_c_location, loclist_generate_c_location): Take a
'string_file &' instead of a 'ui_file *'.
* dwarf2loc.h (dwarf2_compile_property_to_c): Likewise.
* dwarf2read.c (do_ui_file_peek_last): Delete.
(dwarf2_compute_name): Use string_file.
* event-top.c (gdb_setup_readline): Use stdio_file.
* gdbarch.sh (verify_gdbarch): Use string_file.
* gdbtypes.c (safe_parse_type): Use null_stream.
* guile/scm-breakpoint.c (gdbscm_breakpoint_commands): Use
string_file.
* guile/scm-disasm.c (gdbscm_print_insn_from_port): Take a
'string_file *' instead of a 'ui_file *'.
(gdbscm_arch_disassemble): Use string_file.
* guile/scm-frame.c (frscm_print_frame_smob): Use string_file.
* guile/scm-ports.c (class ioscm_file_port): Now a class that
inherits from ui_file.
(ioscm_file_port_delete, ioscm_file_port_rewind)
(ioscm_file_port_put): Delete.
(ioscm_file_port_write): Rename to ...
(ioscm_file_port::write): ... this. Remove file_port_magic
checks.
(ioscm_file_port_new): Delete.
(ioscm_with_output_to_port_worker): Use ioscm_file_port and
ui_file_up.
* guile/scm-type.c (tyscm_type_name): Use string_file.
* guile/scm-value.c (vlscm_print_value_smob, gdbscm_value_print):
Use string_file.
* infcmd.c (print_return_value_1): Use string_file.
* infrun.c (print_target_wait_results): Use string_file.
* language.c (add_language): Use string_file.
* location.c (explicit_to_string_internal): Use string_file.
* main.c (captured_main_1): Use null_file.
* maint.c (maintenance_print_architecture): Use stdio_file.
* mi/mi-cmd-stack.c (list_arg_or_local): Use string_file.
* mi/mi-common.h (struct mi_interp) <out, err, log, targ,
event_channel>: Change type to mi_console_file pointer.
* mi/mi-console.c (mi_console_file_fputs, mi_console_file_flush)
(mi_console_file_delete): Delete.
(struct mi_console_file): Delete.
(mi_console_file_magic): Delete.
(mi_console_file_new): Delete.
(mi_console_file::mi_console_file): New.
(mi_console_file_delete): Delete.
(mi_console_file_fputs): Delete.
(mi_console_file::write): New.
(mi_console_raw_packet): Delete.
(mi_console_file::flush): New.
(mi_console_file_flush): Delete.
(mi_console_set_raw): Rename to ...
(mi_console_file::set_raw): ... this.
* mi/mi-console.h (class mi_console_file): New class.
(mi_console_file_new, mi_console_set_raw): Delete.
* mi/mi-interp.c (mi_interpreter_init): Use mi_console_file.
(mi_set_logging): Use delete and tee_file. Adjust.
* mi/mi-main.c (output_register): Use string_file.
(mi_cmd_data_evaluate_expression): Use string_file.
(mi_cmd_data_read_memory): Use string_file.
(mi_cmd_execute, print_variable_or_computed): Use string_file.
* mi/mi-out.c (mi_ui_out::main_stream): New.
(mi_ui_out::rewind): Use main_stream and
string_file.
(mi_ui_out::put): Use main_stream and string_file.
(mi_ui_out::mi_ui_out): Remove 'stream' parameter.
Allocate a 'string_file' instead.
(mi_out_new): Don't allocate a mem_fileopen stream here.
* mi/mi-out.h (mi_ui_out::mi_ui_out): Remove 'stream' parameter.
(mi_ui_out::main_stream): Declare method.
* printcmd.c (eval_command): Use string_file.
* psymtab.c (maintenance_print_psymbols): Use stdio_file.
* python/py-arch.c (archpy_disassemble): Use string_file.
* python/py-breakpoint.c (bppy_get_commands): Use string_file.
* python/py-frame.c (frapy_str): Use string_file.
* python/py-framefilter.c (py_print_type, py_print_single_arg):
Use string_file.
* python/py-type.c (typy_str): Use string_file.
* python/py-unwind.c (unwind_infopy_str): Use string_file.
* python/py-value.c (valpy_str): Use string_file.
* record-btrace.c (btrace_insn_history): Use string_file.
* regcache.c (regcache_print): Use stdio_file.
* reggroups.c (maintenance_print_reggroups): Use stdio_file.
* remote.c (escape_buffer): Use string_file.
* rust-lang.c (rust_get_disr_info): Use string_file.
* serial.c (serial_open_ops_1): Use stdio_file.
(do_serial_close): Use delete.
* stack.c (print_frame_arg): Use string_file.
(print_frame_args): Remove local mem_fileopen stream, not used.
(print_frame): Use string_file.
* symmisc.c (maintenance_print_symbols): Use stdio_file.
* symtab.h (struct symbol_computed_ops) <generate_c_location>:
Take a 'string_file *' instead of a 'ui_file *'.
* top.c (new_ui): Use stdio_file and stderr_file.
(free_ui): Use delete.
(execute_command_to_string): Use string_file.
(quit_confirm): Use string_file.
* tracepoint.c (collection_list::append_exp): Use string_file.
* tui/tui-disasm.c (tui_disassemble): Use string_file.
* tui/tui-file.c: Don't include "ui-file.h".
(enum streamtype, struct tui_stream): Delete.
(tui_file_new, tui_file_delete, tui_fileopen, tui_sfileopen)
(tui_file_isatty, tui_file_rewind, tui_file_put): Delete.
(tui_file::tui_file): New method.
(tui_file_fputs): Delete.
(tui_file_get_strbuf): Delete.
(tui_file::puts): New method.
(tui_file_adjust_strbuf): Delete.
(tui_file_flush): Delete.
(tui_file::flush): New method.
* tui/tui-file.h: Tweak intro comment.
Include ui-file.h.
(tui_fileopen, tui_sfileopen, tui_file_get_strbuf)
(tui_file_adjust_strbuf): Delete declarations.
(class tui_file): New class.
* tui/tui-io.c (tui_initialize_io): Use tui_file.
* tui/tui-regs.c (tui_restore_gdbout): Use delete.
(tui_register_format): Use string_stream.
* tui/tui-stack.c (tui_make_status_line): Use string_file.
(tui_get_function_from_frame): Use string_file.
* typeprint.c (type_to_string): Use string_file.
* ui-file.c (struct ui_file, ui_file_magic, ui_file_new): Delete.
(null_stream): New global.
(ui_file_delete): Delete.
(ui_file::ui_file): New.
(null_file_isatty): Delete.
(ui_file::~ui_file): New.
(null_file_rewind): Delete.
(ui_file::printf): New.
(null_file_put): Delete.
(null_file_flush): Delete.
(ui_file::putstr): New.
(null_file_write): Delete.
(ui_file::putstrn): New.
(null_file_read): Delete.
(ui_file::putc): New.
(null_file_fputs): Delete.
(null_file_write_async_safe): Delete.
(ui_file::vprintf): New.
(null_file_delete): Delete.
(null_file::write): New.
(null_file_fseek): Delete.
(null_file::puts): New.
(ui_file_data): Delete.
(null_file::write_async_safe): New.
(gdb_flush, ui_file_isatty): Adjust.
(ui_file_put, ui_file_rewind): Delete.
(ui_file_write): Adjust.
(ui_file_write_for_put): Delete.
(ui_file_write_async_safe, ui_file_read): Adjust.
(ui_file_fseek): Delete.
(fputs_unfiltered): Adjust.
(set_ui_file_flush, set_ui_file_isatty, set_ui_file_rewind)
(set_ui_file_put, set_ui_file_write, set_ui_file_write_async_safe)
(set_ui_file_read, set_ui_file_fputs, set_ui_file_fseek)
(set_ui_file_data): Delete.
(string_file::~string_file, string_file::write)
(struct accumulated_ui_file, do_ui_file_xstrdup, ui_file_xstrdup)
(do_ui_file_as_string, ui_file_as_string): Delete.
(do_ui_file_obsavestring, ui_file_obsavestring): Delete.
(struct mem_file): Delete.
(mem_file_new): Delete.
(stdio_file::stdio_file): New.
(mem_file_delete): Delete.
(stdio_file::stdio_file): New.
(mem_fileopen): Delete.
(stdio_file::~stdio_file): New.
(mem_file_rewind): Delete.
(stdio_file::set_stream): New.
(mem_file_put): Delete.
(stdio_file::open): New.
(mem_file_write): Delete.
(stdio_file_magic, struct stdio_file): Delete.
(stdio_file_new, stdio_file_delete, stdio_file_flush): Delete.
(stdio_file::flush): New.
(stdio_file_read): Rename to ...
(stdio_file::read): ... this. Adjust.
(stdio_file_write): Rename to ...
(stdio_file::write): ... this. Adjust.
(stdio_file_write_async_safe): Rename to ...
(stdio_file::write_async_safe) ... this. Adjust.
(stdio_file_fputs): Rename to ...
(stdio_file::puts) ... this. Adjust.
(stdio_file_isatty): Delete.
(stdio_file_fseek): Delete.
(stdio_file::isatty): New.
(stderr_file_write): Rename to ...
(stderr_file::write) ... this. Adjust.
(stderr_file_fputs): Rename to ...
(stderr_file::puts) ... this. Adjust.
(stderr_fileopen, stdio_fileopen, gdb_fopen): Delete.
(stderr_file::stderr_file): New.
(tee_file_magic): Delete.
(struct tee_file): Delete.
(tee_file::tee_file): New.
(tee_file_new): Delete.
(tee_file::~tee_file): New.
(tee_file_delete): Delete.
(tee_file_flush): Rename to ...
(tee_file::flush): ... this. Adjust.
(tee_file_write): Rename to ...
(tee_file::write): ... this. Adjust.
(tee_file::write_async_safe): New.
(tee_file_fputs): Rename to ...
(tee_file::puts): ... this. Adjust.
(tee_file_isatty): Rename to ...
(tee_file::isatty): ... this. Adjust.
* ui-file.h (struct obstack, struct ui_file): Don't
forward-declare.
(ui_file_new, ui_file_flush_ftype, set_ui_file_flush)
(ui_file_write_ftype)
(set_ui_file_write, ui_file_fputs_ftype, set_ui_file_fputs)
(ui_file_write_async_safe_ftype, set_ui_file_write_async_safe)
(ui_file_read_ftype, set_ui_file_read, ui_file_isatty_ftype)
(set_ui_file_isatty, ui_file_rewind_ftype, set_ui_file_rewind)
(ui_file_put_method_ftype, ui_file_put_ftype, set_ui_file_put)
(ui_file_delete_ftype, set_ui_file_data, ui_file_fseek_ftype)
(set_ui_file_fseek): Delete.
(ui_file_data, ui_file_delete, ui_file_rewind)
(struct ui_file): New.
(ui_file_up): New.
(class null_file): New.
(null_stream): Declare.
(ui_file_write_for_put, ui_file_put): Delete.
(ui_file_xstrdup, ui_file_as_string, ui_file_obsavestring):
Delete.
(ui_file_fseek, mem_fileopen, stdio_fileopen, stderr_fileopen)
(gdb_fopen, tee_file_new): Delete.
(struct string_file): New.
(struct stdio_file): New.
(stdio_file_up): New.
(struct stderr_file): New.
(class tee_file): New.
* ui-out.c (ui_out::field_stream): Take a 'string_file &' instead
of a 'ui_file *'. Adjust.
* ui-out.h (class ui_out) <field_stream>: Likewise.
* utils.c (do_ui_file_delete, make_cleanup_ui_file_delete)
(null_stream): Delete.
(error_stream): Take a 'string_file &' instead of a 'ui_file *'.
Adjust.
* utils.h (struct ui_file): Delete forward declaration..
(make_cleanup_ui_file_delete, null_stream): Delete declarations.
(error_stream): Take a 'string_file &' instead of a
'ui_file *'.
* varobj.c (varobj_value_get_print_value): Use string_file.
* xtensa-tdep.c (xtensa_verify_config): Use string_file.
* gdbarch.c: Regenerate.
2017-02-02 19:11:47 +08:00
|
|
|
gdb_stdout = new null_file ();
|
2005-11-01 19:09:18 +08:00
|
|
|
break;
|
2010-12-08 01:26:06 +08:00
|
|
|
case 'D':
|
2014-05-17 03:15:10 +08:00
|
|
|
if (optarg[0] == '\0')
|
2014-08-05 23:12:01 +08:00
|
|
|
error (_("%s: empty path for `--data-directory'"),
|
|
|
|
gdb_program_name);
|
2014-05-17 03:15:10 +08:00
|
|
|
set_gdb_data_directory (optarg);
|
2012-11-17 03:43:39 +08:00
|
|
|
gdb_datadir_provided = 1;
|
2010-12-08 01:26:06 +08:00
|
|
|
break;
|
2000-02-07 08:19:45 +08:00
|
|
|
#ifdef GDBTK
|
|
|
|
case 'z':
|
|
|
|
{
|
2010-12-29 08:58:14 +08:00
|
|
|
extern int gdbtk_test (char *);
|
|
|
|
|
2000-02-07 08:19:45 +08:00
|
|
|
if (!gdbtk_test (optarg))
|
2014-08-05 23:12:01 +08:00
|
|
|
error (_("%s: unable to load tclcommand file \"%s\""),
|
|
|
|
gdb_program_name, optarg);
|
2000-02-07 08:19:45 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'y':
|
2001-10-04 23:04:27 +08:00
|
|
|
/* Backwards compatibility only. */
|
|
|
|
break;
|
2000-02-07 08:19:45 +08:00
|
|
|
case 'w':
|
|
|
|
{
|
2012-02-21 03:44:01 +08:00
|
|
|
/* Set the external editor commands when gdb is farming out files
|
|
|
|
to be edited by another program. */
|
|
|
|
extern char *external_editor_command;
|
|
|
|
|
2000-02-07 08:19:45 +08:00
|
|
|
external_editor_command = xstrdup (optarg);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif /* GDBTK */
|
2000-02-23 08:25:43 +08:00
|
|
|
case 'i':
|
2003-02-05 Jim Ingham <jingham@apple.com>
Keith Seitz <keiths@redhat.com>
Elena Zannoni <ezannoni@redhat.com>
Andrew Cagney <ac131313@redhat.com>
* Makefile.in (SUBDIR_CLI_OBS): Add "cli-interp.o".
(SUBDIR_CLI_SRCS): Add "cli/cli-interp.c".
(SUBDIR_MI_OBS): Add "mi-interp.o".
(SUBDIR_MI_SRCS): Add "mi/mi-interp.c".
(SFILES): Add "interps.c".
(COMMON_OBS): Add "interps.o".
(interps_h, mi_main_h): Define.
(interps.o, cli-interp.o, mi-interp.o): Add dependencies.
(mi-main.o, main.o, event-top.o): Update dependencies.
* cli/cli-interp.c: New file.
* interps.h, interps.c: New files.
* top.c: (gdb_init): Don't install the default interpreter, handed
by captured_main.
* main.c: Include "interps.h".
(interpreter_p): Note that it should malloc'ed.
(captured_command_loop): Call current_interp_command_loop.
(captured_main): Initialize interpreter_p to INTERP_CONSOLE. Use
xfree and xstrdup when updating interpreter_p. Install the
default interpreter. Add hack to stop mi1's copyright notice
being encoded.
* event-top.h (gdb_setup_readline): Declare.
(gdb_disable_readline): Declare.
* event-top.c: Include "interps.h".
(display_gdb_prompt): Call current_interp_display_prompt_p.
(gdb_setup_readline): Initialize gdb_stdout, gdb_stderr,
gdb_stdlog, and gdb_stdtarg.
(_initialize_event_loop): Don't call gdb_setup_readline.
* cli-out.c (cli_out_set_stream): New function.
* cli-out.h (cli_out_set_stream): Declare.
2003-02-06 09:19:12 +08:00
|
|
|
xfree (interpreter_p);
|
|
|
|
interpreter_p = xstrdup (optarg);
|
2000-02-23 08:25:43 +08:00
|
|
|
break;
|
1999-04-16 09:35:26 +08:00
|
|
|
case 'd':
|
2016-10-12 10:02:23 +08:00
|
|
|
dirarg.push_back (optarg);
|
1999-04-16 09:35:26 +08:00
|
|
|
break;
|
|
|
|
case 't':
|
|
|
|
ttyarg = optarg;
|
|
|
|
break;
|
|
|
|
case 'q':
|
|
|
|
quiet = 1;
|
|
|
|
break;
|
|
|
|
case 'b':
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
i = strtol (optarg, &p, 0);
|
|
|
|
if (i == 0 && p == optarg)
|
2014-08-05 23:18:51 +08:00
|
|
|
warning (_("could not set baud rate to `%s'."),
|
|
|
|
optarg);
|
1999-04-16 09:35:26 +08:00
|
|
|
else
|
|
|
|
baud_rate = i;
|
|
|
|
}
|
2002-09-25 11:10:26 +08:00
|
|
|
break;
|
1999-04-16 09:35:26 +08:00
|
|
|
case 'l':
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
i = strtol (optarg, &p, 0);
|
|
|
|
if (i == 0 && p == optarg)
|
2014-08-05 23:18:51 +08:00
|
|
|
warning (_("could not set timeout limit to `%s'."),
|
|
|
|
optarg);
|
1999-04-16 09:35:26 +08:00
|
|
|
else
|
|
|
|
remote_timeout = i;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
Add support for the readnever concept
The purpose of this concept is to turn the load of debugging
information off, either globally (via the '--readnever' option), or
objfile-specific. The implementation proposed here is an extension of
the patch distributed with Fedora GDB; looking at the Fedora patch
itself and the history, one can see some reasons why it was never
resubmitted:
- The patch appears to have been introduced as a workaround, at
least initially;
- The patch is far from perfect, as it simply shunts the load of
DWARF debugging information, without really worrying about the
other debug format.
- Who really does non-symbolic debugging anyways?
One use of this feature is when a user simply wants to do the
following sequence: attach, dump core, detach. Loading the debugging
information in this case is an unnecessary cause of delay.
This patch expands the version shipped with Fedora GDB in order to
make the feature available for all the debuginfo backends, not only
for DWARF. It also implements a per-objfile flag which can be
activated by using the "-readnever" command when using the
'add-symbol-file' or 'symbol-file' commands.
It's also worth mentioning that this patch tests whether GDB correctly
fails to initialize if both '--readnow' and '--readnever' options are
passed.
Tested on the BuildBot.
gdb/ChangeLog:
2017-12-01 Andrew Cagney <cagney@redhat.com>
Joel Brobecker <brobecker@adacore.com>
Sergio Durigan Junior <sergiodj@redhat.com>
* NEWS (Changes since GDB 8.0: Mention new '--readnever'
feature.
* coffread.c (coff_symfile_read): Do not map over sections with
'coff_locate_sections' if readnever is on.
* dwarf2read.c (dwarf2_has_info): Return 0 if
readnever is on.
* elfread.c (elf_symfile_read): Do not map over sections with
'elf_locate_sections' if readnever is on.
* main.c (validate_readnow_readnever): New function.
(captured_main_1): Add support for --readnever.
(print_gdb_help): Document --readnever.
* objfile-flags.h (enum objfile_flag) <OBJF_READNEVER>: New
flag.
* symfile.c (readnever_symbol_files): New global.
(symbol_file_add_with_addrs): Set 'OBJF_READNEVER' when
'READNEVER_SYMBOL_FILES' is set.
(validate_readnow_readnever): New function.
(symbol_file_command): Handle '-readnever' option.
Call 'validate_readnow_readnever'.
(add_symbol_file_command): Handle '-readnever' option.
Call 'validate_readnow_readnever'.
(_initialize_symfile): Document new '-readnever' option for
both 'symbol-file' and 'add-symbol-file' commands.
* top.h (readnever_symbol_files): New extern global.
* xcoffread.c (xcoff_initial_scan): Do not read debug
information if readnever is on.
gdb/doc/ChangeLog:
2017-12-01 Andrew Cagney <cagney@redhat.com>
Joel Brobecker <brobecker@adacore.com>
Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.texinfo (File Options): Document --readnever.
(Commands to Specify Files): Likewise, for 'symbol-file' and
'add-symbol-file'.
gdb/testsuite/ChangeLog:
2017-12-01 Joel Brobecker <brobecker@adacore.com>
Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
* gdb.base/readnever.c, gdb.base/readnever.exp: New files.
2017-11-25 05:56:08 +08:00
|
|
|
case OPT_READNOW:
|
|
|
|
{
|
|
|
|
readnow_symbol_files = 1;
|
|
|
|
validate_readnow_readnever ();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OPT_READNEVER:
|
|
|
|
{
|
|
|
|
readnever_symbol_files = 1;
|
|
|
|
validate_readnow_readnever ();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
case '?':
|
2014-08-05 23:12:01 +08:00
|
|
|
error (_("Use `%s --help' for a complete list of options."),
|
|
|
|
gdb_program_name);
|
1999-04-16 09:35:26 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-09 03:20:38 +08:00
|
|
|
if (batch_flag)
|
1999-04-16 09:35:26 +08:00
|
|
|
quiet = 1;
|
|
|
|
}
|
|
|
|
|
2014-06-19 16:13:57 +08:00
|
|
|
/* Try to set up an alternate signal stack for SIGSEGV handlers. */
|
|
|
|
setup_alternate_signal_stack ();
|
|
|
|
|
2015-05-07 01:40:52 +08:00
|
|
|
/* Initialize all files. */
|
2013-03-23 18:48:23 +08:00
|
|
|
gdb_init (gdb_program_name);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
/* Now that gdb_init has created the initial inferior, we're in
|
|
|
|
position to set args for that inferior. */
|
Per-inferior args and tty and environment.
* infcmd.c (inferior_args): Rename to ...
(inferior_args_scratch): ... this.
(inferior_io_terminal): Rename to ...
(inferior_io_terminal_scratch): ... this.
(inferior_argc, inferior_argv): Remove.
(set_inferior_io_terminal, get_inferior_io_terminal): Store
inside current_inferior().
(set_inferior_tty_command, show_inferior_tty_command): New.
(get_inferior_args, set_inferior_args): Store inside
current_inferior().
(notice_args_set): Likewise and rename to...
(set_args_command): ... this.
(set_inferior_args_vector): Likewise.
(notice_args_read): Rename to...
(show_args_command): ...new.
(tty_command): Remove.
(run_command_1): Don't free old args, as they are freed by
set_inferior_arg now.
(run_no_args_command): Likewise.
(inferior_environ): Remove.
(run_command_1): Use environment of the current inferior.
(environment_info, set_environment_command)
(unset_environment_command, path_info, path_command): Likewise.
(_initialize_infcmd): Adjust for function and variable renames.
Do not init inferior_environ.
* inferior.h (set_inferior_arg): Adjust prototype.
(struct inferior): New fields args, argc, argv, terminal, environment.
(inferior_environ): Remove declaration.
* inferior.c (free_inferior): Free new fields.
(add_inferior_silent): Initialize 'environment' field.
* main.c (captured_main): Set arguments only after the initial
inferior has been created. Set set_inferior_io_terminal,
not tty_command.
* mi/mi-main.c (mi_cmd_env_path): Use environment of the current
inferior.
(_initialize_mi_cmd_env): Adjust for disappearance of global
inferior_environ.
* solib.c (solib_find): Use environment of the current inferior.
2010-01-20 22:23:07 +08:00
|
|
|
if (set_args)
|
|
|
|
{
|
|
|
|
/* The remaining options are the command-line options for the
|
|
|
|
inferior. The first one is the sym/exec file, and the rest
|
|
|
|
are arguments. */
|
|
|
|
if (optind >= argc)
|
2014-08-05 23:12:01 +08:00
|
|
|
error (_("%s: `--args' specified but no program specified"),
|
|
|
|
gdb_program_name);
|
|
|
|
|
Per-inferior args and tty and environment.
* infcmd.c (inferior_args): Rename to ...
(inferior_args_scratch): ... this.
(inferior_io_terminal): Rename to ...
(inferior_io_terminal_scratch): ... this.
(inferior_argc, inferior_argv): Remove.
(set_inferior_io_terminal, get_inferior_io_terminal): Store
inside current_inferior().
(set_inferior_tty_command, show_inferior_tty_command): New.
(get_inferior_args, set_inferior_args): Store inside
current_inferior().
(notice_args_set): Likewise and rename to...
(set_args_command): ... this.
(set_inferior_args_vector): Likewise.
(notice_args_read): Rename to...
(show_args_command): ...new.
(tty_command): Remove.
(run_command_1): Don't free old args, as they are freed by
set_inferior_arg now.
(run_no_args_command): Likewise.
(inferior_environ): Remove.
(run_command_1): Use environment of the current inferior.
(environment_info, set_environment_command)
(unset_environment_command, path_info, path_command): Likewise.
(_initialize_infcmd): Adjust for function and variable renames.
Do not init inferior_environ.
* inferior.h (set_inferior_arg): Adjust prototype.
(struct inferior): New fields args, argc, argv, terminal, environment.
(inferior_environ): Remove declaration.
* inferior.c (free_inferior): Free new fields.
(add_inferior_silent): Initialize 'environment' field.
* main.c (captured_main): Set arguments only after the initial
inferior has been created. Set set_inferior_io_terminal,
not tty_command.
* mi/mi-main.c (mi_cmd_env_path): Use environment of the current
inferior.
(_initialize_mi_cmd_env): Adjust for disappearance of global
inferior_environ.
* solib.c (solib_find): Use environment of the current inferior.
2010-01-20 22:23:07 +08:00
|
|
|
symarg = argv[optind];
|
|
|
|
execarg = argv[optind];
|
|
|
|
++optind;
|
|
|
|
set_inferior_args_vector (argc - optind, &argv[optind]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* OK, that's all the options. */
|
|
|
|
|
|
|
|
/* The first argument, if specified, is the name of the
|
|
|
|
executable. */
|
|
|
|
if (optind < argc)
|
|
|
|
{
|
|
|
|
symarg = argv[optind];
|
|
|
|
execarg = argv[optind];
|
|
|
|
optind++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If the user hasn't already specified a PID or the name of a
|
|
|
|
core file, then a second optional argument is allowed. If
|
|
|
|
present, this argument should be interpreted as either a
|
|
|
|
PID or a core file, whichever works. */
|
|
|
|
if (pidarg == NULL && corearg == NULL && optind < argc)
|
|
|
|
{
|
|
|
|
pid_or_core_arg = argv[optind];
|
|
|
|
optind++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Any argument left on the command line is unexpected and
|
|
|
|
will be ignored. Inform the user. */
|
|
|
|
if (optind < argc)
|
2011-01-06 06:22:53 +08:00
|
|
|
fprintf_unfiltered (gdb_stderr,
|
|
|
|
_("Excess command line "
|
|
|
|
"arguments ignored. (%s%s)\n"),
|
Per-inferior args and tty and environment.
* infcmd.c (inferior_args): Rename to ...
(inferior_args_scratch): ... this.
(inferior_io_terminal): Rename to ...
(inferior_io_terminal_scratch): ... this.
(inferior_argc, inferior_argv): Remove.
(set_inferior_io_terminal, get_inferior_io_terminal): Store
inside current_inferior().
(set_inferior_tty_command, show_inferior_tty_command): New.
(get_inferior_args, set_inferior_args): Store inside
current_inferior().
(notice_args_set): Likewise and rename to...
(set_args_command): ... this.
(set_inferior_args_vector): Likewise.
(notice_args_read): Rename to...
(show_args_command): ...new.
(tty_command): Remove.
(run_command_1): Don't free old args, as they are freed by
set_inferior_arg now.
(run_no_args_command): Likewise.
(inferior_environ): Remove.
(run_command_1): Use environment of the current inferior.
(environment_info, set_environment_command)
(unset_environment_command, path_info, path_command): Likewise.
(_initialize_infcmd): Adjust for function and variable renames.
Do not init inferior_environ.
* inferior.h (set_inferior_arg): Adjust prototype.
(struct inferior): New fields args, argc, argv, terminal, environment.
(inferior_environ): Remove declaration.
* inferior.c (free_inferior): Free new fields.
(add_inferior_silent): Initialize 'environment' field.
* main.c (captured_main): Set arguments only after the initial
inferior has been created. Set set_inferior_io_terminal,
not tty_command.
* mi/mi-main.c (mi_cmd_env_path): Use environment of the current
inferior.
(_initialize_mi_cmd_env): Adjust for disappearance of global
inferior_environ.
* solib.c (solib_find): Use environment of the current inferior.
2010-01-20 22:23:07 +08:00
|
|
|
argv[optind],
|
|
|
|
(optind == argc - 1) ? "" : " ...");
|
|
|
|
}
|
|
|
|
|
2011-01-09 11:20:33 +08:00
|
|
|
/* Lookup gdbinit files. Note that the gdbinit file name may be
|
2010-12-29 08:58:14 +08:00
|
|
|
overriden during file initialization, so get_init_files should be
|
|
|
|
called after gdb_init. */
|
2009-04-27 18:24:08 +08:00
|
|
|
get_init_files (&system_gdbinit, &home_gdbinit, &local_gdbinit);
|
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
/* Do these (and anything which might call wrap_here or *_filtered)
|
2003-02-05 Jim Ingham <jingham@apple.com>
Keith Seitz <keiths@redhat.com>
Elena Zannoni <ezannoni@redhat.com>
Andrew Cagney <ac131313@redhat.com>
* Makefile.in (SUBDIR_CLI_OBS): Add "cli-interp.o".
(SUBDIR_CLI_SRCS): Add "cli/cli-interp.c".
(SUBDIR_MI_OBS): Add "mi-interp.o".
(SUBDIR_MI_SRCS): Add "mi/mi-interp.c".
(SFILES): Add "interps.c".
(COMMON_OBS): Add "interps.o".
(interps_h, mi_main_h): Define.
(interps.o, cli-interp.o, mi-interp.o): Add dependencies.
(mi-main.o, main.o, event-top.o): Update dependencies.
* cli/cli-interp.c: New file.
* interps.h, interps.c: New files.
* top.c: (gdb_init): Don't install the default interpreter, handed
by captured_main.
* main.c: Include "interps.h".
(interpreter_p): Note that it should malloc'ed.
(captured_command_loop): Call current_interp_command_loop.
(captured_main): Initialize interpreter_p to INTERP_CONSOLE. Use
xfree and xstrdup when updating interpreter_p. Install the
default interpreter. Add hack to stop mi1's copyright notice
being encoded.
* event-top.h (gdb_setup_readline): Declare.
(gdb_disable_readline): Declare.
* event-top.c: Include "interps.h".
(display_gdb_prompt): Call current_interp_display_prompt_p.
(gdb_setup_readline): Initialize gdb_stdout, gdb_stderr,
gdb_stdlog, and gdb_stdtarg.
(_initialize_event_loop): Don't call gdb_setup_readline.
* cli-out.c (cli_out_set_stream): New function.
* cli-out.h (cli_out_set_stream): Declare.
2003-02-06 09:19:12 +08:00
|
|
|
after initialize_all_files() but before the interpreter has been
|
|
|
|
installed. Otherwize the help/version messages will be eaten by
|
|
|
|
the interpreter's output handler. */
|
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
if (print_version)
|
|
|
|
{
|
|
|
|
print_gdb_version (gdb_stdout);
|
|
|
|
wrap_here ("");
|
|
|
|
printf_filtered ("\n");
|
|
|
|
exit (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (print_help)
|
|
|
|
{
|
|
|
|
print_gdb_help (gdb_stdout);
|
|
|
|
fputs_unfiltered ("\n", gdb_stdout);
|
|
|
|
exit (0);
|
|
|
|
}
|
|
|
|
|
2013-04-12 16:57:07 +08:00
|
|
|
if (print_configuration)
|
|
|
|
{
|
|
|
|
print_gdb_configuration (gdb_stdout);
|
|
|
|
wrap_here ("");
|
|
|
|
printf_filtered ("\n");
|
|
|
|
exit (0);
|
|
|
|
}
|
|
|
|
|
2003-02-05 Jim Ingham <jingham@apple.com>
Keith Seitz <keiths@redhat.com>
Elena Zannoni <ezannoni@redhat.com>
Andrew Cagney <ac131313@redhat.com>
* Makefile.in (SUBDIR_CLI_OBS): Add "cli-interp.o".
(SUBDIR_CLI_SRCS): Add "cli/cli-interp.c".
(SUBDIR_MI_OBS): Add "mi-interp.o".
(SUBDIR_MI_SRCS): Add "mi/mi-interp.c".
(SFILES): Add "interps.c".
(COMMON_OBS): Add "interps.o".
(interps_h, mi_main_h): Define.
(interps.o, cli-interp.o, mi-interp.o): Add dependencies.
(mi-main.o, main.o, event-top.o): Update dependencies.
* cli/cli-interp.c: New file.
* interps.h, interps.c: New files.
* top.c: (gdb_init): Don't install the default interpreter, handed
by captured_main.
* main.c: Include "interps.h".
(interpreter_p): Note that it should malloc'ed.
(captured_command_loop): Call current_interp_command_loop.
(captured_main): Initialize interpreter_p to INTERP_CONSOLE. Use
xfree and xstrdup when updating interpreter_p. Install the
default interpreter. Add hack to stop mi1's copyright notice
being encoded.
* event-top.h (gdb_setup_readline): Declare.
(gdb_disable_readline): Declare.
* event-top.c: Include "interps.h".
(display_gdb_prompt): Call current_interp_display_prompt_p.
(gdb_setup_readline): Initialize gdb_stdout, gdb_stderr,
gdb_stdlog, and gdb_stdtarg.
(_initialize_event_loop): Don't call gdb_setup_readline.
* cli-out.c (cli_out_set_stream): New function.
* cli-out.h (cli_out_set_stream): Declare.
2003-02-06 09:19:12 +08:00
|
|
|
/* FIXME: cagney/2003-02-03: The big hack (part 1 of 2) that lets
|
|
|
|
GDB retain the old MI1 interpreter startup behavior. Output the
|
|
|
|
copyright message before the interpreter is installed. That way
|
|
|
|
it isn't encapsulated in MI output. */
|
|
|
|
if (!quiet && strcmp (interpreter_p, INTERP_MI1) == 0)
|
|
|
|
{
|
2010-12-29 08:58:14 +08:00
|
|
|
/* Print all the junk at the top, with trailing "..." if we are
|
|
|
|
about to read a symbol file (possibly slowly). */
|
2003-02-05 Jim Ingham <jingham@apple.com>
Keith Seitz <keiths@redhat.com>
Elena Zannoni <ezannoni@redhat.com>
Andrew Cagney <ac131313@redhat.com>
* Makefile.in (SUBDIR_CLI_OBS): Add "cli-interp.o".
(SUBDIR_CLI_SRCS): Add "cli/cli-interp.c".
(SUBDIR_MI_OBS): Add "mi-interp.o".
(SUBDIR_MI_SRCS): Add "mi/mi-interp.c".
(SFILES): Add "interps.c".
(COMMON_OBS): Add "interps.o".
(interps_h, mi_main_h): Define.
(interps.o, cli-interp.o, mi-interp.o): Add dependencies.
(mi-main.o, main.o, event-top.o): Update dependencies.
* cli/cli-interp.c: New file.
* interps.h, interps.c: New files.
* top.c: (gdb_init): Don't install the default interpreter, handed
by captured_main.
* main.c: Include "interps.h".
(interpreter_p): Note that it should malloc'ed.
(captured_command_loop): Call current_interp_command_loop.
(captured_main): Initialize interpreter_p to INTERP_CONSOLE. Use
xfree and xstrdup when updating interpreter_p. Install the
default interpreter. Add hack to stop mi1's copyright notice
being encoded.
* event-top.h (gdb_setup_readline): Declare.
(gdb_disable_readline): Declare.
* event-top.c: Include "interps.h".
(display_gdb_prompt): Call current_interp_display_prompt_p.
(gdb_setup_readline): Initialize gdb_stdout, gdb_stderr,
gdb_stdlog, and gdb_stdtarg.
(_initialize_event_loop): Don't call gdb_setup_readline.
* cli-out.c (cli_out_set_stream): New function.
* cli-out.h (cli_out_set_stream): Declare.
2003-02-06 09:19:12 +08:00
|
|
|
print_gdb_version (gdb_stdout);
|
|
|
|
if (symarg)
|
|
|
|
printf_filtered ("..");
|
|
|
|
wrap_here ("");
|
2006-07-28 05:31:40 +08:00
|
|
|
printf_filtered ("\n");
|
2010-12-29 08:58:14 +08:00
|
|
|
gdb_flush (gdb_stdout); /* Force to screen during slow
|
|
|
|
operations. */
|
2003-02-05 Jim Ingham <jingham@apple.com>
Keith Seitz <keiths@redhat.com>
Elena Zannoni <ezannoni@redhat.com>
Andrew Cagney <ac131313@redhat.com>
* Makefile.in (SUBDIR_CLI_OBS): Add "cli-interp.o".
(SUBDIR_CLI_SRCS): Add "cli/cli-interp.c".
(SUBDIR_MI_OBS): Add "mi-interp.o".
(SUBDIR_MI_SRCS): Add "mi/mi-interp.c".
(SFILES): Add "interps.c".
(COMMON_OBS): Add "interps.o".
(interps_h, mi_main_h): Define.
(interps.o, cli-interp.o, mi-interp.o): Add dependencies.
(mi-main.o, main.o, event-top.o): Update dependencies.
* cli/cli-interp.c: New file.
* interps.h, interps.c: New files.
* top.c: (gdb_init): Don't install the default interpreter, handed
by captured_main.
* main.c: Include "interps.h".
(interpreter_p): Note that it should malloc'ed.
(captured_command_loop): Call current_interp_command_loop.
(captured_main): Initialize interpreter_p to INTERP_CONSOLE. Use
xfree and xstrdup when updating interpreter_p. Install the
default interpreter. Add hack to stop mi1's copyright notice
being encoded.
* event-top.h (gdb_setup_readline): Declare.
(gdb_disable_readline): Declare.
* event-top.c: Include "interps.h".
(display_gdb_prompt): Call current_interp_display_prompt_p.
(gdb_setup_readline): Initialize gdb_stdout, gdb_stderr,
gdb_stdlog, and gdb_stdtarg.
(_initialize_event_loop): Don't call gdb_setup_readline.
* cli-out.c (cli_out_set_stream): New function.
* cli-out.h (cli_out_set_stream): Declare.
2003-02-06 09:19:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Install the default UI. All the interpreters should have had a
|
2010-12-29 08:58:14 +08:00
|
|
|
look at things by now. Initialize the default interpreter. */
|
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 08:11:55 +08:00
|
|
|
set_top_level_interpreter (interpreter_p);
|
2003-02-05 Jim Ingham <jingham@apple.com>
Keith Seitz <keiths@redhat.com>
Elena Zannoni <ezannoni@redhat.com>
Andrew Cagney <ac131313@redhat.com>
* Makefile.in (SUBDIR_CLI_OBS): Add "cli-interp.o".
(SUBDIR_CLI_SRCS): Add "cli/cli-interp.c".
(SUBDIR_MI_OBS): Add "mi-interp.o".
(SUBDIR_MI_SRCS): Add "mi/mi-interp.c".
(SFILES): Add "interps.c".
(COMMON_OBS): Add "interps.o".
(interps_h, mi_main_h): Define.
(interps.o, cli-interp.o, mi-interp.o): Add dependencies.
(mi-main.o, main.o, event-top.o): Update dependencies.
* cli/cli-interp.c: New file.
* interps.h, interps.c: New files.
* top.c: (gdb_init): Don't install the default interpreter, handed
by captured_main.
* main.c: Include "interps.h".
(interpreter_p): Note that it should malloc'ed.
(captured_command_loop): Call current_interp_command_loop.
(captured_main): Initialize interpreter_p to INTERP_CONSOLE. Use
xfree and xstrdup when updating interpreter_p. Install the
default interpreter. Add hack to stop mi1's copyright notice
being encoded.
* event-top.h (gdb_setup_readline): Declare.
(gdb_disable_readline): Declare.
* event-top.c: Include "interps.h".
(display_gdb_prompt): Call current_interp_display_prompt_p.
(gdb_setup_readline): Initialize gdb_stdout, gdb_stderr,
gdb_stdlog, and gdb_stdtarg.
(_initialize_event_loop): Don't call gdb_setup_readline.
* cli-out.c (cli_out_set_stream): New function.
* cli-out.h (cli_out_set_stream): Declare.
2003-02-06 09:19:12 +08:00
|
|
|
|
|
|
|
/* FIXME: cagney/2003-02-03: The big hack (part 2 of 2) that lets
|
|
|
|
GDB retain the old MI1 interpreter startup behavior. Output the
|
|
|
|
copyright message after the interpreter is installed when it is
|
|
|
|
any sane interpreter. */
|
|
|
|
if (!quiet && !current_interp_named_p (INTERP_MI1))
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
2010-12-29 08:58:14 +08:00
|
|
|
/* Print all the junk at the top, with trailing "..." if we are
|
|
|
|
about to read a symbol file (possibly slowly). */
|
1999-04-16 09:35:26 +08:00
|
|
|
print_gdb_version (gdb_stdout);
|
|
|
|
if (symarg)
|
|
|
|
printf_filtered ("..");
|
1999-07-08 04:19:36 +08:00
|
|
|
wrap_here ("");
|
2006-07-28 05:31:40 +08:00
|
|
|
printf_filtered ("\n");
|
2010-12-29 08:58:14 +08:00
|
|
|
gdb_flush (gdb_stdout); /* Force to screen during slow
|
|
|
|
operations. */
|
1999-04-16 09:35:26 +08:00
|
|
|
}
|
|
|
|
|
2006-07-28 05:31:40 +08:00
|
|
|
/* Set off error and warning messages with a blank line. */
|
2017-04-06 02:21:34 +08:00
|
|
|
tmp_warn_preprint.reset ();
|
2002-06-25 13:35:16 +08:00
|
|
|
warning_pre_print = _("\nwarning: ");
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2009-01-28 23:01:00 +08:00
|
|
|
/* Read and execute the system-wide gdbinit file, if it exists.
|
|
|
|
This is done *before* all the command line arguments are
|
|
|
|
processed; it sets global parameters, which are independent of
|
|
|
|
what file you are debugging or what directory you are in. */
|
|
|
|
if (system_gdbinit && !inhibit_gdbinit)
|
2017-09-13 04:14:33 +08:00
|
|
|
catch_command_errors (source_script, system_gdbinit, 0);
|
2009-01-28 23:01:00 +08:00
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
/* Read and execute $HOME/.gdbinit file, if it exists. This is done
|
|
|
|
*before* all the command line arguments are processed; it sets
|
|
|
|
global parameters, which are independent of what file you are
|
|
|
|
debugging or what directory you are in. */
|
|
|
|
|
2012-10-16 05:45:04 +08:00
|
|
|
if (home_gdbinit && !inhibit_gdbinit && !inhibit_home_gdbinit)
|
2017-09-13 04:14:33 +08:00
|
|
|
catch_command_errors (source_script, home_gdbinit, 0);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2012-07-02 20:05:01 +08:00
|
|
|
/* Process '-ix' and '-iex' options early. */
|
2016-10-12 10:02:23 +08:00
|
|
|
for (i = 0; i < cmdarg_vec.size (); i++)
|
2012-07-02 20:05:01 +08:00
|
|
|
{
|
2016-10-12 10:02:23 +08:00
|
|
|
const struct cmdarg &cmdarg_p = cmdarg_vec[i];
|
|
|
|
|
|
|
|
switch (cmdarg_p.type)
|
|
|
|
{
|
|
|
|
case CMDARG_INIT_FILE:
|
2017-09-13 04:14:33 +08:00
|
|
|
catch_command_errors (source_script, cmdarg_p.string,
|
|
|
|
!batch_flag);
|
2016-10-12 10:02:23 +08:00
|
|
|
break;
|
|
|
|
case CMDARG_INIT_COMMAND:
|
|
|
|
catch_command_errors (execute_command, cmdarg_p.string,
|
|
|
|
!batch_flag);
|
|
|
|
break;
|
|
|
|
}
|
2012-07-02 20:05:01 +08:00
|
|
|
}
|
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
/* Now perform all the actions indicated by the arguments. */
|
|
|
|
if (cdarg != NULL)
|
|
|
|
{
|
2015-02-09 22:59:10 +08:00
|
|
|
catch_command_errors (cd_command, cdarg, 0);
|
1999-04-16 09:35:26 +08:00
|
|
|
}
|
|
|
|
|
2016-10-12 10:02:23 +08:00
|
|
|
for (i = 0; i < dirarg.size (); i++)
|
2015-02-09 22:59:10 +08:00
|
|
|
catch_command_errors (directory_switch, dirarg[i], 0);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2010-04-24 02:09:16 +08:00
|
|
|
/* Skip auto-loading section-specified scripts until we've sourced
|
2010-12-29 08:58:14 +08:00
|
|
|
local_gdbinit (which is often used to augment the source search
|
|
|
|
path). */
|
gdb/
auto-load: Implementation.
* NEWS: New descriptions for "info auto-load",
"info auto-load gdb-scripts", "info auto-load python-scripts",
"info auto-load local-gdbinit" and "info auto-load libthread-db".
Deprecate "info auto-load-scripts", "set auto-load-scripts on|off"
and "show auto-load-scripts". New description for "set auto-load",
"show auto-load", "set auto-load gdb-scripts",
"show auto-load gdb-scripts", "set auto-load python-scripts",
"show auto-load python-scripts", "set auto-load local-gdbinit",
"show auto-load local-gdbinit", "set auto-load libthread-db" and
"show auto-load libthread-db".
* auto-load.c: Remove include python/python-internal.h. Add includes
exceptions.h, cli/cli-script.h, gdbcmd.h, cli/cli-decode.h and
cli/cli-setshow.h.
(GDB_AUTO_FILE_NAME, source_gdb_script_for_objfile)
(auto_load_gdb_scripts, show_auto_load_gdb_scripts): New.
(gdbpy_global_auto_load): Rename to ...
(global_auto_load): ... here.
(auto_load_local_gdbinit, auto_load_local_gdbinit_pathname)
(auto_load_local_gdbinit_loaded, show_auto_load_local_gdbinit)
(script_language_gdb, source_gdb_script_for_objfile): New.
(struct loaded_script): New field language.
(hash_loaded_script_entry, eq_loaded_script_entry): Calculate also
LANGUAGE.
(maybe_add_script): Add parameter language. Drop redundant
entry.full_path initialization. Initialize entry.language and
(*slot)->language.
(auto_load_objfile_script): Change parameter suffix to language.
Remove the call of maybe_add_script.
Call language->source_script_for_objfile.
(load_auto_scripts_for_objfile, struct collect_matching_scripts_data):
New.
(collect_matching_scripts): Adjust it for
struct collect_matching_scripts_data.
(auto_load_info_scripts_pattern_nl): New variable.
(info_auto_load_scripts): Rename to ...
(auto_load_info_scripts): ... here, add parameter language. Adjust it
for struct collect_matching_scripts_data.
(info_auto_load_gdb_scripts, info_auto_load_local_gdbinit)
(set_auto_load_cmd, auto_load_set_cmdlist_get, show_auto_load_cmd)
(auto_load_show_cmdlist_get, info_auto_load_cmd)
(auto_load_info_cmdlist_get): New.
(_initialize_auto_load): Move add_info of "auto-load-scripts" to
python/py-auto-load.c. New installment for "set auto-load gdb-scripts",
"info auto-load gdb-scripts", "set auto-load local-gdbinit" and
"info auto-load local-gdbinit".
* auto-load.h (struct script_language): New.
(gdbpy_global_auto_load): Rename to ...
(global_auto_load): ... here.
(auto_load_local_gdbinit, auto_load_local_gdbinit_pathname)
(auto_load_local_gdbinit_loaded): New declarations.
(maybe_add_script): New parameter language.
(auto_load_objfile_script): Change parameter suffix to language.
(load_auto_scripts_for_objfile, auto_load_info_scripts_pattern_nl)
(auto_load_info_scripts, auto_load_set_cmdlist_get)
(auto_load_show_cmdlist_get, auto_load_info_cmdlist_get): New
declarations.
* linux-thread-db.c: Include auto-load.h and ctype.h.
(auto_load_thread_db, show_auto_load_thread_db): New.
(struct thread_db_info): New field filename.
(delete_thread_db_info): Call xfree for FILENAME.
(try_thread_db_load): Initialize FILENAME.
(try_thread_db_load_from_pdir, try_thread_db_load_from_dir): Return
if !AUTO_LOAD_THREAD_DB.
(info_auto_load_libthread_db_compare, info_auto_load_libthread_db): New.
(_initialize_thread_db): Install auto_load_thread_db
as "set auto-load libthread-db" and install info_auto_load_libthread_db
as "info auto-load libthread-db".
* main.c (captured_main): Rename gdbpy_global_auto_load to
global_auto_load. Initialize AUTO_LOAD_LOCAL_GDBINIT_PATHNAME and
AUTO_LOAD_LOCAL_GDBINIT_LOADED.
(print_gdb_help): Extend the help for 'local init file'.
* python/py-auto-load.c: Remove a comment about gdb scripts extension.
(GDBPY_AUTO_SECTION_NAME): Extend the comment it is Python specific.
(auto_load_scripts): Rename to ...
(auto_load_python_scripts): ... here, update the comment.
(gdbpy_load_auto_script_for_objfile): New declaration.
(show_auto_load_python_scripts, script_language_python)
(gdbpy_load_auto_script_for_objfile): New.
(source_section_scripts): Refactor the code.
(load_auto_scripts_for_objfile): Rename to ...
(gdbpy_load_auto_scripts_for_objfile): ... here, update the
auto_load_objfile_script caller, drop GDBPY_GLOBAL_AUTO_LOAD checking.
(info_auto_load_python_scripts): New.
(gdbpy_initialize_auto_load): New variables cmd and cmd_name.
Rename "set auto-load-scripts" to "set auto-load python-scripts".
Register "set auto-load-scripts" as its deprecated alias. Register
"info auto-load python-scripts". Register "info auto-load-scripts" as
its deprecated alias.
(load_auto_scripts_for_objfile): Rename to ...
(gdbpy_load_auto_scripts_for_objfile): ... here.
* python/python.h (load_auto_scripts_for_objfile): Rename to ...
(gdbpy_load_auto_scripts_for_objfile): ... here.
gdb/doc/
auto-load: Implementation.
* gdb.texinfo (Mode Options): New anchor for -nx.
(Startup): New anchors for Option -init-eval-command,
Home Directory Init File
and Init File in the Current Directory during Startup.
Mention set auto-load local-gdbinit with a reference.
Change the sample code to "set auto-load python-scripts".
(Threads): New anchor set libthread-db-search-path.
Provide references to libthread_db.so.1 file.
(Controlling GDB): New menu item for Auto-loading.
(Auto-loading, Init File in the Current Directory)
(libthread_db.so.1 file, objfile-gdb.gdb file): New nodes.
(Python): Rename the menu item Auto-loading to Python Auto-loading.
(Writing a Pretty-Printer, Objfiles In Python): Update the renamed
reference.
(Auto-loading): Rename to ...
(Python Auto-loading): ... here. Change "set auto-load-scripts" to
"set auto-load python-scripts", new anchor for it. Change
"show auto-load-scripts" to "show auto-load python-scripts", new anchor
for it. Change "info auto-load-scripts"
to "info auto-load python-scripts", new anchor for it. Change "scripts"
to "Python scripts".
gdb/testsuite/
auto-load: Implementation.
* gdb.base/help.exp (test set height): Increase the height.
* gdb.python/py-objfile-script.exp (info auto-load-scripts): Change
to ...
(info auto-load python-scripts): ... here.
* gdb.python/py-section-script.exp (info auto-load-scripts *): Change
to ...
(info auto-load python-scripts *): ... here.
2012-04-17 23:51:48 +08:00
|
|
|
save_auto_load = global_auto_load;
|
|
|
|
global_auto_load = 0;
|
2010-04-24 02:09:16 +08:00
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
if (execarg != NULL
|
|
|
|
&& symarg != NULL
|
2003-02-07 08:27:31 +08:00
|
|
|
&& strcmp (execarg, symarg) == 0)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
1999-11-09 09:23:30 +08:00
|
|
|
/* The exec file and the symbol-file are the same. If we can't
|
|
|
|
open it, better only print one error message.
|
2010-12-29 08:58:14 +08:00
|
|
|
catch_command_errors returns non-zero on success! */
|
2017-09-13 04:14:33 +08:00
|
|
|
if (catch_command_errors (exec_file_attach, execarg,
|
|
|
|
!batch_flag))
|
|
|
|
catch_command_errors (symbol_file_add_main_adapter, symarg,
|
|
|
|
!batch_flag);
|
1999-04-16 09:35:26 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (execarg != NULL)
|
2017-09-13 04:14:33 +08:00
|
|
|
catch_command_errors (exec_file_attach, execarg,
|
|
|
|
!batch_flag);
|
1999-04-16 09:35:26 +08:00
|
|
|
if (symarg != NULL)
|
2017-09-13 04:14:33 +08:00
|
|
|
catch_command_errors (symbol_file_add_main_adapter, symarg,
|
|
|
|
!batch_flag);
|
1999-04-16 09:35:26 +08:00
|
|
|
}
|
|
|
|
|
2008-01-06 00:49:53 +08:00
|
|
|
if (corearg && pidarg)
|
2011-01-06 06:22:53 +08:00
|
|
|
error (_("Can't attach to process and specify "
|
|
|
|
"a core file at the same time."));
|
2008-01-06 00:49:53 +08:00
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
if (corearg != NULL)
|
2015-02-09 22:59:10 +08:00
|
|
|
catch_command_errors (core_file_command, corearg, !batch_flag);
|
2008-01-06 00:49:53 +08:00
|
|
|
else if (pidarg != NULL)
|
2015-02-09 22:59:10 +08:00
|
|
|
catch_command_errors (attach_command, pidarg, !batch_flag);
|
2008-01-06 00:49:53 +08:00
|
|
|
else if (pid_or_core_arg)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
2008-01-06 00:49:53 +08:00
|
|
|
/* The user specified 'gdb program pid' or gdb program core'.
|
|
|
|
If pid_or_core_arg's first character is a digit, try attach
|
|
|
|
first and then corefile. Otherwise try just corefile. */
|
2002-01-11 07:03:08 +08:00
|
|
|
|
2008-01-06 00:49:53 +08:00
|
|
|
if (isdigit (pid_or_core_arg[0]))
|
1999-11-09 09:23:30 +08:00
|
|
|
{
|
2008-01-06 00:49:53 +08:00
|
|
|
if (catch_command_errors (attach_command, pid_or_core_arg,
|
2015-02-09 22:59:10 +08:00
|
|
|
!batch_flag) == 0)
|
2008-01-06 00:49:53 +08:00
|
|
|
catch_command_errors (core_file_command, pid_or_core_arg,
|
2015-02-09 22:59:10 +08:00
|
|
|
!batch_flag);
|
1999-11-09 09:23:30 +08:00
|
|
|
}
|
2008-01-06 00:49:53 +08:00
|
|
|
else /* Can't be a pid, better be a corefile. */
|
|
|
|
catch_command_errors (core_file_command, pid_or_core_arg,
|
2015-02-09 22:59:10 +08:00
|
|
|
!batch_flag);
|
1999-04-16 09:35:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ttyarg != NULL)
|
Per-inferior args and tty and environment.
* infcmd.c (inferior_args): Rename to ...
(inferior_args_scratch): ... this.
(inferior_io_terminal): Rename to ...
(inferior_io_terminal_scratch): ... this.
(inferior_argc, inferior_argv): Remove.
(set_inferior_io_terminal, get_inferior_io_terminal): Store
inside current_inferior().
(set_inferior_tty_command, show_inferior_tty_command): New.
(get_inferior_args, set_inferior_args): Store inside
current_inferior().
(notice_args_set): Likewise and rename to...
(set_args_command): ... this.
(set_inferior_args_vector): Likewise.
(notice_args_read): Rename to...
(show_args_command): ...new.
(tty_command): Remove.
(run_command_1): Don't free old args, as they are freed by
set_inferior_arg now.
(run_no_args_command): Likewise.
(inferior_environ): Remove.
(run_command_1): Use environment of the current inferior.
(environment_info, set_environment_command)
(unset_environment_command, path_info, path_command): Likewise.
(_initialize_infcmd): Adjust for function and variable renames.
Do not init inferior_environ.
* inferior.h (set_inferior_arg): Adjust prototype.
(struct inferior): New fields args, argc, argv, terminal, environment.
(inferior_environ): Remove declaration.
* inferior.c (free_inferior): Free new fields.
(add_inferior_silent): Initialize 'environment' field.
* main.c (captured_main): Set arguments only after the initial
inferior has been created. Set set_inferior_io_terminal,
not tty_command.
* mi/mi-main.c (mi_cmd_env_path): Use environment of the current
inferior.
(_initialize_mi_cmd_env): Adjust for disappearance of global
inferior_environ.
* solib.c (solib_find): Use environment of the current inferior.
2010-01-20 22:23:07 +08:00
|
|
|
set_inferior_io_terminal (ttyarg);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
/* Error messages should no longer be distinguished with extra output. */
|
2002-06-25 13:35:16 +08:00
|
|
|
warning_pre_print = _("warning: ");
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
/* Read the .gdbinit file in the current directory, *if* it isn't
|
|
|
|
the same as the $HOME/.gdbinit file (it should exist, also). */
|
gdb/
auto-load: Implementation.
* NEWS: New descriptions for "info auto-load",
"info auto-load gdb-scripts", "info auto-load python-scripts",
"info auto-load local-gdbinit" and "info auto-load libthread-db".
Deprecate "info auto-load-scripts", "set auto-load-scripts on|off"
and "show auto-load-scripts". New description for "set auto-load",
"show auto-load", "set auto-load gdb-scripts",
"show auto-load gdb-scripts", "set auto-load python-scripts",
"show auto-load python-scripts", "set auto-load local-gdbinit",
"show auto-load local-gdbinit", "set auto-load libthread-db" and
"show auto-load libthread-db".
* auto-load.c: Remove include python/python-internal.h. Add includes
exceptions.h, cli/cli-script.h, gdbcmd.h, cli/cli-decode.h and
cli/cli-setshow.h.
(GDB_AUTO_FILE_NAME, source_gdb_script_for_objfile)
(auto_load_gdb_scripts, show_auto_load_gdb_scripts): New.
(gdbpy_global_auto_load): Rename to ...
(global_auto_load): ... here.
(auto_load_local_gdbinit, auto_load_local_gdbinit_pathname)
(auto_load_local_gdbinit_loaded, show_auto_load_local_gdbinit)
(script_language_gdb, source_gdb_script_for_objfile): New.
(struct loaded_script): New field language.
(hash_loaded_script_entry, eq_loaded_script_entry): Calculate also
LANGUAGE.
(maybe_add_script): Add parameter language. Drop redundant
entry.full_path initialization. Initialize entry.language and
(*slot)->language.
(auto_load_objfile_script): Change parameter suffix to language.
Remove the call of maybe_add_script.
Call language->source_script_for_objfile.
(load_auto_scripts_for_objfile, struct collect_matching_scripts_data):
New.
(collect_matching_scripts): Adjust it for
struct collect_matching_scripts_data.
(auto_load_info_scripts_pattern_nl): New variable.
(info_auto_load_scripts): Rename to ...
(auto_load_info_scripts): ... here, add parameter language. Adjust it
for struct collect_matching_scripts_data.
(info_auto_load_gdb_scripts, info_auto_load_local_gdbinit)
(set_auto_load_cmd, auto_load_set_cmdlist_get, show_auto_load_cmd)
(auto_load_show_cmdlist_get, info_auto_load_cmd)
(auto_load_info_cmdlist_get): New.
(_initialize_auto_load): Move add_info of "auto-load-scripts" to
python/py-auto-load.c. New installment for "set auto-load gdb-scripts",
"info auto-load gdb-scripts", "set auto-load local-gdbinit" and
"info auto-load local-gdbinit".
* auto-load.h (struct script_language): New.
(gdbpy_global_auto_load): Rename to ...
(global_auto_load): ... here.
(auto_load_local_gdbinit, auto_load_local_gdbinit_pathname)
(auto_load_local_gdbinit_loaded): New declarations.
(maybe_add_script): New parameter language.
(auto_load_objfile_script): Change parameter suffix to language.
(load_auto_scripts_for_objfile, auto_load_info_scripts_pattern_nl)
(auto_load_info_scripts, auto_load_set_cmdlist_get)
(auto_load_show_cmdlist_get, auto_load_info_cmdlist_get): New
declarations.
* linux-thread-db.c: Include auto-load.h and ctype.h.
(auto_load_thread_db, show_auto_load_thread_db): New.
(struct thread_db_info): New field filename.
(delete_thread_db_info): Call xfree for FILENAME.
(try_thread_db_load): Initialize FILENAME.
(try_thread_db_load_from_pdir, try_thread_db_load_from_dir): Return
if !AUTO_LOAD_THREAD_DB.
(info_auto_load_libthread_db_compare, info_auto_load_libthread_db): New.
(_initialize_thread_db): Install auto_load_thread_db
as "set auto-load libthread-db" and install info_auto_load_libthread_db
as "info auto-load libthread-db".
* main.c (captured_main): Rename gdbpy_global_auto_load to
global_auto_load. Initialize AUTO_LOAD_LOCAL_GDBINIT_PATHNAME and
AUTO_LOAD_LOCAL_GDBINIT_LOADED.
(print_gdb_help): Extend the help for 'local init file'.
* python/py-auto-load.c: Remove a comment about gdb scripts extension.
(GDBPY_AUTO_SECTION_NAME): Extend the comment it is Python specific.
(auto_load_scripts): Rename to ...
(auto_load_python_scripts): ... here, update the comment.
(gdbpy_load_auto_script_for_objfile): New declaration.
(show_auto_load_python_scripts, script_language_python)
(gdbpy_load_auto_script_for_objfile): New.
(source_section_scripts): Refactor the code.
(load_auto_scripts_for_objfile): Rename to ...
(gdbpy_load_auto_scripts_for_objfile): ... here, update the
auto_load_objfile_script caller, drop GDBPY_GLOBAL_AUTO_LOAD checking.
(info_auto_load_python_scripts): New.
(gdbpy_initialize_auto_load): New variables cmd and cmd_name.
Rename "set auto-load-scripts" to "set auto-load python-scripts".
Register "set auto-load-scripts" as its deprecated alias. Register
"info auto-load python-scripts". Register "info auto-load-scripts" as
its deprecated alias.
(load_auto_scripts_for_objfile): Rename to ...
(gdbpy_load_auto_scripts_for_objfile): ... here.
* python/python.h (load_auto_scripts_for_objfile): Rename to ...
(gdbpy_load_auto_scripts_for_objfile): ... here.
gdb/doc/
auto-load: Implementation.
* gdb.texinfo (Mode Options): New anchor for -nx.
(Startup): New anchors for Option -init-eval-command,
Home Directory Init File
and Init File in the Current Directory during Startup.
Mention set auto-load local-gdbinit with a reference.
Change the sample code to "set auto-load python-scripts".
(Threads): New anchor set libthread-db-search-path.
Provide references to libthread_db.so.1 file.
(Controlling GDB): New menu item for Auto-loading.
(Auto-loading, Init File in the Current Directory)
(libthread_db.so.1 file, objfile-gdb.gdb file): New nodes.
(Python): Rename the menu item Auto-loading to Python Auto-loading.
(Writing a Pretty-Printer, Objfiles In Python): Update the renamed
reference.
(Auto-loading): Rename to ...
(Python Auto-loading): ... here. Change "set auto-load-scripts" to
"set auto-load python-scripts", new anchor for it. Change
"show auto-load-scripts" to "show auto-load python-scripts", new anchor
for it. Change "info auto-load-scripts"
to "info auto-load python-scripts", new anchor for it. Change "scripts"
to "Python scripts".
gdb/testsuite/
auto-load: Implementation.
* gdb.base/help.exp (test set height): Increase the height.
* gdb.python/py-objfile-script.exp (info auto-load-scripts): Change
to ...
(info auto-load python-scripts): ... here.
* gdb.python/py-section-script.exp (info auto-load-scripts *): Change
to ...
(info auto-load python-scripts *): ... here.
2012-04-17 23:51:48 +08:00
|
|
|
if (local_gdbinit)
|
|
|
|
{
|
2017-08-04 06:53:22 +08:00
|
|
|
auto_load_local_gdbinit_pathname
|
|
|
|
= gdb_realpath (local_gdbinit).release ();
|
gdb/
auto-load: Implementation.
* NEWS: New descriptions for "info auto-load",
"info auto-load gdb-scripts", "info auto-load python-scripts",
"info auto-load local-gdbinit" and "info auto-load libthread-db".
Deprecate "info auto-load-scripts", "set auto-load-scripts on|off"
and "show auto-load-scripts". New description for "set auto-load",
"show auto-load", "set auto-load gdb-scripts",
"show auto-load gdb-scripts", "set auto-load python-scripts",
"show auto-load python-scripts", "set auto-load local-gdbinit",
"show auto-load local-gdbinit", "set auto-load libthread-db" and
"show auto-load libthread-db".
* auto-load.c: Remove include python/python-internal.h. Add includes
exceptions.h, cli/cli-script.h, gdbcmd.h, cli/cli-decode.h and
cli/cli-setshow.h.
(GDB_AUTO_FILE_NAME, source_gdb_script_for_objfile)
(auto_load_gdb_scripts, show_auto_load_gdb_scripts): New.
(gdbpy_global_auto_load): Rename to ...
(global_auto_load): ... here.
(auto_load_local_gdbinit, auto_load_local_gdbinit_pathname)
(auto_load_local_gdbinit_loaded, show_auto_load_local_gdbinit)
(script_language_gdb, source_gdb_script_for_objfile): New.
(struct loaded_script): New field language.
(hash_loaded_script_entry, eq_loaded_script_entry): Calculate also
LANGUAGE.
(maybe_add_script): Add parameter language. Drop redundant
entry.full_path initialization. Initialize entry.language and
(*slot)->language.
(auto_load_objfile_script): Change parameter suffix to language.
Remove the call of maybe_add_script.
Call language->source_script_for_objfile.
(load_auto_scripts_for_objfile, struct collect_matching_scripts_data):
New.
(collect_matching_scripts): Adjust it for
struct collect_matching_scripts_data.
(auto_load_info_scripts_pattern_nl): New variable.
(info_auto_load_scripts): Rename to ...
(auto_load_info_scripts): ... here, add parameter language. Adjust it
for struct collect_matching_scripts_data.
(info_auto_load_gdb_scripts, info_auto_load_local_gdbinit)
(set_auto_load_cmd, auto_load_set_cmdlist_get, show_auto_load_cmd)
(auto_load_show_cmdlist_get, info_auto_load_cmd)
(auto_load_info_cmdlist_get): New.
(_initialize_auto_load): Move add_info of "auto-load-scripts" to
python/py-auto-load.c. New installment for "set auto-load gdb-scripts",
"info auto-load gdb-scripts", "set auto-load local-gdbinit" and
"info auto-load local-gdbinit".
* auto-load.h (struct script_language): New.
(gdbpy_global_auto_load): Rename to ...
(global_auto_load): ... here.
(auto_load_local_gdbinit, auto_load_local_gdbinit_pathname)
(auto_load_local_gdbinit_loaded): New declarations.
(maybe_add_script): New parameter language.
(auto_load_objfile_script): Change parameter suffix to language.
(load_auto_scripts_for_objfile, auto_load_info_scripts_pattern_nl)
(auto_load_info_scripts, auto_load_set_cmdlist_get)
(auto_load_show_cmdlist_get, auto_load_info_cmdlist_get): New
declarations.
* linux-thread-db.c: Include auto-load.h and ctype.h.
(auto_load_thread_db, show_auto_load_thread_db): New.
(struct thread_db_info): New field filename.
(delete_thread_db_info): Call xfree for FILENAME.
(try_thread_db_load): Initialize FILENAME.
(try_thread_db_load_from_pdir, try_thread_db_load_from_dir): Return
if !AUTO_LOAD_THREAD_DB.
(info_auto_load_libthread_db_compare, info_auto_load_libthread_db): New.
(_initialize_thread_db): Install auto_load_thread_db
as "set auto-load libthread-db" and install info_auto_load_libthread_db
as "info auto-load libthread-db".
* main.c (captured_main): Rename gdbpy_global_auto_load to
global_auto_load. Initialize AUTO_LOAD_LOCAL_GDBINIT_PATHNAME and
AUTO_LOAD_LOCAL_GDBINIT_LOADED.
(print_gdb_help): Extend the help for 'local init file'.
* python/py-auto-load.c: Remove a comment about gdb scripts extension.
(GDBPY_AUTO_SECTION_NAME): Extend the comment it is Python specific.
(auto_load_scripts): Rename to ...
(auto_load_python_scripts): ... here, update the comment.
(gdbpy_load_auto_script_for_objfile): New declaration.
(show_auto_load_python_scripts, script_language_python)
(gdbpy_load_auto_script_for_objfile): New.
(source_section_scripts): Refactor the code.
(load_auto_scripts_for_objfile): Rename to ...
(gdbpy_load_auto_scripts_for_objfile): ... here, update the
auto_load_objfile_script caller, drop GDBPY_GLOBAL_AUTO_LOAD checking.
(info_auto_load_python_scripts): New.
(gdbpy_initialize_auto_load): New variables cmd and cmd_name.
Rename "set auto-load-scripts" to "set auto-load python-scripts".
Register "set auto-load-scripts" as its deprecated alias. Register
"info auto-load python-scripts". Register "info auto-load-scripts" as
its deprecated alias.
(load_auto_scripts_for_objfile): Rename to ...
(gdbpy_load_auto_scripts_for_objfile): ... here.
* python/python.h (load_auto_scripts_for_objfile): Rename to ...
(gdbpy_load_auto_scripts_for_objfile): ... here.
gdb/doc/
auto-load: Implementation.
* gdb.texinfo (Mode Options): New anchor for -nx.
(Startup): New anchors for Option -init-eval-command,
Home Directory Init File
and Init File in the Current Directory during Startup.
Mention set auto-load local-gdbinit with a reference.
Change the sample code to "set auto-load python-scripts".
(Threads): New anchor set libthread-db-search-path.
Provide references to libthread_db.so.1 file.
(Controlling GDB): New menu item for Auto-loading.
(Auto-loading, Init File in the Current Directory)
(libthread_db.so.1 file, objfile-gdb.gdb file): New nodes.
(Python): Rename the menu item Auto-loading to Python Auto-loading.
(Writing a Pretty-Printer, Objfiles In Python): Update the renamed
reference.
(Auto-loading): Rename to ...
(Python Auto-loading): ... here. Change "set auto-load-scripts" to
"set auto-load python-scripts", new anchor for it. Change
"show auto-load-scripts" to "show auto-load python-scripts", new anchor
for it. Change "info auto-load-scripts"
to "info auto-load python-scripts", new anchor for it. Change "scripts"
to "Python scripts".
gdb/testsuite/
auto-load: Implementation.
* gdb.base/help.exp (test set height): Increase the height.
* gdb.python/py-objfile-script.exp (info auto-load-scripts): Change
to ...
(info auto-load python-scripts): ... here.
* gdb.python/py-section-script.exp (info auto-load-scripts *): Change
to ...
(info auto-load python-scripts *): ... here.
2012-04-17 23:51:48 +08:00
|
|
|
|
2012-04-17 23:54:35 +08:00
|
|
|
if (!inhibit_gdbinit && auto_load_local_gdbinit
|
2012-04-17 23:56:21 +08:00
|
|
|
&& file_is_auto_load_safe (local_gdbinit,
|
|
|
|
_("auto-load: Loading .gdbinit "
|
|
|
|
"file \"%s\".\n"),
|
|
|
|
local_gdbinit))
|
gdb/
auto-load: Implementation.
* NEWS: New descriptions for "info auto-load",
"info auto-load gdb-scripts", "info auto-load python-scripts",
"info auto-load local-gdbinit" and "info auto-load libthread-db".
Deprecate "info auto-load-scripts", "set auto-load-scripts on|off"
and "show auto-load-scripts". New description for "set auto-load",
"show auto-load", "set auto-load gdb-scripts",
"show auto-load gdb-scripts", "set auto-load python-scripts",
"show auto-load python-scripts", "set auto-load local-gdbinit",
"show auto-load local-gdbinit", "set auto-load libthread-db" and
"show auto-load libthread-db".
* auto-load.c: Remove include python/python-internal.h. Add includes
exceptions.h, cli/cli-script.h, gdbcmd.h, cli/cli-decode.h and
cli/cli-setshow.h.
(GDB_AUTO_FILE_NAME, source_gdb_script_for_objfile)
(auto_load_gdb_scripts, show_auto_load_gdb_scripts): New.
(gdbpy_global_auto_load): Rename to ...
(global_auto_load): ... here.
(auto_load_local_gdbinit, auto_load_local_gdbinit_pathname)
(auto_load_local_gdbinit_loaded, show_auto_load_local_gdbinit)
(script_language_gdb, source_gdb_script_for_objfile): New.
(struct loaded_script): New field language.
(hash_loaded_script_entry, eq_loaded_script_entry): Calculate also
LANGUAGE.
(maybe_add_script): Add parameter language. Drop redundant
entry.full_path initialization. Initialize entry.language and
(*slot)->language.
(auto_load_objfile_script): Change parameter suffix to language.
Remove the call of maybe_add_script.
Call language->source_script_for_objfile.
(load_auto_scripts_for_objfile, struct collect_matching_scripts_data):
New.
(collect_matching_scripts): Adjust it for
struct collect_matching_scripts_data.
(auto_load_info_scripts_pattern_nl): New variable.
(info_auto_load_scripts): Rename to ...
(auto_load_info_scripts): ... here, add parameter language. Adjust it
for struct collect_matching_scripts_data.
(info_auto_load_gdb_scripts, info_auto_load_local_gdbinit)
(set_auto_load_cmd, auto_load_set_cmdlist_get, show_auto_load_cmd)
(auto_load_show_cmdlist_get, info_auto_load_cmd)
(auto_load_info_cmdlist_get): New.
(_initialize_auto_load): Move add_info of "auto-load-scripts" to
python/py-auto-load.c. New installment for "set auto-load gdb-scripts",
"info auto-load gdb-scripts", "set auto-load local-gdbinit" and
"info auto-load local-gdbinit".
* auto-load.h (struct script_language): New.
(gdbpy_global_auto_load): Rename to ...
(global_auto_load): ... here.
(auto_load_local_gdbinit, auto_load_local_gdbinit_pathname)
(auto_load_local_gdbinit_loaded): New declarations.
(maybe_add_script): New parameter language.
(auto_load_objfile_script): Change parameter suffix to language.
(load_auto_scripts_for_objfile, auto_load_info_scripts_pattern_nl)
(auto_load_info_scripts, auto_load_set_cmdlist_get)
(auto_load_show_cmdlist_get, auto_load_info_cmdlist_get): New
declarations.
* linux-thread-db.c: Include auto-load.h and ctype.h.
(auto_load_thread_db, show_auto_load_thread_db): New.
(struct thread_db_info): New field filename.
(delete_thread_db_info): Call xfree for FILENAME.
(try_thread_db_load): Initialize FILENAME.
(try_thread_db_load_from_pdir, try_thread_db_load_from_dir): Return
if !AUTO_LOAD_THREAD_DB.
(info_auto_load_libthread_db_compare, info_auto_load_libthread_db): New.
(_initialize_thread_db): Install auto_load_thread_db
as "set auto-load libthread-db" and install info_auto_load_libthread_db
as "info auto-load libthread-db".
* main.c (captured_main): Rename gdbpy_global_auto_load to
global_auto_load. Initialize AUTO_LOAD_LOCAL_GDBINIT_PATHNAME and
AUTO_LOAD_LOCAL_GDBINIT_LOADED.
(print_gdb_help): Extend the help for 'local init file'.
* python/py-auto-load.c: Remove a comment about gdb scripts extension.
(GDBPY_AUTO_SECTION_NAME): Extend the comment it is Python specific.
(auto_load_scripts): Rename to ...
(auto_load_python_scripts): ... here, update the comment.
(gdbpy_load_auto_script_for_objfile): New declaration.
(show_auto_load_python_scripts, script_language_python)
(gdbpy_load_auto_script_for_objfile): New.
(source_section_scripts): Refactor the code.
(load_auto_scripts_for_objfile): Rename to ...
(gdbpy_load_auto_scripts_for_objfile): ... here, update the
auto_load_objfile_script caller, drop GDBPY_GLOBAL_AUTO_LOAD checking.
(info_auto_load_python_scripts): New.
(gdbpy_initialize_auto_load): New variables cmd and cmd_name.
Rename "set auto-load-scripts" to "set auto-load python-scripts".
Register "set auto-load-scripts" as its deprecated alias. Register
"info auto-load python-scripts". Register "info auto-load-scripts" as
its deprecated alias.
(load_auto_scripts_for_objfile): Rename to ...
(gdbpy_load_auto_scripts_for_objfile): ... here.
* python/python.h (load_auto_scripts_for_objfile): Rename to ...
(gdbpy_load_auto_scripts_for_objfile): ... here.
gdb/doc/
auto-load: Implementation.
* gdb.texinfo (Mode Options): New anchor for -nx.
(Startup): New anchors for Option -init-eval-command,
Home Directory Init File
and Init File in the Current Directory during Startup.
Mention set auto-load local-gdbinit with a reference.
Change the sample code to "set auto-load python-scripts".
(Threads): New anchor set libthread-db-search-path.
Provide references to libthread_db.so.1 file.
(Controlling GDB): New menu item for Auto-loading.
(Auto-loading, Init File in the Current Directory)
(libthread_db.so.1 file, objfile-gdb.gdb file): New nodes.
(Python): Rename the menu item Auto-loading to Python Auto-loading.
(Writing a Pretty-Printer, Objfiles In Python): Update the renamed
reference.
(Auto-loading): Rename to ...
(Python Auto-loading): ... here. Change "set auto-load-scripts" to
"set auto-load python-scripts", new anchor for it. Change
"show auto-load-scripts" to "show auto-load python-scripts", new anchor
for it. Change "info auto-load-scripts"
to "info auto-load python-scripts", new anchor for it. Change "scripts"
to "Python scripts".
gdb/testsuite/
auto-load: Implementation.
* gdb.base/help.exp (test set height): Increase the height.
* gdb.python/py-objfile-script.exp (info auto-load-scripts): Change
to ...
(info auto-load python-scripts): ... here.
* gdb.python/py-section-script.exp (info auto-load-scripts *): Change
to ...
(info auto-load python-scripts *): ... here.
2012-04-17 23:51:48 +08:00
|
|
|
{
|
|
|
|
auto_load_local_gdbinit_loaded = 1;
|
|
|
|
|
2017-09-13 04:14:33 +08:00
|
|
|
catch_command_errors (source_script, local_gdbinit, 0);
|
gdb/
auto-load: Implementation.
* NEWS: New descriptions for "info auto-load",
"info auto-load gdb-scripts", "info auto-load python-scripts",
"info auto-load local-gdbinit" and "info auto-load libthread-db".
Deprecate "info auto-load-scripts", "set auto-load-scripts on|off"
and "show auto-load-scripts". New description for "set auto-load",
"show auto-load", "set auto-load gdb-scripts",
"show auto-load gdb-scripts", "set auto-load python-scripts",
"show auto-load python-scripts", "set auto-load local-gdbinit",
"show auto-load local-gdbinit", "set auto-load libthread-db" and
"show auto-load libthread-db".
* auto-load.c: Remove include python/python-internal.h. Add includes
exceptions.h, cli/cli-script.h, gdbcmd.h, cli/cli-decode.h and
cli/cli-setshow.h.
(GDB_AUTO_FILE_NAME, source_gdb_script_for_objfile)
(auto_load_gdb_scripts, show_auto_load_gdb_scripts): New.
(gdbpy_global_auto_load): Rename to ...
(global_auto_load): ... here.
(auto_load_local_gdbinit, auto_load_local_gdbinit_pathname)
(auto_load_local_gdbinit_loaded, show_auto_load_local_gdbinit)
(script_language_gdb, source_gdb_script_for_objfile): New.
(struct loaded_script): New field language.
(hash_loaded_script_entry, eq_loaded_script_entry): Calculate also
LANGUAGE.
(maybe_add_script): Add parameter language. Drop redundant
entry.full_path initialization. Initialize entry.language and
(*slot)->language.
(auto_load_objfile_script): Change parameter suffix to language.
Remove the call of maybe_add_script.
Call language->source_script_for_objfile.
(load_auto_scripts_for_objfile, struct collect_matching_scripts_data):
New.
(collect_matching_scripts): Adjust it for
struct collect_matching_scripts_data.
(auto_load_info_scripts_pattern_nl): New variable.
(info_auto_load_scripts): Rename to ...
(auto_load_info_scripts): ... here, add parameter language. Adjust it
for struct collect_matching_scripts_data.
(info_auto_load_gdb_scripts, info_auto_load_local_gdbinit)
(set_auto_load_cmd, auto_load_set_cmdlist_get, show_auto_load_cmd)
(auto_load_show_cmdlist_get, info_auto_load_cmd)
(auto_load_info_cmdlist_get): New.
(_initialize_auto_load): Move add_info of "auto-load-scripts" to
python/py-auto-load.c. New installment for "set auto-load gdb-scripts",
"info auto-load gdb-scripts", "set auto-load local-gdbinit" and
"info auto-load local-gdbinit".
* auto-load.h (struct script_language): New.
(gdbpy_global_auto_load): Rename to ...
(global_auto_load): ... here.
(auto_load_local_gdbinit, auto_load_local_gdbinit_pathname)
(auto_load_local_gdbinit_loaded): New declarations.
(maybe_add_script): New parameter language.
(auto_load_objfile_script): Change parameter suffix to language.
(load_auto_scripts_for_objfile, auto_load_info_scripts_pattern_nl)
(auto_load_info_scripts, auto_load_set_cmdlist_get)
(auto_load_show_cmdlist_get, auto_load_info_cmdlist_get): New
declarations.
* linux-thread-db.c: Include auto-load.h and ctype.h.
(auto_load_thread_db, show_auto_load_thread_db): New.
(struct thread_db_info): New field filename.
(delete_thread_db_info): Call xfree for FILENAME.
(try_thread_db_load): Initialize FILENAME.
(try_thread_db_load_from_pdir, try_thread_db_load_from_dir): Return
if !AUTO_LOAD_THREAD_DB.
(info_auto_load_libthread_db_compare, info_auto_load_libthread_db): New.
(_initialize_thread_db): Install auto_load_thread_db
as "set auto-load libthread-db" and install info_auto_load_libthread_db
as "info auto-load libthread-db".
* main.c (captured_main): Rename gdbpy_global_auto_load to
global_auto_load. Initialize AUTO_LOAD_LOCAL_GDBINIT_PATHNAME and
AUTO_LOAD_LOCAL_GDBINIT_LOADED.
(print_gdb_help): Extend the help for 'local init file'.
* python/py-auto-load.c: Remove a comment about gdb scripts extension.
(GDBPY_AUTO_SECTION_NAME): Extend the comment it is Python specific.
(auto_load_scripts): Rename to ...
(auto_load_python_scripts): ... here, update the comment.
(gdbpy_load_auto_script_for_objfile): New declaration.
(show_auto_load_python_scripts, script_language_python)
(gdbpy_load_auto_script_for_objfile): New.
(source_section_scripts): Refactor the code.
(load_auto_scripts_for_objfile): Rename to ...
(gdbpy_load_auto_scripts_for_objfile): ... here, update the
auto_load_objfile_script caller, drop GDBPY_GLOBAL_AUTO_LOAD checking.
(info_auto_load_python_scripts): New.
(gdbpy_initialize_auto_load): New variables cmd and cmd_name.
Rename "set auto-load-scripts" to "set auto-load python-scripts".
Register "set auto-load-scripts" as its deprecated alias. Register
"info auto-load python-scripts". Register "info auto-load-scripts" as
its deprecated alias.
(load_auto_scripts_for_objfile): Rename to ...
(gdbpy_load_auto_scripts_for_objfile): ... here.
* python/python.h (load_auto_scripts_for_objfile): Rename to ...
(gdbpy_load_auto_scripts_for_objfile): ... here.
gdb/doc/
auto-load: Implementation.
* gdb.texinfo (Mode Options): New anchor for -nx.
(Startup): New anchors for Option -init-eval-command,
Home Directory Init File
and Init File in the Current Directory during Startup.
Mention set auto-load local-gdbinit with a reference.
Change the sample code to "set auto-load python-scripts".
(Threads): New anchor set libthread-db-search-path.
Provide references to libthread_db.so.1 file.
(Controlling GDB): New menu item for Auto-loading.
(Auto-loading, Init File in the Current Directory)
(libthread_db.so.1 file, objfile-gdb.gdb file): New nodes.
(Python): Rename the menu item Auto-loading to Python Auto-loading.
(Writing a Pretty-Printer, Objfiles In Python): Update the renamed
reference.
(Auto-loading): Rename to ...
(Python Auto-loading): ... here. Change "set auto-load-scripts" to
"set auto-load python-scripts", new anchor for it. Change
"show auto-load-scripts" to "show auto-load python-scripts", new anchor
for it. Change "info auto-load-scripts"
to "info auto-load python-scripts", new anchor for it. Change "scripts"
to "Python scripts".
gdb/testsuite/
auto-load: Implementation.
* gdb.base/help.exp (test set height): Increase the height.
* gdb.python/py-objfile-script.exp (info auto-load-scripts): Change
to ...
(info auto-load python-scripts): ... here.
* gdb.python/py-section-script.exp (info auto-load-scripts *): Change
to ...
(info auto-load python-scripts *): ... here.
2012-04-17 23:51:48 +08:00
|
|
|
}
|
|
|
|
}
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2010-04-24 02:09:16 +08:00
|
|
|
/* Now that all .gdbinit's have been read and all -d options have been
|
|
|
|
processed, we can read any scripts mentioned in SYMARG.
|
|
|
|
We wait until now because it is common to add to the source search
|
|
|
|
path in local_gdbinit. */
|
gdb/
auto-load: Implementation.
* NEWS: New descriptions for "info auto-load",
"info auto-load gdb-scripts", "info auto-load python-scripts",
"info auto-load local-gdbinit" and "info auto-load libthread-db".
Deprecate "info auto-load-scripts", "set auto-load-scripts on|off"
and "show auto-load-scripts". New description for "set auto-load",
"show auto-load", "set auto-load gdb-scripts",
"show auto-load gdb-scripts", "set auto-load python-scripts",
"show auto-load python-scripts", "set auto-load local-gdbinit",
"show auto-load local-gdbinit", "set auto-load libthread-db" and
"show auto-load libthread-db".
* auto-load.c: Remove include python/python-internal.h. Add includes
exceptions.h, cli/cli-script.h, gdbcmd.h, cli/cli-decode.h and
cli/cli-setshow.h.
(GDB_AUTO_FILE_NAME, source_gdb_script_for_objfile)
(auto_load_gdb_scripts, show_auto_load_gdb_scripts): New.
(gdbpy_global_auto_load): Rename to ...
(global_auto_load): ... here.
(auto_load_local_gdbinit, auto_load_local_gdbinit_pathname)
(auto_load_local_gdbinit_loaded, show_auto_load_local_gdbinit)
(script_language_gdb, source_gdb_script_for_objfile): New.
(struct loaded_script): New field language.
(hash_loaded_script_entry, eq_loaded_script_entry): Calculate also
LANGUAGE.
(maybe_add_script): Add parameter language. Drop redundant
entry.full_path initialization. Initialize entry.language and
(*slot)->language.
(auto_load_objfile_script): Change parameter suffix to language.
Remove the call of maybe_add_script.
Call language->source_script_for_objfile.
(load_auto_scripts_for_objfile, struct collect_matching_scripts_data):
New.
(collect_matching_scripts): Adjust it for
struct collect_matching_scripts_data.
(auto_load_info_scripts_pattern_nl): New variable.
(info_auto_load_scripts): Rename to ...
(auto_load_info_scripts): ... here, add parameter language. Adjust it
for struct collect_matching_scripts_data.
(info_auto_load_gdb_scripts, info_auto_load_local_gdbinit)
(set_auto_load_cmd, auto_load_set_cmdlist_get, show_auto_load_cmd)
(auto_load_show_cmdlist_get, info_auto_load_cmd)
(auto_load_info_cmdlist_get): New.
(_initialize_auto_load): Move add_info of "auto-load-scripts" to
python/py-auto-load.c. New installment for "set auto-load gdb-scripts",
"info auto-load gdb-scripts", "set auto-load local-gdbinit" and
"info auto-load local-gdbinit".
* auto-load.h (struct script_language): New.
(gdbpy_global_auto_load): Rename to ...
(global_auto_load): ... here.
(auto_load_local_gdbinit, auto_load_local_gdbinit_pathname)
(auto_load_local_gdbinit_loaded): New declarations.
(maybe_add_script): New parameter language.
(auto_load_objfile_script): Change parameter suffix to language.
(load_auto_scripts_for_objfile, auto_load_info_scripts_pattern_nl)
(auto_load_info_scripts, auto_load_set_cmdlist_get)
(auto_load_show_cmdlist_get, auto_load_info_cmdlist_get): New
declarations.
* linux-thread-db.c: Include auto-load.h and ctype.h.
(auto_load_thread_db, show_auto_load_thread_db): New.
(struct thread_db_info): New field filename.
(delete_thread_db_info): Call xfree for FILENAME.
(try_thread_db_load): Initialize FILENAME.
(try_thread_db_load_from_pdir, try_thread_db_load_from_dir): Return
if !AUTO_LOAD_THREAD_DB.
(info_auto_load_libthread_db_compare, info_auto_load_libthread_db): New.
(_initialize_thread_db): Install auto_load_thread_db
as "set auto-load libthread-db" and install info_auto_load_libthread_db
as "info auto-load libthread-db".
* main.c (captured_main): Rename gdbpy_global_auto_load to
global_auto_load. Initialize AUTO_LOAD_LOCAL_GDBINIT_PATHNAME and
AUTO_LOAD_LOCAL_GDBINIT_LOADED.
(print_gdb_help): Extend the help for 'local init file'.
* python/py-auto-load.c: Remove a comment about gdb scripts extension.
(GDBPY_AUTO_SECTION_NAME): Extend the comment it is Python specific.
(auto_load_scripts): Rename to ...
(auto_load_python_scripts): ... here, update the comment.
(gdbpy_load_auto_script_for_objfile): New declaration.
(show_auto_load_python_scripts, script_language_python)
(gdbpy_load_auto_script_for_objfile): New.
(source_section_scripts): Refactor the code.
(load_auto_scripts_for_objfile): Rename to ...
(gdbpy_load_auto_scripts_for_objfile): ... here, update the
auto_load_objfile_script caller, drop GDBPY_GLOBAL_AUTO_LOAD checking.
(info_auto_load_python_scripts): New.
(gdbpy_initialize_auto_load): New variables cmd and cmd_name.
Rename "set auto-load-scripts" to "set auto-load python-scripts".
Register "set auto-load-scripts" as its deprecated alias. Register
"info auto-load python-scripts". Register "info auto-load-scripts" as
its deprecated alias.
(load_auto_scripts_for_objfile): Rename to ...
(gdbpy_load_auto_scripts_for_objfile): ... here.
* python/python.h (load_auto_scripts_for_objfile): Rename to ...
(gdbpy_load_auto_scripts_for_objfile): ... here.
gdb/doc/
auto-load: Implementation.
* gdb.texinfo (Mode Options): New anchor for -nx.
(Startup): New anchors for Option -init-eval-command,
Home Directory Init File
and Init File in the Current Directory during Startup.
Mention set auto-load local-gdbinit with a reference.
Change the sample code to "set auto-load python-scripts".
(Threads): New anchor set libthread-db-search-path.
Provide references to libthread_db.so.1 file.
(Controlling GDB): New menu item for Auto-loading.
(Auto-loading, Init File in the Current Directory)
(libthread_db.so.1 file, objfile-gdb.gdb file): New nodes.
(Python): Rename the menu item Auto-loading to Python Auto-loading.
(Writing a Pretty-Printer, Objfiles In Python): Update the renamed
reference.
(Auto-loading): Rename to ...
(Python Auto-loading): ... here. Change "set auto-load-scripts" to
"set auto-load python-scripts", new anchor for it. Change
"show auto-load-scripts" to "show auto-load python-scripts", new anchor
for it. Change "info auto-load-scripts"
to "info auto-load python-scripts", new anchor for it. Change "scripts"
to "Python scripts".
gdb/testsuite/
auto-load: Implementation.
* gdb.base/help.exp (test set height): Increase the height.
* gdb.python/py-objfile-script.exp (info auto-load-scripts): Change
to ...
(info auto-load python-scripts): ... here.
* gdb.python/py-section-script.exp (info auto-load-scripts *): Change
to ...
(info auto-load python-scripts *): ... here.
2012-04-17 23:51:48 +08:00
|
|
|
global_auto_load = save_auto_load;
|
2010-09-23 03:59:15 +08:00
|
|
|
ALL_OBJFILES (objfile)
|
|
|
|
load_auto_scripts_for_objfile (objfile);
|
2010-04-24 02:09:16 +08:00
|
|
|
|
2012-03-20 02:19:26 +08:00
|
|
|
/* Process '-x' and '-ex' options. */
|
2016-10-12 10:02:23 +08:00
|
|
|
for (i = 0; i < cmdarg_vec.size (); i++)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
2016-10-12 10:02:23 +08:00
|
|
|
const struct cmdarg &cmdarg_p = cmdarg_vec[i];
|
|
|
|
|
|
|
|
switch (cmdarg_p.type)
|
|
|
|
{
|
|
|
|
case CMDARG_FILE:
|
2017-09-13 04:14:33 +08:00
|
|
|
catch_command_errors (source_script, cmdarg_p.string,
|
|
|
|
!batch_flag);
|
2016-10-12 10:02:23 +08:00
|
|
|
break;
|
|
|
|
case CMDARG_COMMAND:
|
|
|
|
catch_command_errors (execute_command, cmdarg_p.string,
|
|
|
|
!batch_flag);
|
|
|
|
break;
|
|
|
|
}
|
1999-04-16 09:35:26 +08:00
|
|
|
}
|
|
|
|
|
2010-12-29 08:58:14 +08:00
|
|
|
/* Read in the old history after all the command files have been
|
|
|
|
read. */
|
1999-07-08 04:19:36 +08:00
|
|
|
init_history ();
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2010-03-09 03:20:38 +08:00
|
|
|
if (batch_flag)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
|
|
|
/* We have hit the end of the batch file. */
|
2005-11-04 19:49:12 +08:00
|
|
|
quit_force (NULL, 0);
|
1999-04-16 09:35:26 +08:00
|
|
|
}
|
2016-09-25 11:10:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
captured_main (void *data)
|
|
|
|
{
|
|
|
|
struct captured_main_args *context = (struct captured_main_args *) data;
|
|
|
|
|
|
|
|
captured_main_1 (context);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
1999-11-09 09:23:30 +08:00
|
|
|
/* NOTE: cagney/1999-11-07: There is probably no reason for not
|
|
|
|
moving this loop and the code found in captured_command_loop()
|
|
|
|
into the command_loop() proper. The main thing holding back that
|
2010-12-29 08:58:14 +08:00
|
|
|
change - SET_TOP_LEVEL() - has been eliminated. */
|
1999-11-09 09:23:30 +08:00
|
|
|
while (1)
|
|
|
|
{
|
Eliminate catch_errors
If you want to use catch_errors with a function with parameters, then
currently you have to manually write a "capture" struct wrapping the
arguments and marshall/unmarshall that.
https://sourceware.org/ml/gdb-patches/2017-09/msg00834.html proposed
adjusting catch_errors to use gdb::function_view, which would allow
passing lambdas with automatic captures. However, it seems like using
TRY/CATCH directly instead ends up producing clearer and easier to
debug code. This is what this commit does.
Note that removing catch_errors exposes further cleanup opportunities
around no longer having to follow catch_errors callback type, and also
removes a few cleanups.
I didn't do anything to save/restore current_uiout because I think
that should be the responsibility of the code that changes
current_uiout in the first place.
(Another approach could be to make catch_errors a variadic template
like:
template<typename Function, typename... Args>
int catch_errors (const char *errstring, return_mask mask,
Function &&func, Args... args);
and then with:
extern void function_with_args (int, int);
extern void function_with_no_args ();
calls to the above functions would be wrapped like this:
catch_errors ("some error happened", RETURN_MASK_ERROR,
function_with_args, arg1, arg2);
catch_errors ("some error happened", RETURN_MASK_ERROR,
function_with_no_args);
but I'm thinking that that doesn't improve much if at all either.)
gdb/ChangeLog
2017-10-10 Pedro Alves <palves@redhat.com>
Tom Tromey <tom@tromey.com>
* breakpoint.c (breakpoint_cond_eval): Change return type to bool
and reverse logic.
(WP_DELETED, WP_VALUE_CHANGED, WP_VALUE_NOT_CHANGED, WP_IGNORE):
No longer macros. Instead ...
(enum wp_check_result): They're now values of this new
enumeration.
(watchpoint_check): Change return type to wp_check_result and
parameter type to bpstat.
(bpstat_check_watchpoint): Use TRY/CATCH instead of catch_errors.
(bpstat_check_breakpoint_conditions): Use TRY/CATCH instead of
catch_errors. Reverse logic of watchpoint_check call.
(breakpoint_re_set_one): Now returns void and takes a breakpoint
pointer as parameter.
(breakpoint_re_set): Use TRY/CATCH instead of catch_errors.
* common/common-exceptions.c (throw_exception_sjlj): Update
comments to avoid mentioning catch_errors.
* exceptions.c (catch_errors): Delete.
* exceptions.h: Update comments to avoid mentioning catch_errors.
(catch_errors_ftype, catch_errors): Delete.
* infrun.c (normal_stop): Use TRY/CATCH instead of catch_errors.
(hook_stop_stub): Delete.
(restore_selected_frame): Change return type to void, and
parameter type to const frame_id &.
(restore_infcall_control_state): Use TRY/CATCH instead of
catch_errors.
* main.c (captured_command_loop): Return void and remove
parameter. Remove references to catch_errors.
(captured_main): Use TRY/CATCH instead of catch_errors.
* objc-lang.c (objc_submethod_helper_data)
(find_objc_msgcall_submethod_helper): Delete.
(find_objc_msgcall_submethod): Use TRY/CATCH instead of
catch_errors.
* record-full.c (record_full_message): Return void.
(record_full_message_args, record_full_message_wrapper): Delete.
(record_full_message_wrapper_safe): Return bool and use TRY/CATCH
instead of catch_errors.
* solib-aix.c (solib_aix_open_symbol_file_object): Change
parameter type to int.
* solib-darwin.c (open_symbol_file_object): Ditto.
* solib-dsbt.c (open_symbol_file_object): Ditto.
* solib-frv.c (open_symbol_file_object): Ditto.
* solib-svr4.c (open_symbol_file_object): Ditto.
* solib-target.c (solib_target_open_symbol_file_object): Ditto.
* solib.c (update_solib_list): Use TRY/CATCH instead of
catch_errors.
* solist.h (struct target_so_ops) <open_symbol_file_object>:
Change type.
* symmisc.c (struct print_symbol_args): Remove.
(dump_symtab_1): Use TRY/CATCH instead of catch_errors.
(print_symbol): Change type.
* windows-nat.c (handle_load_dll, handle_unload_dll): Return void
and remove parameters.
(catch_errors): New.
(get_windows_debug_event): Adjust.
gdb/testsuite/ChangeLog:
2017-10-10 Pedro Alves <palves@redhat.com>
* lib/selftest-support.exp (selftest_setup): Update for
captured_command_loop's prototype change.
2017-10-10 23:45:50 +08:00
|
|
|
TRY
|
|
|
|
{
|
|
|
|
captured_command_loop ();
|
|
|
|
}
|
|
|
|
CATCH (ex, RETURN_MASK_ALL)
|
|
|
|
{
|
|
|
|
exception_print (gdb_stderr, ex);
|
|
|
|
}
|
|
|
|
END_CATCH
|
1999-11-09 09:23:30 +08:00
|
|
|
}
|
|
|
|
/* No exit -- exit is through quit_command. */
|
|
|
|
}
|
1999-04-16 09:35:26 +08:00
|
|
|
|
1999-11-09 09:23:30 +08:00
|
|
|
int
|
2002-09-27 01:46:04 +08:00
|
|
|
gdb_main (struct captured_main_args *args)
|
1999-11-09 09:23:30 +08:00
|
|
|
{
|
2016-06-21 08:11:53 +08:00
|
|
|
TRY
|
|
|
|
{
|
|
|
|
captured_main (args);
|
|
|
|
}
|
|
|
|
CATCH (ex, RETURN_MASK_ALL)
|
|
|
|
{
|
|
|
|
exception_print (gdb_stderr, ex);
|
|
|
|
}
|
|
|
|
END_CATCH
|
|
|
|
|
2003-03-21 06:25:16 +08:00
|
|
|
/* The only way to end up here is by an error (normal exit is
|
|
|
|
handled by quit_force()), hence always return an error status. */
|
|
|
|
return 1;
|
1999-04-16 09:35:26 +08:00
|
|
|
}
|
|
|
|
|
1999-11-09 09:23:30 +08:00
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
/* Don't use *_filtered for printing help. We don't want to prompt
|
|
|
|
for continue no matter how small the screen or how much we're going
|
|
|
|
to print. */
|
|
|
|
|
|
|
|
static void
|
2000-02-02 08:21:19 +08:00
|
|
|
print_gdb_help (struct ui_file *stream)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
2013-07-01 19:22:12 +08:00
|
|
|
const char *system_gdbinit;
|
|
|
|
const char *home_gdbinit;
|
|
|
|
const char *local_gdbinit;
|
2009-01-28 23:01:00 +08:00
|
|
|
|
|
|
|
get_init_files (&system_gdbinit, &home_gdbinit, &local_gdbinit);
|
|
|
|
|
2013-07-06 15:28:24 +08:00
|
|
|
/* Note: The options in the list below are only approximately sorted
|
|
|
|
in the alphabetical order, so as to group closely related options
|
|
|
|
together. */
|
2002-06-25 13:35:16 +08:00
|
|
|
fputs_unfiltered (_("\
|
1999-04-16 09:35:26 +08:00
|
|
|
This is the GNU debugger. Usage:\n\n\
|
2001-11-22 08:23:13 +08:00
|
|
|
gdb [options] [executable-file [core-file or process-id]]\n\
|
|
|
|
gdb [options] --args executable-file [inferior-arguments ...]\n\n\
|
2002-06-25 13:35:16 +08:00
|
|
|
"), stream);
|
|
|
|
fputs_unfiltered (_("\
|
2013-07-06 15:28:24 +08:00
|
|
|
Selection of debuggee and its files:\n\n\
|
2001-11-22 08:23:13 +08:00
|
|
|
--args Arguments after executable-file are passed to inferior\n\
|
2013-07-06 15:28:24 +08:00
|
|
|
--core=COREFILE Analyze the core dump COREFILE.\n\
|
|
|
|
--exec=EXECFILE Use EXECFILE as the executable.\n\
|
|
|
|
--pid=PID Attach to running process PID.\n\
|
|
|
|
--directory=DIR Search for source files in DIR.\n\
|
|
|
|
--se=FILE Use FILE as symbol file and executable file.\n\
|
|
|
|
--symbols=SYMFILE Read symbols from SYMFILE.\n\
|
|
|
|
--readnow Fully read symbol files on first access.\n\
|
Add support for the readnever concept
The purpose of this concept is to turn the load of debugging
information off, either globally (via the '--readnever' option), or
objfile-specific. The implementation proposed here is an extension of
the patch distributed with Fedora GDB; looking at the Fedora patch
itself and the history, one can see some reasons why it was never
resubmitted:
- The patch appears to have been introduced as a workaround, at
least initially;
- The patch is far from perfect, as it simply shunts the load of
DWARF debugging information, without really worrying about the
other debug format.
- Who really does non-symbolic debugging anyways?
One use of this feature is when a user simply wants to do the
following sequence: attach, dump core, detach. Loading the debugging
information in this case is an unnecessary cause of delay.
This patch expands the version shipped with Fedora GDB in order to
make the feature available for all the debuginfo backends, not only
for DWARF. It also implements a per-objfile flag which can be
activated by using the "-readnever" command when using the
'add-symbol-file' or 'symbol-file' commands.
It's also worth mentioning that this patch tests whether GDB correctly
fails to initialize if both '--readnow' and '--readnever' options are
passed.
Tested on the BuildBot.
gdb/ChangeLog:
2017-12-01 Andrew Cagney <cagney@redhat.com>
Joel Brobecker <brobecker@adacore.com>
Sergio Durigan Junior <sergiodj@redhat.com>
* NEWS (Changes since GDB 8.0: Mention new '--readnever'
feature.
* coffread.c (coff_symfile_read): Do not map over sections with
'coff_locate_sections' if readnever is on.
* dwarf2read.c (dwarf2_has_info): Return 0 if
readnever is on.
* elfread.c (elf_symfile_read): Do not map over sections with
'elf_locate_sections' if readnever is on.
* main.c (validate_readnow_readnever): New function.
(captured_main_1): Add support for --readnever.
(print_gdb_help): Document --readnever.
* objfile-flags.h (enum objfile_flag) <OBJF_READNEVER>: New
flag.
* symfile.c (readnever_symbol_files): New global.
(symbol_file_add_with_addrs): Set 'OBJF_READNEVER' when
'READNEVER_SYMBOL_FILES' is set.
(validate_readnow_readnever): New function.
(symbol_file_command): Handle '-readnever' option.
Call 'validate_readnow_readnever'.
(add_symbol_file_command): Handle '-readnever' option.
Call 'validate_readnow_readnever'.
(_initialize_symfile): Document new '-readnever' option for
both 'symbol-file' and 'add-symbol-file' commands.
* top.h (readnever_symbol_files): New extern global.
* xcoffread.c (xcoff_initial_scan): Do not read debug
information if readnever is on.
gdb/doc/ChangeLog:
2017-12-01 Andrew Cagney <cagney@redhat.com>
Joel Brobecker <brobecker@adacore.com>
Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.texinfo (File Options): Document --readnever.
(Commands to Specify Files): Likewise, for 'symbol-file' and
'add-symbol-file'.
gdb/testsuite/ChangeLog:
2017-12-01 Joel Brobecker <brobecker@adacore.com>
Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
* gdb.base/readnever.c, gdb.base/readnever.exp: New files.
2017-11-25 05:56:08 +08:00
|
|
|
--readnever Do not read symbol files.\n\
|
2013-07-06 15:28:24 +08:00
|
|
|
--write Set writing into executable and core files.\n\n\
|
2002-06-25 13:35:16 +08:00
|
|
|
"), stream);
|
|
|
|
fputs_unfiltered (_("\
|
2013-07-06 15:28:24 +08:00
|
|
|
Initial commands and command files:\n\n\
|
2005-11-07 21:56:48 +08:00
|
|
|
--command=FILE, -x Execute GDB commands from FILE.\n\
|
2013-07-06 15:28:24 +08:00
|
|
|
--init-command=FILE, -ix\n\
|
|
|
|
Like -x but execute commands before loading inferior.\n\
|
2005-11-07 21:56:48 +08:00
|
|
|
--eval-command=COMMAND, -ex\n\
|
|
|
|
Execute a single GDB command.\n\
|
|
|
|
May be used multiple times and in conjunction\n\
|
|
|
|
with --command.\n\
|
2013-07-06 15:28:24 +08:00
|
|
|
--init-eval-command=COMMAND, -iex\n\
|
|
|
|
Like -ex but before loading inferior.\n\
|
|
|
|
--nh Do not read ~/.gdbinit.\n\
|
|
|
|
--nx Do not read any .gdbinit files in any directory.\n\n\
|
2002-06-25 13:35:16 +08:00
|
|
|
"), stream);
|
|
|
|
fputs_unfiltered (_("\
|
2013-07-06 15:28:24 +08:00
|
|
|
Output and user interface control:\n\n\
|
1999-04-16 09:35:26 +08:00
|
|
|
--fullname Output information used by emacs-GDB interface.\n\
|
2000-02-03 12:14:45 +08:00
|
|
|
--interpreter=INTERP\n\
|
|
|
|
Select a specific interpreter / user interface\n\
|
1999-04-16 09:35:26 +08:00
|
|
|
--tty=TTY Use TTY for input/output by the program being debugged.\n\
|
2013-07-06 15:28:24 +08:00
|
|
|
-w Use the GUI interface.\n\
|
|
|
|
--nw Do not use the GUI interface.\n\
|
2002-06-25 13:35:16 +08:00
|
|
|
"), stream);
|
1999-04-16 09:35:26 +08:00
|
|
|
#if defined(TUI)
|
2002-06-25 13:35:16 +08:00
|
|
|
fputs_unfiltered (_("\
|
1999-04-16 09:35:26 +08:00
|
|
|
--tui Use a terminal user interface.\n\
|
2002-06-25 13:35:16 +08:00
|
|
|
"), stream);
|
1999-04-16 09:35:26 +08:00
|
|
|
#endif
|
2012-03-17 00:47:34 +08:00
|
|
|
fputs_unfiltered (_("\
|
2013-07-06 15:28:24 +08:00
|
|
|
--dbx DBX compatibility mode.\n\
|
2014-06-06 17:28:19 +08:00
|
|
|
-q, --quiet, --silent\n\
|
|
|
|
Do not print version number on startup.\n\n\
|
2013-07-06 15:28:24 +08:00
|
|
|
"), stream);
|
|
|
|
fputs_unfiltered (_("\
|
|
|
|
Operating modes:\n\n\
|
|
|
|
--batch Exit after processing options.\n\
|
|
|
|
--batch-silent Like --batch, but suppress all gdb stdout output.\n\
|
|
|
|
--return-child-result\n\
|
|
|
|
GDB exit code will be the child's exit code.\n\
|
|
|
|
--configuration Print details about GDB configuration and then exit.\n\
|
|
|
|
--help Print this message and then exit.\n\
|
|
|
|
--version Print version information and then exit.\n\n\
|
|
|
|
Remote debugging options:\n\n\
|
|
|
|
-b BAUDRATE Set serial port baud rate used for remote debugging.\n\
|
|
|
|
-l TIMEOUT Set timeout in seconds for remote debugging.\n\n\
|
|
|
|
Other options:\n\n\
|
|
|
|
--cd=DIR Change current directory to DIR.\n\
|
2014-05-17 03:15:10 +08:00
|
|
|
--data-directory=DIR, -D\n\
|
|
|
|
Set GDB's data-directory to DIR.\n\
|
2002-06-25 13:35:16 +08:00
|
|
|
"), stream);
|
|
|
|
fputs_unfiltered (_("\n\
|
2009-01-28 23:01:00 +08:00
|
|
|
At startup, GDB reads the following init files and executes their commands:\n\
|
|
|
|
"), stream);
|
|
|
|
if (system_gdbinit)
|
|
|
|
fprintf_unfiltered (stream, _("\
|
|
|
|
* system-wide init file: %s\n\
|
|
|
|
"), system_gdbinit);
|
|
|
|
if (home_gdbinit)
|
|
|
|
fprintf_unfiltered (stream, _("\
|
|
|
|
* user-specific init file: %s\n\
|
|
|
|
"), home_gdbinit);
|
|
|
|
if (local_gdbinit)
|
|
|
|
fprintf_unfiltered (stream, _("\
|
gdb/
auto-load: Implementation.
* NEWS: New descriptions for "info auto-load",
"info auto-load gdb-scripts", "info auto-load python-scripts",
"info auto-load local-gdbinit" and "info auto-load libthread-db".
Deprecate "info auto-load-scripts", "set auto-load-scripts on|off"
and "show auto-load-scripts". New description for "set auto-load",
"show auto-load", "set auto-load gdb-scripts",
"show auto-load gdb-scripts", "set auto-load python-scripts",
"show auto-load python-scripts", "set auto-load local-gdbinit",
"show auto-load local-gdbinit", "set auto-load libthread-db" and
"show auto-load libthread-db".
* auto-load.c: Remove include python/python-internal.h. Add includes
exceptions.h, cli/cli-script.h, gdbcmd.h, cli/cli-decode.h and
cli/cli-setshow.h.
(GDB_AUTO_FILE_NAME, source_gdb_script_for_objfile)
(auto_load_gdb_scripts, show_auto_load_gdb_scripts): New.
(gdbpy_global_auto_load): Rename to ...
(global_auto_load): ... here.
(auto_load_local_gdbinit, auto_load_local_gdbinit_pathname)
(auto_load_local_gdbinit_loaded, show_auto_load_local_gdbinit)
(script_language_gdb, source_gdb_script_for_objfile): New.
(struct loaded_script): New field language.
(hash_loaded_script_entry, eq_loaded_script_entry): Calculate also
LANGUAGE.
(maybe_add_script): Add parameter language. Drop redundant
entry.full_path initialization. Initialize entry.language and
(*slot)->language.
(auto_load_objfile_script): Change parameter suffix to language.
Remove the call of maybe_add_script.
Call language->source_script_for_objfile.
(load_auto_scripts_for_objfile, struct collect_matching_scripts_data):
New.
(collect_matching_scripts): Adjust it for
struct collect_matching_scripts_data.
(auto_load_info_scripts_pattern_nl): New variable.
(info_auto_load_scripts): Rename to ...
(auto_load_info_scripts): ... here, add parameter language. Adjust it
for struct collect_matching_scripts_data.
(info_auto_load_gdb_scripts, info_auto_load_local_gdbinit)
(set_auto_load_cmd, auto_load_set_cmdlist_get, show_auto_load_cmd)
(auto_load_show_cmdlist_get, info_auto_load_cmd)
(auto_load_info_cmdlist_get): New.
(_initialize_auto_load): Move add_info of "auto-load-scripts" to
python/py-auto-load.c. New installment for "set auto-load gdb-scripts",
"info auto-load gdb-scripts", "set auto-load local-gdbinit" and
"info auto-load local-gdbinit".
* auto-load.h (struct script_language): New.
(gdbpy_global_auto_load): Rename to ...
(global_auto_load): ... here.
(auto_load_local_gdbinit, auto_load_local_gdbinit_pathname)
(auto_load_local_gdbinit_loaded): New declarations.
(maybe_add_script): New parameter language.
(auto_load_objfile_script): Change parameter suffix to language.
(load_auto_scripts_for_objfile, auto_load_info_scripts_pattern_nl)
(auto_load_info_scripts, auto_load_set_cmdlist_get)
(auto_load_show_cmdlist_get, auto_load_info_cmdlist_get): New
declarations.
* linux-thread-db.c: Include auto-load.h and ctype.h.
(auto_load_thread_db, show_auto_load_thread_db): New.
(struct thread_db_info): New field filename.
(delete_thread_db_info): Call xfree for FILENAME.
(try_thread_db_load): Initialize FILENAME.
(try_thread_db_load_from_pdir, try_thread_db_load_from_dir): Return
if !AUTO_LOAD_THREAD_DB.
(info_auto_load_libthread_db_compare, info_auto_load_libthread_db): New.
(_initialize_thread_db): Install auto_load_thread_db
as "set auto-load libthread-db" and install info_auto_load_libthread_db
as "info auto-load libthread-db".
* main.c (captured_main): Rename gdbpy_global_auto_load to
global_auto_load. Initialize AUTO_LOAD_LOCAL_GDBINIT_PATHNAME and
AUTO_LOAD_LOCAL_GDBINIT_LOADED.
(print_gdb_help): Extend the help for 'local init file'.
* python/py-auto-load.c: Remove a comment about gdb scripts extension.
(GDBPY_AUTO_SECTION_NAME): Extend the comment it is Python specific.
(auto_load_scripts): Rename to ...
(auto_load_python_scripts): ... here, update the comment.
(gdbpy_load_auto_script_for_objfile): New declaration.
(show_auto_load_python_scripts, script_language_python)
(gdbpy_load_auto_script_for_objfile): New.
(source_section_scripts): Refactor the code.
(load_auto_scripts_for_objfile): Rename to ...
(gdbpy_load_auto_scripts_for_objfile): ... here, update the
auto_load_objfile_script caller, drop GDBPY_GLOBAL_AUTO_LOAD checking.
(info_auto_load_python_scripts): New.
(gdbpy_initialize_auto_load): New variables cmd and cmd_name.
Rename "set auto-load-scripts" to "set auto-load python-scripts".
Register "set auto-load-scripts" as its deprecated alias. Register
"info auto-load python-scripts". Register "info auto-load-scripts" as
its deprecated alias.
(load_auto_scripts_for_objfile): Rename to ...
(gdbpy_load_auto_scripts_for_objfile): ... here.
* python/python.h (load_auto_scripts_for_objfile): Rename to ...
(gdbpy_load_auto_scripts_for_objfile): ... here.
gdb/doc/
auto-load: Implementation.
* gdb.texinfo (Mode Options): New anchor for -nx.
(Startup): New anchors for Option -init-eval-command,
Home Directory Init File
and Init File in the Current Directory during Startup.
Mention set auto-load local-gdbinit with a reference.
Change the sample code to "set auto-load python-scripts".
(Threads): New anchor set libthread-db-search-path.
Provide references to libthread_db.so.1 file.
(Controlling GDB): New menu item for Auto-loading.
(Auto-loading, Init File in the Current Directory)
(libthread_db.so.1 file, objfile-gdb.gdb file): New nodes.
(Python): Rename the menu item Auto-loading to Python Auto-loading.
(Writing a Pretty-Printer, Objfiles In Python): Update the renamed
reference.
(Auto-loading): Rename to ...
(Python Auto-loading): ... here. Change "set auto-load-scripts" to
"set auto-load python-scripts", new anchor for it. Change
"show auto-load-scripts" to "show auto-load python-scripts", new anchor
for it. Change "info auto-load-scripts"
to "info auto-load python-scripts", new anchor for it. Change "scripts"
to "Python scripts".
gdb/testsuite/
auto-load: Implementation.
* gdb.base/help.exp (test set height): Increase the height.
* gdb.python/py-objfile-script.exp (info auto-load-scripts): Change
to ...
(info auto-load python-scripts): ... here.
* gdb.python/py-section-script.exp (info auto-load-scripts *): Change
to ...
(info auto-load python-scripts *): ... here.
2012-04-17 23:51:48 +08:00
|
|
|
* local init file (see also 'set auto-load local-gdbinit'): ./%s\n\
|
2009-01-28 23:01:00 +08:00
|
|
|
"), local_gdbinit);
|
|
|
|
fputs_unfiltered (_("\n\
|
1999-04-16 09:35:26 +08:00
|
|
|
For more information, type \"help\" from within GDB, or consult the\n\
|
|
|
|
GDB manual (available as on-line info or a printed manual).\n\
|
2002-06-25 13:35:16 +08:00
|
|
|
"), stream);
|
2008-06-06 06:36:57 +08:00
|
|
|
if (REPORT_BUGS_TO[0] && stream == gdb_stdout)
|
|
|
|
fprintf_unfiltered (stream, _("\
|
|
|
|
Report bugs to \"%s\".\n\
|
|
|
|
"), REPORT_BUGS_TO);
|
1999-04-16 09:35:26 +08:00
|
|
|
}
|