+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.
+
2017-12-01 Tom Tromey <tom@tromey.com>
* Makefile.in (all_deps_files): New variable.
*** Changes since GDB 8.0
+* New "--readnever" command line option instructs GDB to not read each
+ symbol file's symbolic debug information. This makes startup faster
+ but at the expense of not being able to perform symbolic debugging.
+ This option is intended for use cases where symbolic debugging will
+ not be used, e.g., when you only need to dump the debuggee's core.
+
* GDB now uses the GNU MPFR library, if available, to emulate target
floating-point arithmetic during expression evaluation when the target
uses different floating-point formats than the host. At least version
}
}
- bfd_map_over_sections (abfd, coff_locate_sections, (void *) info);
+ if (!(objfile->flags & OBJF_READNEVER))
+ bfd_map_over_sections (abfd, coff_locate_sections, (void *) info);
if (info->stabsects)
{
+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'.
+
2017-11-29 Pedro Alves <palves@redhat.com>
PR c++/19436
the default, which is to read it incrementally as it is needed.
This makes startup slower, but makes future operations faster.
+@item --readnever
+@anchor{--readnever}
+@cindex @code{--readnever}, command-line option
+Do not read each symbol file's symbolic debug information. This makes
+startup faster but at the expense of not being able to perform
+symbolic debugging. DWARF unwind information is also not read,
+meaning backtraces may become incomplete or inaccurate. One use of
+this 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.
@end table
@node Mode Options
load symbol table information, if you want to be sure @value{GDBN} has the
entire symbol table available.
+@cindex @code{-readnever}, option for symbol-file command
+@cindex never read symbols
+@cindex symbols, never read
+@item symbol-file @r{[} -readnever @r{]} @var{filename}
+@itemx file @r{[} -readnever @r{]} @var{filename}
+You can instruct @value{GDBN} to never read the symbolic information
+contained in @var{filename} by using the @samp{-readnever} option.
+@xref{--readnever}.
+
@c FIXME: for now no mention of directories, since this seems to be in
@c flux. 13mar1992 status is that in theory GDB would look either in
@c current dir or in same dir as myprog; but issues like competing
@kindex add-symbol-file
@cindex dynamic linking
@item add-symbol-file @var{filename} @var{address}
-@itemx add-symbol-file @var{filename} @var{address} @r{[} -readnow @r{]}
+@itemx add-symbol-file @var{filename} @var{address} @r{[} -readnow @r{|} -readnever @r{]}
@itemx add-symbol-file @var{filename} @var{address} -s @var{section} @var{address} @dots{}
The @code{add-symbol-file} command reads additional symbol table
information from the file @var{filename}. You would use this command
dwarf2_has_info (struct objfile *objfile,
const struct dwarf2_debug_sections *names)
{
+ if (objfile->flags & OBJF_READNEVER)
+ return 0;
+
dwarf2_per_objfile = ((struct dwarf2_per_objfile *)
objfile_data (objfile, dwarf2_objfile_data_key));
if (!dwarf2_per_objfile)
struct elfinfo ei;
memset ((char *) &ei, 0, sizeof (ei));
- bfd_map_over_sections (abfd, elf_locate_sections, (void *) & ei);
+ if (!(objfile->flags & OBJF_READNEVER))
+ bfd_map_over_sections (abfd, elf_locate_sections, (void *) & ei);
elf_read_minimal_symbols (objfile, symfile_flags, &ei);
symbol_file_add_main (arg, add_flags);
}
+/* 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);
+ }
+}
+
/* Type of this option. */
enum cmdarg_kind
{
OPT_NOWINDOWS,
OPT_WINDOWS,
OPT_IX,
- OPT_IEX
+ OPT_IEX,
+ OPT_READNOW,
+ OPT_READNEVER
};
static struct option long_options[] =
{
{"tui", no_argument, 0, OPT_TUI},
{"dbx", no_argument, &dbx_commands, 1},
- {"readnow", no_argument, &readnow_symbol_files, 1},
- {"r", no_argument, &readnow_symbol_files, 1},
+ {"readnow", no_argument, NULL, OPT_READNOW},
+ {"readnever", no_argument, NULL, OPT_READNEVER},
+ {"r", no_argument, NULL, OPT_READNOW},
{"quiet", no_argument, &quiet, 1},
{"q", no_argument, &quiet, 1},
{"silent", no_argument, &quiet, 1},
}
break;
+ case OPT_READNOW:
+ {
+ readnow_symbol_files = 1;
+ validate_readnow_readnever ();
+ }
+ break;
+
+ case OPT_READNEVER:
+ {
+ readnever_symbol_files = 1;
+ validate_readnow_readnever ();
+ }
+ break;
+
case '?':
error (_("Use `%s --help' for a complete list of options."),
gdb_program_name);
--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\
+ --readnever Do not read symbol files.\n\
--write Set writing into executable and core files.\n\n\
"), stream);
fputs_unfiltered (_("\
unrelated to filesystem names. It can be for example
"<image in memory>". */
OBJF_NOT_FILENAME = 1 << 6,
+
+ /* User requested that we do not read this objfile's symbolic
+ information. */
+ OBJF_READNEVER = 1 << 7,
};
DEF_ENUM_FLAGS_TYPE (enum objfile_flag, objfile_flags);
/* Global variables owned by this file. */
int readnow_symbol_files; /* Read full symbols immediately. */
+int readnever_symbol_files; /* Never read full symbols. */
/* Functions this file defines. */
flags |= OBJF_READNOW;
add_flags &= ~SYMFILE_NO_READ;
}
+ else if (readnever_symbol_files
+ || (parent != NULL && (parent->flags & OBJF_READNEVER)))
+ {
+ flags |= OBJF_READNEVER;
+ add_flags |= SYMFILE_NO_READ;
+ }
/* Give user a chance to burp if we'd be
interactively wiping out any existing symbols. */
return debugfile;
}
+/* Make sure that OBJF_{READNOW,READNEVER} are not set
+ simultaneously. */
+
+static void
+validate_readnow_readnever (objfile_flags flags)
+{
+ if ((flags & OBJF_READNOW) && (flags & OBJF_READNEVER))
+ error (_("-readnow and -readnever cannot be used simultaneously"));
+}
+
/* This is the symbol-file command. Read the file, analyze its
symbols, and add a struct symtab to a symtab list. The syntax of
the command is rather bizarre:
{
if (strcmp (arg, "-readnow") == 0)
flags |= OBJF_READNOW;
+ else if (strcmp (arg, "-readnever") == 0)
+ flags |= OBJF_READNEVER;
else if (*arg == '-')
error (_("unknown option `%s'"), arg);
else
- {
- symbol_file_add_main_1 (arg, add_flags, flags);
- name = arg;
- }
+ name = arg;
}
if (name == NULL)
error (_("no symbol file name was specified"));
+
+ validate_readnow_readnever (flags);
+
+ symbol_file_add_main_1 (name, add_flags, flags);
}
}
}
else if (strcmp (arg, "-readnow") == 0)
flags |= OBJF_READNOW;
+ else if (strcmp (arg, "-readnever") == 0)
+ flags |= OBJF_READNEVER;
else if (strcmp (arg, "-s") == 0)
{
expecting_sec_name = 1;
}
}
+ validate_readnow_readnever (flags);
+
/* This command takes at least two arguments. The first one is a
filename, and the second is the address where this file has been
loaded. Abort now if this address hasn't been provided by the
observer_attach_free_objfile (symfile_free_objfile);
-#define READNOW_HELP \
+#define READNOW_READNEVER_HELP \
"The '-readnow' option will cause GDB to read the entire symbol file\n\
immediately. This makes the command slower, but may make future operations\n\
-faster."
+faster.\n\
+The '-readnever' option will prevent GDB from reading the symbol file's\n\
+symbolic debug information."
c = add_cmd ("symbol-file", class_files, symbol_file_command, _("\
Load symbol table from executable file FILE.\n\
-Usage: symbol-file [-readnow] FILE\n\
+Usage: symbol-file [-readnow | -readnever] FILE\n\
The `file' command can also load symbol tables, as well as setting the file\n\
-to execute.\n" READNOW_HELP), &cmdlist);
+to execute.\n" READNOW_READNEVER_HELP), &cmdlist);
set_cmd_completer (c, filename_completer);
c = add_cmd ("add-symbol-file", class_files, add_symbol_file_command, _("\
Load symbols from FILE, assuming FILE has been dynamically loaded.\n\
-Usage: add-symbol-file FILE ADDR [-readnow | -s SECT-NAME SECT-ADDR]...\n\
+Usage: add-symbol-file FILE ADDR [-readnow | -readnever | \
+-s SECT-NAME SECT-ADDR]...\n\
ADDR is the starting address of the file's text.\n\
Each '-s' argument provides a section name and address, and\n\
should be specified if the data and bss segments are not contiguous\n\
with the text. SECT-NAME is a section name to be loaded at SECT-ADDR.\n"
-READNOW_HELP),
+READNOW_READNEVER_HELP),
&cmdlist);
set_cmd_completer (c, filename_completer);
+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-12-01 Yao Qi <yao.qi@linaro.org>
* gdb.arch/aarch64-atomic-inst.exp: Replace mail address with
--- /dev/null
+/* Copyright 2016-2017 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+static void
+fun_three (int a, char b, void *c)
+{
+ /* Do nothing. */
+}
+
+static void
+fun_two (unsigned int p, const char *y)
+{
+ fun_three ((int) p, '1', (void *) y);
+}
+
+static void
+fun_one (int *x)
+{
+ fun_two (10, (const char *) x);
+}
+
+int
+main (void)
+{
+ int a = 10;
+
+ fun_one (&a);
+ return 0;
+}
--- /dev/null
+# Copyright 2016-2017 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+standard_testfile .c
+
+if { [build_executable "failed to build" $testfile $srcfile { debug }] == -1 } {
+ untested "Couldn't compile ${srcfile}"
+ return -1
+}
+
+save_vars { GDBFLAGS } {
+ append GDBFLAGS " --readnever"
+ clean_restart ${binfile}
+}
+
+if ![runto_main] then {
+ perror "couldn't run to breakpoint"
+ continue
+}
+
+gdb_test "break fun_three" \
+ "Breakpoint $decimal at $hex"
+
+gdb_test "continue" \
+ "Breakpoint $decimal, $hex in fun_three \\(\\)"
+
+gdb_test "backtrace" \
+ [multi_line "#0 $hex in fun_three \\(\\)" \
+ "#1 $hex in fun_two \\(\\)" \
+ "#2 $hex in fun_one \\(\\)" \
+ "#3 $hex in main \\(\\)" ]
+
+gdb_test_no_output "maint info symtabs" \
+ "maint info symtabs no output for --readnever"
+gdb_test_no_output "maint info psymtabs" \
+ "maint info psymtabs no output for --readnever"
+
+# Test invalid combination of flags.
+save_vars { GDBFLAGS } {
+ append GDBFLAGS " --readnever --readnow"
+ gdb_exit
+ gdb_spawn
+
+ set test "test readnow and readnever at the same time"
+ gdb_test_multiple "" $test {
+ "'--readnow' and '--readnever' cannot be specified simultaneously" {
+ pass $test
+ set test "expect eof after failure"
+ gdb_test_multiple "" $test {
+ eof {
+ pass $test
+ }
+ }
+ }
+ }
+}
+
+
+# Test symbol-file's -readnever option.
+
+# Restart GDB without the --readnever option.
+gdb_exit
+gdb_start
+gdb_test "symbol-file ${binfile}0.o -readnever" \
+ "Reading symbols from ${binfile}0\.o\.\.\.\\\(no debugging symbols found\\\)\.\.\.done\." \
+ "use symbol-file -readnever"
+
+gdb_test_no_output "maint info symtabs" \
+ "maint info symtabs no output for symbol-file -readnever"
+gdb_test_no_output "maint info psymtabs" \
+ "maint info psymtabs no output for symbol-file -readnever"
/* From random places. */
extern int readnow_symbol_files;
+extern int readnever_symbol_files;
/* Perform _initialize initialization. */
extern void gdb_init (char *);
/* Read the string table. */
init_stringtab (abfd, stringtab_offset, objfile);
- /* Read the .debug section, if present. */
- {
- struct bfd_section *secp;
- bfd_size_type length;
- bfd_byte *debugsec = NULL;
+ /* Read the .debug section, if present and if we're not ignoring
+ it. */
+ if (!(objfile->flags & OBJF_READNEVER))
+ {
+ struct bfd_section *secp;
+ bfd_size_type length;
+ bfd_byte *debugsec = NULL;
- secp = bfd_get_section_by_name (abfd, ".debug");
- if (secp)
- {
- length = bfd_section_size (abfd, secp);
- if (length)
- {
- debugsec
- = (bfd_byte *) obstack_alloc (&objfile->objfile_obstack,
- length);
+ secp = bfd_get_section_by_name (abfd, ".debug");
+ if (secp)
+ {
+ length = bfd_section_size (abfd, secp);
+ if (length)
+ {
+ debugsec
+ = (bfd_byte *) obstack_alloc (&objfile->objfile_obstack,
+ length);
- if (!bfd_get_full_section_contents (abfd, secp, &debugsec))
- {
- error (_("Error reading .debug section of `%s': %s"),
- name, bfd_errmsg (bfd_get_error ()));
- }
- }
- }
- info->debugsec = (char *) debugsec;
- }
+ if (!bfd_get_full_section_contents (abfd, secp, &debugsec))
+ {
+ error (_("Error reading .debug section of `%s': %s"),
+ name, bfd_errmsg (bfd_get_error ()));
+ }
+ }
+ }
+ info->debugsec = (char *) debugsec;
+ }
}
/* Read the symbols. We keep them in core because we will want to