Tom de Vries [Wed, 19 Feb 2020 21:57:19 +0000 (22:57 +0100)]
[gdb/testsuite] Fix xpass in gdb.python/lib-types.exp
When running gdb.python/lib-types.exp, we have an xpass:
...
(gdb) python print (str (typedef_const_typedef_class1_ref_obj.type))^M
typedef_const_typedef_class1_ref^M
(gdb) XPASS: gdb.python/lib-types.exp: \
python print (str (typedef_const_typedef_class1_ref_obj.type)) \
(PRMS gcc/55641)
...
When running the same with gcc 4.8, we have an xfail instead:
...
(gdb) python print (str (typedef_const_typedef_class1_ref_obj.type))^M
const typedef_const_typedef_class1_ref^M
(gdb) XFAIL: gdb.python/lib-types.exp: \
python print (str (typedef_const_typedef_class1_ref_obj.type)) \
(PRMS gcc/55641)
...
Fix the xpass by xfailing only for the gcc 4.8 pattern.
Tested on x86_64-linux, with:
- gcc 7.5.0
- gcc 4.8.5
- clang 5.0.2
gdb/testsuite/ChangeLog:
2020-02-19 Tom de Vries <tdevries@suse.de>
* gdb.python/lib-types.exp: Make xfail more strict.
Tom de Vries [Wed, 19 Feb 2020 21:33:42 +0000 (22:33 +0100)]
[gdb/testsuite] Fix funcall_ref.exp xpass
When running gdb.ada/funcall_ref.exp I run into two XPASSes:
...
(gdb) p get ("Hello world!")^M
$1 = (n => 12, s => "Hello world!")^M
(gdb) XPASS: gdb.ada/funcall_ref.exp: p get ("Hello world!")
ptype get ("Hello world!")^M
type = <ref> record^M
n: natural;^M
s: access array (1 .. n) of character;^M
end record^M
(gdb) XPASS: gdb.ada/funcall_ref.exp: ptype get ("Hello world!")
...
The xfails are documented in funcall_ref.exp:
...
# Currently, GCC describes such functions as returning pointers (instead of
# references).
setup_xfail *-*-*
...
Using gnatmake 4.8, we can reproduce the XFAILs:
...
(gdb) p get ("Hello world!")^M
$1 = (access foo.bar) 0x6147b0 <system.secondary_stack.chunk+48>^M
(gdb) XFAIL: gdb.ada/funcall_ref.exp: p get ("Hello world!")
ptype get ("Hello world!")^M
type = access record^M
n: natural;^M
s: access array (1 .. n) of character;^M
end record^M
(gdb) XFAIL: gdb.ada/funcall_ref.exp: ptype get ("Hello world!")
...
Fix the XPASSes by:
- removing the xfail setup
- switching the order of the two tests
- detecting the "access record" type and declaring the first test unsupported,
and skipping the second test
Tested on x86_64-linux, both with gnatmake 4.8.5 and gnatmake 7.5.0.
gdb/testsuite/ChangeLog:
2020-02-19 Tom de Vries <tdevries@suse.de>
* gdb.ada/funcall_ref.exp: Replace xfail setup by unsupported check.
Simon Marchi [Wed, 19 Feb 2020 21:04:52 +0000 (16:04 -0500)]
gdb: dwarf2/read.c: remove unused objfile parameters/variables
This is a simple cleanup. These functions used to use the objfile's
obstack for allocation in the hash tables, but they don't anymore.
Remove the unnecessary objfile parameters, which in turn allows removing
some local variables.
gdb/ChangeLog:
* dwarf2/read.c (allocate_signatured_type_table,
allocate_dwo_unit_table, allocate_type_unit_groups_table,
allocate_dwo_file_hash_table, allocate_dwp_loaded_cutus_table):
Remove objfile parameter, update all callers.
Doug Evans [Wed, 19 Feb 2020 20:54:59 +0000 (13:54 -0700)]
rust/25535 Apply embedded offset to enum variant calculation
Hopefully straightforward (and I didn't miss anything ...).
gdb/ChangeLog
2020-02-19 Doug Evans <dje@google.com>
PR rust/25535
* rust-lang.c (rust_print_enum): Apply embedded_offset to
rust_enum_variant calculation.
gdb/testsuite/ChangeLog
2020-02-19 Doug Evans <dje@google.com>
PR rust/25535
* gdb.rust/simple.exp: Add test.
* gdb.rust/simple.rs: Add test.
Tom de Vries [Wed, 19 Feb 2020 20:33:39 +0000 (21:33 +0100)]
[gdb/testsuite] Fix corefile-buildid.exp with check-read1
When running gdb.base/corefile-buildid.exp using check-read1, I run into:
...
FAIL: gdb.base/corefile-buildid.exp: shared: info files (timeout)
FAIL: gdb.base/corefile-buildid.exp: symlink shared: info files (timeout)
FAIL: gdb.base/corefile-buildid.exp: shared sepdebug: info files (timeout)
FAIL: gdb.base/corefile-buildid.exp: symlink shared sepdebug: info files \
(timeout)
...
This is caused by attempting to match the output of an "info files" command
using a single gdb_test in check_exec_file.
Fix this by doing line-by-line matching in check_exec_file.
Tested on x86_64-linux, using make targets check and check-read1.
gdb/testsuite/ChangeLog:
2020-02-19 Tom de Vries <tdevries@suse.de>
* gdb.base/corefile-buildid.exp (check_exec_file): Match info files
output line-by-line.
Tom Tromey [Wed, 19 Feb 2020 19:18:09 +0000 (12:18 -0700)]
Fix declaration of mips_pc_is_mips
A build where CORE_ADDR is not the same as bfd_vma pointed out that
mips_pc_is_mips is declared using bfd_vma as the parameter type, but
defined using CORE_ADDR. This patch fixes the declaration.
gdb/ChangeLog
2020-02-19 Tom Tromey <tromey@adacore.com>
* mips-tdep.h (mips_pc_is_mips): Parameter type is CORE_ADDR.
Tom Tromey [Wed, 19 Feb 2020 18:06:33 +0000 (11:06 -0700)]
Use obstack_strdup in ada-lang.c
I happened across a spot that was still using obstack_alloc and
strcpy, rather than obstack_strdup. This patch makes the obvious fix.
gdb/ChangeLog
2020-02-19 Tom Tromey <tromey@adacore.com>
* ada-lang.c (cache_symbol): Use obstack_strdup.
Andrew Burgess [Wed, 5 Feb 2020 11:50:07 +0000 (11:50 +0000)]
Merge changes from GCC for the config/ directory
GCC's config/ChangeLog since the last time this merge was done
(in the binutils-gdb commit
0b4d000cc4e8e77c823) is included at the
end of this commit message.
It is worth noting that the binutils-gdb commit
301a9420d947da1458
added the file config/debuginfod.m4 which is not present in GCC's
config/ directory. This file is preserved, unmodified, after this
commit.
In order to regenerate all of the configure files, I configured with
--enable-maintainer-mode, and built the 'all' target. I then did the
same thing on a source tree without this patch, and only committed
those files that changed when this patch was added.
GCC's config/ChangeLog entries:
2020-02-12 Sandra Loosemore <sandra@codesourcery.com>
PR libstdc++/79193
PR libstdc++/88999
* no-executables.m4: Use a non-empty program to test for linker
support.
2020-02-01 Andrew Burgess <andrew.burgess@embecosm.com>
* lib-link.m4 (AC_LIB_LINKFLAGS_BODY): Update shell syntax.
2020-01-27 Andrew Burgess <andrew.burgess@embecosm.com>
* lib-link.m4 (AC_LIB_LINKFLAGS_BODY): Add new
--with-libXXX-type=... option. Use this to guide the selection of
either a shared library or a static library.
2020-01-24 Maciej W. Rozycki <macro@wdc.com>
* toolexeclibdir.m4: New file.
2019-09-10 Christophe Lyon <christophe.lyon@st.com>
* futex.m4: Handle *-uclinux*.
* tls.m4 (GCC_CHECK_TLS): Likewise.
2019-09-06 Florian Weimer <fweimer@redhat.com>
* futex.m4 (GCC_LINUX_FUTEX): Include <unistd.h> for the syscall
function.
2019-07-08 Richard Sandiford <richard.sandiford@arm.com>
* bootstrap-Og.mk: New file.
2019-06-25 Kwok Cheung Yeung <kcy@codesourcery.com>
Andrew Stubbs <ams@codesourcery.com>
* gthr.m4 (GCC_AC_THREAD_HEADER): Add case for gcn.
2019-05-30 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* ax_count_cpus.m4: New file.
2019-05-02 Richard Biener <rguenther@suse.de>
PR bootstrap/85574
* bootstrap-lto.mk (extra-compare): Set to gcc/lto1$(exeext).
2019-04-16 Martin Liska <mliska@suse.cz>
* bootstrap-lto-lean.mk: Filter out -flto in STAGEtrain_CFLAGS.
2019-04-09 Martin Liska <mliska@suse.cz>
* bootstrap-lto-lean.mk: New file.
2019-03-02 Johannes Pfau <johannespfau@gmail.com>
* mh-mingw: Also set __USE_MINGW_ACCESS flag for C++ code.
2018-10-31 Joseph Myers <joseph@codesourcery.com>
PR bootstrap/82856
* math.m4, tls.m4: Use AC_LANG_SOURCE.
Merge from binutils-gdb:
2018-06-19 Simon Marchi <simon.marchi@ericsson.com>
* override.m4 (_GCC_AUTOCONF_VERSION): Bump from 2.64 to 2.69.
config/ChangeLog:
* ax_count_cpus.m4: New file, backported from GCC.
* bootstrap-Og.mk: New file, backported from GCC.
* bootstrap-lto-lean.mk: New file, backported from GCC.
* bootstrap-lto.mk: Changes backported from GCC.
* futex.m4: Changes backported from GCC.
* gthr.m4: Changes backported from GCC.
* lib-link.m4: Changes backported from GCC.
* mh-mingw: Changes backported from GCC.
* no-executables.m4: Changes backported from GCC.
* tls.m4: Changes backported from GCC.
* toolexeclibdir.m4: New file, backported from GCC.
binutils/ChangeLog:
* configure: Regenerate.
gdb/ChangeLog:
* configure: Regenerate.
gdbserver/ChangeLog:
* configure: Regenerate.
gdbsupport/ChangeLog:
* configure: Regenerate.
intl/ChangeLog:
* configure: Regenerate.
libiberty/ChangeLog:
* configure: Regenerate.
zlib/ChangeLog.bin-gdb:
* configure: Regenerate.
Sergey Belyashov [Wed, 19 Feb 2020 17:46:10 +0000 (17:46 +0000)]
Various fixes for the Z80 support.
PR 25537
ld * emultempl/z80.em: Remove machine compatability checking.
PR 25517
* testsuite/ld-z80/arch_ez80_adl.d: Update command line.
* testsuite/ld-z80/arch_ez80_z80.d: Likewise.
* testsuite/ld-z80/arch_r800.d: Likewise.
* testsuite/ld-z80/arch_z180.d: Likewise.
* testsuite/ld-z80/arch_z80n.d: Likewise.
* testsuite/ld-z80/comb_arch_ez80_z80.d: Likewise.
* testsuite/ld-z80/comb_arch_z180_z80.d: Likewise.
* testsuite/ld-z80/comb_arch_z80_ez80.d: Likewise.
* testsuite/ld-z80/comb_arch_z80_z180.d: Likewise.
* testsuite/ld-z80/comb_arch_z80_z80n.d: Likewise.
* testsuite/ld-z80/relocs_b_ez80.d: Likewise.
* testsuite/ld-z80/relocs_b_z80.d: Likewise.
* testsuite/ld-z80/relocs_f_ez80.d: Likewise.
* testsuite/ld-z80/relocs_f_z80.d: Likewise.
* testsuite/ld-z80/relocs_f_z80n.d: Likewise.
bfd
* cpu-z80.c: Add machine type compatibility checking.
gas
* config/tc-z80.c (md_parse_option): Do not use an underscore
prefix for local labels in SDCC compatability mode.
(z80_start_line_hook): Remove SDCC dollar label support.
* testsuite/gas/z80/sdcc.d: Update expected disassembly.
* testsuite/gas/z80/sdcc.s: Likewise.
* config/tc-z80.c: Add -march option.
* doc/as.texi: Update Z80 documentation.
* doc/c-z80.texi: Likewise.
* testsuite/gas/z80/ez80_adl_all.d: Update command line.
* testsuite/gas/z80/ez80_adl_suf.d: Likewise.
* testsuite/gas/z80/ez80_pref_dis.d: Likewise.
* testsuite/gas/z80/ez80_z80_all.d: Likewise.
* testsuite/gas/z80/ez80_z80_suf.d: Likewise.
* testsuite/gas/z80/gbz80_all.d: Likewise.
* testsuite/gas/z80/r800_extra.d: Likewise.
* testsuite/gas/z80/r800_ii8.d: Likewise.
* testsuite/gas/z80/r800_z80_doc.d: Likewise.
* testsuite/gas/z80/sdcc.d: Likewise.
* testsuite/gas/z80/z180.d: Likewise.
* testsuite/gas/z80/z180_z80_doc.d: Likewise.
* testsuite/gas/z80/z80_doc.d: Likewise.
* testsuite/gas/z80/z80_ii8.d: Likewise.
* testsuite/gas/z80/z80_in_f_c.d: Likewise.
* testsuite/gas/z80/z80_op_ii_ld.d: Likewise.
* testsuite/gas/z80/z80_out_c_0.d: Likewise.
* testsuite/gas/z80/z80_sli.d: Likewise.
* testsuite/gas/z80/z80n_all.d: Likewise.
* testsuite/gas/z80/z80n_reloc.d: Likewise.
Tom Tromey [Wed, 19 Feb 2020 14:50:21 +0000 (07:50 -0700)]
Remove useless NULL check in python.c
I noticed that do_start_initialization, in python.c, checks the result
of xmalloc. However, xmalloc cannot fail, so this check is useless.
This patch also changes the code to use XNEWVEC.
gdb/ChangeLog
2020-02-19 Tom Tromey <tromey@adacore.com>
* python/python.c (do_start_initialization): Use XNEWVEC. Remove
NULL check.
H.J. Lu [Wed, 19 Feb 2020 12:54:45 +0000 (04:54 -0800)]
x86: Mark cvtpi2ps and cvtpi2pd as MMX
* config/tc-i386.c (output_insn): Mark cvtpi2ps and cvtpi2pd
with GNU_PROPERTY_X86_FEATURE_2_MMX.
* testsuite/gas/i386/i386.exp: Run property-3 and
x86-64-property-3.
* testsuite/gas/i386/property-3.d: New file.
* testsuite/gas/i386/property-3.s: Likewise.
* testsuite/gas/i386/x86-64-property-3.d: Likewise.
Tom de Vries [Wed, 19 Feb 2020 12:41:10 +0000 (13:41 +0100)]
[gdb/testsuite] Fix c++/14186 kpass in cpexprs.exp
With gdb.cp/cpexprs.exp, we see:
...
KPASS: gdb.cp/cpexprs.exp: p CV::m(int) const (PRMS c++/14186)
KPASS: gdb.cp/cpexprs.exp: p CV::m(int) volatile (PRMS c++/14186)
KPASS: gdb.cp/cpexprs.exp: p CV::m(int) const volatile (PRMS c++/14186)
...
The tests have been KPASSing since Sept 4 2017, due to commit
3693fdb3c8
'Make "p S::method() const::static_var" work too'.
Fix this by removing the corresponding kfail.
gdb/testsuite/ChangeLog:
2020-02-19 Tom de Vries <tdevries@suse.de>
* gdb.cp/cpexprs.exp: Remove c++/14186 kfail.
H.J. Lu [Wed, 19 Feb 2020 11:29:51 +0000 (03:29 -0800)]
plugin: Call dlclose before return in try_load_plugin
Since plugin can be used only once in try_load_plugin, call dlclose
before return.
PR binutils/25355
* plugin.c (plugin_list_entry): Remove handle.
(try_load_plugin): Call dlclose before return.
Tom de Vries [Wed, 19 Feb 2020 07:24:44 +0000 (08:24 +0100)]
[gdb/testsuite] Be quiet about missing prelink in solib-overlap.exp
When running gdb.base/solib-overlap.exp, I get:
...
Running src/gdb/testsuite/gdb.base/solib-overlap.exp ...
sh: prelink: command not found
=== gdb Summary ===
nr of untested testcases 1
...
The verbose output on stdout/stderr is due to using system to execute
prelink, which also means that the output is not captured in gdb.log and
gdb.sum.
Fix this by using exec instead of system.
Tested on x86_64-linux, with:
- no prelink installed, and
- a fake prelink installed, using "cp /usr/bin/echo ~/bin/prelink".
gdb/testsuite/ChangeLog:
2020-02-19 Tom de Vries <tdevries@suse.de>
* gdb.base/solib-overlap.exp: Use exec instead of system to execute
prelink.
Tom de Vries [Wed, 19 Feb 2020 06:05:13 +0000 (07:05 +0100)]
[gdb/testsuite] Ignore pass in gdb_caching_proc
Before commit
d4295de4f3 "[gdb/testsuite] Handle missing gnatmake in
gnat_runtime_has_debug_info", calling the gdb_caching_proc
gnat_runtime_has_debug_info could generate a pass because of using
gdb_compile_ada.
This has been fixed in that commit by using a factored out variant
gdb_compile_ada_1, which does not call pass.
Additionally, fix cases like this in more generic way: by ignoring pass calls
during execution of a gdb_caching_proc.
Build and reg-tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-02-19 Tom de Vries <tdevries@suse.de>
* lib/cache.exp (ignore_pass, gdb_do_cache_wrap): New proc.
(gdb_do_cache): Use gdb_do_cache_wrap.
* gdb.base/gdb-caching-proc.exp (test_proc): Use gdb_do_cache_wrap.
Alan Modra [Wed, 19 Feb 2020 02:52:39 +0000 (13:22 +1030)]
file size check in _bfd_alloc_and_read
* coffgen.c (_bfd_coff_get_external_symbols): Remove file size check.
* elf.c (bfd_elf_get_str_section): Likewise.
(_bfd_elf_slurp_version_tables): Likewise.
* libbfd-in.h (_bfd_constant_p): Define.
(_bfd_alloc_and_read, _bfd_malloc_and_read): Check read size against
file size before allocating memory.
* libbfd.h: Regenerate.
Alan Modra [Wed, 19 Feb 2020 02:46:01 +0000 (13:16 +1030)]
_bfd_alloc_and_read
This patch provides two new inline functions that are then used in
places that allocate memory, read from file, and then deallocate on a
read failure.
* libbfd-in.h (_bfd_alloc_and_read, _bfd_malloc_and_read): New.
* aoutx.h (aout_get_external_symbols): Replace calls to
bfd_[m]alloc and bfd_bread with call to _bfd_[m]alloc_and_read.
(slurp_reloc_table): Likewise.
* archive.c (do_slurp_bsd_armap): Likewise.
(do_slurp_coff_armap): Likewise.
* archive64.c (_bfd_archive_64_bit_slurp_armap): Likewise.
* coff-rs6000.c (_bfd_xcoff_slurp_armap): Likewise.
* coff64-rs6000.c (xcoff64_slurp_armap): Likewise.
* coffcode.h (coff_set_arch_mach_hook, buy_and_read): Likewise.
* coffgen.c (coff_real_object_p, coff_object_p, build_debug_section),
(_bfd_coff_get_external_symbols): Likewise.
* ecoff.c (ecoff_slurp_symbolic_header),
(_bfd_ecoff_slurp_symbolic_info, ecoff_slurp_reloc_table),
(_bfd_ecoff_slurp_armap, ecoff_link_add_object_symbols, READ),
(ecoff_indirect_link_order): Likewise.
* elf.c (bfd_elf_get_str_section, setup_group, elf_read_notes),
(_bfd_elf_slurp_version_tables): Likewise.
* elf32-m32c.c (m32c_elf_relax_section): Likewise.
* elf32-rl78.c (rl78_elf_relax_section): Likewise.
* elf32-rx.c (elf32_rx_relax_section): Likewise.
* elf64-alpha.c (READ): Likewise.
* elf64-mips.c (mips_elf64_slurp_one_reloc_table): Likewise.
* elf64-sparc.c (elf64_sparc_slurp_one_reloc_table): Likewise.
* elfcode.h (elf_slurp_symbol_table),
(elf_slurp_reloc_table_from_section): Likewise.
* elflink.c (elf_link_add_object_symbols),
(elf_link_check_versioned_symbol): Likewise.
* elfxx-mips.c (READ): Likewise.
* i386lynx.c (slurp_reloc_table): Likewise.
* lynx-core.c (lynx_core_file_p): Likewise.
* mach-o.c (bfd_mach_o_canonicalize_relocs),
(bfd_mach_o_read_symtab_strtab, bfd_mach_o_alloc_and_read),
(bfd_mach_o_read_prebound_dylib, bfd_mach_o_read_dyld_content
* pdp11.c (aout_get_external_symbols, slurp_reloc_table
* pef.c (bfd_pef_print_loader_section, bfd_pef_scan_start_address),
(bfd_pef_parse_symbols): Likewise.
* peicode.h (pe_ILF_object_p, pe_bfd_object_p
* som.c (setup_sections, som_slurp_string_table),
(som_slurp_reloc_table, som_bfd_count_ar_symbols),
(som_bfd_fill_in_ar_symbols): Likewise.
* vms-alpha.c (module_find_nearest_line, evax_bfd_print_dst),
(evax_bfd_print_image): Likewise.
* vms-lib.c (_bfd_vms_lib_archive_p): Likewise.
* wasm-module.c (wasm_scan): Likewise.
* xcofflink.c (xcoff_link_add_symbols): Likewise.
* xsym.c (bfd_sym_read_name_table),
(bfd_sym_print_type_information_table_entry): Likewise.
* libbfd.h: Regenerate.
Alan Modra [Wed, 19 Feb 2020 02:45:20 +0000 (13:15 +1030)]
Miscellaneous memory alloc related fixes
Some minor tidies. Allocating memory for internal relocs and symbols
after reading external relocs is slightly better with fuzzed files.
You can at least do something about silly sizes that way.
* aoutx.h (slurp_reloc_table): Allocate reloc_cache after
reading external relocs.
* ecoff.c (ecoff_slurp_reloc_table): Likewise.
* archive.c (_bfd_write_archive_contents): Don't twiddle bfd_error
after bfd_bread.
* archive64.c (_bfd_archive_64_bit_slurp_armap): Remove unnecessary
bfd_release.
* elf32-m32c.c (m32c_offset_for_reloc): Make shndx_buf a bfd_byte*.
(m32c_elf_relax_section): Likewise.
* elf32-rl78.c (rl78_offset_for_reloc): Likewise.
(rl78_elf_relax_section): Likewise.
* elf32-rx.c (rx_offset_for_reloc): Likewise.
(elf32_rx_relax_section): Likewise.
* mach-o.c (bfd_mach_o_alloc_and_read): Move earlier with better
parameter types and use..
(bfd_mach_o_read_dylinker, bfd_mach_o_read_dylib),
(bfd_mach_o_read_fvmlib, bfd_mach_o_read_str): ..in these functions.
* peicode.h (pe_bfd_object_p): Don't zero the part of opthdr
being read from file, just the extra.
* som.c (som_slurp_symbol_table): Allocate internal symbol buffer
after reading external syms. Free on failure.
Alan Modra [Wed, 19 Feb 2020 02:45:06 +0000 (13:15 +1030)]
_bfd_mul_overflow
This patch removes the bfd_alloc2 series of memory allocation functions,
replacing them with __builtin_mul_overflow followed by bfd_alloc. Why
do that? Well, a followup patch will implement _bfd_alloc_and_read
and I don't want to implement alloc2 variants as well.
* coffcode.h (buy_and_read, coff_slurp_line_table),
(coff_slurp_symbol_table, coff_slurp_reloc_table): Replace
bfd_[z][m]alloc2 calls with _bfd_mul_overflow followed by the
corresponding bfd_alloc call. Adjust variables to suit.
* coffgen.c (_bfd_coff_get_external_symbols): Likewise.
* ecoff.c (_bfd_ecoff_slurp_symbolic_info),
(_bfd_ecoff_slurp_symbol_table, READ): Likewise.
* elf.c (bfd_elf_get_elf_syms, setup_group, bfd_section_from_shdr),
(swap_out_syms, _bfd_elf_slurp_version_tables): Likewise.
* elf32-m32c.c (m32c_elf_relax_section): Likewise.
* elf32-rl78.c (rl78_elf_relax_section): Likewise.
* elf32-rx.c (elf32_rx_relax_section): Likewise.
* elf64-alpha.c (READ): Likewise.
* elfcode.h (elf_object_p, elf_write_relocs, elf_write_shdrs_and_ehdr),
(elf_slurp_symbol_table, elf_slurp_reloc_table),
(bfd_from_remote_memory): Likewise.
* elfcore.h (core_find_build_id): Likewise.
* elfxx-mips.c (READ): Likewise.
* mach-o.c (bfd_mach_o_mangle_sections),
(bfd_mach_o_read_symtab_symbols, bfd_mach_o_read_thread),
(bfd_mach_o_read_dysymtab, bfd_mach_o_flatten_sections),
(bfd_mach_o_scan, bfd_mach_o_fat_archive_p): Likewise.
* som.c (setup_sections, som_prep_for_fixups)
(som_build_and_write_symbol_table, som_slurp_symbol_table),
(som_slurp_reloc_table, som_bfd_count_ar_symbols),
(som_bfd_fill_in_ar_symbols, som_slurp_armap),
(som_bfd_ar_write_symbol_stuff): Likewise.
* vms-alpha.c (vector_grow1): Likewise.
* vms-lib.c (vms_add_index): Likewise.
* wasm-module.c (wasm_scan_name_function_section): Likewise.
* libbfd.c (bfd_malloc2, bfd_realloc2, bfd_zmalloc2): Delete.
* opncls.c (bfd_alloc2, bfd_zalloc2): Delete.
* libbfd-in.h (bfd_malloc2, bfd_realloc2, bfd_zmalloc2),
(bfd_alloc2, bfd_zalloc2): Delete.
(_bfd_mul_overflow): Define.
* libbfd.h: Regenerate.
Alan Modra [Wed, 19 Feb 2020 02:44:45 +0000 (13:14 +1030)]
alloc2 used unnecessarily
The bfd_alloc2 series of functions were invented to handle cases where
nmemb * size can overflow. This patch changes some places where the
calculation can't overflow.
* elf.c (bfd_section_from_shdr): Use bfd_zalloc rather than
bfd_zalloc2.
(assign_section_numbers): Likewise.
(elf_map_symbols): Likewise, and bfd_alloc rather than bfd_alloc2.
(_bfd_elf_map_sections_to_segments): Use bfd_malloc rather than
bfd_malloc2, size_t amt, and unsigned tls_count.
(rewrite_elf_program_header): Use bfd_malloc and size_t amt.
* elflink.c (elf_create_symbuf): Use bfd_malloc.
(elf_output_implib): Use bfd_alloc.
Alan Modra [Wed, 19 Feb 2020 02:44:28 +0000 (13:14 +1030)]
bfd_get_size cache
We have calls to bfd_get_size when swapping in ELF section headers.
Since object files can have a large number of sections, it's worth
caching the file size rather than making lots of stat system calls.
* bfd.c (struct bfd): Move format and direction to other
bitfields. Add "size".
* bfdio.c (bfd_get_size): Cache size when not writing file.
* opncls.c (bfd_get_debug_link_info_1): Allow for bfd_get_size
returning zero, ie. unknown.
(bfd_get_alt_debug_link_info): Likewise.
* bfd-in2.h: Regenerate.
Alan Modra [Wed, 19 Feb 2020 02:44:05 +0000 (13:14 +1030)]
bfd_get_file_size calls
bfd_get_file_size can return 0, meaning the file size is unknown.
* coffgen.c (_bfd_coff_get_external_symbols): Don't call
bfd_get_file_size twice.
(_bfd_coff_read_string_table): Allow for bfd_get_file_size
zero, ie. unknown, return.
* elf-attrs.c (_bfd_elf_parse_attributes): Likewise.
* elfcode.h (elf_swap_shdr_in): Likewise.
(elf_object_p): Don't call bfd_get_file_size twice and correct
file size check.
Alan Modra [Wed, 19 Feb 2020 02:42:52 +0000 (13:12 +1030)]
Check return status of memory alloc functions
This fixes a number of places that call a memory allocation function
without checking for a NULL return before using.
* mach-o.c (bfd_mach_o_flatten_sections): Return a bfd_boolean,
FALSE if memory alloc fails. Adjust calls.
* som.c (som_prep_for_fixups): Likewise.
* vms-alpha.c (alpha_vms_add_fixup_lp, alpha_vms_add_fixup_ca),
(alpha_vms_add_fixup_qr, alpha_vms_add_fixup_lr),
(alpha_vms_add_lw_reloc, alpha_vms_add_qw_reloc): Likewise.
* som.c (som_build_and_write_symbol_table): Return via error_return
on seek failure.
* vms-alpha.c (VEC_APPEND): Adjust for vector_grow1 changes.
(VEC_APPEND_EL): Delete.
(vector_grow1): Return pointer to element. Catch overflow.
Return NULL on memory allocation failure.
(alpha_vms_add_fixup_lp): Replace VEC_APPEND_EL with VEC_APPEND.
(alpha_vms_add_fixup_ca): Likewise.
(alpha_vms_link_add_object_symbols): Check VEC_APPEND result
before using.
* elf.c (bfd_section_from_shdr): Check bfd_zalloc2 result.
Alan Modra [Wed, 19 Feb 2020 02:42:00 +0000 (13:12 +1030)]
bfd_size_type to size_t
bfd_size_type was invented a long time ago in the K&R days. Many
places in binutils ought to be using size_t instead (and there are
lots of places that use long or unsigned long that really ought to use
size_t too). Note that you can't change everything over to size_t: A
32-bit host needs a larger type than size_t to support reading and
processing of 64-bit ELF object files. This patch just tidies some
of the more obvious uses of bfd_size_type that could be size_t. There
no doubt are more lurking in the source. Incidentally, practically
all functions used for output of object files can use size_t and don't
need to worry about overflow of size expressions. If you have
something like
symcount * sizeof (void *)
when symcount is counting symbols already in memory then you know that
this expression can't overflow since the size of a symbol in memory is
larger by far than that of a pointer.
* aix386-core.c (aix386_core_file_p): Use size_t for "amt".
* aout-target.h (object_p): Likewise.
* aout-tic30.c (tic30_aout_object_p): Likewise.
* aoutx.h (some_aout_object_p, mkobject, make_empty_symbol),
(emit_stringtab, write_syms, link_hash_table_create),
(aout_link_write_other_symbol): Likewise.
* archive.c (_bfd_generic_mkarchive, bfd_generic_archive_p),
(bfd_ar_hdr_from_filesystem, _bfd_write_archive_contents),
(_bfd_compute_and_write_armap): Likewise.
* archures.c (bfd_arch_list): Likewise.
* bfd.c (bfd_record_phdr): Likewise.
* binary.c (binary_canonicalize_symtab): Likewise.
* cisco-core.c (cisco_core_file_validate): Likewise.
* coff-arm.c (coff_arm_link_hash_table_create, find_thumb_glue),
(find_arm_glue, record_arm_to_thumb_glue),
(record_thumb_to_arm_glue): Likewise.
* coff-ppc.c (ppc_coff_link_hash_table_create, record_toc),
(ppc_allocate_toc_section): Likewise.
* coff-rs6000.c (_bfd_xcoff_mkobject, _bfd_xcoff_archive_p): Likewise.
* coff-sh.c (sh_relax_section): Likewise.
* coff64-rs6000.c (xcoff64_archive_p): Likewise.
* coffcode.h (handle_COMDAT, coff_new_section_hook),
(coff_set_alignment_hook, coff_mkobject),
(coff_compute_section_file_positions): Likewise.
* coffgen.c (coff_make_empty_symbol, coff_bfd_make_debug_symbol),
(coff_find_nearest_line_with_names),
( bfd_coff_set_symbol_class): Likewise.
* cofflink.c (_bfd_coff_link_hash_table_create),
(_bfd_coff_link_input_bfd): Likewise.
* dwarf1.c (alloc_dwarf1_unit, alloc_dwarf1_func): Likewise.
* dwarf2.c (read_abbrevs, read_attribute_value, add_line_info),
(build_line_info_table, sort_line_sequences),
(line_info_add_include_dir, line_info_add_file_name),
(decode_line_info, scan_unit_for_symbols, parse_comp_unit),
(place_sections, _bfd_dwarf2_slurp_debug_info): Likewise.
* ecoff.c (_bfd_ecoff_mkobject, _bfd_ecoff_make_empty_symbol),
(_bfd_ecoff_find_nearest_line),
(_bfd_ecoff_bfd_link_hash_table_create): Likewise.
* ecofflink.c (bfd_ecoff_debug_init): Likewise.
* elf-hppa.h (_bfd_elf_hppa_gen_reloc_type): Likewise.
* elf-m10300.c (mn10300_elf_relax_section),
(elf32_mn10300_link_hash_table_create): Likewise.
* elf-strtab.c (_bfd_elf_strtab_init): Likewise.
* elf.c (make_mapping, copy_elf_program_header): Likewise.
* elf32-arm.c (elf32_arm_link_hash_table_create),
(elf32_arm_setup_section_lists, elf32_arm_check_relocs),
(elf32_arm_new_section_hook): Likewise.
* elf32-avr.c (elf_avr_new_section_hook),
(elf32_avr_link_hash_table_create, get_local_syms),
(elf32_avr_setup_section_lists): Likewise.
* elf32-bfin.c (bfinfdpic_elf_link_hash_table_create),
(bfin_link_hash_table_create): Likewise.
* elf32-cr16.c (elf32_cr16_link_hash_table_create): Likewise.
* elf32-cris.c (elf_cris_link_hash_table_create): Likewise.
* elf32-csky.c (csky_elf_link_hash_table_create),
(csky_elf_check_relocs, elf32_csky_setup_section_lists): Likewise.
* elf32-frv.c (frvfdpic_elf_link_hash_table_create): Likewise.
* elf32-hppa.c (elf32_hppa_link_hash_table_create),
(elf32_hppa_setup_section_lists, get_local_syms): Likewise.
* elf32-i386.c (elf_i386_check_relocs): Likewise.
* elf32-lm32.c (lm32_elf_link_hash_table_create): Likewise.
* elf32-m32r.c (m32r_elf_link_hash_table_create),
(m32r_elf_check_relocs): Likewise.
* elf32-m68hc1x.c (m68hc11_elf_hash_table_create),
(elf32_m68hc11_setup_section_lists),
(elf32_m68hc11_size_stubs): Likewise.
* elf32-m68k.c (elf_m68k_link_hash_table_create): Likewise.
* elf32-metag.c (elf_metag_link_hash_table_create),
(elf_metag_setup_section_lists): Likewise.
* elf32-microblaze.c (microblaze_elf_link_hash_table_create),
(microblaze_elf_check_relocs): Likewise.
* elf32-nds32.c (nds32_elf_link_hash_table_create),
(nds32_elf_check_relocs): Likewise.
* elf32-nios2.c (nios2_elf32_setup_section_lists),
(get_local_syms, nios2_elf32_check_relocs),
(nios2_elf32_link_hash_table_create): Likewise.
* elf32-or1k.c (or1k_elf_link_hash_table_create),
(or1k_elf_check_relocs): Likewise.
* elf32-ppc.c (ppc_elf_modify_segment_map, update_plt_info): Likewise.
* elf32-pru.c (pru_elf32_link_hash_table_create): Likewise.
* elf32-s390.c (elf_s390_link_hash_table_create),
(elf_s390_check_relocs): Likewise.
* elf32-score.c (score_elf_create_got_section),
(s3_elf32_score_new_section_hook),
(elf32_score_link_hash_table_create): Likewise.
* elf32-score7.c (score_elf_create_got_section),
(s7_elf32_score_new_section_hook): Likewise.
* elf32-sh.c (sh_elf_link_hash_table_create),
(sh_elf_check_relocs): Likewise.
* elf32-tic6x.c (elf32_tic6x_link_hash_table_create),
(elf32_tic6x_new_section_hook, elf32_tic6x_check_relocs): Likewise.
* elf32-tilepro.c (tilepro_elf_link_hash_table_create),
(tilepro_elf_check_relocs): Likewise.
* elf32-v850.c (remember_hi16s_reloc): Likewise.
* elf32-vax.c (elf_vax_link_hash_table_create): Likewise.
* elf32-xtensa.c (elf_xtensa_link_hash_table_create),
(elf_xtensa_new_section_hook): Likewise.
* elf64-alpha.c (elf64_alpha_bfd_link_hash_table_create),
(get_got_entry, elf64_alpha_check_relocs): Likewise.
* elf64-hppa.c (elf64_hppa_hash_table_create): Likewise.
* elf64-ia64-vms.c (elf64_ia64_object_p): Likewise.
* elf64-mmix.c (mmix_elf_new_section_hook): Likewise.
* elf64-ppc.c (ppc64_elf_new_section_hook),
(ppc64_elf_link_hash_table_create, update_local_sym_info),
(update_plt_info, ppc64_elf_check_relocs): Likewise.
* elf64-s390.c (elf_s390_link_hash_table_create),
(elf_s390_check_relocs): Likewise.
* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
* elflink.c (bfd_elf_link_record_local_dynamic_symbol),
(_bfd_elf_link_find_version_dependencies, elf_link_add_object_symbols),
(elf_link_add_archive_symbols, compute_bucket_count),
(bfd_elf_size_dynsym_hash_dynstr, _bfd_elf_link_hash_table_create),
(bfd_elf_get_bfd_needed_list, elf_link_swap_symbols_out),
(bfd_elf_final_link): Likewise.
* elfnn-aarch64.c (elfNN_aarch64_link_hash_table_create),
(elfNN_aarch64_setup_section_lists, elfNN_aarch64_check_relocs),
(elfNN_aarch64_new_section_hook): Likewise.
* elfnn-ia64.c (elfNN_ia64_object_p): Likewise.
* elfnn-riscv.c (riscv_elf_link_hash_table_create),
(riscv_elf_check_relocs): Likewise.
* elfxx-mips.c (_bfd_mips_elf_new_section_hook),
(_bfd_mips_elf_add_symbol_hook, _bfd_mips_elf_check_relocs),
(_bfd_mips_elf_modify_segment_map, _bfd_mips_elf_set_section_contents),
(_bfd_mips_elf_link_hash_table_create): Likewise.
* elfxx-sparc.c (_bfd_sparc_elf_link_hash_table_create),
(_bfd_sparc_elf_check_relocs),
(_bfd_sparc_elf_new_section_hook): Likewise.
* elfxx-tilegx.c (tilegx_elf_link_hash_table_create),
(tilegx_elf_check_relocs): Likewise.
* elfxx-x86.c (_bfd_x86_elf_link_hash_table_create): Likewise.
* format.c (bfd_check_format_matches): Likewise.
* hash.c (_bfd_stringtab_init): Likewise.
* ihex.c (ihex_scan): Likewise.
* irix-core.c (irix_core_core_file_p): Likewise.
* linker.c (bfd_wrapped_link_hash_lookup),
(_bfd_generic_link_hash_table_create),
(_bfd_generic_reloc_link_order): Likewise.
* lynx-core.c (lynx_core_file_p): Likewise.
* netbsd-core.c (netbsd_core_file_p): Likewise.
* osf-core.c (osf_core_core_file_p): Likewise.
* pdp11.c (some_aout_object_p, mkobject, make_empty_symbol),
(link_hash_table_create, aout_link_write_other_symbol): Likewise.
* peXXigen.c (_bfd_XX_bfd_copy_private_section_data): Likewise.
* peicode.h (pe_mkobject): Likewise.
* ppcboot.c (ppcboot_mkobject, ppcboot_canonicalize_symtab): Likewise.
* ptrace-core.c (ptrace_unix_core_file_p): Likewise.
* sco5-core.c (read_uarea): Likewise.
* som.c (hppa_som_gen_reloc_type, som_object_p, som_prep_headers),
(som_write_fixups, som_write_space_strings, som_write_symbol_strings),
(som_finish_writing, som_canonicalize_symtab, som_new_section_hook),
(som_bfd_copy_private_section_data, bfd_som_set_section_attributes),
(bfd_som_attach_aux_hdr, som_write_armap): Likewise.
* srec.c (srec_scan): Likewise.
* syms.c (_bfd_generic_make_empty_symbol): Likewise.
* targets.c (bfd_target_list): Likewise.
* tekhex.c (first_phase, tekhex_sizeof_headers): Likewise.
* trad-core.c (trad_unix_core_file_p): Likewise.
* vms-alpha.c (vms_initialize, alpha_vms_bfd_link_hash_table_create),
(vms_new_section_hook): Likewise.
* wasm-module.c (wasm_make_empty_symbol): Likewise.
* xcofflink.c (xcoff_get_section_contents),
(_bfd_xcoff_bfd_link_hash_table_create, xcoff_set_import_path),
(xcoff_find_function, bfd_xcoff_link_record_set, xcoff_build_ldsym),
(bfd_xcoff_size_dynamic_sections, xcoff_link_input_bfd): Likewise.
Alan Modra [Wed, 19 Feb 2020 02:41:17 +0000 (13:11 +1030)]
c99 elfxx-riscv.c fix
We can't use c99 without enabling c99 support for older compilers
that don't enable c99 by default. So if you want to use c99 contructs
in binutils you'll need to first arrange for -std=c99 to be passed to
older compilers.
* elfxx-riscv.c (riscv_multi_letter_ext_valid_p): Don't use C99.
Alan Modra [Wed, 19 Feb 2020 02:40:47 +0000 (13:10 +1030)]
Adjust PR25355 testcase
* testsuite/ld-plugin/pr25355.d: Allow alpha-linux nm result.
Maciej W. Rozycki [Wed, 19 Feb 2020 01:24:37 +0000 (01:24 +0000)]
gdbserver: Add RISC-V/Linux support
Implement RISC-V/Linux support for both RV64 and RV32 systems, including
XML target description handling based on features determined, GPR and
FPR regset support including dynamic sizing of the latter, and software
breakpoint handling. Define two NT_FPREGSET regsets of a different size
matching the FPR sizes supported for generic `gdbserver' code to pick
from according to what the OS supplies.
Also handle a glibc bug where ELF_NFPREG is defined in terms of NFPREG,
however NFPREG is nowhere defined.
2020-02-19 Maciej W. Rozycki <macro@wdc.com>
Andrew Burgess <andrew.burgess@embecosm.com>
gdb/
* NEWS: Mention RISC-V GNU/Linux GDBserver support.
gdbserver/
* linux-riscv-low.cc: New file.
* Makefile.in (SFILES): Add linux-riscv-low.cc, arch/riscv.c,
and nat/riscv-linux-tdesc.c.
* configure.srv <riscv*-*-linux*> (srv_tgtobj)
(srv_linux_regsets, srv_linux_usrregs, srv_linux_thread_db):
Define.
Andrew Burgess [Wed, 19 Feb 2020 01:24:37 +0000 (01:24 +0000)]
gdb/riscv: Update API for looking up target descriptions
In preparation for adding the RISC-V gdbserver, this commit
restructures the API for looking up target descriptions.
The current API is riscv_create_target_description, which creates a
target description from a riscv_gdbarch_features, but also caches the
created target descriptions so that for a given features object we
always get back the same target description object. This is important
for GDB due to the way gdbarch objects are reused.
As the same target description is always returned to GDB, and can be
returned multiple times, it is returned as a const, however, the
current cache actually stores a non-const target description. This is
improved in this patch so that the cache holds a const target
description.
For gdbsever, this caching of the target descriptions is not needed,
the gdbserver looks up one target description to describe the target
it is actually running on and that is it. Further the gdbserver
actually needs to modify the target description that is looked up, so
for the gdbsever, returning a const target description is not
acceptable.
This commit aims to address this by creating two parallel target
description APIs, on is the old riscv_create_target_description,
however, this no longer performs any caching, and just creates a new
target description, and returns it as non-const.
The second API is riscv_lookup_target_description, this one performs
the caching, and calls riscv_create_target_description to create a
target description when needed.
In order to make sure the correct API is used in the correct place I
have guarded the code using the GDBSERVER define. For GDB the
riscv_create_target_description is static, and not generally usable
throughout GDB, only the lookup API is global. In gdbserver, the
lookup functions, and the cache are not defined or created at all,
only the riscv_create_target_description API is available.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* arch/riscv.c (struct riscv_gdbarch_features_hasher): Only define
if GDBSERVER is not defined.
(riscv_tdesc_cache): Likewise, also store const target_desc.
(STATIC_IN_GDB): Define.
(riscv_create_target_description): Update declaration with
STATIC_IN_GDB.
(riscv_lookup_target_description): New function, only define if
GDBSERVER is not defined.
* arch/riscv.h (riscv_create_target_description): Declare only
when GDBSERVER is defined.
(riscv_lookup_target_description): New declaration when GDBSERVER
is not defined.
* nat/riscv-linux-tdesc.c (riscv_linux_read_description): Rename to...
(riscv_linux_read_features): ...this, and return
riscv_gdbarch_features instead of target_desc.
* nat/riscv-linux-tdesc.h: Include 'arch/riscv.h'.
(riscv_linux_read_description): Rename to...
(riscv_linux_read_features): ...this.
* riscv-linux-nat.c (riscv_linux_nat_target::read_description):
Update to use riscv_gdbarch_features and
riscv_lookup_target_description.
* riscv-tdep.c (riscv_find_default_target_description): Use
riscv_lookup_target_description instead of
riscv_create_target_description.
GDB Administrator [Wed, 19 Feb 2020 00:00:39 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom de Vries [Tue, 18 Feb 2020 23:05:40 +0000 (00:05 +0100)]
[gdb/testsuite] Be quiet about untested dtrace-prob.exp
When running gdb.base/dtrace-probe.exp, I get this on stdout/stderr:
...
Running src/gdb/testsuite/gdb.base/dtrace-probe.exp ...
gdb compile failed, ld: error in \
build/gdb/testsuite/outputs/gdb.base/dtrace-probe/dtrace-probe.o\
(.eh_frame); no .eh_frame_hdr table will be created
ld: crt1.o: in function `_start':
start.S:110: undefined reference to `main'
ld: build/gdb/testsuite/outputs/gdb.base/dtrace-probe/dtrace-probe-p.o:\
(.SUNW_dof+0x88): undefined reference to `main'
ld: build/gdb/testsuite/outputs/gdb.base/dtrace-probe/dtrace-probe-p.o:\
(.SUNW_dof+0xb8): undefined reference to `main'
collect2: error: ld returned 1 exit status
=== gdb Summary ===
nr of untested testcases 1
...
There is no reason to be this verbose about the failure to compile.
Fix this by using quiet as additional option to gdb_compile in
dtrace_build_usdt_test_program. Note that the error message still occurs in
gdb.log.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-02-19 Tom de Vries <tdevries@suse.de>
* lib/dtrace.exp (dtrace_build_usdt_test_program): Use quiet as
gdb_compile option.
Simon Marchi [Tue, 18 Feb 2020 22:30:51 +0000 (17:30 -0500)]
gdb: change print format of flag enums with value 0
If a flag enum has value 0 and the enumeration type does not have an
enumerator with value 0, we currently print:
$1 = (unknown: 0x0)
I don't like the display of "unknown" here, since for flags, 0 is a
an expected value. It just means that no flags are set. This patch
makes it so that we print it as a simple 0 in this situation:
$1 = 0
If there is an enumerator with value 0, it is still printed using that
enumerator, for example (from the test):
$1 = FE_NONE
gdb/ChangeLog:
* valprint.c (generic_val_print_enum_1): When printing a flag
enum with value 0 and there is no enumerator with value 0, print
just "0" instead of "(unknown: 0x0)".
gdb/testsuite/ChangeLog:
* gdb.base/printcmds.exp (test_print_enums): Update expected
output.
Simon Marchi [Tue, 18 Feb 2020 22:30:21 +0000 (17:30 -0500)]
gdb: print unknown part of flag enum in hex
When we print the "unknown" part of a flag enum, it is printed in
decimal. I think it would be more useful if it was printed in hex, as
it helps to determine which bits are set more than a decimal value.
gdb/ChangeLog:
* valprint.c (generic_val_print_enum_1): Print unknown part of
flag enum in hex.
gdb/testsuite/ChangeLog:
* gdb.base/printcmds.exp (test_print_enums): Expect hex values
for "unknown".
Simon Marchi [Tue, 18 Feb 2020 22:29:23 +0000 (17:29 -0500)]
gdb: allow duplicate enumerators in flag enums
I have come across some uses cases where it would be desirable to treat
an enum that has duplicate values as a "flag enum". For example, this
one here [1]:
enum membarrier_cmd {
MEMBARRIER_CMD_QUERY = 0,
MEMBARRIER_CMD_GLOBAL = (1 << 0),
MEMBARRIER_CMD_GLOBAL_EXPEDITED = (1 << 1),
MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED = (1 << 2),
MEMBARRIER_CMD_PRIVATE_EXPEDITED = (1 << 3),
MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED = (1 << 4),
MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE = (1 << 5),
MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE = (1 << 6),
/* Alias for header backward compatibility. */
MEMBARRIER_CMD_SHARED = MEMBARRIER_CMD_GLOBAL,
};
The last enumerator is kept for backwards compatibility. Without this
patch, this enumeration wouldn't be considered a flag enum, because two
enumerators collide. With this patch, it would be considered a flag
enum, and the value 3 would be printed as:
MEMBARRIER_CMD_GLOBAL | MEMBARRIER_CMD_GLOBAL_EXPEDITED
Although if people prefer, we could display both MEMBARRIER_CMD_GLOBAL
and MEMBARRIER_CMD_SHARED in the result. It wouldn't be wrong, and
could perhaps be useful in case a bit may have multiple meanings
(depending on some other bit value).
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/membarrier.h?id=
0bf999f9c5e74c7ecf9dafb527146601e5c848b9#n125
gdb/ChangeLog:
* dwarf2/read.c (update_enumeration_type_from_children): Allow
flag enums to contain duplicate enumerators.
* valprint.c (generic_val_print_enum_1): Update comment.
gdb/testsuite/ChangeLog:
* gdb.base/printcmds.c (enum flag_enum): Add FE_TWO_LEGACY
enumerator.
Simon Marchi [Tue, 18 Feb 2020 22:28:23 +0000 (17:28 -0500)]
gdb: fix printing of flag enums with multi-bit enumerators
GDB has this feature where if an enum looks like it is meant to
represent binary flags, it will present the values of that type as a
bitwise OR of the flags that are set in the value.
The original motivation for this patch is to fix this behavior:
enum hello { AAA = 0x1, BBB = 0xf0 };
(gdb) p (enum hello) 0x11
$1 = (AAA | BBB)
This is wrong because the bits set in BBB (0xf0) are not all set in the
value 0x11, but GDB presents it as if they all were.
I think that enumerations with enumerators that have more than one bit
set should simply not qualify as "flag enum", as far as this
heuristic is concerned. I'm not sure what it means to have flags of
more than one bit. So this is what this patch implements.
I have added an assert in generic_val_print_enum_1 to make sure the flag
enum types respect that, in case they are used by other debug info
readers, in the future.
I've enhanced the gdb.base/printcmds.exp test to cover this case. I've
also added tests for printing flag enums with value 0, both when the
enumeration has and doesn't have an enumerator for value 0.
gdb/ChangeLog:
* dwarf2/read.c: Include "count-one-bits.h".
(update_enumeration_type_from_children): If an enumerator has
multiple bits set, don't treat the enumeration as a "flag enum".
* valprint.c (generic_val_print_enum_1): Assert that enumerators
of flag enums have 0 or 1 bit set.
gdb/testsuite/ChangeLog:
* gdb.base/printcmds.c (enum flag_enum): Prefix enumerators with
FE_, add FE_NONE.
(three): Update.
(enum flag_enum_without_zero): New enum.
(flag_enum_without_zero): New variable.
(enum not_flag_enum): New enum.
(three_not_flag): New variable.
* gdb.base/printcmds.exp (test_artificial_arrays): Update.
(test_print_enums): Add more tests for printing flag enums.
Bernd Edlinger [Sun, 16 Feb 2020 20:43:33 +0000 (21:43 +0100)]
Fix build with gcc-4.8.x
Use an explicit conversion from unique_ptr<T> to
displaced_step_closure_up to avoid a compiler bug
with gcc-4.8.4:
../../binutils-gdb/gdb/amd64-tdep.c:1514:10: error: cannot bind
'std::unique_ptr<amd64_displaced_step_closure>' lvalue to
'std::unique_ptr<amd64_displaced_step_closure>&&'
gdb:
2020-02-18 Bernd Edlinger <bernd.edlinger@hotmail.de>
* aarch64-tdep.c (aarch64_displaced_step_copy_insn): Use an explicit
conversion.
* amd64-tdep.c (amd64_displaced_step_copy_insn): Likewise.
* arm-linux-tdep.c (arm_linux_displaced_step_copy_insn): Likewise.
* i386-tdep.c (i386_displaced_step_copy_insn): Likewise.
* rs6000-tdep.c (ppc_displaced_step_copy_insn): Likewise.
* s390-tdep.c (s390_displaced_step_copy_insn): Likewise.
Simon Marchi [Tue, 18 Feb 2020 19:37:18 +0000 (14:37 -0500)]
gdb: update email address for Palmer Dabbelt
gdb/ChangeLog:
* MAINTAINERS: Change palmer@sifive.com to palmer@dabbelt.com.
Tom de Vries [Tue, 18 Feb 2020 09:18:36 +0000 (10:18 +0100)]
[gdb/testsuite] Handle missing gnatmake in gnat_runtime_has_debug_info
After de-installing gnatmake, I get on stdout/stderr:
...
Running src/gdb/testsuite/gdb.base/gdb-caching-proc.exp ...
FAIL: gdb-caching-proc.exp: failed to compile gnat-debug-info test binary
...
FAIL: gdb-caching-proc.exp: failed to compile gnat-debug-info test binary
...
In gdb.sum, we see these FAILs (each paired with an UNSUPPORTED as well)
followed by:
...
PASS: gdb-caching-proc.exp: gnat_runtime_has_debug_info consistency
...
Likewise, after re-installing gnatmake, I get a PASS for each of the
UNSUPPORTEDs, and the FAILs disappear.
The FAIL comes from gnat_runtime_has_debug_info, the PASS/UNSUPPORTED comes
from gdb_compile_ada.
Fix this by removing the corresponding fail call in
gnat_runtime_has_debug_info, as well as using a new variant gdb_compile_ada_1
that doesn't call pass/unsupported.
Tested on x86_64-linux, with gnatmake installed and de-installed.
gdb/testsuite/ChangeLog:
2020-02-18 Tom de Vries <tdevries@suse.de>
* lib/ada.exp (gdb_compile_ada_1): Factor out of ...
(gdb_compile_ada): ... here.
(gnat_runtime_has_debug_info): Remove fail call for gdb_compile_ada
failure. Use gdb_compile_ada_1 instead of gdb_compile_ada.
GDB Administrator [Tue, 18 Feb 2020 00:00:30 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Mon, 17 Feb 2020 17:00:26 +0000 (10:00 -0700)]
Fix gdbserver-without-gdb build
An earlier patch changed gdbserver to use the already-built top-level
gnulib and gdbsupport. However, if one did a build that did not
include gdb, then gdbserver would fail to build.
The problem is that configure.ac only adds gnulib and gdbsupport to
the build when gdb is being built. This patch fixes the problem by
arranging for this to happen when gdbserver is built.
ChangeLog
2020-02-17 Tom Tromey <tom@tromey.com>
* configure: Rebuild.
* configure.ac (configdirs): Add gnulib and gdbsupport when building
gdbserver.
H.J. Lu [Mon, 17 Feb 2020 15:12:10 +0000 (07:12 -0800)]
x86: Remove CpuABM and add CpuPOPCNT
AMD ABM has 2 instructions: popcnt and lzcnt. ABM CPUID feature bit has
been reused for lzcnt and a POPCNT CPUID feature bit is added for popcnt
which used to be the part of SSE4.2. This patch removes CpuABM and adds
CpuPOPCNT. It changes ABM to enable both lzcnt and popcnt, changes SSE4.2
to also enable popcnt.
gas/
* config/tc-i386.c (cpu_arch): Add .popcnt.
* doc/c-i386.texi: Remove abm and .abm. Add popcnt and .popcnt.
Add a tab before @samp{.sse4a}.
opcodes/
* i386-gen.c (cpu_flag_init): Replace CpuABM with
CpuLZCNT|CpuPOPCNT. Add CpuPOPCNT to CPU_SSE4_2_FLAGS. Add
CPU_POPCNT_FLAGS.
(cpu_flags): Remove CpuABM. Add CpuPOPCNT.
* i386-opc.h (CpuABM): Removed.
(CpuPOPCNT): New.
(i386_cpu_flags): Remove cpuabm. Add cpupopcnt.
* i386-opc.tbl: Replace CpuABM|CpuSSE4_2 with CpuPOPCNT on
popcnt. Remove CpuABM from lzcnt.
* i386-init.h: Regenerated.
* i386-tbl.h: Likewise.
Jan Beulich [Mon, 17 Feb 2020 07:59:52 +0000 (08:59 +0100)]
x86: fold certain VCVT{,U}SI2S{S,D} templates
There don't really need to be separate Cpu64 and CpuNo64 templates for
these. One small issue with this is that slightly strange code
.intel_syntax noprefix
.code16
.arch i286
.arch .avx
vcvtsi2sd xmm0, xmm0, dword ptr [bx]
vcvtsi2sd xmm0, xmm0, qword ptr [bx]
vcvtsi2sd xmm0, xmm0, ebx
vcvtsi2sd xmm0, xmm0, rbx
now will match in behavior with the AVX512 counterparts in that not
only the 2nd vcvtsi2sd won't assemble, but also the first. The last
two, otoh, will continue to assemble fine (due to the lack of any
memory operand size specifier). As a result, another way to make
things behave more consistently would be to avoid the folding and
add IgnoreSize to the CpuNo64 AVX512 variants. A 3rd way to do so
would be to add Cpu386 to any such insn template.
While doing this also make the usual cosmetic adjustments for the
insns touched anyway. Additionally drop the redundant Cpu64 from
the SAE forms of VCVT{,U}SI2SD - they won't assemble outside of
64-bit mode due to there not being anything to match the Reg64
operand.
Jan Beulich [Mon, 17 Feb 2020 07:59:07 +0000 (08:59 +0100)]
x86: fold AddrPrefixOpReg templates
There's no need to have separate Cpu64 and CpuNo64 templates: There
already is special logic handling the attribute, and all that's needed
is rejecting 16-bit address registers in 64-bit mode. Suppress suffix
guessing and group all involved logic together, outside of suffix
processing (arguably it doesn't even belong in process_suffix()).
Also, since no AddrPrefixOpReg template permits any suffixes, move the
No_*Suf specifiers for them to a central place. Along with this drop
the no longer relevant NoRex64 from there.
Jan Beulich [Mon, 17 Feb 2020 07:57:54 +0000 (08:57 +0100)]
x86/Intel: don't swap operands of MONITOR{,X} and MWAIT{,X}
Generally, the documentation doesn't allow for any explicit operands
to be specified with MONITOR/MWAIT. To permit the more legible
overriding of the address size via specifying operands, the option is
being retained even in Intel mode, but operand swapping is being
suppressed by this patch. This is both because it makes no sense here
(all of the operands are inputs) and because, as a result, old gcc
(prior to 4.8) actually expects it this way with -mintel-syntax (and
hence gets fixed by this change rather than, as claimed by a reply in
the bug report, broken).
Jan Beulich [Mon, 17 Feb 2020 07:56:18 +0000 (08:56 +0100)]
x86/Intel: improve diagnostics for ambiguous VCVT* operands
Conversions which shrink element size and which have a memory source
can't be disambiguated between their 128- and 256-bit variants by
looking at the register operand. "operand size mismatch", however, is a
pretty misleading diagnostic. Generalize the logic introduced for
VFPCLASSP{S,D} such that, with suitable similar adjustments to the
respective templates, it'll cover these cases too.
For VCVTNEPS2BF16 also fold the two previously separate AVX512VL
templates to achieve the intended effect. This is then also accompanied
by a respective addition to the inval-avx512f testcase.
H.J. Lu [Mon, 17 Feb 2020 04:10:20 +0000 (20:10 -0800)]
x86: Don't disable SSE3 when disabling SSE4a
Since SSE3 is independent of SSE4a, don't disable SSE3 when disabling
SSE4a.
* i386-gen.c (cpu_flag_init): Remove CPU_ANY_SSE3_FLAGS from
CPU_ANY_SSE4A_FLAGS.
Alan Modra [Mon, 17 Feb 2020 01:07:38 +0000 (11:37 +1030)]
Re: x86: Don't disable SSE4a when disabling SSE4
* i386-gen.c (cpu_flag_init): Correct last change.
GDB Administrator [Mon, 17 Feb 2020 00:00:40 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Sun, 16 Feb 2020 16:36:51 +0000 (08:36 -0800)]
x86: Don't disable SSE4a when disabling SSE4
commit
7deea9aad8 changed nosse4 to include CpuSSE4a. But AMD SSE4a is
a superset of SSE3 and Intel SSE4 is a superset of SSSE3. Disable Intel
SSE4 shouldn't disable AMD SSE4a. This patch restores nosse4. It also
adds .sse4a and nosse4a.
gas/
* config/tc-i386.c (cpu_arch): Add .sse4a and nosse4a. Restore
nosse4.
* doc/c-i386.texi: Document sse4a and nosse4a.
opcodes/
* i386-gen.c (cpu_flag_init): Add CPU_ANY_SSE4A_FLAGS. Remove
CPU_ANY_SSE4_FLAGS.
GDB Administrator [Sun, 16 Feb 2020 00:01:29 +0000 (00:01 +0000)]
Automatic date update in version.in
GDB Administrator [Sat, 15 Feb 2020 00:00:32 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Fri, 14 Feb 2020 21:45:40 +0000 (16:45 -0500)]
gdb: introduce displaced_step_closure_up type alias
To help with readability, add the type displaced_step_closure_up, an
alias for std::unique_ptr<displaced_step_closure>, and use it throughout
the code base.
gdb/ChangeLog:
* aarch64-tdep.c (aarch64_displaced_step_copy_insn): Use
displaced_step_closure_up.
* aarch64-tdep.h (aarch64_displaced_step_copy_insn): Likewise.
(struct displaced_step_closure_up):
* amd64-tdep.c (amd64_displaced_step_copy_insn): Likewise.
* amd64-tdep.h (amd64_displaced_step_copy_insn): Likewise.
* arm-linux-tdep.c (arm_linux_displaced_step_copy_insn):
Likewise.
* gdbarch.sh (displaced_step_copy_insn): Likewise.
* gdbarch.c, gdbarch.h: Re-generate.
* i386-linux-tdep.c (i386_linux_displaced_step_copy_insn): Use
displaced_step_closure_up.
* i386-tdep.c (i386_displaced_step_copy_insn): Likewise.
* i386-tdep.h (i386_displaced_step_copy_insn): Likewise.
* infrun.h (displaced_step_closure_up): New type alias.
(struct displaced_step_inferior_state) <step_closure>: Change
type to displaced_step_closure_up.
* rs6000-tdep.c (ppc_displaced_step_copy_insn): Use
displaced_step_closure_up.
* s390-tdep.c (s390_displaced_step_copy_insn): Likewise.
Tom Tromey [Fri, 14 Feb 2020 21:34:20 +0000 (14:34 -0700)]
Change gdbserver to use existing gnulib and libiberty
This changes gdbserver so that it no longer builds its own gnulib and
libiberty. Instead, it now relies on the ones that were already built
at the top level.
gdbsupport is still built specially for gdbserver. This is more
complicated and will be tackled in a subsequent patch.
ChangeLog
2020-02-14 Tom Tromey <tom@tromey.com>
* Makefile.in: Rebuild.
* Makefile.def: Make gdbserver require gnulib and libiberty.
gdbserver/ChangeLog
2020-02-14 Tom Tromey <tom@tromey.com>
* acinclude.m4: Don't include acx_configure_dir.m4.
* Makefile.in (LIBIBERTY_BUILDDIR, GNULIB_BUILDDIR): Update.
(SUBDIRS, CLEANDIRS, REQUIRED_SUBDIRS): Remove.
(all, install-only, uninstall, clean-info, clean)
(maintainer-clean): Don't recurse.
(subdir_do, all-lib): Remove.
($(LIBGNU) $(LIBIBERTY) $(GNULIB_H)): Remove rule.
(GNULIB_H): Remove.
(generated_files): Update.
($(GNULIB_BUILDDIR)/Makefile): Remove rule.
* configure: Rebuild.
* configure.ac: Don't configure gnulib or libiberty.
(GNULIB): Update.
gdbsupport/ChangeLog
2020-02-14 Tom Tromey <tom@tromey.com>
* common-defs.h: Change path to gnulib/config.h.
Change-Id: I469cbbf5db2ab37109c058e9e3a1e4f4dabdfc98
Tom Tromey [Fri, 14 Feb 2020 21:16:23 +0000 (14:16 -0700)]
Cache .gnu_debugdata BFD
While looking at the output of "maint info bfd" with multiple
inferiors, I noticed that there were duplicate entries for
.gnu_debugdata.
There is no reason to re-create this BFD each time it is needed. This
patch arranges to share the data.
gdb/ChangeLog
2020-02-14 Tom Tromey <tom@tromey.com>
* minidebug.c (gnu_debug_key): New global.
(find_separate_debug_file_in_section): Use it.
Change-Id: If139f89f0f07db33f399afdbcfbf5aaeffe4de46
Tom Tromey [Fri, 14 Feb 2020 21:14:38 +0000 (14:14 -0700)]
Have testsuite find gdbserver in new location
This updates the gdb testsuite to look for gdbserver in its new
location. The old location is also checked for, on the theory that
perhaps someone sets GDB to a full path for install testing.
gdb/testsuite/ChangeLog
2020-02-14 Tom Tromey <tom@tromey.com>
* lib/gdbserver-support.exp (find_gdbserver): Find gdbserver in
build directory.
* boards/gdbserver-base.exp: Update path to gdbserver.
Change-Id: If03db762ba53882ddfaf2d2d516de14c3fa03938
Simon Marchi [Fri, 14 Feb 2020 20:29:08 +0000 (15:29 -0500)]
gdb: make gdbarch_displaced_step_copy_insn return an std::unique_ptr
This callback dynamically allocates a specialized displaced_step_closure, and
gives the ownership of the object to its caller. So I think it would make
sense for the callback to return an std::unique_ptr, this is what this patch
implements.
gdb/ChangeLog:
* gdbarch.sh (displaced_step_copy_insn): Change return type to an
std::unique_ptr.
* gdbarch.c: Re-generate.
* gdbarch.h: Re-generate.
* infrun.c (displaced_step_prepare_throw): Adjust to std::unique_ptr
change.
* aarch64-tdep.c (aarch64_displaced_step_copy_insn): Change return
type to std::unique_ptr.
* aarch64-tdep.h (aarch64_displaced_step_copy_insn): Likewise.
* amd64-tdep.c (amd64_displaced_step_copy_insn): Likewise.
* amd64-tdep.h (amd64_displaced_step_copy_insn): Likewise.
* arm-linux-tdep.c (arm_linux_displaced_step_copy_insn): Likewise.
* i386-linux-tdep.c (i386_linux_displaced_step_copy_insn): Likewise.
* i386-tdep.c (i386_displaced_step_copy_insn): Likewise.
* i386-tdep.h (i386_displaced_step_copy_insn): Likewise.
* rs6000-tdep.c (ppc_displaced_step_copy_insn): Likewise.
* s390-tdep.c (s390_displaced_step_copy_insn): Likewise.
Simon Marchi [Fri, 14 Feb 2020 20:11:58 +0000 (15:11 -0500)]
gdb: cleanup of displaced_step_inferior_state::reset/displaced_step_clear
displaced_step_inferior_state::reset and displaced_step_clear appear to
have the same goal, but they don't do the same thing.
displaced_step_inferior_state::reset clears more things than
displaced_step_clear, but it misses free'ing the closure, which
displaced_step_clear does.
This patch replaces displaced_step_clear's implementation with just a call to
displaced_step_inferior_state::reset. It then changes
displaced_step_inferior_state::step_closure to be a unique_ptr, to indicate the
fact that displaced_step_inferior_state owns the closure (and so that it is
automatically freed when the field is reset).
The test gdb.base/step-over-syscall.exp caught a problem when doing this, which
I consider to be a latent bug which my cleanup exposes. In
handle_inferior_event, in the TARGET_WAITKIND_FORKED case, if we displaced-step
over a fork syscall, we make sure to restore the memory that we used as a
displaced-stepping buffer in the child. We do so using the
displaced_step_inferior_state of the parent. However, we do it after calling
displaced_step_fixup for the parent, which clears the information in the
parent's displaced_step_inferior_state. It worked fine before, because
displaced_step_clear didn't completely clear the displaced_step_inferior_state
structure, so the required information (in this case the gdbarch) was
still available after clearing.
I fixed it by making GDB restore the child's memory before calling the
displaced_step_fixup on the parent. This way, the data in the
displaced_step_inferior_state structure is still valid when we use it for the
child. This is the error you would get in
gdb.base/step-over-syscall.exp without this fix:
/home/smarchi/src/binutils-gdb/gdb/gdbarch.c:3911: internal-error: ULONGEST gdbarch_max_insn_length(gdbarch*): Assertion `gdbarch != NULL' failed.
gdb/ChangeLog:
* infrun.c (get_displaced_step_closure_by_addr): Adjust to
std::unique_ptr.
(displaced_step_clear): Rename to...
(displaced_step_reset): ... this. Just call displaced->reset ().
(displaced_step_clear_cleanup): Rename to...
(displaced_step_reset_cleanup): ... this.
(displaced_step_prepare_throw): Adjust to std::unique_ptr.
(displaced_step_fixup): Likewise.
(resume_1): Likewise.
(handle_inferior_event): Restore child's memory before calling
displaced_step_fixup on the parent.
* infrun.h (displaced_step_inferior_state) <reset>: Adjust
to std::unique_ptr.
<step_closure>: Change type to std::unique_ptr.
Simon Marchi [Fri, 14 Feb 2020 19:41:07 +0000 (14:41 -0500)]
gnulib: import count-one-bits module and use it
For a fix I intend to submit, I would need a function that counts the
number of set bits in a word. There is __builtin_popcount that is
supported by gcc and clang, but there is also a gnulib module that wraps
that and provides a fallback for other compilers, so I think it would be
good to use it.
I also noticed that there is a bitcount function in arch/arm.c, so I
thought that as a first step I would replace that one with the gnulib
count-one-bits module. This is what this patch does.
The gnulib module provides multiple functions, with various parameter
length (unsigned int, unsigned long int, unsigned long long int), I
chose the one that made sense for each call site based on the argument
type.
gnulib/ChangeLog:
* update-gnulib.sh (IMPORTED_GNULIB_MODULES): Import
count-one-bits module.
* configure: Re-generate.
* aclocal.m4: Re-generate.
* Makefile.in: Re-generate.
* import/count-one-bits.c: New file.
* import/count-one-bits.h: New file.
* import/Makefile.am: Re-generate.
* import/Makefile.in: Re-generate.
* import/m4/gnulib-cache.m4: Re-generate.
* import/m4/gnulib-comp.m4: Re-generate.
* import/m4/count-one-bits.m4: New file.
gdb/ChangeLog:
* arm-tdep.c: Include count-one-bits.h.
(cleanup_block_store_pc): Use count_one_bits.
(cleanup_block_load_pc): Use count_one_bits.
(arm_copy_block_xfer): Use count_one_bits.
(thumb2_copy_block_xfer): Use count_one_bits.
(thumb_copy_pop_pc_16bit): Use count_one_bits.
* arch/arm-get-next-pcs.c: Include count-one-bits.h.
(thumb_get_next_pcs_raw): Use count_one_bits.
(arm_get_next_pcs_raw): Use count_one_bits_l.
* arch/arm.c (bitcount): Remove.
* arch/arm.h (bitcount): Remove.
Tom Tromey [Fri, 14 Feb 2020 16:24:42 +0000 (09:24 -0700)]
Return unique_xmalloc_ptr from call_site_find_chain
call_site_find_chain returns a pointer that the caller must
deallocate. It seemed better here to return a unique_xmalloc_ptr
instead.
gdb/ChangeLog
2020-02-14 Tom Tromey <tromey@adacore.com>
* dwarf2/frame-tailcall.c (dwarf2_tailcall_sniffer_first):
Update.
* dwarf2/loc.h (call_site_find_chain): Return unique_xmalloc_ptr.
* dwarf2/loc.c (call_site_find_chain_1): Return
unique_xmalloc_ptr.
(call_site_find_chain): Likewise.
H.J. Lu [Fri, 14 Feb 2020 14:09:28 +0000 (06:09 -0800)]
Remove the old movsx and movzx documentation for AT&T syntax
* doc/c-i386.texi: Remove the old movsx and movzx documentation
for AT&T syntax.
H.J. Lu [Fri, 14 Feb 2020 13:40:19 +0000 (05:40 -0800)]
Remove Intel syntax comments on movsx and movzx
Since movsx and movzx are valid mnemonic in AT&T syntax, remove Intel
syntax comments on movsx and movzx to avoid confusing other readers.
* i386-opc.tbl (movsx): Remove Intel syntax comments.
(movzx): Likewise.
Jan Beulich [Fri, 14 Feb 2020 13:27:28 +0000 (14:27 +0100)]
x86: replace adhoc (partly wrong) ambiguous operand checking for MOVSX/MOVZX
For these to get treatment consistent with other operand size checking
the special logic shouldn't live in md_assemble(), but process_suffix().
And there's more logic involved than simply zapping the suffix.
Note however that MOVS[BW]* and MOVZ[BW]* still won't be fully
consistent, due to the objection to fold MOVS* templates just like was
done for MOVZ* in
c07315e0c6 ("x86: allow suffix-less movzw and 64-bit
movzb").
Note further that it is against my own intentions to have MOVSX/MOVZX
silently default to a byte source in AT&T mode. This should happen only
when the destination register is a 16-bit one. In all other cases there
is an ambiguity, and the user should be warned. But it was explicitly
requested for this to be done in a way inconsistent with everything
else.
Note finally that the assembler change points out (and this patch fixes)
a wrong Intel syntax test introduced by
bc31405ebb2c ("x86-64: Properly
encode and decode movsxd"): When source code specifies a 16-bit
destination register, disassembly expectations shouldn't have been to
find a 32-bit one.
Jan Beulich [Fri, 14 Feb 2020 13:04:23 +0000 (14:04 +0100)]
x86: adjust segment override prefix emission
Since we already suppress the prefix altogether when it's the default
one for the chosen addressing mode, let's do so also when instruction
prefix and override specified with the memory operand match. (Note that
insn prefix specified segment overrides never get discarded.)
Jan Beulich [Fri, 14 Feb 2020 13:03:19 +0000 (14:03 +0100)]
x86: optimize away pointless segment overrides
When optimizing there's no point keeping the segment overrides when we
warn about their presence in the first place.
Jan Beulich [Fri, 14 Feb 2020 13:02:05 +0000 (14:02 +0100)]
x86: extend LEA's segment override warning
For one both possible forms should be warned about. And then, to guard
against future surprises, qualify the original opcode check by excluding
VEX/EVEX-like templates.
H.J. Lu [Fri, 14 Feb 2020 12:57:01 +0000 (04:57 -0800)]
x86: Document movsx/movsxd/movzx for AT&T syntax
Document different mnemonics of movsx, movsxd and movzx in AT&T syntax.
PR gas/25438
* doc/c-i386.texi: Document movsx, movsxd and movzx for AT&T
syntax.
Eli Zaretskii [Fri, 14 Feb 2020 09:53:55 +0000 (11:53 +0200)]
Fix argv[] in programs invoked by gdbserver on MS-Windows
gdbserver/ChangeLog
2020-02-14 Eli Zaretskii <eliz@gnu.org>
* win32-low.c (create_process): Prepend PROGRAM to ARGS when
preparing the command line for CreateProcess.
(win32_create_inferior): Reflect the program name in debugging
output that shows the process and its command line.
Richard Biener [Fri, 14 Feb 2020 07:32:53 +0000 (08:32 +0100)]
[gdb] Speedup lnp_state_machine::handle_special_opcode
I see for some program at gdb startup:
...
Samples: 102K of event 'cycles:pu', Event count (approx.):
91710925103
Overhead Command Shared Object Symbol
15.21% gdb gdb [.]
lnp_state_machine::handle_special
...
where the divisions are the places we stall. The following
micro-optimizes things but it smells like m_line_header->line_range
is constant, likewise probably m_line_header->maximum_ops_per_instruction
so eventually the divisions could be avoided completely with some
lookup table.
Well. Micro-optimizing with this patch improves things
(don't expect [load] CSE over the gdbarch_adjust_dwarf2_line call).
Build and reg-tested on x86_64-linux.
gdb/ChangeLog:
2020-02-14 Richard Biener <rguenther@suse.de>
* dwarf2/read.c (lnp_state_machine::handle_special_opcode): Apply CSE
on expression with division operators.
GDB Administrator [Fri, 14 Feb 2020 00:00:26 +0000 (00:00 +0000)]
Automatic date update in version.in
H.J. Lu [Thu, 13 Feb 2020 21:44:17 +0000 (13:44 -0800)]
x86: Resolve PLT32 reloc aganst local symbol to section
Since PLT entry isn't needed for branch to local symbol, we can resolve
R_386_PLT32/R_X86_64_PLT32 relocation aganst local symbol to section,
similar to R_386_PC32/R_X86_64_PC32.
2020-02-13 Fangrui Song <maskray@google.com>
H.J. Lu <hongjiu.lu@intel.com>
PR gas/25551
* config/tc-i386.c (tc_i386_fix_adjustable): Don't check
BFD_RELOC_386_PLT32 nor BFD_RELOC_X86_64_PLT32.
* testsuite/gas/i386/i386.exp: Run relax-5 and x86-64-relax-4.
* testsuite/gas/i386/relax-5.d: New file.
* testsuite/gas/i386/relax-5.s: Likewise.
* testsuite/gas/i386/x86-64-relax-4.d: Likewise.
* testsuite/gas/i386/x86-64-relax-4.s: Likewise.
Simon Marchi [Thu, 13 Feb 2020 21:27:51 +0000 (16:27 -0500)]
gdbserver: rename source files to .cc
For the same reasons outlined in the previous patch, this patch renames
gdbserver source files to .cc.
I have moved the "-x c++" switch to only those rules that require it.
gdbserver/ChangeLog:
* Makefile.in: Rename source files from .c to .cc.
* %.c: Rename to %.cc.
* configure.ac: Rename server.c to server.cc.
* configure: Re-generate.
Simon Marchi [Thu, 13 Feb 2020 21:27:02 +0000 (16:27 -0500)]
gdbsupport: rename source files to .cc
This patch renames the .c source files in gdbsupport to .cc.
In the gdb directory, there is an argument against renaming the source
files, which is that it makes using some git commands more difficult to
do archeology. Some commands have some kind of "follow" option that
makes git try to follow renames, but it doesn't work in all situations.
Given that we have just moved the gdbsupport directory, that argument
doesn't hold for source files in that directory. I therefore suggest
renaming them to .cc, so that they are automatically recognized as C++
by various tools and editors.
The original motivation behind this is that when building gdbsupport
with clang, I get:
CC agent.o
clang: error: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Werror,-Wdeprecated]
In the gdb/ directory, we make clang happy by passing "-x c++". We
could do this in gdbsupport too, but I think that renaming the files is
a better long-term solution.
gdbserver still does its own build of gdbsupport, so a few changes in
its Makefile are necessary.
gdbsupport/ChangeLog:
* Makefile.am: Rename source files from .c to .cc.
(CC, CFLAGS): Don't override.
(AM_CFLAGS): Rename to ...
(AM_CXXFLAGS): ... this.
* Makefile.in: Re-generate.
* %.c: Rename to %.cc.
gdbserver/ChangeLog:
* Makefile.in: Rename gdbsupport source files from .c to .cc.
Tom de Vries [Thu, 13 Feb 2020 14:42:07 +0000 (15:42 +0100)]
[gdb/testsuite] Remove stale exec in gdb_compile_ada
When running test-case gdb.ada/ptype_tagged_param.exp, I get:
...
PASS: gdb.ada/ptype_tagged_param.exp: compilation foo.adb
...
However, when I then de-install gnatmake and run again, I get the same result.
This is due to a stale exec. After removing the stale exec, I get:
...
UNSUPPORTED: gdb.ada/ptype_tagged_param.exp: compilation foo.adb
...
Fix this removing the stale exec in gdb_compile_ada before compilation.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-02-13 Tom de Vries <tdevries@suse.de>
* lib/ada.exp (gdb_compile_ada): Delete stale exec before compilation.
Tom de Vries [Thu, 13 Feb 2020 14:34:06 +0000 (15:34 +0100)]
[gdb/testsuite] Add unsupported tests in catch_ex_std.exp
If I de-install gnatbind, I run into:
...
FAIL: gdb.ada/catch_ex_std.exp: gnatbind foo
...
Fix this by marking the test unsupported instead:
...
UNSUPPORTED: gdb.ada/catch_ex_std.exp: gnatbind foo
...
Likewise for gnatlink.
Tested on x86_64-linux, with and without gnatbind/gnatlink installed.
gdb/testsuite/ChangeLog:
2020-02-13 Tom de Vries <tdevries@suse.de>
* gdb.ada/catch_ex_std.exp: Indicate unsupported if gnatbind/gnatlink
are missing.
H.J. Lu [Thu, 13 Feb 2020 11:17:51 +0000 (03:17 -0800)]
plugin: Search bfd-plugins directories only once
try_load_plugin is updated to take either plugin name or plugin entry.
load_plugin is updated to search bfd-plugins directories first to build
a list of plugins and call try_load_plugin with each plugin on the list.
When --plugin is used, the plugin list only has one entry.
* plugin.c (try_load_plugin): Make plugin_list_iter an argument
and use it if it isn't NULL. Remove has_plugin_p argument. Add
a build_list_p argument. Don't search plugin_list. Short circuit
when building the plugin list.
(has_plugin): Renamed to has_plugin_list.
(bfd_plugin_set_plugin): Don't set has_plugin.
(bfd_plugin_specified_p): Check plugin_list instead.
(build_plugin_list): New function.
(load_plugin): Call build_plugin_list and use plugin_list.
Alok Kumar Sharma [Thu, 13 Feb 2020 10:26:11 +0000 (15:56 +0530)]
Adding myself to gdb/MAINTAINERS
2020-02-13 Alok Kumar Sharma <AlokKumar.Sharma@amd.com>
* MAINTAINERS (Write After Approval): Adding myself.
Change-Id: I2e6095a63247902f5fe23d58c2df8f995e41cf58
Jan Beulich [Thu, 13 Feb 2020 09:19:28 +0000 (10:19 +0100)]
x86: fix SSE4a dependencies of ".arch .nosse*"
Since ".arch .sse4a" enables SSE3 and earlier, disabling SSE3 should
also disable SSE4a. And as per its name, ".arch .nosse4" should also do
so.
Tom de Vries [Thu, 13 Feb 2020 07:37:34 +0000 (08:37 +0100)]
[gdb/testsuite] Fix gnatmake_version_at_least
After de-installing gnatmake, I get:
...
Running src/gdb/testsuite/gdb.ada/rename_subscript_param.exp ...
ERROR: tcl error sourcing src/gdb/testsuite/gdb.ada/rename_subscript_param.exp.
ERROR: couldn't execute "gnatmake": no such file or directory
while executing
"exec $gnatmake --version"
(procedure "gnatmake_version_at_least" line 4)
...
Fix this by wrapping the exec call in a catch call.
Tested with and withouth gnatmake installed on x86_64-linux.
gdb/testsuite/ChangeLog:
2020-02-13 Tom de Vries <tdevries@suse.de>
* lib/ada.exp (gnatmake_version_at_least): Wrap exec call in a catch
call.
Tom Tromey [Thu, 13 Feb 2020 00:05:42 +0000 (17:05 -0700)]
Remove some dead code from event-loop.c
This removes some dead code from event-loop.c.
This patch is from my old series to merge the gdb and gdbserver event
loops; but since it is just removing dead code, it seemed simple to
commit it separately.
gdb/ChangeLog
2020-02-12 Tom Tromey <tom@tromey.com>
* event-loop.c (event_data, gdb_event, event_handler_func):
Remove.
GDB Administrator [Thu, 13 Feb 2020 00:00:41 +0000 (00:00 +0000)]
Automatic date update in version.in
Tom Tromey [Wed, 12 Feb 2020 22:45:08 +0000 (15:45 -0700)]
Move the frame data to the BFD when possible
Now that comp_unit and the remaining frame data are all independent of
the objfile, it can all be stored on the BFD and shared across
inferiors.
As with other code doing this same thing, care must be taken to not
share the data when the objfile requires relocations. So, two keys
are used: one for the BFD and one for the objfile, and
gdb_bfd_requires_relocations is used to differentiate between the two
cases.
gdb/ChangeLog
2020-02-12 Tom Tromey <tom@tromey.com>
* dwarf2/frame.c (dwarf2_frame_bfd_data): New global.
(dwarf2_frame_objfile_data): Add comment.
(find_comp_unit, set_comp_unit): New functions.
(dwarf2_frame_find_fde): Use find_comp_unit.
(dwarf2_build_frame_info): Use set_comp_unit.
Tom Tromey [Wed, 12 Feb 2020 22:45:08 +0000 (15:45 -0700)]
Remove the objfile backlink from comp_unit
This removes the objfile backlink from comp_unit. The only remaining
uses involved fetching the text offset from the objfile. However,
this is already conveniently computed at all the sites that call
execute_cfa_program, and so it can simply be passed in.
gdb/ChangeLog
2020-02-12 Tom Tromey <tom@tromey.com>
* dwarf2/frame.c (struct comp_unit) <objfile>: Remove.
(comp_unit): Don't initialize objfile.
(execute_cfa_program): Add text_offset parameter.
(execute_cfa_program_test, dwarf2_fetch_cfa_info)
(dwarf2_frame_cache): Update.
(dwarf2_build_frame_info): Don't set "objfile" member.
Tom Tromey [Wed, 12 Feb 2020 22:45:08 +0000 (15:45 -0700)]
Remove a use of the comp_unit backlink
The DWARF frame comp_unit object still has a backlink to the objfile.
In order to be truly objfile-independent, this must be removed.
This patch removes one such use, by passing the gdbarch to
decode_frame_entry directly.
gdb/ChangeLog
2020-02-12 Tom Tromey <tom@tromey.com>
* dwarf2/frame.c (decode_frame_entry_1): Add gdbarch parameter.
(decode_frame_entry): Likewise.
(dwarf2_build_frame_info): Update.
Tom Tromey [Wed, 12 Feb 2020 22:45:08 +0000 (15:45 -0700)]
Add per-unit obstack
This adds an auto_obstack to the DWARF frame comp_unit object, and
then changes the remaining code here to use the comp_unit obstack
rather than the objfile obstack.
At this point, all the storage for frame data is self-contained --
that is, it is independent of the objfile.
gdb/ChangeLog
2020-02-12 Tom Tromey <tom@tromey.com>
* dwarf2/frame.c (struct comp_unit) <obstack>: New member.
(decode_frame_entry_1): Use the comp_unit obstack.
Tom Tromey [Wed, 12 Feb 2020 22:45:08 +0000 (15:45 -0700)]
Store the comp_unit instead of the FDE table
This changes the DWARF frame code to store the comp_unit on the
objfile, rather than storing the FDE table. It also changes the
comp_unit to be heap-allocated using "new".
This change makes it simpler for a later patch to add a field to the
comp_unit, and to have deallaction work properly. This in turn is
important for making the frame data be independent of the objfile.
gdb/ChangeLog
2020-02-12 Tom Tromey <tom@tromey.com>
* dwarf2/frame.c (struct comp_unit): Add initializers and
constructor.
(dwarf2_frame_objfile_data): Store a comp_unit.
(dwarf2_frame_find_fde): Update.
(dwarf2_build_frame_info): Use "new".
Tom Tromey [Wed, 12 Feb 2020 22:45:08 +0000 (15:45 -0700)]
Change fde table to a vector
This removes struct dwarf2_fde_table, replacing it with a typedef of
std::vector. This simplifies the code somewhat.
gdb/ChangeLog
2020-02-12 Tom Tromey <tom@tromey.com>
* dwarf2/frame.c (struct dwarf2_fde_table): Remove.
(dwarf2_fde_table): Typedef for std::vector.
(dwarf2_frame_objfile_data): Remove the deleter. Now static.
(dwarf2_frame_find_fde, add_fde, decode_frame_entry_1)
(decode_frame_entry): Update.
(dwarf2_build_frame_info): Use "new".
Christian Biesinger [Wed, 12 Feb 2020 22:49:08 +0000 (16:49 -0600)]
Change booleans to bool in ARM's gdbarch_tdep
gdb/ChangeLog:
2020-02-12 Christian Biesinger <cbiesinger@google.com>
* arm-tdep.c (arm_gdbarch_init): Update.
* arm-tdep.h (struct gdbarch_tdep) <have_fpa_registers,
have_wmmx_registers, have_vfp_pseudos, have_neon_pseudos,
have_neon, is_m>: Change to bool.
Christian Biesinger [Wed, 12 Feb 2020 22:28:48 +0000 (16:28 -0600)]
Print more information in arm_dump_tdep
I am keeping the (int) casts because a future patch will change the type
to bool.
gdb/ChangeLog:
2020-02-12 Christian Biesinger <cbiesinger@google.com>
* arm-tdep.c (arm_dump_tdep): Print more fields of tdep.
Tom Tromey [Wed, 12 Feb 2020 21:41:33 +0000 (14:41 -0700)]
Remove dwarf_expr_baton
The type dwarf_expr_baton is unused and can be removed.
gdb/ChangeLog
2020-02-12 Tom Tromey <tom@tromey.com>
* dwarf2/loc.c (struct dwarf_expr_baton): Remove.
Change-Id: Id8342da31398b9b4b08f31be7c3d612e9590bbbf
Hannes Domani [Sat, 8 Feb 2020 18:08:40 +0000 (19:08 +0100)]
Fix kill of processes created by win32_create_inferior
handle_v_kill uses signal_pid because win32 doesn't support multi-process.
Without this gdb just refuses to kill the process:
(gdb) kill
Kill the program being debugged? (y or n) y
Sending packet: $vKill;a410#33...Packet received: E01
Packet vKill (kill) is supported
Can't kill process
gdbserver/ChangeLog:
2020-02-12 Hannes Domani <ssbssa@yahoo.de>
* win32-low.c (win32_create_inferior): Set signal_pid.
Hannes Domani [Sun, 9 Feb 2020 16:37:58 +0000 (17:37 +0100)]
Cache the Thread Local Base pointer type in the gdbarch
gdb/ChangeLog:
2020-02-12 Hannes Domani <ssbssa@yahoo.de>
* windows-tdep.c (struct windows_gdbarch_data): Add tib_ptr_type.
(windows_get_tlb_type): Use windows_gdbarch_data->tib_ptr_type.
Jan Beulich [Wed, 12 Feb 2020 15:20:56 +0000 (16:20 +0100)]
x86: correct VFPCLASSP{S,D} operand size handling
With AVX512VL disabled (e.g. when writing code for the Knights family
of processors) these insns aren't ambiguous when used with a memory
source, and hence should be accepted without suffix or operand size
specifier. When AVX512VL is enabled, to be consistent with this as
well as other ambiguous operand size handling it would seem better to
just warn about the ambiguity in AT&T mode, and still default to 512-bit
operands (on the assumption that the code may have been written without
AVX512VL in mind yet), but it was requested to leave AT&T syntax mode
alone here.
Jan Beulich [Wed, 12 Feb 2020 15:19:52 +0000 (16:19 +0100)]
x86: fold two JMP templates
Now that the AMD64 check in match_template() applies to 64-bit code
only, the non-64-bit and the Amd64 template can be folded, as being
otherwise compatible with one another. (Oddly enough the same doesn't
apply to CALL, due to the suffixes it permits, while JMP doesn't
allow for any.)
Jan Beulich [Wed, 12 Feb 2020 15:19:03 +0000 (16:19 +0100)]
x86-64: Intel64 adjustments for insns dealing with far pointers
AMD and Intel differ in their handling of far indirect branches as well
as LFS/LGS/LSS: AMD CPUs ignore REX.W while Intel ones honors it. (Note
how the latter three were hybrids so far, while far branches were fully
AMD-like.)
Maciej W. Rozycki [Wed, 12 Feb 2020 13:50:30 +0000 (13:50 +0000)]
Disable gdbserver on host != target configurations
Correct fallout from commit
919adfe84092 ("Move gdbserver to top level")
and revert to not building `gdbserver' in a cross-configuration, that is
where host != target, matching the documented behaviour. We have no way
to support non-native `gdbserver', and native `gdbserver' is usually of
no use with cross-GDB of the chosen host.
gdbserver/ChangeLog:
2020-02-12 Maciej W. Rozycki <macro@wdc.com>
Pedro Alves <palves@redhat.com>
Skip building gdbserver in a cross-configuration.
* configure.srv: Set $gdbserver_host depending on whether $target
is $host. Use $gdbserver_host instead of $host.
Tom de Vries [Wed, 12 Feb 2020 10:15:33 +0000 (11:15 +0100)]
[gdb] Fix -Wstrict-null-sentinel warning (--with-iconv-bin)
When using configure flag --with-iconv-bin=$(which iconv), we run into:
...
gdb/charset.c: In function 'void find_charset_names()':
gdb/charset.c:821:75: error: missing sentinel in function call [-Werror=format=]
iconv_program = concat (iconv_dir.c_str(), SLASH_STRING, "iconv", NULL);
^
cc1plus: all warnings being treated as errors
...
Fix the warning.
Build and reg-tested on x86_64-linux.
2020-02-12 Lukas Durfina <ldurfina@tachyum.com>
Tom de Vries <tdevries@suse.de>
* charset.c (find_charset_names): Cast concat NULL sentinel to char *.
Jan Beulich [Wed, 12 Feb 2020 09:59:32 +0000 (10:59 +0100)]
x86: also disallow non-byte/-word registers with byte/word suffix
Along the lines of
be4c5e58bd ("x86: Always disallow double word suffix
with word general register") also adjust check_{byte,word}_reg(), to make
overall behavior consistent again in this regard.
Jan Beulich [Wed, 12 Feb 2020 09:58:42 +0000 (10:58 +0100)]
x86/Intel: improve diagnostics
The diagnostics issued by check_*_reg() are pretty AT&T-centric. Re-use
logic already used for SIMD memory operand size checking also for ones
where GPRs would alternatively also be allowed. (There's certainly room
for further improvement here.)
Tom Tromey [Wed, 12 Feb 2020 01:11:32 +0000 (18:11 -0700)]
Update a comment in psymtab.h
This updates a comment in psymtab.h to reflect the current reality.
gdb/ChangeLog
2020-02-11 Tom Tromey <tom@tromey.com>
* psymtab.h: Update comment.
Change-Id: I438bb5929c3ebd1a4c6e9a902490f2ef63014ab3
Tom Tromey [Wed, 12 Feb 2020 00:31:10 +0000 (17:31 -0700)]
Don't allow copying of auto_obstack
Add DISABLE_COPY_AND_ASSIGN to struct auto_obstack, to prevent copying
it. Copying an auto_obstack would be a bug.
2020-02-11 Tom Tromey <tom@tromey.com>
* gdb_obstack.h (struct auto_obstack): Use
DISABLE_COPY_AND_ASSIGN.
Change-Id: Ic9e5ab20acfcfa61c241fed4d99bbb1caefba3cd
Tom Tromey [Wed, 12 Feb 2020 00:31:10 +0000 (17:31 -0700)]
Don't forward-declare struct objfile in dwarf2/frame.h
dwarf2/frame.h forward-declares struct objfile, but there's no need
for this.
gdb/ChangeLog
2020-02-11 Tom Tromey <tom@tromey.com>
* dwarf2/frame.h (struct objfile): Don't forward declare.
Change-Id: I4d54d46ac9422eeb64dc5f0b934792e77a875aa5