Tom Tromey [Mon, 21 Oct 2019 17:21:14 +0000 (11:21 -0600)]
Style disassembly in the TUI
This patch changes the TUI disassembly window to style its contents.
The styling should be identical to what is seen in the CLI. This
involved a bit of rearrangement, so that the source and disassembly
windows could share both the copy_source_line utility function, and
the ability to react to changes in "set style enabled".
This version introduces a new function to strip the styling from the
address string when computing the length. As a byproduct, it also
removes the unused "insn_size" computation from
tui_disasm_window::set_contents.
gdb/ChangeLog
2019-11-05 Tom Tromey <tom@tromey.com>
* tui/tui-source.h (struct tui_source_window): Inline
constructor. Remove destructor.
<style_changed, m_observable>: Move to superclass.
* tui/tui-winsource.h (tui_copy_source_line): Declare.
(struct tui_source_window_base): Move private members to end.
<style_changed, m_observable>: Move from tui_source_window.
* tui/tui-winsource.c (tui_copy_source_line): Move from
tui-source.c. Rename from copy_source_line. Add special handling
for negative line number.
(tui_source_window_base::style_changed): Move from
tui_source_window.
(tui_source_window_base): Register observer.
(~tui_source_window_base): New.
* tui/tui-source.c (copy_source_line): Move to tui-winsource.c;
rename.
(tui_source_window::set_contents): Use tui_copy_source_line.
(tui_source_window::tui_source_window): Move to tui-source.h.
(tui_source_window::~tui_source_window): Remove.
(tui_source_window::style_changed): Move to superclass.
* tui/tui-disasm.c (tui_disassemble): Create string file with
styling, when possible. Add "addr_size" parameter.
(tui_disasm_window::set_contents): Use tui_copy_source_line.
Don't compute maximum size.
(len_without_escapes): New function
Change-Id: I8722635eeecbbb1633d943a65b856404c2d467b0
Tom Tromey [Mon, 21 Oct 2019 16:58:08 +0000 (10:58 -0600)]
Change tui_source_element::line to have type std::string
This changes tui_source_element::line to be of type std::string. This
reduces the number of copies made.
gdb/ChangeLog
2019-11-05 Tom Tromey <tom@tromey.com>
* tui/tui-winsource.h (struct tui_source_element) <line>: Now a
std::string.
* tui/tui-winsource.c (tui_show_source_line): Update.
* tui/tui-source.c (tui_source_window::set_contents): Update.
* tui/tui-disasm.c (tui_disasm_window::set_contents): Update.
Change-Id: Id600f3e1d386a2911f187366e05e2ec599068dd2
Christian Biesinger [Tue, 5 Nov 2019 20:52:59 +0000 (14:52 -0600)]
Fix ARI warning in symtab.h
gdb/ChangeLog:
2019-11-05 Christian Biesinger <cbiesinger@google.com>
* symtab.h (gdb_static_assert): Put && operator at the beginning
of the line instead of the end.
Change-Id: I6d05c2f5e46c3f317ba97458509b2da9fd03464b
Tim R?hsen [Tue, 5 Nov 2019 16:03:07 +0000 (16:03 +0000)]
Fix memory allocation and release problems in the bfd documentation processor.
* doc/chew.c (add_to_definition): Use correct type when
calculating size of array reallocation.
(nextword): Always initialise the word return parameter.
(compile): Check return value of nextword().
Jan Beulich [Tue, 5 Nov 2019 08:19:50 +0000 (09:19 +0100)]
x86: fold OP_Mwaitx() into OP_Mwait()
There's no need to have separate functions, the difference can easily be
expressed using the function arguments.
Jan Beulich [Tue, 5 Nov 2019 08:19:10 +0000 (09:19 +0100)]
x86: split MONITORX/MWAITX entries
Both encodings do not ignore the 66/F3/F2 prefixes, so don't have the
disassembler ignore them either.
Jan Beulich [Tue, 5 Nov 2019 08:18:23 +0000 (09:18 +0100)]
x86: consolidate disassembler enum naming a little
The original idea looks to have been for names to be composed in the
order that decoding gets done, which helps both reading and modifying
the code. Switch (back) to this model for some of the affected non-
vector insn enumerators.
Alan Modra [Fri, 1 Nov 2019 03:15:25 +0000 (13:45 +1030)]
GENERATE_SHLIB_SCRIPT vs. EMBEDDED.
A target that sets EMBEDDED non-empty is one that doesn't want to put
the ELF file header or program header in a memory image. Likely the
target isn't interested in supporting dynamically loaded executables,
shared libraries, or PIEs, because loaders for such binaries generally
require program headers to be present. This isn't 100% true though.
The target might be one where the loader accesses the file system in
order to retrieve headers.
Also, note that not all "shared libraries" require gcc -shared or the
shared library support in the linker. I believe one implementation of
shared libraries on uclinux is like this.
So, this patch removes GENERATE_SHLIB_SCRIPT and GENERATE_PIE_SCRIPT
in most emulparams files where EMBEDDED is set, restoring the shared
lib and pie support in emulparams files that unset EMBEDDED after
including a file where the support is removed.
Exceptions to the general rule that EMBEDDED disables shared libs are:
arm*-*-symbianelf*, where the OS wants shared library support
without ELF program headers in the image, and
sh*-*-uclinux*, where I've left things as they were, ie. both
EMBEDDED and GENERATE_SHLIB_SCRIPT because I'm unsure as to the
shared library scheme.
* emulparams/aarch64elf.sh (GENERATE_SHLIB_SCRIPT),
(GENERATE_PIE_SCRIPT): Don't set.
* emulparams/aarch64elf32.sh (GENERATE_SHLIB_SCRIPT),
(GENERATE_PIE_SCRIPT): Don't set.
* emulparams/arcelf.sh (GENERATE_SHLIB_SCRIPT): Don't set.
* emulparams/armelf.sh (GENERATE_SHLIB_SCRIPT),
(GENERATE_PIE_SCRIPT): Don't set.
* emulparams/armelf_fbsd.sh (GENERATE_SHLIB_SCRIPT): Set.
* emulparams/armelf_nbsd.sh (GENERATE_SHLIB_SCRIPT),
(GENERATE_PIE_SCRIPT): Set.
* emulparams/armelf_vxworks.sh (GENERATE_SHLIB_SCRIPT): Set.
* emulparams/armsymbian.sh (GENERATE_SHLIB_SCRIPT): Set.
* emulparams/elf32bfin.sh (GENERATE_SHLIB_SCRIPT): Don't set.
* emulparams/elf32microblaze.sh (GENERATE_SHLIB_SCRIPT): Don't set.
* emulparams/score3_elf.sh (GENERATE_SHLIB_SCRIPT): Don't set.
* emulparams/shelf.sh (GENERATE_SHLIB_SCRIPT): Don't set.
* emulparams/shelf_nbsd.sh (GENERATE_SHLIB_SCRIPT),
(GENERATE_PIE_SCRIPT): Set.
* emulparams/shelf_uclinux.sh (GENERATE_SHLIB_SCRIPT): Set.
Alan Modra [Fri, 1 Nov 2019 03:11:50 +0000 (13:41 +1030)]
Unset EMBEDDED rather than assigning as empty
No real changes here, just making it that much easier to find targets
that set EMBEDDED to a non-empty string.
* emulparams/elf32bfinfd.sh: Unset EMBEDDED rather assigning as empty.
* emulparams/elf32frvfd.sh: Likewise.
* emulparams/elf32lm32fd.sh: Likewise.
* emulparams/i386lynx.sh: Likewise.
GDB Administrator [Tue, 5 Nov 2019 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in
Christian Biesinger [Fri, 25 Oct 2019 18:40:27 +0000 (13:40 -0500)]
Add static_asserts for the sizes of space-critical structs
Specifically the three structs mentioned in symtab.h:
- general_symbol_info
- symbol
- partial_symbol
This ensures that those structs won't accidentally get bigger.
gdb/ChangeLog:
2019-11-04 Christian Biesinger <cbiesinger@google.com>
* psympriv.h: Add static_asserts for sizeof (general_symbol_info)
and sizeof (symbol).
* symtab.h: Add a static_assert for sizeof (partial_symbol).
Change-Id: Idd68320aa3e79ee7cc749019724636a58ce4b9c6
Rainer Orth [Mon, 4 Nov 2019 17:13:14 +0000 (18:13 +0100)]
Obsolete Solaris 10 support
Here's the patch corresponding to the Solaris 10 obsoletion announcement
https://sourceware.org/ml/gdb/2019-10/msg00008.html
Right now it doesn't remove any code, but obviates the need to test on
that ancient platform. Besides, some of the patches I have in my queue
would require different solutions for Solaris 10 and 11.
There are a few comment-only references that I've kept since they are
still correct as is, even when GDB doesn't support Solaris 10 any
longer. The only code fragment I've left in is support for
/proc/<pid/path/a.out in procfs.c (procfs_target::pid_to_exec_file):
while current Solaris 11 updates provide /proc/<pid>/execname, that
wasn't present in Solaris 11.0 and still isn't in current Illumos and I
didn't want to make live harder for them.
Tested on i386-pc-solaris2.10 (obsolete configuration rejected) and
x86_64-pc-linux-gnu x sparc64-solaris2.10 (likewise)
resp. x86_64-pc-linux-gnu x sparcv9-solaris2.11 (still builds; I'm using
the sparcv9 form for 64-bit SPARC customary on Solaris in the
MAINTAINERS file now).
* NEWS (Changes since GDB 8.3): Document Solaris 10 removal.
* configure.host: Mark *-*-solaris2.10* obsolete.
* configure.tgt: Mark Solaris < 11 obsolete.
* MAINTAINERS (Target Instruction Set Architectures) <sparc>:
Update target triplet.
Jan Beulich [Mon, 4 Nov 2019 14:48:38 +0000 (15:48 +0100)]
x86: re-arrange process_operands()
Alter the sequence of conditions evaluated, without affecting the
overall result. This is going to help subsequent changes (and as a nice
side effect also slightly reduces overall indentation depth).
While doing this take the liberty of simplifying the calculation of the
operand index of the register operand in ShortForm handling.
Nick Clifton [Mon, 4 Nov 2019 12:02:20 +0000 (12:02 +0000)]
Fix potential array overruns when disassembling corrupt v850 binaries.
* v850-dis.c (get_v850_sreg_name): New function. Returns the name
of a v850 system register. Move the v850_sreg_names array into
this function.
(get_v850_reg_name): Likewise for ordinary register names.
(get_v850_vreg_name): Likewise for vector register names.
(get_v850_cc_name): Likewise for condition codes.
* get_v850_float_cc_name): Likewise for floating point condition
codes.
(get_v850_cacheop_name): Likewise for cache-ops.
(get_v850_prefop_name): Likewise for pref-ops.
(disassemble): Use the new accessor functions.
Fāng-ruì Sòng [Fri, 1 Nov 2019 21:47:55 +0000 (14:47 -0700)]
Implement objcopy/strip --keep-section=<sectionpattern>
llvm-objcopy and llvm-strip support an option --keep-section that
keeps some sections from being removed.
* objcopy.c (enum option_values): Add OPTION_KEEP_SECTION.
(SECTION_CONTEXT_KEEP): Define. Adjust other SECTION_CONTEXT macros.
(copy_usage): Describe --keep-section.
(strip_usage): Likewise.
(copy_main): Handle SECTION_CONTEXT_KEEP.
(strip_main): Likewise.
(is_strip_section_1): Likewise.
* testsuite/binutils-all/objcopy.exp: Add tests.
* testsuite/binutils-all/keep-section-1.d: New test driver file.
* testsuite/binutils-all/keep-section-2.d: Likewise.
* doc/binutils.texi: Document the new feature.
* NEWS: Mention the new feature.
GDB Administrator [Mon, 4 Nov 2019 00:00:16 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Sun, 3 Nov 2019 00:01:13 +0000 (00:01 +0000)]
Automatic date update in version.in
Tom de Vries [Sat, 2 Nov 2019 05:55:10 +0000 (06:55 +0100)]
[gdb/testsuite] Remove superfluous 3rd argument from gdb_test call (4)
There's a pattern:
...
gdb_test <command> <pattern> <command>
...
that can be written shorter as:
...
gdb_test <command> <pattern>
...
Detect this pattern in proc gdb_test:
...
global gdb_prompt
upvar timeout timeout
if [llength $args]>2 then {
set message [lindex $args 2]
+ if { $message == [lindex $args 0] && [llength $args] == 3 } {
+ error "HERE"
+ }
} else {
set message [lindex $args 0]
}
...
and fix all occurrences in the testsuite/gdb.base subdir.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2019-11-02 Tom de Vries <tdevries@suse.de>
* gdb.base/advance.exp: Drop superfluous 3rd argument to gdb_test.
* gdb.base/anon.exp: Same.
* gdb.base/auto-connect-native-target.exp: Same.
* gdb.base/call-ar-st.exp: Same.
* gdb.base/catch-syscall.exp: Same.
* gdb.base/commands.exp: Same.
* gdb.base/default.exp: Same.
* gdb.base/display.exp: Same.
* gdb.base/float.exp: Same.
* gdb.base/foll-fork.exp: Same.
* gdb.base/help.exp: Same.
* gdb.base/info-macros.exp: Same.
* gdb.base/info-proc.exp: Same.
* gdb.base/info-target.exp: Same.
* gdb.base/long_long.exp: Same.
* gdb.base/macscp.exp: Same.
* gdb.base/memattr.exp: Same.
* gdb.base/nofield.exp: Same.
* gdb.base/pointers.exp: Same.
* gdb.base/printcmds.exp: Same.
* gdb.base/ptype.exp: Same.
* gdb.base/restore.exp: Same.
* gdb.base/return.exp: Same.
* gdb.base/scope.exp: Same.
* gdb.base/set-noassign.exp: Same.
* gdb.base/setshow.exp: Same.
* gdb.base/shlib-call.exp: Same.
* gdb.base/signals.exp: Same.
* gdb.base/sigstep.exp: Same.
* gdb.base/skip.exp: Same.
* gdb.base/solib-symbol.exp: Same.
* gdb.base/stap-probe.exp: Same.
* gdb.base/step-line.exp: Same.
* gdb.base/step-test.exp: Same.
* gdb.base/style.exp: Same.
* gdb.base/varargs.exp: Same.
* gdb.base/vla-datatypes.exp: Same.
* gdb.base/vla-ptr.exp: Same.
* gdb.base/vla-sideeffect.exp: Same.
* gdb.base/volatile.exp: Same.
* gdb.base/watch-cond-infcall.exp: Same.
* gdb.base/watchpoint.exp: Same.
Change-Id: Ifd24dc13d552e7dd03f9049db419b08c6adc4112
Tom de Vries [Sat, 2 Nov 2019 05:55:10 +0000 (06:55 +0100)]
[gdb/testsuite] Remove superfluous 3rd argument from gdb_test call (3)
There's a pattern:
...
gdb_test <command> <pattern> <command>
...
that can be written shorter as:
...
gdb_test <command> <pattern>
...
Detect this pattern in proc gdb_test:
...
global gdb_prompt
upvar timeout timeout
if [llength $args]>2 then {
set message [lindex $args 2]
+ if { $message == [lindex $args 0] && [llength $args] == 3 } {
+ error "HERE"
+ }
} else {
set message [lindex $args 0]
}
...
and fix all occurrences in the testsuite/gdb.cp subdir.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2019-11-02 Tom de Vries <tdevries@suse.de>
* gdb.cp/anon-union.exp: Drop superfluous 3rd argument to gdb_test.
* gdb.cp/cpexprs.exp: Same.
* gdb.cp/except-multi-location.exp: Same.
* gdb.cp/exceptprint.exp: Same.
* gdb.cp/gdb2384.exp: Same.
* gdb.cp/inherit.exp: Same.
* gdb.cp/m-static.exp: Same.
* gdb.cp/meth-typedefs.exp: Same.
* gdb.cp/misc.exp: Same.
* gdb.cp/namespace.exp: Same.
* gdb.cp/non-trivial-retval.exp: Same.
* gdb.cp/overload.exp: Same.
* gdb.cp/pr17132.exp: Same.
* gdb.cp/re-set-overloaded.exp: Same.
* gdb.cp/rvalue-ref-types.exp: Same.
* gdb.cp/templates.exp: Same.
Change-Id: I0254d0cea71e7376aedb078166188a8010eeaebe
GDB Administrator [Sat, 2 Nov 2019 00:00:15 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Thu, 31 Oct 2019 22:46:16 +0000 (16:46 -0600)]
Simplify print_sys_errmsg
On irc, Christian pointed out that print_sys_errmsg could be
simplified by avoiding alloca entirely. This patch implements this.
gdb/ChangeLog
2019-11-01 Tom Tromey <tromey@adacore.com>
* utils.c (print_sys_errmsg): Simplify.
Change-Id: Ic399dade274ea61b63ef0540b3a3be2f0f80160a
Tom Tromey [Thu, 31 Oct 2019 18:44:27 +0000 (12:44 -0600)]
Fix up safe_strerror constification
The earlier patch to constify safe_strerror missed a couple of spots,
corrected here.
gdb/ChangeLog
2019-11-01 Tom Tromey <tromey@adacore.com>
* gdbsupport/mingw-strerror.c (safe_strerror): Constify result.
Change-Id: I36d5ced144d27b1a6734d9ab9a10a7b9f339ae88
Christian Biesinger [Thu, 31 Oct 2019 23:24:07 +0000 (18:24 -0500)]
Move check for strerror_r to common.m4 where it belongs
gdb/ChangeLog:
2019-11-01 Christian Biesinger <cbiesinger@google.com>
* configure: Regenerate.
* configure.ac: Remove check for strerror_r.
* gdbsupport/common.m4: Check for strerror_r.
gdb/gdbserver/ChangeLog:
2019-11-01 Christian Biesinger <cbiesinger@google.com>
* configure: Regenerate.
* configure.ac: Remove check for strerror_r.
Change-Id: Ibc290c3f84b1db23e998cffdbe2c1f97651d2a8d
Luis Machado [Fri, 1 Nov 2019 13:11:17 +0000 (10:11 -0300)]
[ARM, thumb] Fix disassembling bug after reloading a symbol file
The speed optimization from commit
5f6cac4085c95c5339b9549dc06d4f9184184fa6
made GDB skip reloading all symbols when the same symbol file is reloaded.
As a result, ARM targets only read the mapping symbols the first time we
load a symbol file. When reloaded, the speed optimization above will
cause an early return and gdbarch_record_special_symbol won't be called to
save mapping symbol data, which in turn affects disassembling of thumb
instructions.
First load and correct disassemble output:
Dump of assembler code for function main:
0x0000821c <+0>: bx pc
0x0000821e <+2>: nop
0x00008220 <+4>: mov r0, #0
0x00008224 <+8>: bx lr
Second load and incorrect disassemble output:
Dump of assembler code for function main:
0x0000821c <+0>: bx pc
0x0000821e <+2>: nop
0x00008220 <+4>: movs r0, r0
0x00008222 <+6>: b.n 0x8966
0x00008224 <+8>: vrhadd.u16 d14, d14, d31
This happens because the mapping symbol data is stored in an objfile_key-based
container, and that data isn't preserved across the two symbol loading
operations.
The following patch fixes this by storing the mapping symbol data in a
bfd_key-based container, which doesn't change as long as the bfd is the same.
I've also added a new test to verify the correct disassemble output.
gdb/ChangeLog:
2019-11-01 Luis Machado <luis.machado@linaro.org>
PR gdb/25124
* arm-tdep.c (arm_per_objfile): Rename to ...
(arm_per_bfd): ... this.
(arm_objfile_data_key): Rename to ...
(arm_bfd_data_key): ... this.
(arm_find_mapping_symbol): Adjust access to new bfd_key-based
data.
(arm_record_special_symbol): Likewise.
gdb/testsuite/ChangeLog:
2019-11-01 Luis Machado <luis.machado@linaro.org>
PR gdb/25124
* gdb.arch/pr25124.S: New file.
* gdb.arch/pr25124.exp: New file.
Change-Id: I22c3e6ebe9bfedad66d56fe9656994fa1761c485
GDB Administrator [Fri, 1 Nov 2019 00:00:27 +0000 (00:00 +0000)]
Automatic date update in version.in
Andrew Burgess [Tue, 24 Sep 2019 22:01:14 +0000 (23:01 +0100)]
gdb: Don't print a newline in language la_print_typedef methods
When calling the language la_print_typedef method, don't include a
newline at the end, instead print the newline from the users of
la_print_typedef.
This change will be useful in a later commit when the output from
la_print_typedef will be placed into an MI output field, in which case
the trailing newline is not required.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-typeprint.c (ada_print_typedef): Don't print newline at the
end.
* c-typeprint.c (c_print_typedef): Likewise.
* f-typeprint.c (f_print_typedef): Likewise.
* m2-typeprint.c (m2_print_typedef): Likewise.
* p-typeprint.c (pascal_print_typedef): Likewise.
* rust-lang.c (rust_print_typedef): Likewise.
* symtab.c (print_symbol_info): Print a newline after calling
typedef_print.
Change-Id: I6e697ea1ec0eadaa31aefaea959b2055188d680d
Andrew Burgess [Wed, 10 Jul 2019 14:54:03 +0000 (15:54 +0100)]
gdb: Add new commands to list module variables and functions
This patch adds two new commands "info module functions" and "info
module variables". These commands list all of the functions and
variables grouped by module and then by file.
For example:
(gdb) info module functions
All functions in all modules:
Module "mod1":
File /some/path/gdb/testsuite/gdb.fortran/info-types.f90:
35: void mod1::__copy_mod1_M1t1(Type m1t1, Type m1t1);
25: void mod1::sub_m1_a(integer(kind=4));
31: integer(kind=4) mod1::sub_m1_b(void);
Module "mod2":
File /some/path/gdb/testsuite/gdb.fortran/info-types.f90:
41: void mod2::sub_m2_a(integer(kind=4), logical(kind=4));
49: logical(kind=4) mod2::sub_m2_b(real(kind=4));
The new commands take set of flags that allow the output to be
filtered, the user can filter by variable/function name, type, or
containing module.
As GDB doesn't currently track the relationship between a module and
the variables or functions within it in the symbol table, so I filter
based on the module prefix in order to find the functions or variables
in each module. What this makes clear is that a user could get this
same information using "info variables" and simply provide the prefix
themselves, for example:
(gdb) info module functions -m mod1 _a
All functions matching regular expression "_a",
in all modules matching regular expression "mod1":
Module "mod1":
File /some/path/gdb/testsuite/gdb.fortran/info-types.f90:
25: void mod1::sub_m1_a(integer(kind=4));
Is similar to:
(gdb) info functions mod1::.*_a.*
All functions matching regular expression "mod1::.*_a":
File /some/path/gdb/testsuite/gdb.fortran/info-types.f90:
25: void mod1::sub_m1_a(integer(kind=4));
The benefits I see for a separate command are that the user doesn't
have to think (or know) about the module prefix format, nor worry
about building a proper regexp. The user can also easily scan across
modules without having to build complex regexps.
The new function search_module_symbols is extern in this patch despite
only being used within symtab.c, this is because a later patch in this
series will also be using this function from outside symtab.c.
This patch is a new implementation of an idea originally worked on by
Mark O'Connor, Chris January, David Lecomber, and Xavier Oro from ARM.
gdb/ChangeLog:
* symtab.c (info_module_cmdlist): New variable.
(info_module_command): New function.
(search_module_symbols): New function.
(info_module_subcommand): New function.
(struct info_modules_var_func_options): New struct.
(info_modules_var_func_options_defs): New variable.
(make_info_modules_var_func_options_def_group): New function.
(info_module_functions_command): New function.
(info_module_variables_command): New function.
(info_module_var_func_command_completer): New function.
(_initialize_symtab): Register new 'info module functions' and
'info module variables' commands.
* symtab.h (typedef symbol_search_in_module): New typedef.
(search_module_symbols): Declare new function.
* NEWS: Mention new commands.
gdb/doc/ChangeLog:
* gdb.texinfo (Symbols): Document new 'info module variables' and
'info module functions' commands.
gdb/testsuite/ChangeLog:
* gdb.fortran/info-modules.exp: Update expected results, and add
additional tests for 'info module functinos', and 'info module
variables'.
* gdb.fortran/info-types.exp: Update expected results.
* gdb.fortran/info-types.f90: Extend testcase with additional
module variables and functions.
Change-Id: I8c2960640e2e101b77eff54027d687e21ec22e2b
Andrew Burgess [Tue, 9 Jul 2019 20:38:59 +0000 (21:38 +0100)]
gdb/fortran: Add new 'info modules' command
Add a new command 'info modules' that lists all of the modules GDB
knows about from the debug information.
A module is a debugging entity in the DWARF defined with
DW_TAG_module, currently Fortran is known to use this tag for its
modules. I'm not aware of any other language that currently makes use
of DW_TAG_module.
The output style is similar to the 'info type' output:
(gdb) info modules
All defined modules:
File info-types.f90:
16: mod1
24: mod2
(gdb)
Where the user is told the file the module is defined in and, on the
left hand side, the line number at which the module is defined along
with the name of the module.
This patch is a new implementation of an idea originally worked on by
Mark O'Connor, Chris January, David Lecomber, and Xavier Oro from ARM.
gdb/ChangeLog:
* dwarf2read.c (dw2_symtab_iter_next): Handle MODULE_DOMAIN.
(dw2_expand_marked_cus): Handle MODULES_DOMAIN.
(dw2_debug_names_iterator::next): Handle MODULE_DOMAIN and
MODULES_DOMAIN.
(scan_partial_symbols): Only create partial module symbols for non
declarations.
* psymtab.c (recursively_search_psymtabs): Handle MODULE_DOMAIN
and MODULES_DOMAIN.
* symtab.c (search_domain_name): Likewise.
(search_symbols): Likewise.
(print_symbol_info): Likewise.
(symtab_symbol_info): Likewise.
(info_modules_command): New function.
(_initialize_symtab): Register 'info modules' command.
* symtab.h (enum search_domain): Add MODULES_DOMAIN.
* NEWS: Mention new 'info modules' command.
gdb/doc/ChangeLog:
* gdb.texinfo (Symbols): Document new 'info modules' command.
gdb/testsuite/ChangeLog:
* gdb.fortran/info-modules.exp: New file.
* gdb.fortran/info-types.exp: Build with new file.
* gdb.fortran/info-types.f90: Include and use new module.
* gdb.fortran/info-types-2.f90: New file.
Change-Id: I2b781dd5a06bcad04620ccdc45f01a0f711adfad
Philippe Waroquiers [Sun, 28 Apr 2019 12:44:44 +0000 (14:44 +0200)]
NEWS and documentation for $_gdb_setting and $_gdb_setting_str.
gdb/ChangeLog
2019-10-31 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* NEWS: Mention $_gdb_setting, $_gdb_setting_str, $_gdb_maint_setting
and $_gdb_maint_setting_str.
gdb/doc/ChangeLog
2019-10-31 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* gdb.texinfo (Convenience Funs): Document the new
$_gdb_setting_str, $_gdb_maint_setting and $_gdb_maint_setting_str
convenience functions.
Philippe Waroquiers [Sun, 28 Apr 2019 12:40:50 +0000 (14:40 +0200)]
Test the convenience functions $_gdb_setting and $_gdb_setting_str.
gdb/testsuite/ChangeLog
2019-10-31 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* gdb.base/setshow.exp: Test $_gdb_setting and $_gdb_setting_str.
* gdb.base/settings.exp: Test all settings types using
$_gdb_maint_setting and $_gdb_maint_setting_str in proc_show_setting,
that now verifies that the value of "maint show" is the same as
returned by the settings functions. Test the type of the
maintenance settings.
* gdb.base/default.exp: Update show_conv_list.
Philippe Waroquiers [Sun, 28 Apr 2019 12:38:18 +0000 (14:38 +0200)]
Implement convenience functions to examine GDB settings.
The new convenience functions $_gdb_setting and $_gdb_setting_str
provide access to the GDB settings in user-defined commands.
Similarly, $_gdb_maint_setting and $_gdb_maint_setting_str
provide access to the GDB maintenance settings.
The patch was developed following a comment of Eli about the
'set may-call-functions'. Eli said that user-defined functions
should have a way to change their behavior according to this setting.
Rather than have a specialized $_may_call_functions, this patch
implements a general way to access any GDB setting.
Compared to doing such access via Python 'gdb.parameter' and/or
'gdb.execute("set somesetting tosomevalue"):
* The 'with' command is much better than the above python usage:
if the user types C-c or an error happens between the set pagination off
and the python "set pagination on", the above python
does not restore the original setting.
* Effectively, with the "gdb.parameter" python one liner, it is possible to do
simple 'if' conditions, such as set and restore pagination.
But mixing the "python if" within canned
sequence of commands is cumbersome for non trivial combinations.
E.g. if several commands have to be done for a certain condition
accessed from python, I guess something like will be needed:
python if __some_setting: gdb.execute("some command")
python if __some_setting: gdb.execute("some other command")
python if __some_setting: gdb.execute("some different command")
(without speaking about nested "if-s").
With the convenience function:
if $_gdb_setting("some_setting")
some command
some other command
some different command
end
Integer settings (for example print elements) will also be more difficult
to use.
For example, a user defined function that scans and prints a linked list
might want to use the value of "set print elements" to stop printing
the linked list.
Doing that by mixing python expression/if is likely doable, but seems
not easy with the above one liners.
So, in summary, the $_gdb_setting and $_gdb_setting_str avoids to have the
heterogeneous mix of python and GDB commands in one single script
(and of course, it works even if python is not configured, but that
must be an unusual setup I guess).
gdb/ChangeLog
2019-10-31 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* cli/cli-cmds.c (setting_cmd, value_from_setting)
(gdb_setting_internal_fn, gdb_maint_setting_internal_fn)
(str_value_from_setting, gdb_setting_str_internal_fn)
(gdb_maint_setting_str_internal_fn): New functions.
(_initialize_cli_cmds): Define the new convenience functions.
* gdb/cli/cli-setshow.h (get_setshow_command_value_string): Constify.
* gdb/cli/cli-setshow.c (get_setshow_command_value_string): Constify.
Christian Biesinger [Thu, 31 Oct 2019 22:02:05 +0000 (17:02 -0500)]
Also check for strerror_r in gdbserver
I forgot to do this in
b231e86ac9608056ea837e24d42a878927f5787a
Since safe_strerror is in gdbsupport, gdbserver also needs to
check for strerror_r, although it's less critical since gdbserver
does not use threads as much.
gdb/gdbserver/ChangeLog:
2019-10-31 Christian Biesinger <cbiesinger@google.com>
* config.in: Regenerate.
* configure: Regenerate.
* configure.ac: Also check for strerror_r.
Change-Id: I6a67c8543cd7a28d6dc94f5986f56abcb55727fe
Tom de Vries [Thu, 31 Oct 2019 22:03:25 +0000 (23:03 +0100)]
[gdb/testsuite] Remove superfluous 3rd argument from gdb_test call (2)
There's a pattern:
...
gdb_test <command> <pattern> <command>
...
that can be written shorter as:
...
gdb_test <command> <pattern>
...
Detect this pattern in proc gdb_test:
...
global gdb_prompt
upvar timeout timeout
if [llength $args]>2 then {
set message [lindex $args 2]
+ if { $message == [lindex $args 0] && [llength $args] == 3 } {
+ error "HERE"
+ }
} else {
set message [lindex $args 0]
}
...
and fix all occurrences in some gdb testsuite subdirs.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2019-10-31 Tom de Vries <tdevries@suse.de>
* gdb.arch/amd64-disp-step-avx.exp: Drop superfluous 3rd argument to
gdb_test.
* gdb.arch/amd64-disp-step.exp: Same.
* gdb.asm/asm-source.exp: Same.
* gdb.btrace/buffer-size.exp: Same.
* gdb.btrace/cpu.exp: Same.
* gdb.btrace/enable.exp: Same.
* gdb.dwarf2/count.exp: Same.
* gdb.dwarf2/dw2-ranges-func.exp: Same.
* gdb.dwarf2/dw2-ranges-psym.exp: Same.
* gdb.fortran/vla-datatypes.exp: Same.
* gdb.fortran/vla-history.exp: Same.
* gdb.fortran/vla-ptype.exp: Same.
* gdb.fortran/vla-value.exp: Same.
* gdb.fortran/whatis_type.exp: Same.
* gdb.guile/guile.exp: Same.
* gdb.multi/tids.exp: Same.
* gdb.python/py-finish-breakpoint.exp: Same.
* gdb.python/py-framefilter.exp: Same.
* gdb.python/py-pp-registration.exp: Same.
* gdb.python/py-xmethods.exp: Same.
* gdb.python/python.exp: Same.
* gdb.server/connect-with-no-symbol-file.exp: Same.
* gdb.server/no-thread-db.exp: Same.
* gdb.server/run-without-local-binary.exp: Same.
* gdb.stabs/weird.exp: Same.
* gdb.threads/attach-many-short-lived-threads.exp: Same.
* gdb.threads/thread-find.exp: Same.
* gdb.threads/tls-shared.exp: Same.
* gdb.threads/tls.exp: Same.
* gdb.threads/wp-replication.exp: Same.
* gdb.trace/ax.exp: Same.
* lib/gdb.exp (gdb_test_exact, help_test_raw): Same.
Change-Id: I2fa544c68f8c0099a77e03ff04ddc010eb2b6c7c
Christian Biesinger [Thu, 31 Oct 2019 00:10:13 +0000 (19:10 -0500)]
Don't read agent symbols when disabled
This avoids unnecessary work, and becomes important with the patch in
https://sourceware.org/ml/gdb-patches/2019-10/msg01143.html
gdb/ChangeLog:
2019-10-31 Christian Biesinger <cbiesinger@google.com>
* agent.c (set_can_use_agent): When the setting is turned on,
look up agent symbols if we don't have them yet.
(agent_new_objfile): Don't look up agent symbols when the agent
setting is off.
Change-Id: I6523a5640c95d38299998050a6c620e51096e8ed
Christian Biesinger [Thu, 31 Oct 2019 20:38:25 +0000 (15:38 -0500)]
Regenerate config.in
I forgot to do this in the last commit
(
b231e86ac9608056ea837e24d42a878927f5787a)
gdb/ChangeLog:
2019-10-31 Christian Biesinger <cbiesinger@google.com>
* config.in: Regenerate.
Change-Id: I60946ffd853a59469c35f19ef8012ac6ea88a31c
Christian Biesinger [Thu, 31 Oct 2019 19:41:19 +0000 (14:41 -0500)]
Use strerror_r in safe_strerror if available
Also stores the result in a thread-local static variable and
changes the return value to a const char*.
This is already important because Guile creates threads and
Python can create threads, but with the patch series here:
https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/176
GDB itself will create threads, too.
gdb/ChangeLog:
2019-10-31 Christian Biesinger <cbiesinger@google.com>
* configure: Regenerate.
* configure.ac: Check for strerror_r.
* gdbsupport/common-utils.h (safe_strerror): Change return value
to const char * and document that this function is now threadsafe.
* gdbsupport/posix-strerror.c (safe_strerror): Make buf
thread_local and call strerror_r, if available.
* utils.c (perror_string): Update.
(print_sys_errmsg): Update.
Change-Id: I81048fbaf148035c221c528727f7efe58ba528eb
Luis Machado [Thu, 31 Oct 2019 19:30:44 +0000 (16:30 -0300)]
[ARM] Store exception handling information per-bfd instead of per-objfile
Based on feedback from Tromey, update the use of objfile_key in gdb/arm-tdep.c
to use bfd_key instead. That way we don't have to re-create the exception
handling data all over again if it was done before for the same BFD.
gdb/ChangeLog:
2019-10-31 Luis Machado <luis.machado@linaro.org>
* arm-tdep.c (arm_exidx_data_key): Use bfd_key instead of
objfile_key.
(arm_exidx_new_objfile): Adjust to use objfile->obfd instead of
objfile to fetch per-bfd data.
(arm_find_exidx_entry): Likewise.
Change-Id: Ia7b3208ea8d788414600fa6d770ac76db0562859
Christian Biesinger [Wed, 30 Oct 2019 21:19:11 +0000 (16:19 -0500)]
Convert int to bool in agent.c
Also moves an int declaration inside the for loop.
Code cleanup, no change in behavior intended.
gdb/ChangeLog:
2019-10-31 Christian Biesinger <cbiesinger@google.com>
* gdbsupport/agent.c (debug_agent): Change type to bool.
(use_agent): Likewise.
(all_agent_symbols_look_up): Likewise.
(agent_loaded_p): Change return value to bool.
(agent_look_up_symbols): Update.
(agent_capability_check): Change return value to bool.
* gdbsupport/agent.h (agent_loaded_p): Likewise.
(debug_agent): Change type to bool.
(use_agent): Likewise.
(agent_capability_check): Change return value to bool.
gdb/gdbserver/ChangeLog:
2019-10-31 Christian Biesinger <cbiesinger@google.com>
* ax.h (debug_agent): Remove duplicate declaration.
Change-Id: Icb28a65fcc8c7108bcd59287e6be66bf56f8ccb5
H.J. Lu [Thu, 31 Oct 2019 17:42:04 +0000 (10:42 -0700)]
i386; Add .code16gcc fldenv tests
* testsuite/gas/i386/general.s: Add .code16gcc fldenv tests.
* testsuite/gas/i386/general.l: Updated.
Tom de Vries [Thu, 31 Oct 2019 16:37:02 +0000 (17:37 +0100)]
[gdb/testsuite] Remove superfluous 3rd argument from gdb_test call
There's a pattern:
...
gdb_test <command> <pattern> <command>
...
that can be written shorter as:
...
gdb_test <command> <pattern>
...
Detect this pattern in proc gdb_test:
...
global gdb_prompt
upvar timeout timeout
if [llength $args]>2 then {
set message [lindex $args 2]
+ if { $message == [lindex $args 0] } {
+ error "HERE"
+ }
} else {
set message [lindex $args 0]
}
...
and fix all occurences in gdb.ada.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2019-10-31 Tom de Vries <tdevries@suse.de>
* gdb.ada/array_bounds.exp: Drop superfluous 3rd argument to gdb_test.
* gdb.ada/array_subscript_addr.exp: Same.
* gdb.ada/arrayidx.exp: Same.
* gdb.ada/arrayparam.exp: Same.
* gdb.ada/arrayptr.exp: Same.
* gdb.ada/boolean_expr.exp: Same.
* gdb.ada/call_pn.exp: Same.
* gdb.ada/complete.exp: Same.
* gdb.ada/fixed_cmp.exp: Same.
* gdb.ada/fun_addr.exp: Same.
* gdb.ada/funcall_param.exp: Same.
* gdb.ada/interface.exp: Same.
* gdb.ada/mod_from_name.exp: Same.
* gdb.ada/null_array.exp: Same.
* gdb.ada/packed_array.exp: Same.
* gdb.ada/packed_tagged.exp: Same.
* gdb.ada/print_chars.exp: Same.
* gdb.ada/print_pc.exp: Same.
* gdb.ada/ptype_arith_binop.exp: Same.
* gdb.ada/ptype_field.exp: Same.
* gdb.ada/ptype_tagged_param.exp: Same.
* gdb.ada/rec_return.exp: Same.
* gdb.ada/ref_tick_size.exp: Same.
* gdb.ada/str_ref_cmp.exp: Same.
* gdb.ada/taft_type.exp: Same.
* gdb.ada/tagged.exp: Same.
* gdb.ada/type_coercion.exp: Same.
* gdb.ada/uninitialized_vars.exp: Same.
Change-Id: Ibb84a41573c7f21295f3fd42da9b96534205c5c4
Mihail Ionescu [Thu, 31 Oct 2019 11:22:58 +0000 (11:22 +0000)]
Add support for context sensitive '.arch_extension' to the ARM assembler.
If the extension is not found in the context sensitive table, the legacy
tables are still checked as a fallback. This is particularly useful for
Armv8.1-M as it enables the use of '.arch_extension' with the 'mve' and
'mve.fp' extensions which are not part of the legacy table.
* config/tc-arm.c (selected_ctx_ext_table) New static variable.
(arm_parse_arch): Set context sensitive extension table based on the
chosen base architecture.
(s_arm_arch_extension): Change to lookup extensions in the new context
sensitive tables.
* gas/testsuite/gas/arm/mve-ext.s: New.
* gas/testsuite/gas/arm/mve-ext.d: New.
* gas/testsuite/gas/arm/mvefp-ext.s: New.
* gas/testsuite/gas/arm/mvefp-ext.d: New.
GDB Administrator [Thu, 31 Oct 2019 00:00:22 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom de Vries [Wed, 30 Oct 2019 16:41:03 +0000 (17:41 +0100)]
[gdb/testsuite] Add -early pattern flag for gdb_test_multiple
Proc gdb_test_multiple builds up and executes a gdb_expect expression with
pattern/action clauses. The clauses are either implicit (added by
gdb_test_multiple) or explicit (passed via the gdb_test_multiple parameter
user_code).
However, there are a few implicit clauses which are inserted before the
explicit ones, making sure those take precedence.
Add an -early pattern flag for a gdb_test_multiple user_code clause to specify
that the clause needs to be inserted before any implicit clause.
Using this pattern flag, we can f.i. setup a kfail for an assertion failure
<assert> during gdb_continue_to_breakpoint by the rewrite:
...
gdb_continue_to_breakpoint <msg> <pattern>
...
into:
...
set breakpoint_pattern "(?:Breakpoint|Temporary breakpoint) .* (at|in)"
gdb_test_multiple "continue" "continue to breakpoint: <msg>" {
-early -re "internal-error: <assert>" {
setup_kfail gdb/nnnnn "*-*-*"
exp_continue
}
-re "$breakpoint_pattern <pattern>\r\n$gdb_prompt $" {
pass $gdb_test_name
}
}
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2019-10-30 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (gdb_test_multiple): Handle -early pattern flag.
Change-Id: I376c636b0812be52e7137634b1a4f50bf2b999b6
Christian Biesinger [Tue, 29 Oct 2019 22:14:48 +0000 (17:14 -0500)]
Only clear the minsym array when necessary
The array starts out initialized to zero:
minimal_symbol *msymbol_hash[MINIMAL_SYMBOL_HASH_SIZE] {};
So we only need to explicitly clear it if there were previous minsyms
added to it. This patch does that.
gdb/ChangeLog:
2019-10-30 Christian Biesinger <cbiesinger@google.com>
* minsyms.c (clear_minimal_symbol_hash_tables): New function.
(build_minimal_symbol_hash_tables): Code to clear the table moved
to clear_minimal_symbol_hash_tables.
(minimal_symbol_reader::install): Call clear_minimal_symbol_hash_tables
when needed.
Change-Id: I7da994fe6747f67714e7efe9fdbb0dbc4d6ea532
Delia Burduv [Wed, 30 Oct 2019 13:23:35 +0000 (13:23 +0000)]
Modify the ARNM assembler to accept the omission of the immediate argument for the writeback form of the LDRAA and LDRAB mnemonics
This is a shorthand for the immediate argument being 0, as described here:
https://developer.arm.com/docs/ddi0596/latest/base-instructions-alphabetic-order/ldraa-ldrab-load-register-with-pointer-authentication
This is because the instructions still have a use with an immediate
argument of 0, unlike loads without the PAC functionality. Currently,
the mnemonics are
LDRAA Xt, [Xn, #<simm10>]!
LDRAB Xt, [Xn, #<simm10>]!
After this patch they become
LDRAA Xt, [Xn {, #<simm10>}]!
LDRAB Xt, [Xn {, #<simm10>}]!
gas * config/tc-aarch64.c (parse_address_main): Accept the omission of
the immediate argument for ldraa and ldrab as a shorthand for the
immediate being 0.
* testsuite/gas/aarch64/ldraa-ldrab-no-offset.d: New test.
* testsuite/gas/aarch64/ldraa-ldrab-no-offset.s: New test.
* testsuite/gas/aarch64/illegal-ldraa.s: Modified to accept the
writeback form with no offset.
* testsuite/gas/aarch64/illegal-ldraa.s: Removed missing offset
error.
opcodes * aarch64-opc.c (print_immediate_offset_address): Don't print the
immediate for the writeback form of ldraa/ldrab if it is 0.
* aarch64-tbl.h: Updated the documentation for ADDR_SIMM10.
* aarch64-opc-2.c: Regenerated.
Keith Seitz [Wed, 30 Oct 2019 12:23:16 +0000 (12:23 +0000)]
Add the ability to the BFD library to read build-ids from core flies.
* elf-bfd.h (elf_backend_data) <elf_backend_core_find_build_id>:
New field.
(_bfd_elf32_core_find_build_id, _bfd_elf64_core_find_build_id):
New functions.
(elf_read_notes): Add declaration.
* elf.c (elf_read_notes): Move elf-bfd.h.
(_bfd_elf_core_find_build_id): New function.
(bfd_section_from_phdr): Scan core file PT_LOAD segments for
build-id if none is known.
(elf_parse_notes): For core files, scan for notes.
* elfcore.h (elf_core_file_matches_executable_p): If both
BFDs have identical build-ids, then they match.
(_bfd_elf_core_find_build_id): New function.
* elfxx-target.h (elf_backend_core_find_build_id): Define.
(elfNN_bed): Add elf_backend_core_find_build_id.
Nick Clifton [Wed, 30 Oct 2019 10:52:15 +0000 (10:52 +0000)]
Update email address for Palmer Dabbelt.
* MAINTAINERS: Change palmer@sifive.com to palmer@dabbelt.com.
Fangrui Song [Wed, 30 Oct 2019 10:50:23 +0000 (10:50 +0000)]
Add a --output=<DIR> option to ar to allow the specifying of an output directory.
* ar.c (emum long option numbers): Declare. Use to provide
numerical values for long options.
(long_options): Add --output option.
(usage): Mention the --output option.
(open_output_file): New function. Create a filepath for an output
file and open it.
(extract_file): Use open_output_file().
(open_output_file):
* testsuite/binutils-all/ar.exp: Add a test of the new feature.
* doc/binutils.texi: Document the new feature.
* NEWS: Mention the new feature.
Jan Beulich [Wed, 30 Oct 2019 08:09:13 +0000 (09:09 +0100)]
x86: add tests to cover defaulting of operand sizes for ambiguous insns
Prior to changing the logic in the assembler install tests to make sure
the present defaulting of operand sizes won't get broken. There are a
few anomalies pointed out by this:
- arithmetic insns (add, sub, etc) allow defaulting when their immediate
fits in (signed) 8 bits, but they fail to assemble with larger values,
- mov, other than arithmetic insns, doesn't allow any defaulting,
- movsx/movzx default to byte sources (in AT&T mode), and their special
casing needs to be adjusted first
- bt and friends allow defaulting, while shl and friends don't,
- ambiguous AVX and AVX512 insns don't allow defaulting.
This should ultimately all become consistent (perhaps with the exception
some of the SIMD insns); respective tests will be added to the test
cases here as the issues get addressed.
Jan Beulich [Wed, 30 Oct 2019 08:07:40 +0000 (09:07 +0100)]
x86: re-do "shorthand" handling
Now that the opcode table gets preprocessed, undo parts of commit
dc821c5f9a ("x86: replace Reg8, Reg16, Reg32, and Reg64"): Have the
preprocessor handle the expansion there, while making the expansions
explicit in i386-gen and the register table.
Jan Beulich [Wed, 30 Oct 2019 08:06:42 +0000 (09:06 +0100)]
x86: slightly rearrange struct insn_template
This avoids holes between the individual fields, (potentially) shrinking
the overall template table size by 4 bytes per entry.
Jan Beulich [Wed, 30 Oct 2019 08:05:46 +0000 (09:05 +0100)]
x86: drop stray W
The flag is used to indicate opcodes which can be switched between byte
and word/dword/qword forms (in a "canonical" way). Obviously it's quite
odd then to see it on insns not allowing for byte operands in the first
place. As a result the opcode bytes need to be adjusted accordingly,
which includes comparisons done in optimize_encoding().
To make re-introduction of such issues less likely have i386-gen
diagnose it (in a generally non-fatal way for now).
GDB Administrator [Wed, 30 Oct 2019 00:01:25 +0000 (00:01 +0000)]
Automatic date update in version.in
Simon Marchi [Tue, 29 Oct 2019 21:54:35 +0000 (17:54 -0400)]
Remove unused includes in infcmd.c and infrun.c
include-what-you-use reported this:
../../../src/binutils-gdb/gdb/infcmd.c should remove these lines:
- #include <signal.h> // lines 22-22
- #include "cli/cli-decode.h" // lines 48-48
- #include "cli/cli-utils.h" // lines 56-56
- #include "event-top.h" // lines 38-38
- #include "infcall.h" // lines 57-57
- #include "parser-defs.h" // lines 39-39
../../../src/binutils-gdb/gdb/infrun.c should remove these lines:
- #include <signal.h> // lines 37-37
- #include "cli/cli-script.h" // lines 31-31
- #include "continuations.h" // lines 54-54
- #include "dictionary.h" // lines 45-45
- #include "gdbsupport/gdb_wait.h" // lines 28-28
- #include "interps.h" // lines 55-55
Remove those includes.
Tested by rebuilding, and by quick inspection that the include fields
were indeed unnecessary.
gdb/ChangeLog:
* infcmd.c: Remove includes.
* infrun.c: Remove includes.
Change-Id: I5e25af54ecd2235960c4127add8f604ddbb19153
Simon Marchi [Tue, 29 Oct 2019 21:52:24 +0000 (17:52 -0400)]
Clean up ada-lang.h
This patch cleans up ada-lang.h:
- Some functions just don't exist anymore, remove their declaration
- Some functions are implemented in ada-lang.c and only used there, make
them static to that file.
I moved some functions higher in the file to avoid having to
forward-declare them, but the implementations are unchanged.
gdb/ChangeLog:
* ada-lang.h (GROW_VECT): Move to ada-lang.c.
(grow_vect): Remove declaration.
(ada_type_of_array): Remove declaration.
(ada_update_initial_language): Remove declaration.
(ada_fold_name): Remove declaration.
(ada_fill_in_ada_prototype): Remove declaration.
(user_select_syms): Remove declaration.
(get_selections): Remove declaration.
(ada_tag_type): Remove declaration.
(ada_value_tag): Remove declaration.
(ada_is_others_clause): Remove declaration.
(ada_in_variant): Remove declaration.
(ada_value_struct_elt): Remove declaration.
(ada_attribute_name): Remove declaration.
(ada_system_address_type): Remove declaration.
* ada-lang.c (ada_watch_location_expression): Make static.
(GROW_VECT): Move here from ada-lang.h.
(grow_vect): Make static.
(ada_update_initial_language): Make static.
(ada_fold_name): Make static.
(ada_type_of_array): Make static.
(encoded_ordered_before): Move up.
(sort_choices): Move up.
(print_signatures): Move up.
(ada_print_symbol_signature): Move up.
(get_selections): Move up and make static.
(user_select_syms): Move up and make static.
(ada_value_struct_elt): Move up and make static.
(ada_tag_type): Make static.
(ada_value_tag): Make static.
(ada_is_others_clause): Make static.
(ada_in_variant): Make static.
(ada_attribute_name): Make static.
Change-Id: If0d46ba87d6585ab674c87244068a19e84718fc9
Simon Marchi [Tue, 29 Oct 2019 21:52:15 +0000 (17:52 -0400)]
Remove unused includes in ada-*.c files
include-what-you-use reports:
../../../src/binutils-gdb/gdb/ada-lang.c should remove these lines:
- #include <sys/stat.h> // lines 43-43
- #include <map> // lines 66-66
- #include "c-lang.h" // lines 33-33
- #include "demangle.h" // lines 23-23
- #include "dictionary.h" // lines 47-47
- #include "gdbsupport/gdb_vecs.h" // lines 53-53
- #include "psymtab.h" // lines 58-58
../../../src/binutils-gdb/gdb/ada-lang.c should remove these lines:
- #include <sys/stat.h> // lines 43-43
- #include <map> // lines 66-66
- #include "c-lang.h" // lines 33-33
- #include "demangle.h" // lines 23-23
- #include "dictionary.h" // lines 47-47
- #include "gdbsupport/gdb_vecs.h" // lines 53-53
- #include "psymtab.h" // lines 58-58
../../../src/binutils-gdb/gdb/ada-valprint.c should remove these lines:
- #include "c-lang.h" // lines 31-31
- #include "demangle.h" // lines 26-26
- #include "infcall.h" // lines 32-32
- #include "objfiles.h" // lines 33-33
- #include "symtab.h" // lines 22-22
Remove these includes. Adding an include for gdbarch.h in
ada-valprint.c was necessary, because gdbarch_byte_order wouldn't be
found anymore.
gdb/ChangeLog:
* ada-lang.c: Remove includes.
* ada-typeprint.c: Remove includes.
* ada-valprint.c: Remove includes.
Change-Id: I07c2f2237ef0ed5fd9aa855d33711d780794fce2
Simon Marchi [Tue, 29 Oct 2019 21:51:36 +0000 (17:51 -0400)]
addrmap: use gdb_static_assert for type size assertions
These assertions can be done at compile time instead of at runtime.
gdb/ChangeLog:
* addrmap.c: Add static assertions of type size, moved from
_initialize_addrmap.
(_initialize_addrmap): Remove.
Change-Id: If089fc5d620a7168bdcdf967c6c4fecd6696b670
Christian Biesinger [Sun, 13 Oct 2019 11:57:14 +0000 (06:57 -0500)]
Change some arguments to gdb::string_view instead of name+len
Just some code cleanup. This change has a few benefits:
- Shorter argument list in the functions
- If the caller needs to calculate the string, they no longer
need to explicitly call strlen
- It is easy to pass std::string to this (done in one place
currently)
This also updates a couple of places that were passing 0/1 to
a bool parameter.
gdb/ChangeLog:
2019-10-29 Christian Biesinger <cbiesinger@google.com>
* coffread.c (record_minimal_symbol): Update.
(process_coff_symbol): Update.
* dbxread.c (read_dbx_symtab): Update.
* dwarf2read.c (add_partial_symbol): Update.
(fixup_go_packaging): Update.
(load_partial_dies): Update.
(new_symbol): Update.
* elfread.c (record_minimal_symbol): Change signature to use
gdb::string_view instead of name+len.
(elf_symtab_read): Update.
(elf_rel_plt_read): Update.
* mdebugread.c (parse_partial_symbols): Update.
(handle_psymbol_enumerators): Update.
(new_symbol): Update.
* minsyms.c (minimal_symbol_reader::record_full): Change signature
to use gdb::string_view instead of name+len.
* minsyms.h (class minimal_symbol_reader) <record_full>: Likewise.
* psympriv.h (add_psymbol_to_list): Likewise.
* psymtab.c (add_psymbol_to_bcache): Likewise.
(add_psymbol_to_list): Likewise.
* stabsread.c (define_symbol): Update.
* symtab.c (symbol_set_names): Change signature to use gdb::string_view.
* symtab.h (SYMBOL_SET_NAMES): Likewise.
(symbol_set_names): Likewise.
* xcoffread.c (scan_xcoff_symtab): Update.
Change-Id: I2675c6865e0368f9c755a1081088a53aa54dda4c
Christian Biesinger [Tue, 22 Oct 2019 22:25:50 +0000 (17:25 -0500)]
Only make a nullterminated string if we need to
As of
7bb43059820c5febb4509b15202a93efde442bc6, we no longer need
a nullterminated linkage_name to look up the entry in the hash table.
So this patch makes it so we only make the copy if the entry was
not found.
By auditing all callers of symbol_set_names, I found out that all cases
where the string may not be nullterminated already pass true for COPY_NAME.
So here, I am documenting that as a requirement and am removing the code
that relies on undefined behavior in symbol_set_names (it accessed the string
past the provided length to check for nulltermination). Note that the Ada
case at the beginning of symbol_set_names was already relying on this.
gdb/ChangeLog:
2019-10-29 Christian Biesinger <cbiesinger@google.com>
* symtab.h (symbol_set_names): Document that copy_name must be
set to true for non-nullterminated strings.
* symtab.c (symbol_set_names): Only make a nullterminated copy of
linkage_name if the entry was not found and we need to demangle.
Change-Id: I183302e1f51483ff6dff0fd5c3b0f32f0f04a5d2
Christian Biesinger [Mon, 21 Oct 2019 18:08:03 +0000 (13:08 -0500)]
Replace bsearch with a std::lower_bound-based search
This is more type-safe and can be faster due to inlining and
avoiding overhead from calling through a function pointer.
gdb/ChangeLog:
2019-10-29 Christian Biesinger <cbiesinger@google.com>
* Makefile.in (HFILES_NO_SRCDIR): Add gdb_binary_search.h.
* dwarf2-frame.c (bsearch_fde_cmp): Update.
(dwarf2_frame_find_fde): Replace bsearch with gdb::binary_search.
* gdbsupport/gdb_binary_search.h: New file.
Change-Id: I07e0a0e333f4062b27fc68d3a3f24881ebc68fd4
Christian Biesinger [Sun, 13 Oct 2019 12:12:34 +0000 (07:12 -0500)]
Load system gdbinit files from a directory
Adds a configure option --with-system-gdbinit-dir to specify a directory
in which to look for gdbinit files. All files in this directory are
loaded on startup (subject to -n/-nx as usual) as long as the extension
matches a known and enabled scripting language (.gdb/.py/.scm).
This also changes get_ext_lang_of_file to support ".gdb" files, similar
to get_ext_lang_defn's handling of EXT_LANG_GDB.
gdb/ChangeLog:
2019-10-29 Christian Biesinger <cbiesinger@google.com>
* NEWS: Mention new --with-system-gdbinit-dir option.
* config.in: Regenerate.
* configure: Regenerate.
* configure.ac: Add new option --with-system-gdbinit-dir.
* extension.c (get_ext_lang_of_file): Return extension_language_gdb
for a ".gdb" suffix.
* main.c (get_init_files): Change system_gdbinit argument to
a vector and return the files in SYSTEM_GDBINIT_DIR in
addition to SYSTEM_GDBINIT.
(captured_main_1): Update.
(print_gdb_help): Update.
* top.c (print_gdb_configuration): Also print the value of
SYSTEM_GDBINIT_DIR.
gdb/doc/ChangeLog:
2019-10-29 Christian Biesinger <cbiesinger@google.com>
* Makefile.in: Also set SYSTEM_GDBINIT_DIR for the info manual
generation.
* gdb.texinfo (many sections): Document new --with-system-gdbinit-dir
option.
Change-Id: If233859ecc21bc6421d589b37cd658a3c7d030f2
Andrew Eikum [Tue, 29 Oct 2019 17:07:03 +0000 (17:07 +0000)]
When copying pe format files, copy the dos_message array, rather than re-initiialising it.
* libcoff-in.h (struct pe_tdata): Add dos_message field.
* libcoff.h: Regenerate.
* peXXigen.c (_bfd_XXi_only_swap_filehdr_out): Copy the
dos_message field rather than initialising it.
(_bfd_XX_bfd_copy_private_bfd_data_common): Copy the dos_message
field.
* peicode.h (pe_mkobject): Initialise the dos_message field.
(pe_mkobject_hook): Copy the dos_message field.
(pe_bfd_object_p): Copy the dos_message field.
Nick Clifton [Tue, 29 Oct 2019 15:35:30 +0000 (15:35 +0000)]
Fix array overrun when disassembling corrupt TIC30 binaries.
* tic30-dis.c (print_branch): Correct size of operand array.
Nick Clifton [Tue, 29 Oct 2019 10:25:09 +0000 (10:25 +0000)]
Fix a potential illegal array access in the D30V disassembler.
* d30v-dis.c (print_insn): Check that operand index is valid
before attempting to access the operands array.
Nick Clifton [Tue, 29 Oct 2019 10:01:27 +0000 (10:01 +0000)]
Prevent a left shift by a negative value when disassembling IA64 binaries.
* ia64-opc.c (locate_opcode_ent): Prevent a negative shift when
locating the bit to be tested.
Nick Clifton [Tue, 29 Oct 2019 09:17:39 +0000 (09:17 +0000)]
Fix array overruns in the S12Z disassembler.
* s12z-dis.c (opr_emit_disassembly): Check for illegal register
values.
(shift_size_table): Use a fixed size defined as S12Z_N_SIZES.
(print_insn_s12z): Check for illegal size values.
Andrew Eikum [Tue, 29 Oct 2019 08:02:34 +0000 (08:02 +0000)]
Fix the size of the dos_message field in the internal_extra_pe_filehdr structure on hosts where sizeof(long) == 8.
* coff/internal.h (struct internal_extra_pe_filehdr): Use ints
instead of longs to hold dos_message.
Alan Modra [Tue, 29 Oct 2019 01:05:05 +0000 (11:35 +1030)]
Re: Optimise away eh_frame advance_loc 0
If we happen to get the fixed and variable parts of the advance_loc
in different frags, bad things happen when subtracting one from a
fr_fix of zero.
PR 25125
* dw2gencfi.c (output_cfi_insn): Don't allow DW_CFA_advance_loc4
to be placed in a different frag to the rs_cfa.
GDB Administrator [Tue, 29 Oct 2019 00:00:34 +0000 (00:00 +0000)]
Automatic date update in version.in
Christian Biesinger [Tue, 1 Oct 2019 18:41:58 +0000 (13:41 -0500)]
Add a string_view version of startswith
Makes sure that the string is longer than prefix, so that strncmp will
do the right thing even if the string is not null-terminated.
For use in my string_view conversion patch:
https://sourceware.org/ml/gdb-patches/2019-10/msg00030.html
https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/125
gdb/ChangeLog:
2019-10-28 Christian Biesinger <cbiesinger@google.com>
* gdbsupport/common-utils.h (startswith): Add an overloaded version
that takes gdb::string_view arguments.
Change-Id: I5389855de2fd70e7065a789a79374b0693651b71
Nick Clifton [Mon, 28 Oct 2019 16:45:55 +0000 (16:45 +0000)]
Fix potentially illegal shift and assign operation in CSKY disassembler.
* csky-dis.c (csky_chars_to_number): Check for a negative
count. Use an unsigned integer to construct the return value.
Nick Clifton [Mon, 28 Oct 2019 16:15:34 +0000 (16:15 +0000)]
Fix buffer overrun in TIC30 disassembler.
* tic30-dis.c (OPERAND_BUFFER_LEN): Define. Use as length of
operand buffer. Set value to 15 not 13.
(get_register_operand): Use OPERAND_BUFFER_LEN.
(get_indirect_operand): Likewise.
(print_two_operand): Likewise.
(print_three_operand): Likewise.
(print_oar_insn): Likewise.
Nick Clifton [Mon, 28 Oct 2019 15:44:23 +0000 (15:44 +0000)]
Stop potential illegal memory access in the NS32K disassembler.
* ns32k-dis.c (bit_extract): Add sanitiy check of parameters.
(bit_extract_simple): Likewise.
(bit_copy): Likewise.
(pirnt_insn_ns32k): Ensure that uninitialised elements in the
index_offset array are not accessed.
Nick Clifton [Mon, 28 Oct 2019 15:06:32 +0000 (15:06 +0000)]
Prevent an illegal memory access in the xgate disassembler.
* xgate-dis.c (print_insn): Fix decoding of the XGATE_OP_DYA
operand.
GDB Administrator [Mon, 28 Oct 2019 00:00:43 +0000 (00:00 +0000)]
Automatic date update in version.in
GDB Administrator [Sun, 27 Oct 2019 00:02:01 +0000 (00:02 +0000)]
Automatic date update in version.in
John David Anglin [Sat, 26 Oct 2019 20:48:59 +0000 (16:48 -0400)]
Add some missing casts to suppress implicit cast warnings
PR gas/25121
* config/tc-hppa.c (tc_gen_reloc): Cast some enums to int.
(md_assemble): Likewise.
Alan Modra [Sat, 26 Oct 2019 08:08:26 +0000 (18:38 +1030)]
Optimise away eh_frame advance_loc 0
These can be generated when multiple cfi directives are emitted for an
instruction and the insn frag is closed off between directives, as
happens when listings are enabled. No doubt the advance_loc of zero
could be avoided by backtracking over frags in dw2gencfi.c before
calling cfi_add_advance_loc, but that seems like more work than
cleaning up afterwards as this patch does.
Noticed when looking at the testcase in PR25125.
PR 25125
* dw2gencfi.c (output_cfi_insn): Don't output DW_CFA_advance_loc+0.
* ehopt.c (eh_frame_estimate_size_before_relax): Return -1 for
an advance_loc of zero.
(eh_frame_relax_frag): Translate fr_subtype of 7 to size -1.
(eh_frame_convert_frag): Handle fr_subtype of 7. Abort on
unexpected fr_subtype.
Tom de Vries [Sat, 26 Oct 2019 07:55:32 +0000 (09:55 +0200)]
[gdb] Fix more typos in comments (2)
Fix typos in comments. NFC.
Tested on x86_64-linux.
gdb/ChangeLog:
2019-10-26 Tom de Vries <tdevries@suse.de>
* aarch64-linux-tdep.c: Fix typos in comments.
* aarch64-tdep.c: Same.
* ada-lang.c: Same.
* amd64-nat.c: Same.
* arc-tdep.c: Same.
* arch/aarch64-insn.c: Same.
* block.c: Same.
* breakpoint.h: Same.
* btrace.h: Same.
* c-varobj.c: Same.
* cli/cli-decode.c: Same.
* cli/cli-script.c: Same.
* cli/cli-utils.h: Same.
* coff-pe-read.c: Same.
* coffread.c: Same.
* compile/compile-cplus-symbols.c: Same.
* compile/compile-object-run.c: Same.
* completer.c: Same.
* corelow.c: Same.
* cp-support.c: Same.
* demangle.c: Same.
* dwarf-index-write.c: Same.
* dwarf2-frame.c: Same.
* dwarf2-frame.h: Same.
* eval.c: Same.
* frame-base.h: Same.
* frame.h: Same.
* gdbcmd.h: Same.
* gdbtypes.h: Same.
* gnu-nat.c: Same.
* guile/scm-objfile.c: Same.
* i386-tdep.c: Same.
* i386-tdep.h: Same.
* infcall.c: Same.
* infcall.h: Same.
* linux-nat.c: Same.
* m68k-tdep.c: Same.
* macroexp.c: Same.
* memattr.c: Same.
* mi/mi-cmd-disas.c: Same.
* mi/mi-getopt.h: Same.
* mi/mi-main.c: Same.
* minsyms.c: Same.
* nat/aarch64-sve-linux-sigcontext.h: Same.
* objfiles.h: Same.
* ppc-linux-nat.c: Same.
* ppc-linux-tdep.c: Same.
* ppc-tdep.h: Same.
* progspace.h: Same.
* prologue-value.h: Same.
* python/py-evtregistry.c: Same.
* python/py-instruction.h: Same.
* record-btrace.c: Same.
* record-full.c: Same.
* remote.c: Same.
* rs6000-tdep.c: Same.
* ser-tcp.c: Same.
* sol-thread.c: Same.
* sparc-sol2-tdep.c: Same.
* sparc64-tdep.c: Same.
* stabsread.c: Same.
* symfile.c: Same.
* symtab.h: Same.
* target.c: Same.
* tracepoint.c: Same.
* tui/tui-data.h: Same.
* tui/tui-io.c: Same.
* tui/tui-win.c: Same.
* tui/tui.c: Same.
* unittests/rsp-low-selftests.c: Same.
* user-regs.h: Same.
* utils.c: Same.
* utils.h: Same.
* valarith.c: Same.
* valops.c: Same.
* valprint.c: Same.
* valprint.h: Same.
* value.c: Same.
* value.h: Same.
* varobj.c: Same.
* x86-nat.h: Same.
* xtensa-tdep.c: Same.
gdb/gdbserver/ChangeLog:
2019-10-26 Tom de Vries <tdevries@suse.de>
* linux-aarch64-low.c: Fix typos in comments.
* linux-arm-low.c: Same.
* linux-low.c: Same.
* linux-ppc-low.c: Same.
* proc-service.c: Same.
* regcache.h: Same.
* server.c: Same.
* tracepoint.c: Same.
* win32-low.c: Same.
gdb/stubs/ChangeLog:
2019-10-26 Tom de Vries <tdevries@suse.de>
* ia64vms-stub.c: Fix typos in comments.
* m32r-stub.c: Same.
* m68k-stub.c: Same.
* sh-stub.c: Same.
gdb/testsuite/ChangeLog:
2019-10-26 Tom de Vries <tdevries@suse.de>
* gdb.base/bigcore.c: Fix typos in comments.
* gdb.base/ctf-ptype.c: Same.
* gdb.base/long_long.c: Same.
* gdb.dwarf2/dw2-op-out-param.S: Same.
* gdb.python/py-evthreads.c: Same.
* gdb.reverse/i387-stack-reverse.c: Same.
* gdb.trace/tfile.c: Same.
* lib/compiler.c: Same.
* lib/compiler.cc: Same.
Change-Id: I8573d84a577894270179ae30f46c48d806fc1beb
Alan Modra [Sat, 26 Oct 2019 02:39:44 +0000 (13:09 +1030)]
sort_gnu_build_notes fix
* objcopy.c (sort_gnu_build_notes): Correct sort of deleted
note2.
GDB Administrator [Sat, 26 Oct 2019 00:00:44 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Fri, 25 Oct 2019 22:13:21 +0000 (15:13 -0700)]
elfedit: Report unknown x86 feature
Report unknown x86 feature:
$ ./elfedit --disable-x86-feature foo a.out
elfedit: Error: Unknown x86 feature: foo
$
* elfedit.c (elf_x86_feature): Report unknown x86 feature.
H.J. Lu [Fri, 25 Oct 2019 22:06:39 +0000 (15:06 -0700)]
elfedit.c: Replace BYTE_PUT with byte_put
Since BYTE_PUT is defined as
#define BYTE_PUT(field, val) byte_put (field, val, sizeof (field))
use byte_put, instead of BYTE_PUT, to put 4-byte bitmask at ptr with
"byte_put (ptr, bitmask, 4)", instead of "BYTE_PUT (ptr, bitmask)", to
work with "unsigned char *ptr".
* elfedit.c (update_gnu_property): Replace BYTE_PUT with byte_put.
Ali Tamur [Mon, 21 Oct 2019 23:34:19 +0000 (16:34 -0700)]
Fix find_charset_names.
The patch
f2aec7f6d14 changed the return type of relocate_gdb_directory to
std::string, but the change is not reflected in find_charset_names function.
(Probably missed because the broken code is behind an #ifdef).
gdb/ChangeLog
* charset.c (find_charset_names): Reflect API change.
Christian Biesinger [Fri, 25 Oct 2019 19:46:40 +0000 (14:46 -0500)]
Revert unintentional change in symtab.c
In the previous commit, I accidentally changed the wrong line;
this reverts it to what it should be.
gdb/ChangeLog:
2019-10-25 Christian Biesinger <cbiesinger@google.com>
* symtab.c (symbol_set_names): Revert unintentional change in the
Ada case.
Change-Id: I9abf174927687e74c7435bd4607aab7f248c6e79
Christian Biesinger [Sun, 13 Oct 2019 11:56:58 +0000 (06:56 -0500)]
Don't make an extra copy + allocation of the demangled name
We can just keep around the malloc()-ed name we got from bfd and free
it later.
gdb/ChangeLog:
2019-10-25 Christian Biesinger <cbiesinger@google.com>
* symtab.c (struct demangled_name_entry): Change demangled name
to a unique_xmalloc_ptr<char>, now that we don't allocate it as
part of the struct anymore.
(symbol_set_names): No longer obstack allocate + copy the demangled
name, just store the allocated name from bfd.
Change-Id: Ie6ad50e1e1e73509f55d756f0a437897bb93e3b0
Nick Clifton [Fri, 25 Oct 2019 15:46:07 +0000 (16:46 +0100)]
Improve objcopy's note mergeing capabilities.
* objcopy.c (struct merged_note_section): New structure. Used to
chain together details of mergeable note sections.
(is_merged_note_section): Rename to is_megreable_note_section and
return true for note sections that use GNU_BUILD_ATTRS_SECTION_NAME
as a prefix.
(num_bytes): Delete
(objcoopy_internal_note): Add padded_namesz field.
(DEBUG_MERGE): New macro. Set to non-zero to enable debugging of
the note merging code.
(gap_exists): Rename to overlaps_or_adjoins and return TRUE for
overlapping notes or adjoining notes.
(contained_by, is_deleted_note, is_version_note)
(compare_gnu_build_notes, sort_gnu_build_notes): New functions.
(merge_gnu_build_notes): Rework. Sort notes into a mergeable
order first. Merge them. Then sort them into an ascending
address order before writing them out.
(copy_object): Handle more than one mergeable note section.
* testsuite/binutils-all/note-2-32.d: Update for new merging
behaviour.
* testsuite/binutils-all/note-2-32.s: Likewise.
* testsuite/binutils-all/note-2-64.d: Likewise.
* testsuite/binutils-all/note-2-64.s: Likewise.
* testsuite/binutils-all/note-3-32.d: Likewise.
* testsuite/binutils-all/note-3-32.s: Likewise.
* testsuite/binutils-all/note-3-64.d: Likewise.
* testsuite/binutils-all/note-3-64.s: Likewise.
* testsuite/binutils-all/note-4-32.d: Likewise.
* testsuite/binutils-all/note-4-32.s: Likewise.
* testsuite/binutils-all/note-4-64.d: Likewise.
* testsuite/binutils-all/note-4-64.s: Likewise.
* testsuite/binutils-all/note-6-32.s: New test source file.
* testsuite/binutils-all/note-6-64.s: New test source file.
* testsuite/binutils-all/note-6-32.d: New test driver file.
* testsuite/binutils-all/note-6-64.d: New test driver file.
* testsuite/binutils-all/objcopy.exp: Run the new test.
Nick Clifton [Fri, 25 Oct 2019 15:10:04 +0000 (16:10 +0100)]
Fix potential undefined behaviour in the RX disassembler.
* rx-dis.c (print_insn_rx): Use parenthesis to ensure correct
access to opcodes.op array element.
Tom Tromey [Tue, 8 Oct 2019 20:35:24 +0000 (14:35 -0600)]
Allow out-of-order reads of CIEs
Currently gdb has an assertion that requires CIEs to be read in the
order in which they appear in the debug info:
gdb_assert (n < 1
|| cie_table->entries[n - 1]->cie_pointer < cie->cie_pointer);
This assertion ensures that the table will be sorted, which is
important because it is later searched using bsearch.
However, a customer provided an executable that causes this assertion
to trigger. This executable causes decode_frame_entry_1 to call
decode_frame_entry to find the CIE, resulting in an out-of-order read.
I don't know a good way to construct a reproducer, but this can happen
if the FDE appears before its CIE. See
https://sourceware.org/bugzilla/show_bug.cgi?id=16563
This patch fixes the problem by storing CIEs in an unordered map. The
CIE table is discarded after the frame section is parsed, so this
seemed both simple and straightforward.
gdb/ChangeLog
2019-10-25 Tom Tromey <tromey@adacore.com>
* dwarf2-frame.c (dwarf2_cie_table): Now a typedef.
(bsearch_cie_cmp, add_cie): Remove.
(find_cie): Reimplement.
(decode_frame_entry_1, decode_frame_entry): Change type. Update.
(dwarf2_build_frame_info): Update.
Change-Id: I4a99597fa4b1398a9d105b683a36d992d506485c
Tom Tromey [Thu, 29 Aug 2019 14:45:06 +0000 (10:45 -0400)]
gdbserver does not need xstrdup
gdbserver has its own implementation of xstrdup. However, because
gdbserver links against libiberty now, I think this is not needed.
This patch removes it.
gdb/gdbserver/ChangeLog
2019-10-25 Tom Tromey <tromey@adacore.com>
* utils.c (xstrdup): Remove.
Change-Id: I2aa56d18d0f9af8e70a00dff431d2fda5705a5d5
Alan Modra [Fri, 25 Oct 2019 09:16:24 +0000 (19:46 +1030)]
PR25125, relaxation chooses wrong branch size
The patch I made for PR12049 didn't test for a "negative" branch
properly. "if (target < address)" ought to have been
"if (target < address + fragP->fr_fix)". Rather than making that
change, this patch adds fragP->fr_fix into address earlier. The patch
also avoids running into a bad interaction with the m68k
md_prepare_relax_scan by returning zero growth immediately, since the
adjusted target expression would result in a zero "aim".
PR gas/25125
PR gas/12049
* write.c (relax_frag): Correct calculation of delta for
positive branches where "stretch" would make the branch
negative. Return zero immediately in that case. Correct
TC_PCREL_ADJUST comment.
Tom de Vries [Fri, 25 Oct 2019 08:48:12 +0000 (10:48 +0200)]
[gdb/testsuite] Use -wrap and $gdb_test_name in gdb_test_multiple calls (2)
Make gdb_test_multiple calls shorter by using new gdb_test_multiple variable
$gdb_test_name and new gdb_test_multiple pattern flag -wrap.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2019-10-25 Tom de Vries <tdevries@suse.de>
* gdb.reverse/sigall-precsave.exp: Use -wrap and $gdb_test_name in
gdb_test_multiple calls.
* gdb.reverse/sigall-reverse.exp: Same.
* gdb.reverse/solib-precsave.exp: Same.
* gdb.reverse/solib-reverse.exp: Same.
* gdb.reverse/until-precsave.exp: Same.
* gdb.reverse/until-reverse.exp: Same.
Change-Id: I67bb327d069dbc439410996bcfe6c7f905b2ca52
Alan Modra [Wed, 23 Oct 2019 07:10:51 +0000 (17:40 +1030)]
PR4499, assign file positions assumes segment offsets increasing
This rewrites much of assign_file_positions_for_non_load_sections to
allow objcopy and strip to handle cases like that in PR4499 where
program headers were not in their usual position immediately after the
ELF file header, and PT_LOAD headers were not sorted by paddr.
PR 4499
include/
* elf/internal.h (struct elf_segment_map): Delete header_size.
Add no_sort_lma and idx.
bfd/
* elf-nacl.c (nacl_modify_segment_map): Set no_sort_lma for all
PT_LOAD segments.
* elf32-spu.c (spu_elf_modify_segment_map): Likewise on overlay
PT_LOAD segments.
* elf.c (elf_sort_segments): New function.
(assign_file_positions_except_relocs): Use shortcuts to elfheader
and elf_tdata. Seek to e_phoff not sizeof_ehdr to write program
headers. Move PT_PHDR check..
(assign_file_positions_for_non_load_sections): ..and code setting
PT_PHDR p_vaddr and p_paddr, and code setting __ehdr_start value..
(assign_file_positions_for_load_sections): ..to here. Sort
PT_LOAD headers. Delete header_pad code. Use actual number of
headers rather than allocated in calculating size for program
headers. Don't assume program headers follow ELF file header.
Simplify pt_load_count code. Only set "off" for PT_LOAD or
PT_NOTE in cores.
(rewrite_elf_program_header): Set p_vaddr_offset for segments
that include file and program headers.
(copy_elf_program_header): Likewise, replacing header_size code.
Alan Modra [Fri, 25 Oct 2019 01:51:35 +0000 (12:21 +1030)]
readelf PT_PHDR check
When PT_PHDR isn't covered by a PT_LOAD header, p_vaddr in PT_PHDR
isn't valid but the value might just pass a vaddr test. So test
p_offset as well.
* readelf.c (process_program_headers): Check PT_PHDR p_offset
as well as p_vaddr. Use p_filesz, not p_memsz, in vaddr test.
GDB Administrator [Fri, 25 Oct 2019 00:01:28 +0000 (00:01 +0000)]
Automatic date update in version.in
H.J. Lu [Thu, 24 Oct 2019 22:43:21 +0000 (15:43 -0700)]
Call forget_cached_source_info to clear the stale source cache
Clear the stale source cache when re-reading symbols.
PR gdb/25126
* symfile.c (reread_symbols): Call forget_cached_source_info to
clear the stale source cache.
Christian Biesinger [Thu, 24 Oct 2019 18:51:55 +0000 (13:51 -0500)]
Remove python_has_threads check in configure.ac
The only use of python_has_threads has been removed in
commit
404f29021abaef86a341663444fb069eb1f0282a
gdb/ChangeLog:
2019-10-24 Christian Biesinger <cbiesinger@google.com>
* configure: Rebuild.
* configure.ac: Remove code that sets python_has_threads.
Change-Id: I75f1b873562bc2abc6f2db17699a3e82fcfd2de3
Christian Biesinger [Wed, 23 Oct 2019 22:00:51 +0000 (17:00 -0500)]
Simplify Python checks in configure.ac
The version checking code is not necessary. It is only used to define
HAVE_LIBPYTHON2_6 or HAVE_LIBPYTHON2_7, which is not used anywhere.
If a version check is desired, the PY_{MAJOR,MINOR}_VERSION macro from
the Python headers can be (and is) used, which does not require updating
configure.ac whenever a new Python version is released.
gdb/ChangeLog:
2019-10-24 Christian Biesinger <cbiesinger@google.com>
* config.in: Regenerate.
* configure: Regenerate.
* configure.ac: Remove the code that uses sed to get the python
version and defines HAVE_LIBPYTHON2_6 / HAVE_LIBPYTHON2_7.
Change-Id: I07073870d9040c2bc8519882c8b3c1368edd4513
Tom de Vries [Thu, 24 Oct 2019 16:43:46 +0000 (18:43 +0200)]
[gdb/testsuite] Add -wrap pattern flag to gdb_test_multiple
Currently, in order to rewrite:
...
gdb_test <command> <pattern> <message>
...
using gdb_test_multiple, we get:
...
gdb_test_multiple <command> <message> {
-re "\[\r\n\]*(?:<pattern>)\[\r\n\]+$gdb_prompt $" {
pass $gdb_test_name
}
}
...
Add a '-wrap pattern flag to gdb_test_multiple, that wraps the regexp
pattern as gdb_test wraps its message argument.
This allows us to rewrite into the more compact:
...
gdb_test_multiple <command> <message> {
-re -wrap <pattern> {
pass $gdb_test_name
}
}
...
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2019-10-24 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (gdb_test_multiple): Add -wrap pattern flag.
* gdb.reverse/step-precsave.exp: Rewrite gdb_test_multiple containing
kfail using -wrap pattern flag and convenience variable
gdb_test_name.
Change-Id: Ie42c97d5ab7acf6db351299ccd23a83540fe6e1a
Andrew Burgess [Wed, 23 Oct 2019 12:24:02 +0000 (13:24 +0100)]
gdb/python: Return None from Progspace.block_for_pc on error
The documentation for Progspace.block_for_pc says:
Return the innermost gdb.Block containing the given pc value. If the
block cannot be found for the pc value specified, the function will
return None.
However, the implementation actually throws an error for invalid
addresses, like this:
(gdb) python print gdb.current_progspace ().block_for_pc (1)
Traceback (most recent call last):
File "<string>", line 1, in <module>
RuntimeError: Cannot locate object file for block.
Error while executing Python code.
(gdb)
This has been the behaviour since the command was first added (when
the documentation was still as above) in this commit:
commit
f3e9a8177c41893858fce2bdf339dbe90b3a4ef5
Date: Wed Feb 24 21:18:28 2010 +0000
Since that commit the code in question has moved around, but the
important parts are largely unchanged. The function in question is
now in py-progspace.c:pspy_block_for_pc.
Examining the code shows that the real state is more complex than just
the function throws an error instead of returning None, instead the
real situation is:
1. If we can't find a compilation unit for the $pc value then we
throw an error, but
2. If we can find a compilation unit, but can't find a block within
the compilation unit for the $pc then return None.
I suspect for most users of the Python API this distinction is
irrelevant, and I propose that we standardise on one single failure
mechanism.
Given the function can currently return None in some cases, and is
documented to return None on error, I propose we make that the case
for all error paths, which is what this patch does.
As the Progspace.block_for_pc method is currently untested, I've added
some basic tests including for a call with an invalid $pc.
This is potentially an API breaking change, though an undocumented
part of the API. Also, users should have been checking and handling a
None return value anyway, so my hope is that this shouldn't be too
disruptive.
gdb/ChangeLog:
* python/py-progspace.c (pspy_block_for_pc): Return None for all
error paths.
gdb/testsuite/ChangeLog:
* gdb.python/py-progspace.exp: Add tests for the
Progspace.block_for_pc method.
Change-Id: I9cea8d2132902bcad0013d1fd39080dd5423cc57