Andre Simoes Dias Vieira [Mon, 4 May 2020 12:05:42 +0000 (13:05 +0100)]
gas: PR 25863: Fix scalar vmul inside it block when assembling for MVE
This fixes PR 25863 by fixing the condition in the parsing of vmul in
do_mve_vmull. It also simplifies the code in there fixing latent issues that
would lead to NEON code being accepted when it shouldn't.
gas/ChangeLog:
2020-05-04 Andre Vieira <andre.simoesdiasvieira@arm.com>
PR gas/25863
* config/tc-arm.c (do_mve_vmull): Fix scalar and NEON parsing of vmul.
* testsuite/gas/arm/mve-scalar-vmult-it.d: New test.
* testsuite/gas/arm/mve-scalar-vmult-it.s: New test.
Nick Clifton [Mon, 4 May 2020 09:19:38 +0000 (10:19 +0100)]
Fix an illegal memory access in the assembler when generating a DWARF5 file/directory table with no entries.
PR 25917
* dwarf2dbg.c (out_dir_and_file_list): Check for the directory
table's existence before looking at its entries.
* testsuite/gas/elf/pr25917.s: New test source file.
* testsuite/gas/elf/pr25917.d: New test driver.
* testsuite/gas/elf/elf.exp (run_elf_list_test): Run the new test.
Tom de Vries [Mon, 4 May 2020 06:40:38 +0000 (08:40 +0200)]
[gdb/testsuite] Fix gdb.base/async.exp with gcc-8
When running test-case gdb.base/async.exp with gcc-8, we run into:
...
FAIL: gdb.base/async.exp: stepi&
...
The problem is that with gcc-8, the instruction address is no longer printed:
...
stepi&
-(gdb) 0x00000000004004b2 9 x = 5; x = 5; x = 5;
+(gdb) 9 x = 5; x = 5; x = 5;
completed.
-PASS: gdb.base/async.exp: stepi&
+FAIL: gdb.base/async.exp: stepi&
...
This is due to the fact that gcc-8 contains more precise line info, making the
address being stepped to a "recommended breakpoint location", and consequently
gdb doesn't print the address prefix anymore.
Given that:
- we step through statements on the same line, and
- there's no addres prefix anymore,
this gives the impression of lack of progress, which could be improved upon,
filed as enhancement PR25911 - "Show column when stepping through line".
Fix the FAIL by checking in the test-case whether addresses are at
"recommended breakpoint location" or not.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-05-04 Tom de Vries <tdevries@suse.de>
* gdb.base/async.exp: Check whether instruction addresses are a
"recommended breakpoint location".
Alan Modra [Mon, 4 May 2020 00:50:54 +0000 (10:20 +0930)]
readelf: nds32 specific decoding
* readelf.c (process_nds32_specific): Check size of .nds32_e_flags
section. Don't assume endian of host matches nds32 target. Free
buffer.
GDB Administrator [Mon, 4 May 2020 00:00:06 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Sun, 3 May 2020 17:31:19 +0000 (11:31 -0600)]
Update more calls to add_prefix_cmd
I looked at all the calls to add_prefix_cmd, and replaced them with
calls to add_basic_prefix_cmd or add_show_prefix_cmd when appropriate.
This makes gdb's command language a bit more regular. I don't think
there's a significant downside.
Note that this patch removes a couple of tests. The removed ones are
completely redundant.
gdb/ChangeLog
2020-05-03 Tom Tromey <tom@tromey.com>
* breakpoint.c (catch_command, tcatch_command): Remove.
(_initialize_breakpoint): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
(set_breakpoint_cmd, show_breakpoint_cmd): Remove
* utils.c (set_internal_problem_cmd, show_internal_problem_cmd):
Remove.
(add_internal_problem_command): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* mips-tdep.c (set_mipsfpu_command): Remove.
(_initialize_mips_tdep): Use add_basic_prefix_cmd.
* dwarf2/index-cache.c (set_index_cache_command): Remove.
(_initialize_index_cache): Use add_basic_prefix_cmd.
* memattr.c (dummy_cmd): Remove.
(_initialize_mem): Use add_basic_prefix_cmd, add_show_prefix_cmd.
* tui/tui-win.c (set_tui_cmd, show_tui_cmd): Remove.
(_initialize_tui_win): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* cli/cli-logging.c (set_logging_command): Remove.
(_initialize_cli_logging): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
(show_logging_command): Remove.
* target.c (target_command): Remove.
(add_target): Use add_basic_prefix_cmd.
gdb/testsuite/ChangeLog
2020-05-03 Tom Tromey <tom@tromey.com>
* gdb.base/sepdebug.exp: Remove "catch" test.
* gdb.base/break.exp: Remove "catch" test.
* gdb.base/default.exp: Update expected output.
GDB Administrator [Sun, 3 May 2020 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Sat, 2 May 2020 13:18:16 +0000 (06:18 -0700)]
gold: Compile common tests with -fcommon
Since GCC 10 defaults to -fno-common, add -fcommon to common tests to
force common behavior.
PR gold/25904
* testsuite/Makefile.am (COMMON_TEST_C_CFLAGS): New.
(common_test_1.o): New rule.
(common_test_2.o): Likewise.
(common_test_3.o): Likewise.
(plugin_common_test_1.o): Likewise.
(plugin_common_test_2.o): Likewise.
(common_test_1_v1.o): Likewise.
(common_test_1_v2.o): Likewise.
(common_test_2_pic.o): Compile with $(COMMON_TEST_C_CFLAGS).
(common_test_3_pic.o): Likewise.
* testsuite/Makefile.in: Regenerated.
Hannes Domani [Fri, 1 May 2020 12:50:08 +0000 (14:50 +0200)]
Fix typo in comment of DYN_PROP_ASSOCIATED
gdb/ChangeLog:
2020-05-02 Hannes Domani <ssbssa@yahoo.de>
* gdbtypes.h (enum dynamic_prop_node_kind): Fix typo.
Andrew Burgess [Sat, 2 May 2020 09:28:56 +0000 (10:28 +0100)]
gdb: Fix formatting error in ChangeLog
Tom de Vries [Sat, 2 May 2020 08:56:48 +0000 (10:56 +0200)]
[gdb/testsuite] Fix i386-mpx.exp compilation warnings
When running test-case gdb.arch/i386-mpx.exp with gcc-10, we get:
...
Running src/gdb/testsuite/gdb.arch/i386-mpx.exp ...
gdb compile failed, xgcc: warning: switch '-mmpx' is no longer supported
xgcc: warning: switch '-fcheck-pointer-bounds' is no longer supported
...
The test-case uses a combination of options, -mmpx and -fcheck-pointer-bounds.
The -fcheck-pointer-bounds option requires the -mmpx option:
...
$ gcc -fcheck-pointer-bounds ~/hello.c
hello.c:1:0: warning: Pointer Checker requires MPX support on this target. \
Use -mmpx options to enable MPX.
#include <stdio.h>
cc1: error: ‘-fcheck-pointer-bounds’ is not supported for this target
...
Both options is no longer supported in gcc-9.
Fix the warnings by testing if the option combination is supported.
Tested on x86_64-linux, with gcc-7.5.0 and gcc-10.0.1.
gdb/testsuite/ChangeLog:
2020-05-02 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (supports_mpx_check_pointer_bounds): New proc.
* gdb.arch/i386-mpx-call.exp: Use supports_mpx_check_pointer_bounds.
* gdb.arch/i386-mpx-map.exp: Same.
* gdb.arch/i386-mpx-sigsegv.exp: Same.
* gdb.arch/i386-mpx-simple_segv.exp: Same.
* gdb.arch/i386-mpx.exp: Same.
Tom de Vries [Sat, 2 May 2020 07:50:50 +0000 (09:50 +0200)]
[gdb/testsuite] Update psym-external-decl.exp for gcc-10/clang
When running test-case gdb.base/psym-external-decl.exp with gcc-10, we have:
...
(gdb) print aaa^M
'aaa' has unknown type; cast it to its declared type^M
(gdb) FAIL: gdb.base/psym-external-decl.exp: print aaa
...
With an an earlier version, gcc still emits the debug info for the
declaration of aaa:
...
<0><d2>: Abbrev Number: 1 (DW_TAG_compile_unit)
<d8> DW_AT_name : psym-external-decl.c
<1><f4>: Abbrev Number: 2 (DW_TAG_variable)
<f5> DW_AT_name : aaa
<ff> DW_AT_external : 1
<ff> DW_AT_declaration : 1
...
but with gcc-10 that's no longer the case.
Fix the test-case by adding a use of aaa in psym-external-decl.c.
That still doesn't work for clang, so skip test in that case.
Tested with x86_64-linux, with gcc 7.5.0, gcc 10.0.0 and clang 5.0.2.
Also tested by reverting corresponding fix and ensuring test-case still
fails.
gdb/testsuite/ChangeLog:
2020-05-02 Tom de Vries <tdevries@suse.de>
* gdb.base/psym-external-decl.c (main): Add use of variable aaa.
GDB Administrator [Sat, 2 May 2020 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Fri, 1 May 2020 17:11:06 +0000 (10:11 -0700)]
gold: x86-64: Fix TLSDESC relaxation for x32
X32 TLSDESC sequences can be:
40 8d 05 00 00 00 00 rex lea foo@TLSDESC(%rip), %reg
...
67 ff 10 call *foo@TLSCALL(%eax)
or the same sequence as LP64:
48 8d 05 00 00 00 00 lea foo@TLSDESC(%rip), %reg
...
ff 10 call *foo@TLSCALL(%rax)
We need to support both sequences for x32. For both GDesc -> IE/LE
transitions,
67 ff 10 call *foo@TLSCALL(%eax)
should relaxed to
0f 1f 00 nopl (%rax)
For GDesc -> LE transition,
40 8d 05 00 00 00 00 rex lea foo@TLSDESC(%rip), %reg
should relaxed to
40 c7 c0 fc ff ff ff rex movl $foo@tpoff, %reg
For GDesc -> IE transition,
40 8d 05 00 00 00 00 rex lea foo@TLSDESC(%rip), %reg
should relaxed to
40 8b 05 00 00 00 00 rex movl foo@gottpoff(%rip), %eax
PR gold/25426
* x86_64.cc (Target_x86_64<size>::Relocate::tls_desc_gd_to_ie):
For x32, relax "rex leal foo@tlsdesc(%rip), %reg" to
"rex movl foo@gottpoff(%rip), %eax" and relax ""call *(%eax)"
to "nopl (%rax)".
(Target_x86_64<size>::Relocate::tls_desc_gd_to_le): For x32,
relax "rex leal foo@tlsdesc(%rip), %reg" to
"rex movl foo@tpoff, %eax" and relax "call *foo@tlscall(%eax)"
to "nopl (%rax)".
* testsuite/Makefile.am (tls_test_gnu2.o): Depend on
gcctestdir/as.
(tls_test_file2_gnu2.o): Likewise.
(tls_test_c_gnu2.o): Likewise.
* testsuite/Makefile.in: Regenerated.
H.J. Lu [Fri, 1 May 2020 17:08:31 +0000 (10:08 -0700)]
gold: x86-64: Fix TLSDESC -> LE relaxation
X86-64 TLSDESC sequences can be:
4c 8d 0d 00 00 00 00 leaq foo@TLSDESC(%rip), %r9
4c 89 c8 movq %r9, %rax
ff 10 call *foo@TLSCALL(%rax)
TLSDESC -> LE relaxation can turn them into:
49 c7 c1 fc ff ff ff mov $0xfffffffffffffffc,%r9
4c 89 c8 mov %r9,%rax
66 90 xchg %ax,%ax
We need to check and update the REX byte in this case.
PR gold/25473
* x86_64.cc (Target_x86_64<size>::Relocate::tls_desc_gd_to_ie):
Properly check r8 - r15 in "lea foo@TLSDESC(%rip), %reg".
(Target_x86_64<size>::Relocate::tls_desc_gd_to_le): Properly
relax r8 - r15 in "lea foo@TLSDESC(%rip), %reg".
* testsuite/Makefile.am (check_SCRIPTS): Add x86_64_gd_to_le.sh.
(check_DATA): Add x86_64_gd_to_le.stdout.
(MOSTLYCLEANFILES): Add x86_64_gd_to_le.
(x86_64_gd_to_le.o): New target.
(x86_64_gd_to_le): Likewise.
(x86_64_gd_to_le.stdout): Likewise.
* testsuite/Makefile.in: Regenerated.
* testsuite/x86_64_gd_to_le.s: New file.
* testsuite/x86_64_gd_to_le.sh: Likewise.
H.J. Lu [Fri, 1 May 2020 17:06:15 +0000 (10:06 -0700)]
gold: Make Ordering::operator() even more complex
GCC 9 generates the same function size for Ordering::operator() in
odr_violation1.cc and odr_violation2.cc on x32:
134:
00000000 31 FUNC WEAK DEFAULT 64 _ZN8OrderingclEii
40:
00000000 31 FUNC GLOBAL DEFAULT 10 _ZN8OrderingclEii
This patch makes Ordering::operator() even more complex
134:
00000000 31 FUNC WEAK DEFAULT 64 _ZN8OrderingclEii
42:
00000000 35 FUNC GLOBAL DEFAULT 11 _ZN8OrderingclEii
* testsuite/odr_violation2.cc (Ordering::operator()): Make
expression even more complex.
H.J. Lu [Fri, 1 May 2020 16:05:01 +0000 (09:05 -0700)]
gold: Update ver_test_pr16504.sh
commit
df3a023bd614133fe69afb02cd0e8f3e590a36a9
Author: Alan Modra <amodra@gmail.com>
Date: Tue Jul 23 17:54:42 2019 +0930
SHF_GNU_MBIND requires ELFOSABI_GNU
changed readelf to print IFUNC only for ELFOSABI_GNU. Since
$ readelf -h ver_test_pr16504.so
...
OS/ABI: UNIX - System V
...
we get
$ readelf -sW ver_test_pr16504.so
...
3:
0000000000000378 13 <OS specific>: 10 GLOBAL DEFAULT 9 foo@@VER1
...
Update ver_test_pr16504.sh to also accept "<OS specific>: 10".
* testsuite/ver_test_pr16504.sh: Updated.
H.J. Lu [Fri, 1 May 2020 16:00:14 +0000 (09:00 -0700)]
gold: Increment plt_offset after setting TLSDESC PLT entry
Increment plt_offset after setting the reserved TLSDESC PLT entry.
PR gold/25872
* x86_64.cc (Output_data_plt_x86_64_bnd::do_write): Increment
plt_offset after setting the reserved TLSDESC PLT entry.
(Output_data_plt_x86_64_ibt<size>::do_write): Likewise.
H.J. Lu [Fri, 1 May 2020 15:53:47 +0000 (08:53 -0700)]
gold: Handle local IFUNC symbol for APLT
Handle local IFUNC symbol for APLT like global IFUNC symbol.
PR gold/25872
* x86_64.cc (Output_data_plt_x86_64_bnd::do_address_for_local):
Handle local IFUNC symbol.
(Output_data_plt_x86_64_ibt::do_address_for_local): Likewise.
Tom de Vries [Fri, 1 May 2020 15:57:56 +0000 (17:57 +0200)]
[gdb/testsuite] Fix gdb.ada/operator_bp.exp breakpoint location FAILs
When running test-case gdb.ada/operator_bp.exp with gcc-10, I run into:
...
FAIL: gdb.ada/operator_bp.exp: break "+"
FAIL: gdb.ada/operator_bp.exp: break "-"
FAIL: gdb.ada/operator_bp.exp: break "<"
FAIL: gdb.ada/operator_bp.exp: break "<="
FAIL: gdb.ada/operator_bp.exp: break ">"
FAIL: gdb.ada/operator_bp.exp: break ">="
FAIL: gdb.ada/operator_bp.exp: break "="
FAIL: gdb.ada/operator_bp.exp: break "and"
FAIL: gdb.ada/operator_bp.exp: break "or"
FAIL: gdb.ada/operator_bp.exp: break "xor"
FAIL: gdb.ada/operator_bp.exp: break "not"
...
The first FAIL is because two breakpoint locations are expected, but there are
more than 2:
...
(gdb) break "+"
Breakpoint 2 at 0x402c3c: "+". (6 locations)
(gdb) info break
Num Type Disp Enb Address What
2 breakpoint keep y <MULTIPLE>
2.1 y 0x0000000000402c3c in ops."+"
at operator_bp/ops.adb:25
2.2 y 0x0000000000402e5b in ops."+"
at operator_bp/ops.adb:119
2.3 y 0x0000000000414207 in
system.storage_elements."+" at s-stoele.adb:82
2.4 y 0x0000000000414404 in
system.storage_elements."+" at s-stoele.adb:87
2.5 y 0x0000000000414413 in
system.storage_elements."+" at s-stoele.adb:87
2.6 y 0x0000000000414430 in
system.storage_elements."+" at s-stoele.adb:81
...
This can be traced back to a extra debug info in the executable:
...
$ readelf -w ops_test | grep system__storage_elements__Oadd
<28104> DW_AT_name : system__storage_elements__Oadd__2
<2812e> DW_AT_name : system__storage_elements__Oadd
...
Fix the FAILs by allowing more than the required amount of breakpoint
locations.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-05-01 Tom de Vries <tdevries@suse.de>
* gdb.ada/operator_bp.exp: Allow more than required amount of
breakpoint.
Philippe Waroquiers [Fri, 1 May 2020 14:47:05 +0000 (16:47 +0200)]
Remove gdb-gdb.gdb breakpoint on disappeared function info_command.
The function info_command has disappeared, so this breakpoint does not
work anymore.
"info_command" was a function for the prefix command "info",
giving the list of "info" subcommands.
It is not very clear what the removed breakpoint and its associated
command list was supposed to do.
Removed and pushed as obvious, after discussion with Tom.
Hannes Domani [Fri, 1 May 2020 12:01:02 +0000 (14:01 +0200)]
Fix size recalculation of fortran arrays
My recent change regarding size calculation of arrays of stubbed types
didn't take array strides and associated/allocated type properties into
account, which basically broke fortran arrays.
Fixed by refactoring the array size calculation of
create_array_type_with_stride into a new function, and also use it for
the stubbed array size recalculation.
gdb/ChangeLog:
2020-05-01 Hannes Domani <ssbssa@yahoo.de>
* gdbtypes.c (update_static_array_size): New function.
(create_array_type_with_stride): Use update_static_array_size.
(check_typedef): Likewise.
Tom de Vries [Fri, 1 May 2020 09:04:22 +0000 (11:04 +0200)]
[gdb/testsuite] Fix Wunused-result warning in until-reverse.c
When running test-case gdb.reverse/until-reverse.exp or
gdb.reverse/until-precsave.exp with gcc-10, we run into a Wunused-result
warning:
...
gdb compile failed, gdb.reverse/until-reverse.c: In function 'main':
gdb.reverse/until-reverse.c:40:14: warning: ignoring return value of \
'malloc' declared with attribute 'warn_unused_result' [-Wunused-result]
40 | (void) malloc (1);
| ^~~~~~~~~~
...
Fix this by using the result of malloc as argument to a free call.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-05-01 Tom de Vries <tdevries@suse.de>
* gdb.reverse/until-reverse.c (main): Fix Wunused-result warning.
Alan Modra [Fri, 1 May 2020 06:02:00 +0000 (15:32 +0930)]
PR25900, RISC-V: null pointer dereference
PR 25900
* elfnn-riscv.c (_bfd_riscv_relax_section): Check root.type before
accessing root.u.def of symbols. Also check root.u.def.section
is non-NULL. Reverse tests so as to make the logic positive.
Alan Modra [Fri, 1 May 2020 06:00:12 +0000 (15:30 +0930)]
objdump: long run time when using -D -z
The zero scan is silly when the result isn't used.
* objdump.c (disassemble_bytes): Don't scan for zeros when
disassembling zeros. Translate "resuming at file offset" message.
Formatting. Replace some signed variables with unsigned.
Alan Modra [Fri, 1 May 2020 05:53:17 +0000 (15:23 +0930)]
PR25882, .gnu.attributes are not checked for shared libraries
This allows backend merge_private_bfd_data to examine shared library
e_flags and/or .gnu.attributes. ARM and PowerPC have done so when
using ld.gold for a long time.
(The tic6x change below is dead code due to the earlier FIXME,
but this is probably one of the changes needed there.)
PR 25882
bfd/
* elf32-tic6x.c (elf32_tic6x_merge_attributes): Don't transfer
Tag_ABI_PIC or Tag_ABI_PID from dynamic objects to the output.
ld/
* ldlang.c (lang_check): Call bfd_merge_private_bfd_data for
shared libraries.
Alan Modra [Fri, 1 May 2020 05:50:14 +0000 (15:20 +0930)]
FIXME for merging of e_flags and .gnu.attributes
Code in the linker, present before the addition of .gnu.attributes
support, results in shared libraries not being considered by BFD when
merging e_flags and .gnu.attributes from input files to the output.
That doesn't seem correct to me, but I don't know enough about all the
various ABIs to change the behaviour with any confidence. So this
patch merely punts on dynamic objects in merge_private_bfd_data target
functions, with a FIXME for maintainer attention.
I haven't excluded shared libraries from being considered where the
target merge_private_bfd_data (a) already has code dealing with shared
libraries, or (b) where that function just sets the output to the most
constraining arch/mach combination and other fairly trivial merges, or
(c) when the target has no shared library linker support.
In (a) are: arc, arm, aarch64, riscv, sparc.
In (b) are: bpf, cris, csky, m32r, m68k, mn10300, nios2, tilegx,
tilepro, vax, visium, xtensa.
In (c) are: bpf, cr16, h8300, iq2000, m32c, m68hc11, m68hc12, mcore,
mep, msp430, mt, rl78, rx, v850.
PR 25882
* elf32-bfin.c (elf32_bfin_merge_private_bfd_data): Add FIXME.
* elf32-frv.c (frv_elf_merge_private_bfd_data): Likewise.
* elfxx-mips.c (_bfd_mips_elf_merge_private_bfd_data): Likewise.
* elf32-nds32.c (nds32_elf_merge_private_bfd_data): Likewise.
* elf32-score.c (s3_elf32_score_merge_private_bfd_data): Likewise.
* elf32-score7.c (s7_elf32_score_merge_private_bfd_data): Likewise.
* elf32-sh.c (sh_elf_merge_private_data): Likewise.
* elf32-tic6x.c (elf32_tic6x_merge_attributes): Likewise.
* elf64-ia64-vms.c (elf64_ia64_merge_private_bfd_data): Likewise.
* elfnn-ia64.c (elfNN_ia64_merge_private_bfd_data): Likewise.
Alan Modra [Fri, 1 May 2020 05:47:42 +0000 (15:17 +0930)]
ppc32 merging of e_flags from dynamic objects
EF_PPC_RELOCATABLE and similar flags, if present in an input shared
library, don't have any relevance as far as the output file is
concerned.
Currently, dynamic objects aren't seen in merge_private_bfd_data.
This patch is in preparation for a change to that.
PR 25882
* elf32-ppc.c (ppc_elf_merge_private_bfd_data): Ignore e_flags
from shared libraries.
Alan Modra [Fri, 1 May 2020 02:19:25 +0000 (11:49 +0930)]
Regen ld BLD-POTFILES.in
* po/BLD-POTFILES.in: Regenerate.
GDB Administrator [Fri, 1 May 2020 00:00:16 +0000 (00:00 +0000)]
Automatic date update in version.in
Kamil Rytarowski [Thu, 30 Apr 2020 14:13:33 +0000 (16:13 +0200)]
Add support for NetBSD thread events (create, exit)
Report LWP CREATE and LWP EXIT events and setup this on post_attach()
and post_startup_inferior().
Stop reinitializing the list of recognized threads in update_thread_list().
Handle LWP CREATE and EXIT events in nbsd_nat_target::wait().
gdb/ChangeLog:
* nbsd-nat.c (nbsd_enable_proc_events)
(nbsd_nat_target::post_startup_inferior): Add.
(nbsd_nat_target::post_attach): Call `nbsd_enable_proc_events'.
(nbsd_nat_target::update_thread_list): Rewrite.
(nbsd_nat_target::wait): Handle "PTRACE_LWP_EXIT" and
"PTRACE_LWP_CREATE".
* nbsd-nat.h (nbsd_nat_target::post_startup_inferior): Add.
Tom de Vries [Thu, 30 Apr 2020 16:51:49 +0000 (18:51 +0200)]
Revert "2020-04-29 Sterling Augustine <saugustine@google.com>"
This reverts commit
84ed7a472551bce1ac58e0eced619433fabc956c.
The problem that the commit attempts to address has already been fixed in
commit
770479f223e "gdb: Fix toplevel types with -fdebug-types-section".
The commit itself is superfluous because it sets list_in_scope at a point that
it's already set (by start_symtab).
Philippe Waroquiers [Thu, 30 Apr 2020 16:35:33 +0000 (18:35 +0200)]
Remove duplicated creation of "frame" command and "f" alias.
"frame" and "f" are created twice by stack.c _initialize_stack.
Remove the second creation.
Regression tested on amd64/Debian.
2020-04-30 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* stack.c (_initialize_stack): Remove duplicated creation
of "frame" command and "f" alias.
Hannes Domani [Fri, 24 Apr 2020 15:23:59 +0000 (17:23 +0200)]
Implement debugging of WOW64 processes in gdbserver
gdbserver/ChangeLog:
2020-04-30 Hannes Domani <ssbssa@yahoo.de>
* configure.srv <x86_64-*-mingw*, x86_64-*-cygwin*> (srv_tgtobj):
Add arch/i386.o.
* win32-arm-low.cc (arm_num_regs): New function.
(struct win32_target_ops): Use arm_num_regs.
* win32-i386-low.cc (win32_get_current_dr): Adapt for WOW64
processes.
(i386_get_thread_context): Likewise.
(i386_prepare_to_resume): Likewise.
(i386_thread_added): Likewise.
(i386_single_step): Likewise.
(i386_fetch_inferior_register): Likewise.
(i386_store_inferior_register): Likewise.
(i386_arch_setup): Likewise.
(i386_win32_num_regs): New function.
(struct win32_target_ops): Use i386_win32_num_regs.
* win32-low.cc (win32_get_thread_context): Adapt for WOW64
processes.
(win32_require_context): Likewise.
(child_add_thread): Likewise.
(do_initial_child_stuff): Likewise.
(continue_one_thread): Likewise.
(win32_process_target::resume): Likewise.
(load_psapi): Likewise.
(win32_add_all_dlls): Likewise.
(maybe_adjust_pc): Likewise.
(win32_process_target::qxfer_siginfo): Likewise.
(initialize_low): Likewise.
* win32-low.h (struct win32_target_ops): Change num_regs to
callback function.
Hannes Domani [Mon, 27 Apr 2020 11:14:24 +0000 (13:14 +0200)]
Calculate size of array of stubbed type
Sizes of stubbed types are calculated on demand in check_typedef, so the
same must also be done for arrays of stubbed types.
A stubbed type is usually a structure that has only been forward declared,
but can also happen if the structure has a virtual function that's not
inline in the class definition.
For these stubbed types, the size must be recalculated once the full
definition is available.
gdb/ChangeLog:
2020-04-30 Hannes Domani <ssbssa@yahoo.de>
PR gdb/18706
* gdbtypes.c (check_typedef): Calculate size of array of
stubbed type.
gdb/testsuite/ChangeLog:
2020-04-30 Hannes Domani <ssbssa@yahoo.de>
PR gdb/18706
* gdb.cp/stub-array-size.cc: New test.
* gdb.cp/stub-array-size.exp: New file.
* gdb.cp/stub-array-size.h: New test.
* gdb.cp/stub-array-size2.cc: New test.
Hannes Domani [Thu, 30 Apr 2020 11:17:30 +0000 (13:17 +0200)]
Adjust array pretty printer tests to the new format
gdb/testsuite/ChangeLog:
2020-04-30 Hannes Domani <ssbssa@yahoo.de>
* gdb.python/py-format-string.exp: Adjust pretty_arrays expected
output to the new format.
Alex Coplan [Thu, 30 Apr 2020 14:47:30 +0000 (15:47 +0100)]
AArch64: add GAS support for UDF instruction
binutils * testsuite/binutils-all/aarch64/in-order-all.d: Update to use new
disassembly.
* testsuite/binutils-all/aarch64/out-of-order-all.d: Likewise.
ld/ * testsuite/ld-aarch64/erratum843419_tls_ie.d: Use udf in disassembly.
* testsuite/ld-aarch64/farcall-b-section.d: Likewise.
* testsuite/ld-aarch64/farcall-back.d: Likewise.
* testsuite/ld-aarch64/farcall-bl-section.d: Likewise.
gas/ * config/tc-aarch64.c (fix_insn): Implement for AARCH64_OPND_UNDEFINED.
(parse_operands): Implement for AARCH64_OPND_UNDEFINED.
* testsuite/gas/aarch64/udf.s: New.
* testsuite/gas/aarch64/udf.d: New.
* testsuite/gas/aarch64/udf-invalid.s: New.
* testsuite/gas/aarch64/udf-invalid.l: New.
* testsuite/gas/aarch64/udf-invalid.d: New.
include * opcode/aarch64.h (enum aarch64_opnd): Add AARCH64_OPND_UNDEFINED.
opcodes * aarch64-opc.h (enum aarch64_field_kind): Add FLD_imm16_2.
* aarch64-opc.c (fields): Add entry for FLD_imm16_2.
(operand_general_constraint_met_p): validate AARCH64_OPND_UNDEFINED.
* aarch64-tbl.h (aarch64_opcode_table): Add udf instruction, entry for
FLD_imm16_2.
* aarch64-asm-2.c: Regenerated.
* aarch64-dis-2.c: Regenerated.
* aarch64-opc-2.c: Regenerated.
Nick Clifton [Thu, 30 Apr 2020 12:49:30 +0000 (13:49 +0100)]
Add generic tests for linker support of the -shared or -pie options to tests which use them.
binutils* testsuite/lib/binutils-common.exp (check_pie_support): New
proc.
ld * testsuite/ld-elf/compress1c.d: XFAIL if thet target linker does
not support the -shared command line option.
* /ld-elf/compressed1c.d: Likewise.
* /ld-elf/compressed1e.d: Likewise.
* /ld-elf/dynamic1.d: Likewise.
* /ld-elf/dynsym1.d: Likewise.
* /ld-elf/ehdr_start-shared.d: Likewise.
* /ld-elf/exclude3b.d: Likewise.
* /ld-elf/global1.d: Likewise.
* /ld-elf/hash.d: Likewise.
* /ld-elf/local1.d: Likewise.
* /ld-elf/mbind1b.d: Likewise.
* /ld-elf/now-1.d: Likewise.
* /ld-elf/now-2.d: Likewise.
* /ld-elf/now-3.d: Likewise.
* /ld-elf/now-4.d: Likewise.
* /ld-elf/pr12975.d: Likewise.
* /ld-elf/pr13177.d: Likewise.
* /ld-elf/pr13195.d: Likewise.
* /ld-elf/pr16322.d: Likewise.
* /ld-elf/pr16498a.d: Likewise.
* /ld-elf/pr16498b.d: Likewise.
* /ld-elf/pr17615.d: Likewise.
* /ld-elf/pr19162.d: Likewise.
* /ld-elf/pr19698.d: Likewise.
* /ld-elf/pr20513c.d: Likewise.
* /ld-elf/pr20513d.d: Likewise.
* /ld-elf/pr21389a.d: Likewise.
* /ld-elf/pr21389b.d: Likewise.
* /ld-elf/pr21389c.d: Likewise.
* /ld-elf/pr21562a.d: Likewise.
* /ld-elf/pr21562b.d: Likewise.
* /ld-elf/pr21562c.d: Likewise.
* /ld-elf/pr21562d.d: Likewise.
* /ld-elf/pr21562e.d: Likewise.
* /ld-elf/pr21562f.d: Likewise.
* /ld-elf/pr21562g.d: Likewise.
* /ld-elf/pr21562h.d: Likewise.
* /ld-elf/pr21562i.d: Likewise.
* /ld-elf/pr21562j.d: Likewise.
* /ld-elf/pr21562k.d: Likewise.
* /ld-elf/pr21562l.d: Likewise.
* /ld-elf/pr21562m.d: Likewise.
* /ld-elf/pr21562n.d: Likewise.
* /ld-elf/pr21903a.d: Likewise.
* /ld-elf/pr21903b.d: Likewise.
* /ld-elf/pr22269b.d: Likewise.
* /ld-elf/pr22393-1a.d: Likewise.
* /ld-elf/pr22393-1b.d: Likewise.
* /ld-elf/pr23658-1c.d: Likewise.
* /ld-elf/pr25708.d: Likewise.
* /ld-elf/rpath-1.d: Likewise.
* /ld-elf/rpath-2.d: Likewise.
* /ld-elf/runpath-1.d: Likewise.
* /ld-elf/runpath-2.d: Likewise.
* /ld-elf/sizeofb.d: Likewise.
* /ld-elf/startofb.d: Likewise.
* /ld-elf/strtab.d: Likewise.
* /ld-elf/textaddr2.d: Likewise.
* /ld-elf/textaddr5.d: Likewise.
* /ld-elf/textaddr6.d: Likewise.
* /ld-elf/unknown2.d: Likewise.
* /ld-undefined/entry-3.d: Likewise.
* /ld-undefined/entry-4.d: Likewise.
* /ld-elf/mbind1c.d: XFAIL if the target linker does not support
the -pie option.
* /ld-elf/pie.d: Likewise.
* /ld-elf/pr19539.d: Likewise.
* /ld-elf/pr21903d.d: Likewise.
* /ld-elf/pr22269a.d: Likewise.
* /ld-elf/pr22393-1c.d: Likewise.
* /ld-elf/pr22393-1d.d: Likewise.
* /ld-elf/pr22423.d: Likewise.
* /ld-elf/loadaddr1.d: Expect to fail on the rx-linux target.
* /ld-elf/loadaddr2.d: Likewise.
* /ld-elf/pr22393-1e.d: Likewise.
* /ld-elf/pr22393-1f.d: Likewise.
* /ld-elf/textaddr1.d: Likewise.
* /ld-elf/textaddr4.d: Likewise.
Hannes Domani [Mon, 27 Apr 2020 13:58:09 +0000 (15:58 +0200)]
Use thiscall calling convention for class members
Non-static member functions for Windows 32bit programs need the thiscall
calling convention, so the 'this' pointer needs to be passed in ECX.
gdb/ChangeLog:
2020-04-30 Hannes Domani <ssbssa@yahoo.de>
PR gdb/15559
* i386-tdep.c (i386_push_dummy_call): Call
i386_thiscall_push_dummy_call.
(i386_thiscall_push_dummy_call): New function.
* i386-tdep.h (i386_thiscall_push_dummy_call): Declare.
* i386-windows-tdep.c (i386_windows_push_dummy_call): New function.
(i386_windows_init_abi): Call set_gdbarch_push_dummy_call.
Yoshinori Sato [Thu, 30 Apr 2020 12:35:37 +0000 (13:35 +0100)]
ld: Add rx-linux emulation. gas: Change ELF flags initial value in rx-linux
ld * emulparams/elf32rx_linux.sh: New rx-linux emulation.
* emultempl/rxlinux.em: New.
* configure.tgt: Add rx-linux.
* Makefile.am: Add eelf32rx_linux.c
* Makefile.in: Regenerate.
gas * config/tc-rx.c (elf_flags): Reset default value.
(md_parse_option): For rx-elf Initialize elf_flags with RX_ABI.
Max Filippov [Sat, 25 Apr 2020 07:40:25 +0000 (00:40 -0700)]
xtensa: fix XTENSA_NDIFF handling for PR ld/25861
Fields marked with XTENSA_NDIFF relocations are not negated, they only
have sign bits removed. Don't negate their values when relaxation is
performed. Don't add sign bits when the value is zero. Report overflow
when the result has negative sign but all significant bits are zero.
2020-04-29 Max Filippov <jcmvbkbc@gmail.com>
bfd/
* elf32-xtensa.c (relax_section): Don't negate diff_value for
XTENSA_NDIFF relocations. Don't add sign bits whe diff_value
equals 0. Report overflow when the result has negative sign but
all significant bits are zero.
ld/
* testsuite/ld-xtensa/relax-diff1.d: New test definition.
* testsuite/ld-xtensa/relax-diff1.s: New test source.
* testsuite/ld-xtensa/relax-ndiff.d: New test definition.
* testsuite/ld-xtensa/relax-ndiff.s: New test source.
* testsuite/ld-xtensa/xtensa.exp: (relax-diff1)
(relax-ndiff): New tests.
Max Filippov [Tue, 28 Apr 2020 11:15:05 +0000 (04:15 -0700)]
xtensa: gas: support optional immediate simcall parameter
Starting with RH.0 release Xtensa ISA adds immediate parameter to
simcall opcode. For assembly source compatibility treat "simcall"
instruction without parameter as "simcall 0" when parameter is required.
2020-04-29 Max Filippov <jcmvbkbc@gmail.com>
gas/
* config/tc-xtensa.c (XTENSA_MARCH_EARLIEST): Define macro as 0
if it's not defined.
(microarch_earliest): New static variable.
(xg_translate_idioms): Translate "simcall" to "simcall 0" when
simcall opcode has mandatory parameter.
(xg_init_global_config): Initialize microarch_earliest.
Simon Marchi [Thu, 30 Apr 2020 00:35:35 +0000 (20:35 -0400)]
gdb: silence shellcheck warning SC2162 (use read -r) in gdbarch.sh
shellcheck reports:
In gdbarch.sh line 53:
while IFS='' read line
^--^ SC2162: read without -r will mangle backslashes.
See the rationale at [1]. In our case, we actually want the backslashes
to be interpreted and removed. Silence the warning using a directive.
[1] https://github.com/koalaman/shellcheck/wiki/SC2162
gdb/ChangeLog:
* gdbarch.sh (do_read): Add shellcheck disable directive for
warning SC2162.
Simon Marchi [Thu, 30 Apr 2020 00:35:35 +0000 (20:35 -0400)]
gdb: fix shellcheck warnings SC2154 (referenced but not assigned) in gdbarch.sh
Fix all instances of this kind of warning:
In gdbarch.sh line 96:
m ) staticdefault="${predefault}" ;;
^-----------^ SC2154: predefault is referenced but not assigned.
These warnings appear because we are doing something a bit funky when reading
the gdbarch fields. These variables are not assigned explicitly, but
using some `eval` commands.
I don't think there is so much we can fix about those warnings. To
silence them, I've changed `${foo}` to `${foo:-}`. This tells the shell
to substitute with an empty string if `foo` is not defined. This
retains the current behavior, but the warnings go away.
gdb/ChangeLog:
* gdbarch.sh: Use ${foo:-} where shellcheck would report a
"referenced but not assigned" warning.
Simon Marchi [Thu, 30 Apr 2020 00:35:35 +0000 (20:35 -0400)]
gdb: fix shellcheck warnings SC2034 (unused variable) in gdbarch.sh
shellcheck reports:
In gdbarch.sh line 139:
fallbackdefault="0"
^-------------^ SC2034: fallbackdefault appears unused. Verify use (or export if used externally).
Indeed, the `fallbackdefault` variable appears to be unused, remove the
code that sets it.
gdb/ChangeLog:
* gdbarch.sh: Remove code that sets fallbackdefault.
Simon Marchi [Thu, 30 Apr 2020 00:35:34 +0000 (20:35 -0400)]
gdb: fix shellcheck warnings SC2166 (&& and !! instead of -a and -o) in gdbarch.sh
Fix all warnings of this type:
In gdbarch.sh line 1238:
if [ "x${invalid_p}" = "x0" -a -n "${postdefault}" ]
^-- SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
See the rationale here [1].
[1] https://github.com/koalaman/shellcheck/wiki/SC2166
gdb/ChangeLog:
* gdbarch.sh: Use shell operators && and || instead of
-a and -o.
Simon Marchi [Thu, 30 Apr 2020 00:35:34 +0000 (20:35 -0400)]
gdb: fix shellcheck warnings SC2006 (use $() instead of ``) in gdbarch.sh
Fix all instances of:
In gdbarch.sh line 2195:
printf " `echo "$function" | sed -e 's/./ /g'` %s %s)\n" "$returntype" "$function"
^-- SC2006: Use $(...) notation instead of legacy backticked `...`.
Did you mean:
printf " $(echo "$function" | sed -e 's/./ /g') %s %s)\n" "$returntype" "$function"
See here [1] for the rationale.
[1] https://github.com/koalaman/shellcheck/wiki/SC2006
gdb/ChangeLog:
* gdbarch.sh: Use $(...) instead of `...`.
Simon Marchi [Thu, 30 Apr 2020 00:35:34 +0000 (20:35 -0400)]
gdb: fix shellcheck warnings SC2086 (missing double quotes) in gdbarch.sh
Fix all instances of:
In gdbarch.sh line 31:
if test ! -r ${file}
^-----^ SC2086: Double quote to prevent globbing and word splitting.
Did you mean:
if test ! -r "${file}"
Note that some instances of these are in text that is eval'ed. I'm
pretty sure that things could go wrong during the eval too, but that's
not something shellcheck can check.
gdb/ChangeLog:
* gdbarch.sh: Use double quotes around variables.
Simon Marchi [Thu, 30 Apr 2020 00:35:33 +0000 (20:35 -0400)]
gdb: fix shellcheck warnings SC2059 (variables in printf format string) in gdbarch.sh
Fix all instances of this:
In gdbarch.sh line 2182:
printf " gdb_assert (!(${invalid_p}));\n"
^-- SC2059: Don't use variables in the printf format string. Use printf "..%s.." "$foo".
... by doing exactly as the message suggests.
The rationale explained here [1] makes sense, if there happens to be a
format specifier in text substituted for the variable, the printf won't
do what we expect.
[1] https://github.com/koalaman/shellcheck/wiki/SC2059
gdb/ChangeLog:
* gdbarch.sh: Use %s with printf, instead of variables in the
format string.
Sterling Augustine [Tue, 28 Apr 2020 18:17:50 +0000 (11:17 -0700)]
2020-04-29 Sterling Augustine <saugustine@google.com>
* dwarf2/read.c (setup_type_unit_groups): Set list_in_scope.
GDB Administrator [Thu, 30 Apr 2020 00:00:11 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Wed, 29 Apr 2020 21:25:36 +0000 (14:25 -0700)]
Sync config and libiberty with GCC
config/
2020-04-29 H.J. Lu <hongjiu.lu@intel.com>
Sync with GCC
2020-04-28 H.J. Lu <hongjiu.lu@intel.com>
PR bootstrap/94739
* cet.m4 (GCC_CET_HOST_FLAGS): Add -fcf-protection=none to
-Wl,-z,ibt,-z,shstk. Check whether -fcf-protection=none
-Wl,-z,ibt,-z,shstk works first.
2020-04-25 H.J. Lu <hongjiu.lu@intel.com>
PR bootstrap/94739
* cet.m4 (GCC_CET_HOST_FLAGS): New.
2020-04-22 Jakub Jelinek <jakub@redhat.com>
PR libfortran/94694
PR libfortran/94586
* math.m4 (GCC_CHECK_MATH_INLINE_BUILTIN_FALLBACK1,
GCC_CHECK_MATH_INLINE_BUILTIN_FALLBACK2): New.
libiberty/
2020-04-28 H.J. Lu <hongjiu.lu@intel.com>
PR bootstrap/94739
* configure: Regenerated.
Simon Marchi [Wed, 29 Apr 2020 20:34:54 +0000 (16:34 -0400)]
gdb: fix duplicate test names in gdb.base/break.exp
These test names are duplicated:
2 PASS: gdb.base/break.exp: set breakpoint via non-integer convenience variable disallowed
2 PASS: gdb.base/break.exp: set convenience variable $foo to 81.5
Wrap them with `with_test_prefix`. I've actually wrapped a bit more
tests that are related, I think it helps to give the test names a bit
more context. The modified test names are:
-PASS: gdb.base/break.exp: set convenience variable $foo to bp_location11
-PASS: gdb.base/break.exp: set breakpoint via convenience variable
-PASS: gdb.base/break.exp: set convenience variable $foo to 81.5
-PASS: gdb.base/break.exp: set breakpoint via non-integer convenience variable disallowed
+PASS: gdb.base/break.exp: set line breakpoint via convenience variable: set convenience variable $foo to bp_location11
+PASS: gdb.base/break.exp: set line breakpoint via convenience variable: break $foo
+PASS: gdb.base/break.exp: set line breakpoint via convenience variable: set convenience variable $foo to 81.5
+PASS: gdb.base/break.exp: set line breakpoint via convenience variable: non-integer convenience variable disallowed
-PASS: gdb.base/break.exp: set $l = 47
-PASS: gdb.base/break.exp: break break.c:$l
-PASS: gdb.base/break.exp: set convenience variable $foo to 81.5
-PASS: gdb.base/break.exp: set breakpoint via non-integer convenience variable disallowed
+PASS: gdb.base/break.exp: set line:file breakpoint via convenience variable: set $l = 47
+PASS: gdb.base/break.exp: set line:file breakpoint via convenience variable: break break.c:$l
+PASS: gdb.base/break.exp: set line:file breakpoint via convenience variable: set convenience variable $foo to 81.5
+PASS: gdb.base/break.exp: set line:file breakpoint via convenience variable: non-integer convenience variable disallowed
gdb/testsuite/ChangeLog:
* gdb.base/break.exp: Use with_test_prefix.
Tom Tromey [Wed, 29 Apr 2020 17:16:57 +0000 (11:16 -0600)]
Fix Ada crash with .debug_types
PR ada/25875 concerns a gdb crash when gdb.ada/arr_enum_idx_w_gap.exp
is run using the .debug_types board.
The problem turns out to be caused by weird compiler output. In this
test, the compiler emits a top-level type that refers to an
enumeration type which is nested in a function. However, this
function is just a declaration.
This results in gdb calling read_enumeration_type for the enum type,
but process_enumeration_scope is never called, yielding an enum with
no fields. This causes the crash.
This patch fixes the problem by arranging to create the enum fields in
read_enumeration_type.
Tested on x86-64 Fedora 30.
gdb/ChangeLog
2020-04-29 Tom Tromey <tromey@adacore.com>
PR ada/25875:
* dwarf2/read.c (update_enumeration_type_from_children): Compute
type fields here.
(read_enumeration_type): Call
update_enumeration_type_from_children later. Update comments.
(process_enumeration_scope): Don't create type fields.
Kamil Rytarowski [Wed, 29 Apr 2020 13:33:33 +0000 (15:33 +0200)]
Set NetBSD xml syscall file name to syscalls/netbsd.xml
The syscall literal names are not stable on NetBSD and can change
once a syscall is versioned. Thus these names are internal to the
system and in GDB mostly descriptive, not intended to be a stable
interface with fixed names across GDB and NetBSD versions to track
certain syscalls.
gdb/ChangeLog:
* nbsd-tdep.c: Include "xml-syscall.h".
(nbsd_init_abi): Call `set_xml_syscall_file_name'.
Kamil Rytarowski [Tue, 28 Apr 2020 23:57:38 +0000 (01:57 +0200)]
Add basic event handling in the NetBSD target
Implement the following events:
- single step (TRAP_TRACE)
- software breakpoint (TRAP_DBREG)
- exec() (TRAP_EXEC)
- syscall entry/exit (TRAP_SCE / TRAP_SCX)
Add support for NetBSD specific ::wait () and ::resume ().
Instruct the generic code that exec and syscall events are supported.
Define an empty nbsd_get_syscall_number as it is prerequisite for
catching syscall entry and exit events, even if it is unused.
This function is used to detect whether the gdbarch supports the
'catch syscall' feature.
gdb/ChangeLog:
* nbsd-nat.c: Include "sys/wait.h".
(nbsd_resume, nbsd_nat_target::resume, nbsd_wait)
(nbsd_nat_target::wait, nbsd_nat_target::insert_exec_catchpoint)
(nbsd_nat_target::remove_exec_catchpoint)
(nbsd_nat_target::set_syscall_catchpoint): Add.
* nbsd-nat.h (nbsd_nat_target::resume, nbsd_nat_target::wait)
(nbsd_nat_target::insert_exec_catchpoint)
(nbsd_nat_target::remove_exec_catchpoint)
(nbsd_nat_target::set_syscall_catchpoint): Add.
* nbsd-tdep.c (nbsd_get_syscall_number): Add.
(nbsd_init_abi): Call `set_gdbarch_get_syscall_number' and pass
`nbsd_get_syscall_number'.
Andrew Burgess [Wed, 29 Apr 2020 16:21:10 +0000 (17:21 +0100)]
When displaying ranges, ignore duplicate offsets.
* dwarf.c (display_debug_ranges): Ignore duplicate entries in
range_entries for the same offset.
Nick Clifton [Wed, 29 Apr 2020 16:18:56 +0000 (17:18 +0100)]
Update expected disassembly after recent update.
PR 22699
* testsuite/gas/sh/sh4al-dsp.d: Update expected disassembly.
Nick Clifton [Wed, 29 Apr 2020 15:09:38 +0000 (16:09 +0100)]
Also use unsigned 8-bit immediate values for the LDRC and SETRC insns.
PR 22699
* sh-opc.h: Also use unsigned 8-bit immediate values for the LDRC
and SETRC insns.
Nick Clifton [Wed, 29 Apr 2020 15:01:40 +0000 (16:01 +0100)]
Add a warning if an emtpty SHT_REL, SHT_RELA or SHT_PROGBITS section is detected. Disable all warnings unless the (new) lint mode is enabled.
* readelf.c (warn): New function - like elfcomm.c version but only
produces output if warnings are enabled.
(struct options): Add --lint and --enable-checks.
(usage): Add entry for --lint.
(parse_args): Handle -L. If checks are enabled but no dumps have
been selected then enable all dumps.
(process_section_headers): Replace long if-then-else sequence with
a switch. Add warning messages for empty SHT_REL, SHT_RELA and
SHT_PROGBITS sections.
(process_file): Do not complain if the file is an archive and lint
mode has been enabled.
* elfcomm.c (error): Make the function weak.
(warn): Likewise.
* NEWS: Mention the new feature.
* doc/binutils.texi: Document the new feature.
* dwarf.h (report_leb_status): Add file name and line number
parameters. Include them in the diagnostic output.
(READ_ULEB): Pass file and line number to report_leb_status.
(READ_SLEB): Likewise.
* dwarf.c (read_and_print_leb128): Pass file and line number to
report_leb_status.
* testsuite/binutils-all/readelf.exp: Add test of new feature.
* testsuite/binutils-all/zero-sec.s: New test source file.
* testsuite/binutils-all/zero-sec.r: Expected output from new
test.
Tom Tromey [Wed, 29 Apr 2020 14:10:28 +0000 (08:10 -0600)]
Remove some dead code
print_block_frame_labels has been commented out since 2010.
I don't think we need it; this patch removes it.
2020-04-29 Tom Tromey <tom@tromey.com>
* stack.c (print_block_frame_labels): Remove.
Gunther Nikl [Wed, 29 Apr 2020 13:42:41 +0000 (14:42 +0100)]
bfd: Fix 64-bit relocation handling for a.out
* aoutx.h (swap_std_reloc_out): Special case 64 bit relocations.
(aout_link_reloc_link_order): Likewise. Make r_length an unsigned.
Nick Clifton [Wed, 29 Apr 2020 12:23:32 +0000 (13:23 +0100)]
Updated Serbian translation for the binutils sub-directory, and Swedish translation for the opcodes sub-directory.
Nick Clifton [Wed, 29 Apr 2020 12:13:55 +0000 (13:13 +0100)]
Fix the disassmbly of SH instructions which have an unsigned 8-bit immediate operand.
PR 22699
opcodes * sh-opc.h (IMM0_8): Replace with IMM0_8S and IMM0_8U. Use
IMM0_8S for arithmetic insns and IMM0_8U for logical insns.
* sh-dis.c (print_insn_sh): Change IMM0_8 case to IMM0_8S and add
IMM0_8U case.
gas * config/tc-sh.c (build_Mytes): Change operand type IMM0_8 to
IMM0_8S and add support for IMM0_8U.
* testsuite/gas/sh/sh4a.s: Add test of a logical insn using an
unsigned 8-bit immediate.
* testsuite/gas/sh/sh4a.d: Extended expected disassembly.
Stephen Casner [Wed, 29 Apr 2020 11:24:37 +0000 (12:24 +0100)]
Remove restriction on skipping some linker tests because their default image base is too high.
PR 25829
* testsuite/ld-scripts/default-script.exp: Add --image-base=0 to
LDFLAGS for targets *-*-mingw64 x86_64-*-cygwin.
* testsuite/ld-scripts/default-script1.d: No longer have to skip
test for those targets.
* testsuite/ld-scripts/default-script2.d: Likewise.
* testsuite/ld-scripts/default-script3.d: Likewise.
* testsuite/ld-scripts/default-script4.d: Likewise.
Tom de Vries [Wed, 29 Apr 2020 11:22:21 +0000 (13:22 +0200)]
[gdb/testsuite] Add xfails for PR gcc/90232
With target board debug-types, we have these FAILs:
...
FAIL: gdb.guile/scm-symtab.exp: test simple_struct in static symbols
FAIL: gdb.python/py-symtab.exp: test simple_struct in static symbols
...
due to PR gcc/90232, as explained in commit
15cd93d05e8 "[gdb/symtab] Handle
struct decl with DW_AT_signature".
Marks these as XFAILs.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-04-29 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (debug_types): New proc.
* gdb.guile/scm-symtab.exp: Add xfail for PR gcc/90232.
* gdb.python/py-symtab.exp: Same.
Hannes Domani [Sun, 26 Apr 2020 13:28:46 +0000 (15:28 +0200)]
Fix array pretty formatter
Currently, printing with array pretty formatting makes the output actually
less readable than without:
(gdb) p -array on -- {{1,2,3},{4,5,6}}
$1 = { {1,
2,
3},
{4,
5,
6}}
(gdb) p -array on -array-indexes on -- {{1,2,3},{4,5,6}}
$2 = {[0] = {[0] = 1,
[1] = 2,
[2] = 3},
[1] = {[0] = 4,
[1] = 5,
[2] = 6}}
These changes now also put the first element and the array end bracket on a new
line, similar to the structure pretty formatter:
(gdb) p -array on -- {{1,2,3},{4,5,6}}
$1 = {
{
1,
2,
3
},
{
4,
5,
6
}
}
(gdb) p -array on -array-indexes on -- {{1,2,3},{4,5,6}}
$2 = {
[0] = {
[0] = 1,
[1] = 2,
[2] = 3
},
[1] = {
[0] = 4,
[1] = 5,
[2] = 6
}
}
gdb/ChangeLog:
2020-04-29 Hannes Domani <ssbssa@yahoo.de>
PR gdb/17320
* ada-valprint.c (val_print_packed_array_elements): Move array
end bracket to new line.
(ada_val_print_string): Remove extra spaces before first array
element.
* c-valprint.c (c_value_print_array): Likewise.
* m2-valprint.c (m2_print_array_contents): Likewise.
(m2_value_print_inner): Likewise.
* p-valprint.c (pascal_value_print_inner): Likewise.
* valprint.c (generic_val_print_array): Likewise.
(value_print_array_elements): Move first array element and array
end bracket to new line.
gdb/testsuite/ChangeLog:
2020-04-29 Hannes Domani <ssbssa@yahoo.de>
PR gdb/17320
* gdb.base/pretty-array.c: New test.
* gdb.base/pretty-array.exp: New file.
Tom de Vries [Wed, 29 Apr 2020 09:39:36 +0000 (11:39 +0200)]
[gdb] Fix range loop index in find_method
With target board debug-types, we have:
...
FAIL: gdb.cp/cpexprs.exp: list policy1::function
...
This is a regression triggered by commit
770479f223e "gdb: Fix toplevel types
with -fdebug-types-section".
However, the FAIL is caused by commit
4dedf84da98 "Change
decode_compound_collector to use std::vector" which changes a VEC_iterate loop
into a range loop:
...
- for (ix = 0; VEC_iterate (symbolp, sym_classes, ix, sym); ++ix)
+ unsigned int ix = 0;
+ for (const auto &sym : *sym_classes)
...
but fails to ensure that the increment of ix happens every iteration.
Fix this by calculating the index variable at the start of the loop body:
...
for (const auto &elt : *sym_classes)
{
unsigned int ix = &elt - &*sym_classes->begin ();
...
Tested on x86_64-linux, with native and target board debug-types.
gdb/ChangeLog:
2020-04-29 Tom de Vries <tdevries@suse.de>
PR symtab/25889
* linespec.c (find_method): Fix ix calculation.
gdb/testsuite/ChangeLog:
2020-04-29 Tom de Vries <tdevries@suse.de>
PR symtab/25889
* gdb.cp/cpexprs.exp: Adapt for inclusion.
* gdb.cp/cpexprs-debug-types.exp: New file. Set -fdebug-types-section
and include cpexprs.exp.
GDB Administrator [Wed, 29 Apr 2020 00:00:12 +0000 (00:00 +0000)]
Automatic date update in version.in
Kamil Rytarowski [Tue, 28 Apr 2020 23:46:41 +0000 (01:46 +0200)]
Add definitions of system calls to catch in native NetBSD targets
All platforms on NetBSD use a shared system call table, so use a
single XML file to describe the system calls available on each NetBSD
platform.
gdb/ChangeLog:
* syscalls/update-netbsd.sh: New file.
* syscalls/netbsd.xml: Regenerate.
* data-directory/Makefile.in: Register `netbsd.xml' in
`SYSCALLS_FILES'
Simon Marchi [Tue, 28 Apr 2020 18:29:39 +0000 (14:29 -0400)]
gdb: fix shellcheck warning in update-freebsd.sh
shellcheck reports:
In update-freebsd.sh line 72:
}' $1 >> freebsd.xml.tmp
^-- SC2086: Double quote to prevent globbing and word splitting.
Did you mean:
}' "$1" >> freebsd.xml.tmp
For more information:
https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent globbing ...
Add double quotes to fix it.
gdb/ChangeLog:
* syscalls/update-freebsd.sh: Add double quotes.
Tom Tromey [Tue, 28 Apr 2020 14:54:17 +0000 (08:54 -0600)]
Allow Python commands to be in class_tui
Now that Python code can create TUI windows, it seemed appropriate to
allow Python commands to appear in the "TUI" help class. This patch
adds this capability.
gdb/ChangeLog
2020-04-28 Tom Tromey <tom@tromey.com>
* NEWS: Update.
* python/py-cmd.c (gdbpy_initialize_commands): Add COMMAND_TUI.
(cmdpy_init): Allow class_tui.
gdb/doc/ChangeLog
2020-04-28 Tom Tromey <tom@tromey.com>
* python.texi (Commands In Python): Document gdb.COMMAND_TUI.
Tom de Vries [Tue, 28 Apr 2020 14:34:38 +0000 (16:34 +0200)]
Add missing ChangeLog entries
Mark Williams [Tue, 28 Apr 2020 14:12:45 +0000 (16:12 +0200)]
gdb: Fix toplevel types with -fdebug-types-section
When debugging a program compiled with -fdebug-types-section,
only the first top-level type in each file is visible to gdb.
The problem was caused by moving the assignment to list_in_scope
from process_full_comp_unit and process_full_type_unit to
start_symtab. This was fine for process_full_comp_unit, because
symtabs and comp units are one-to-one. But there can be many type
units per symtab (one for each type), and we only call start_symtab
for the first one. This adds the necessary assignments on the paths
where start_symtab is not called.
gdb/Changelog:
2020-04-28 Mark Williams <mark@myosotissp.com>
PR gdb/24480
* dwarf2read.c: Add missing assingments to list_in_scope when
start_symtab was already called.
gdb/testsuite/Changelog:
2020-04-28 Mark Williams <mark@myosotissp.com>
PR gdb/24480
* dw4-toplevel-types.exp: Test for top level types.
* dw4-toplevel-types.cc: Test for top level types.
Simon Marchi [Tue, 28 Apr 2020 13:49:58 +0000 (09:49 -0400)]
gdb: use gdb:hash_enum as hash function in offset_map_type
When building with g++ 4.8, we get this error (just an excerpt, because
g++ outputs a very long error message):
CXX dwarf2/read.o
...
/home/smarchi/src/binutils-gdb/gdb/dwarf2/read.c:14616:31: required from here
/usr/include/c++/4.8/bits/hashtable_policy.h:1070:12: error: invalid use of incomplete type ‘struct std::hash<sect_offset>’
struct _Hash_code_base<_Key, _Value, _ExtractKey, _H1, _H2,
This is the same problem and fix as in commit
f23f598e28ad ("[gdb] Fix
build breaker with gcc 4.8"). Pass an explicit hash function rather
than relying on the default std::hash<sect_offset>.
gdb/ChangeLog:
PR gdb/25881
* dwarf2/read.c (offset_map_type): Use
gdb:hash_enum<sect_offset> as hash function.
Nick Clifton [Tue, 28 Apr 2020 10:56:06 +0000 (11:56 +0100)]
Rebase libiberty source with latest changes from gcc.
PR 25876
PR demangler/94797
* cp-demangle.c (cplus_demangle_operators): Add ss <=> operator.
* testsuite/demangle-expected: Add operator<=> test.
Tankut Baris Aktemur [Tue, 28 Apr 2020 09:30:52 +0000 (11:30 +0200)]
Fix typo (thead -> thread)
gdb/stubs/ChangeLog:
2020-04-28 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* ia64vms-stub.c: Fix typo in comment (thead -> thread).
gdb/testsuite/ChangeLog:
2020-04-28 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* gdb.threads/stop-with-handle.exp: Fix typo in comment
(theads -> threads).
gdbsupport/ChangeLog:
2020-04-28 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* gdb-sigmask.h: Fix typo (pthead_sigmask -> pthread_sigmask).
Tom de Vries [Tue, 28 Apr 2020 06:33:40 +0000 (08:33 +0200)]
[gdb/testsuite] Add PR number to KFAIL in gdb.opt/inline-cmds.exp
With test-case gdb.opt/inline-cmds.exp, we have:
...
KFAIL: gdb.opt/inline-cmds.exp: next to second func1 (PRMS: gdb/NNNN)
...
I've filed PR25884 for this failure.
Set the KFAIL PR accordingly.
gdb/testsuite/ChangeLog:
2020-04-28 Tom de Vries <tdevries@suse.de>
* gdb.opt/inline-cmds.exp: Set KFAIL PR.
Tom de Vries [Tue, 28 Apr 2020 04:54:55 +0000 (06:54 +0200)]
[gdb/testsuite] Remove KFAIL from gdb.base/info-macros.exp
When running test-case gdb.base/info-macros.exp, we have:
...
(gdb) KFAIL: gdb.base/info-macros.exp: info macros info-macros.c:42 \
(PRMS: gdb/NNNN)
...
The described failure mode however:
...
set test "info macros info-macros.c:42"
set r1 ".*define DEF_MACROS"
set r2 ".*define ONE"
setup_kfail "gdb/NNNN" *-*-*
gdb_test "$test" "$r1$r2"
...
does not match the actual output, given that both defines are in fact
printed.
The pattern fails to match because it's missing a trailing ".*".
Fix this by removing the KFAIL and adding the missing trailing ".*".
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-04-28 Tom de Vries <tdevries@suse.de>
* gdb.base/info-macros.exp: Remove KFAIL. Add missing trailing ".*".
Tom de Vries [Tue, 28 Apr 2020 04:22:36 +0000 (06:22 +0200)]
[gdb/testsuite] Add PR number in KFAIL in gdb.ada/array_ptr_renaming.exp
When running test-case gdb.ada/array_ptr_renaming.exp we run into:
...
(gdb) print ntp^M
$3 = (3 => 30, 40)^M
(gdb) KFAIL: gdb.ada/array_ptr_renaming.exp: print ntp (PRMS: gdb/NNNN)
...
I've opened PR25883 for this failure. Reference the PR from the KFAIL, such
that we have:
...
KFAIL: gdb.ada/array_ptr_renaming.exp: print ntp (PRMS: gdb/25883)
...
gdb/testsuite/ChangeLog:
2020-04-28 Tom de Vries <tdevries@suse.de>
* gdb.ada/array_ptr_renaming.exp: Add PR number in KFAIL.
Tom de Vries [Tue, 28 Apr 2020 04:12:35 +0000 (06:12 +0200)]
[gdb/symtab] Handle struct decl with DW_AT_signature
Consider a test-case with sources 36.c:
...
struct s { int i; };
extern void f (void);
int main (void) {
struct s a;
f ();
return 0;
}
...
and 36b.c:
...
struct s { int j; };
void f (void) {
struct s b;
}
...
compiled like this:
...
$ gcc 36.c 36b.c -g
...
It contains DWARF like this:
...
<0><d2>: Abbrev Number: 1 (DW_TAG_compile_unit)
<d8> DW_AT_name : 36.c
<1><f4>: Abbrev Number: 2 (DW_TAG_structure_type)
<f5> DW_AT_name : s
<2><fe>: Abbrev Number: 3 (DW_TAG_member)
<ff> DW_AT_name : i
<1><110>: Abbrev Number: 5 (DW_TAG_subprogram)
<111> DW_AT_name : main
<2><12d>: Abbrev Number: 6 (DW_TAG_variable)
<12e> DW_AT_name : a
<132> DW_AT_type : <0xf4>
<0><146>: Abbrev Number: 1 (DW_TAG_compile_unit)
<14c> DW_AT_name : 36b.c
<1><168>: Abbrev Number: 2 (DW_TAG_structure_type)
<169> DW_AT_name : s
<2><172>: Abbrev Number: 3 (DW_TAG_member)
<173> DW_AT_name : j
<1><184>: Abbrev Number: 5 (DW_TAG_subprogram)
<185> DW_AT_name : f
<2><19b>: Abbrev Number: 6 (DW_TAG_variable)
<19c> DW_AT_name : b
<1a0> DW_AT_type : <0x168>
...
And when printing "struct s", we get first a random one (with int j), and then
context-specific ones (with int i in main, and int j in f):
...
$ gdb -batch a.out \
-ex "ptype struct s" \
-ex start \
-ex "ptype struct s" \
-ex "break f" -ex continue \
-ex "ptype struct s" \
| grep "int [ij];"
int j;
int i;
int j;
...
Same for -readnow.
However, if we use -fdebug-types-section:
...
$ gcc 36.c 36b.c -g -fdebug-types-section
...
we get:
...
$ gdb ... | grep "int [ij];"
int j;
int i;
int i;
$ gdb -readnow ... | grep "int [ij];"
int j;
int j;
int j;
...
This is due to the fact that both "struct s" DIEs have been moved to the
.debug_types section:
...
Compilation Unit @ offset 0x0:
Signature: 0xfd1462823bb6f7b7
<0><17>: Abbrev Number: 1 (DW_TAG_type_unit)
<1><1d>: Abbrev Number: 2 (DW_TAG_structure_type)
<1e> DW_AT_name : s
<2><27>: Abbrev Number: 3 (DW_TAG_member)
<28> DW_AT_name : i
Compilation Unit @ offset 0x3a:
Signature: 0x534310fbefba324d
<0><51>: Abbrev Number: 1 (DW_TAG_type_unit)
<1><57>: Abbrev Number: 2 (DW_TAG_structure_type)
<58> DW_AT_name : s
<2><61>: Abbrev Number: 3 (DW_TAG_member)
<62> DW_AT_name : j
...
and there's no longer a "struct s" DIE in the 36.c and
and 36b.c CUs to specify which "struct s" belongs in the CU. This is gcc
PR90232.
However, using a tentative patch for gcc that adds these DIEs (according to
DWARF standard: If the complete declaration of a type has been placed in a
separate type unit, an incomplete declaration of that type in the compilation
unit may provide the unique 64-bit signature of the type using a
DW_AT_signature attribute):
...
<0><d2>: Abbrev Number: 5 (DW_TAG_compile_unit)
<d8> DW_AT_name : 36.c
+ <1><f4>: Abbrev Number: 6 (DW_TAG_structure_type)
+ <f5> DW_AT_name : s
+ <f7> DW_AT_signature : signature: 0xfd1462823bb6f7b7
+ <ff> DW_AT_declaration : 1
<0><13c>: Abbrev Number: 5 (DW_TAG_compile_unit)
<142> DW_AT_name : 36b.c
+ <1><15e>: Abbrev Number: 6 (DW_TAG_structure_type)
+ <15f> DW_AT_name : s
+ <161> DW_AT_signature : signature: 0x534310fbefba324d
+ <169> DW_AT_declaration : 1
...
still does not help, because they're declarations, so new_symbol is not called
for them in process_structure_scope.
Fix this by calling new_symbol for these decls.
Build and tested on x86_64-linux.
Also tested with target board enabling by default -fdebug-types-section
-gdwarf-4, and with gcc with aforementioned tentative patch. In this
configuration, the patch reduces number of FAILs from 2888 to 238.
gdb/ChangeLog:
2020-04-28 Tom de Vries <tdevries@suse.de>
* dwarf2/read.c (process_structure_scope): Add symbol for struct decl
with DW_AT_signature.
gdb/testsuite/ChangeLog:
2020-04-28 Tom de Vries <tdevries@suse.de>
* gdb.dwarf2/main-foo.c: New test.
* gdb.dwarf2/struct-with-sig.exp: New file.
GDB Administrator [Tue, 28 Apr 2020 00:00:10 +0000 (00:00 +0000)]
Automatic date update in version.in
Alan Modra [Mon, 27 Apr 2020 23:02:13 +0000 (08:32 +0930)]
alpha-vms: divide by zero
The zero check was on the wrong operand. And, yes, the second operand
popped is supposed to be divided by the first operand popped.
* vms-alpha.c (_bfd_vms_slurp_etir): Correct divide by zero check.
Emit warning message.
Tamar Christina [Mon, 27 Apr 2020 16:39:31 +0000 (17:39 +0100)]
x86: Add i386 PE big-object support
The 64-bit version of binutils got support for the PE COFF BIG OBJ format a
couple of years ago. The BIG OBJ format is a slightly different COFF format
which extends the size of the number of section field in the header from a
uint16_t to a uint32_t and so greatly increases the number of sections allowed.
However the 32-bit version of bfd never got support for this. The GHC Haskell
compiler generates a great deal of symbols due to it's use of
-ffunction-sections and -fdata-sections.
This meant that we could not build the 32-bit version of the GHC Compiler for
many releases now as binutils didn't have this support.
This patch adds the support to the 32-bit port of binutils as well and also does
come cleanup in the code.
bfd/ChangeLog:
* coff-i386.c (COFF_WITH_PE_BIGOBJ): New.
* coff-x86_64.c (COFF_WITH_PE_BIGOBJ): New.
* config.bfd (targ_selvecs): Rename x86_64_pe_be_vec
to x86_64_pe_big_vec as it not a big-endian format.
(vec i386_pe_big_vec): New.
* configure.ac: Likewise.
* targets.c: Likewise.
* configure: Regenerate.
* pe-i386.c (TARGET_SYM_BIG, TARGET_NAME_BIG,
COFF_WITH_PE_BIGOBJ): New.
* pe-x86_64.c (TARGET_SYM_BIG, TARGET_NAME_BIG):
New.
(x86_64_pe_be_vec): Moved.
gas/ChangeLog:
* NEWS: Add news entry for big-obj.
* config/tc-i386.c (i386_target_format): Support new format.
* doc/c-i386.texi: Add i386 support.
* testsuite/gas/pe/big-obj.d: Rename test to not be x64 specific.
* testsuite/gas/pe/pe.exp (big-obj): Make test run on i386 as well.
ld/ChangeLog:
* pe-dll.c (pe_detail_list): Add pe-bigobj-i386.
Simon Marchi [Mon, 27 Apr 2020 14:46:51 +0000 (10:46 -0400)]
gdb, gdbserver: remove configure check for fs_base/gs_base in user_regs_struct
I recently stumbled on this code mentioning Linux kernel 2.6.25, and
thought it could be time for some spring cleaning (newer GDBs probably
don't need to supports 12-year old kernels). I then found that the
"legacy" case is probably broken anyway, which gives an even better
motivation for its removal.
In short, this patch removes the configure checks that check if
user_regs_struct contains the fs_base/gs_base fields and adjusts all
uses of the HAVE_STRUCT_USER_REGS_STRUCT_{FS,GS}_BASE macros. The
longer explanation/rationale follows.
Apparently, Linux kernels since 2.6.25 (that's from 2008) have been
reliably providing fs_base and gs_base as part of user_regs_struct.
Commit
df5d438e33d7 in the Linux kernel [1] seems related. This means
that we can get these values by reading registers with PTRACE_GETREGS.
Previously, these values were obtained using a separate
PTRACE_ARCH_PRCTL ptrace call.
First, I'm not even sure the configure check was really right in the
first place.
The user_regs_struct used by GDB comes from
/usr/include/x86_64-linux-gnu/sys/user.h (or equivalent on other
distros) and is provided by glibc. glibc has had the fs_base/gs_base
fields in there for a very long time, at least since this commit from
2001 [2]. The Linux kernel also has its version of user_regs_struct,
which I think was exported to user-space at some point. It included the
fs_base/gs_base fields since at least this 2002 commit [3]. In any
case, my conclusion is that the fields were there long before the
aforementioned Linux kernel commit. The kernel commit didn't add these
fields, it only made sure that they have reliable values when obtained
with PTRACE_GETREGS.
So, checking for the presence of the fs_base/gs_base fields in struct
user_regs_struct doesn't sound like a good way of knowing if we can
reliably get the fs_base/gs_base values from PTRACE_GETREGS. My guess
is that if we were using that strategy on a < 2.6.25 kernel, things
would not work correctly:
- configure would find that the user_regs_struct has the fs_base/gs_base
fields (which are probided by glibc anyway)
- we would be reading the fs_base/gs_base values using PTRACE_GETREGS,
for which the kernel would provide unreliable values
Second, I have tried to see how things worked by forcing GDB to not use
fs_base/gs_base from PTRACE_GETREGS (forcing it to use the "legacy"
code, by configuring with
ac_cv_member_struct_user_regs_struct_gs_base=no ac_cv_member_struct_user_regs_struct_fs_base=no
Doing so breaks writing registers back to the inferior. For example,
calling an inferior functions gives an internal error:
(gdb) p malloc(10)
/home/smarchi/src/binutils-gdb/gdb/i387-tdep.c:1408: internal-error: invalid i387 regnum 152
The relevant last frames where this error happens are:
#8 0x0000563123d262fc in internal_error (file=0x563123e93fd8 "/home/smarchi/src/binutils-gdb/gdb/i387-tdep.c", line=1408, fmt=0x563123e94482 "invalid i387 regnum %d") at /home/smarchi/src/binutils-gdb/gdbsupport/errors.cc:55
#9 0x0000563123047d0d in i387_collect_xsave (regcache=0x5631269453f0, regnum=152, xsave=0x7ffd38402a20, gcore=0) at /home/smarchi/src/binutils-gdb/gdb/i387-tdep.c:1408
#10 0x0000563122c69e8a in amd64_collect_xsave (regcache=0x5631269453f0, regnum=152, xsave=0x7ffd38402a20, gcore=0) at /home/smarchi/src/binutils-gdb/gdb/amd64-tdep.c:3448
#11 0x0000563122c5e94c in amd64_linux_nat_target::store_registers (this=0x56312515fd10 <the_amd64_linux_nat_target>, regcache=0x5631269453f0, regnum=152) at /home/smarchi/src/binutils-gdb/gdb/amd64-linux-nat.c:335
#12 0x00005631234c8c80 in target_store_registers (regcache=0x5631269453f0, regno=152) at /home/smarchi/src/binutils-gdb/gdb/target.c:3485
#13 0x00005631232e8df7 in regcache::raw_write (this=0x5631269453f0, regnum=152, buf=0x56312759e468 "@\225\372\367\377\177") at /home/smarchi/src/binutils-gdb/gdb/regcache.c:765
#14 0x00005631232e8f0c in regcache::cooked_write (this=0x5631269453f0, regnum=152, buf=0x56312759e468 "@\225\372\367\377\177") at /home/smarchi/src/binutils-gdb/gdb/regcache.c:778
#15 0x00005631232e75ec in regcache::restore (this=0x5631269453f0, src=0x5631275eb130) at /home/smarchi/src/binutils-gdb/gdb/regcache.c:283
#16 0x0000563123083fc4 in infcall_suspend_state::restore (this=0x5631273ed930, gdbarch=0x56312718cf20, tp=0x5631270bca90, regcache=0x5631269453f0) at /home/smarchi/src/binutils-gdb/gdb/infrun.c:9103
#17 0x0000563123081eed in restore_infcall_suspend_state (inf_state=0x5631273ed930) at /home/smarchi/src/binutils-gdb/gdb/infrun.c:9151
The problem seems to be that amd64_linux_nat_target::store_registers
calls amd64_native_gregset_supplies_p to know whether gregset provides
fs_base. When !HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE,
amd64_native_gregset_supplies_p returns false. store_registers
therefore assumes that it must be an "xstate" register. This is of
course wrong, and that leads to the failed assertion when
i387_collect_xsave doesn't recognize the register.
amd64_linux_nat_target::store_registers could probably be fixed to
handle this case, but I don't think it's worth it, given that it would
only be to support very old kernels.
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=
df5d438e33d7fc914ba9b6e0d6b019a8966c5fcc
[2] https://sourceware.org/git/?p=glibc.git;a=commit;h=
c9cf6ddeebb7bb
[3] https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git/commit/?id=
88e4bc32686ebd0b1111a94f93eba2d334241f68
gdb/ChangeLog:
* configure.ac: Remove check for fs_base/gs_base in
user_regs_struct.
* configure: Re-generate.
* config.in: Re-generate.
* amd64-nat.c (amd64_native_gregset_reg_offset): Adjust.
* amd64-linux-nat.c (amd64_linux_nat_target::fetch_registers,
amd64_linux_nat_target::store_registers, ps_get_thread_area, ): Adjust.
gdbserver/ChangeLog:
* configure.ac: Remove check for fs_base/gs_base in
user_regs_struct.
* configure: Re-generate.
* config.in: Re-generate.
* linux-x86-low.cc (x86_64_regmap, x86_fill_gregset,
x86_store_gregset): Adjust.
Tom Tromey [Mon, 27 Apr 2020 14:23:53 +0000 (08:23 -0600)]
Expand dynamic type documentation
This expands the Python dynamic type documentation, as suggested by
Christian.
gdb/doc/ChangeLog
2020-04-27 Tom Tromey <tromey@adacore.com>
* python.texi (Types In Python): Mention missing fields. Add
dynamic type example.
Simon Marchi [Mon, 27 Apr 2020 13:19:48 +0000 (09:19 -0400)]
gdbsupport: include cstdlib in common-defs.h
In PR 25731 [1], the following build failure was reported:
../../binutils-gdb/gdb/gdbtypes.c:1254:10: error: no member named 'abs' in namespace 'std'; did you mean simply 'abs'?
= ((std::abs (stride) * element_count) + 7) / 8;
^~~~~~~~
abs
/usr/include/stdlib.h:129:6: note: 'abs' declared here
int abs(int) __pure2;
^
The original report was using:
$ gcc -v
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin15.6.0
Note that I was _not_ able to reproduce using:
$ g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.33.17)
Target: x86_64-apple-darwin19.3.0
The proposed fix is to include <cstdlib> in addition to <stdlib.h>.
Here's an excerpt of [2] relevant to this problem:
These headers [speaking of the .h form] are allowed to also declare
the same names in the std namespace, and the corresponding cxxx
headers are allowed to also declare the same names in the global
namespace: including <cstdlib> definitely provides std::malloc and
may also provide ::malloc. Including <stdlib.h> definitely provides
::malloc and may also provide std::malloc
Since we use std::abs, we should not assume that our include of stdlib.h
declares an `abs` function in the `std` namespace.
If we replace the include of stdlib.h with cstdlib, then we fall in the
opposite situation. A standard C++ library may decide to only put the
declarations in the std namespace, requiring us to prefix all standard
functions with `std::`. I'm not against that, but for the moment I think the
safest way forward is to just include both.
Note that I don't know what effect this patch can have on any stdlib.h fix
provided by gnulib.
[1] https://sourceware.org/bugzilla/show_bug.cgi?id=25731
[2] https://en.cppreference.com/w/cpp/header#C_compatibility_headers
gdbsupport/ChangeLog:
* common-defs.h: Include cstdlib.h.
Luis Machado [Sat, 25 Apr 2020 03:32:44 +0000 (00:32 -0300)]
Fix remaining inline/tailcall unwinding breakage for x86_64
Commit
5939967b355ba6a940887d19847b7893a4506067 fixed inline
frame unwinding breakage for some targets (aarch64, riscv, s390...)
but regressed a few amd64 testcases related to tailcalls.
Given the following example situation...
Frame #-1 - sentinel frame
Frame # 0 - inline frame
Frame # 1 - normal frame
... suppose we're at level #1 and call into dwarf2_tailcall_sniffer_first.
We'll attempt to fetch PC, which used to be done via the gdbarch_unwind_pc call
(before
5939967b355ba6a940887d19847b7893a4506067), but now it is being handled
by the get_frame_register function.
gdbarch_unwind_pc will attempt to use frame #1's cache to retrieve information
about the PC. Here's where different architectures behave differently.
x86_64 will find a dwarf rule to retrieve PC from memory, at a CFA + offset
location. So the PC value is readily available and there is no need to
create a lazy value.
For aarch64 (and others), GCC doesn't emit an explicit location for PC, so we
eventually will find that PC is DWARF2_FRAME_REG_UNSPECIFIED. This is known
and is handled by GDB by assuming GCC really meant DWARF2_FRAME_REG_SAME_VALUE.
This means we'll attempt to fetch the register value from frame #0, via a call
to frame_unwind_got_register, which will trigger the creation of a lazy value
that requires a valid frame id for frame #0.
We don't have a valid id for frame #0 yet, so we assert.
Given the above, the following patch attempts to handle the situation without
being too hacky. We verify if the next frame is an inline frame and if its
frame id has been computed already. If it hasn't been computed yet, then we
use the safer get_frame_register function, otherwise we use the regular
gdbarch_unwind_pc hook.
gdb/ChangeLog:
2020-04-27 Luis Machado <luis.machado@linaro.org>
* dwarf2/frame-tailcall.c (dwarf2_tailcall_sniffer_first): Handle
problematic inline frame unwinding situation.
* frame.c (frame_id_computed_p): New function.
* frame.h (frame_id_computed_p): New prototype.
Nick Clifton [Mon, 27 Apr 2020 10:35:25 +0000 (11:35 +0100)]
GAS: Allow automatically assigned entries in the file table to be reassigned if the source file specifically requests to use the assigned slot.
PR 25878
* dwarf2dbg.c (struct file_entry): Add auto_assigned field.
(assign_file_to_slot): New function. Fills in an entry in the
files table.
(allocate_filenum): Use new function.
(allocate_filename_to_slot): Use new function. If the specified
slot entry is already in use, but was chosen automatically then
reassign the automatic entry.
GDB Administrator [Mon, 27 Apr 2020 00:00:15 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Sun, 26 Apr 2020 19:36:04 +0000 (13:36 -0600)]
Remove class_pseudo
The class_pseudo constant is unused, so this removes it.
Tested by rebuilding.
gdb/ChangeLog
2020-04-26 Tom Tromey <tom@tromey.com>
* command.h (enum command_class) <class_pseudo>: Remove.
Alan Modra [Sun, 26 Apr 2020 09:00:50 +0000 (18:30 +0930)]
readelf: NULL dereference
This fixes another missing error check.
* readelf.c (get_num_dynamic_syms): Check DT_MIPS_XHASH was
read before dereferencing, and gracefully return. Remove
gnu_hash_error variable. Free gnu hash arrays if number of
syms found is zero.
Philippe Waroquiers [Sun, 26 Apr 2020 14:01:52 +0000 (16:01 +0200)]
Fix comments and whitespace in lookup_cmd_composition
2020-04-26 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* cli/cli-decode.c (lookup_cmd_composition): Fix comments
and whitespace.
liuhongt [Mon, 16 Mar 2020 03:03:12 +0000 (11:03 +0800)]
Improve -mlfence-after-load
1.Implict load for POP/POPF/POPA/XLATB, no load for Anysize insns
2. Add -mlfence-before-ret=shl/yes, adjust operand size of
or/not/shl according to ret's.
3. Issue warning for REP CMPS/SCAS since they would affect control
flow behavior.
4. Adjust testcases and documents.
gas/Changelog:
* config/tc-i386.c (lfence_before_ret_shl): New member.
(load_insn_p): implict load for POP/POPA/POPF/XLATB, no load
for Anysize insns.
(insert_after_load): Issue warning for REP CMPS/SCAS.
(insert_before_before): Handle iret, Handle
-mlfence-before-ret=shl, Adjust operand size of or/not/shl to ret's,
(md_parse_option): Change -mlfence-before-ret=[none|not|or] to
-mlfence-before-ret=[none/not/or/shl/yes].
Enable -mlfence-before-ret=shl when
-mlfence-beofre-indirect-branch=all and no explict -mlfence-before-ret option.
(md_show_usage): Ditto.
* doc/c-i386.texi: Ditto.
* testsuite/gas/i386/i386.exp: Add new testcases.
* testsuite/gas/i386/lfence-load-b.d: New.
* testsuite/gas/i386/lfence-load-b.e: New.
* testsuite/gas/i386/lfence-load.d: Modified.
* testsuite/gas/i386/lfence-load.e: New.
* testsuite/gas/i386/lfence-load.s: Modified.
* testsuite/gas/i386/lfence-ret-a.d: Modified.
* testsuite/gas/i386/lfence-ret-b.d: Modified.
* testsuite/gas/i386/lfence-ret-c.d: New.
* testsuite/gas/i386/lfence-ret-d.d: New.
* testsuite/gas/i386/lfence-ret.s: Modified.
* testsuite/gas/i386/x86-64-lfence-load-b.d: New.
* testsuite/gas/i386/x86-64-lfence-load.d: Modified.
* testsuite/gas/i386/x86-64-lfence-load.s: Modified.
* testsuite/gas/i386/x86-64-lfence-ret-a.d: Modified.
* testsuite/gas/i386/x86-64-lfence-ret-b.d: Modified.
* testsuite/gas/i386/x86-64-lfence-ret-c.d: New.
* testsuite/gas/i386/x86-64-lfence-ret-d.d: New
* testsuite/gas/i386/x86-64-lfence-ret-e.d: New.
* testsuite/gas/i386/x86-64-lfence-ret.e: New.
* testsuite/gas/i386/x86-64-lfence-ret.s: New.
GDB Administrator [Sun, 26 Apr 2020 00:00:07 +0000 (00:00 +0000)]
Automatic date update in version.in
Kamil Rytarowski [Fri, 24 Apr 2020 16:10:07 +0000 (18:10 +0200)]
Remove unused code block in inf_ptrace_target::wait
Remove unused PT_GET_PROCESS_STATE block. It used to be used
by OpenBSD, but it is now reimplemented independently in
obsd-nat.c.
gdb/ChangeLog:
* inf-ptrace.c (inf_ptrace_target::wait): Remove
`PT_GET_PROCESS_STATE' block.
Change-Id: I9b872df8517b658c0dfe889fc1e4a7009bc5c076
Tom de Vries [Sat, 25 Apr 2020 15:19:26 +0000 (17:19 +0200)]
[gdb/testsuite] Add target board debug-types
This patch adds a target board debug-types that switches on
-fdebug-types-section by default.
This -fdebug-types-section option is a gcc option that enables the generation
of a .debug_types section, which is only effective for DWARF version 4.
There are two other boards that enable this: dwarf4-gdb-index and fisson, but
while those test some meaningful combination of options, this board is
intended to test only -fdebug-types-section.
Current results with gcc 7.5.0 are:
...
=== gdb Summary ===
# of expected passes 75832
# of unexpected failures 2841
# of expected failures 130
# of known failures 75
# of unresolved testcases 22
# of untested testcases 37
# of unsupported tests 83
...
Related known issues:
- PR gcc/90232 - "gcc drops top-level dies with -fdebug-types-section"
- PR gdb/25875 - "segv in ada_discrete_type_low_bound"
- PR gdb/14148 - "-fdebug-types-section regresses static scope of types"
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-04-25 Tom de Vries <tdevries@suse.de>
* boards/debug-types.exp: New file.
Andrew Burgess [Thu, 23 Apr 2020 09:44:30 +0000 (10:44 +0100)]
gdb/testsuite: Remove build paths from test names
Having paths in test names makes it harder to compare results from
different builds of GDB.
gdb/testsuite/ChangeLog:
* gdb.btrace/multi-inferior.exp: Avoid paths in test names.
GDB Administrator [Sat, 25 Apr 2020 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Fri, 24 Apr 2020 21:35:01 +0000 (15:35 -0600)]
Remove symbol_get_demangled_name
Now that symbol_get_demangled_name is only used by general_symbol_info
methods, and because these methods already check the symbol's language
to decide what to return, symbol_get_demangled_name is no longer
needed. This patch removes it.
gdb/ChangeLog
2020-04-24 Tom Tromey <tom@tromey.com>
* symtab.h (symbol_get_demangled_name): Don't declare.
* symtab.c (symbol_get_demangled_name): Remove.
(general_symbol_info::natural_name)
(general_symbol_info::demangled_name): Update.