binutils-gdb.git
5 years agoAdd support for NetBSD/sh3 core reg sections to readelf.
Christos Zoulas [Wed, 12 Jun 2019 13:35:04 +0000 (14:35 +0100)]
Add support for NetBSD/sh3 core reg sections to readelf.

PR 24665
* readelf.c (get_netbsd_elfcore_note_type): Add support for SH
core notes.

5 years agoAdd support to readelf to display NetBSD auxv notes in core files.
Christos Zoulas [Wed, 12 Jun 2019 12:52:04 +0000 (13:52 +0100)]
Add support to readelf to display NetBSD auxv notes in core files.

PR 24664
* readelf.c (get_netbsd_elfcore_note_type): Add support for NetBSD
auxv notes.

5 years agoAutomatic date update in version.in
GDB Administrator [Wed, 12 Jun 2019 00:00:16 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoDwarf: Don't add nameless modules to partial symbol table (ChangeLogs)
Pedro Alves [Tue, 11 Jun 2019 19:37:09 +0000 (20:37 +0100)]
Dwarf: Don't add nameless modules to partial symbol table (ChangeLogs)

Add missing ChangeLog entries for previous commit.

gdb/ChangeLog:
2019-06-11  Bernhard Heckel  <bernhard.heckel@intel.com>

* dwarf2read.c (add_partial_symbol): Skip nameless modules.

gdb/testsuite/Changelog:
2019-06-11  Bernhard Heckel  <bernhard.heckel@intel.com>

* gdb.fortran/block-data.f: New.
* gdb.fortran/block-data.exp: New.

5 years agoDwarf: Don't add nameless modules to partial symbol table
Bernhard Heckel [Wed, 27 Feb 2019 14:21:12 +0000 (15:21 +0100)]
Dwarf: Don't add nameless modules to partial symbol table

A name for BLOCK DATA in Fortran is optional.  If no name has been
assigned, GDB crashes during read-in of DWARF when BLOCK DATA is
represented via DW_TAG_module.  BLOCK DATA is used for one-time
initialization of non-pointer variables in named common blocks.

As of now there is no issue when gfortran is used as DW_TAG_module is
not emitted.  However, with Intel ifort the nameless DW_TAG_module is
present and has the following form:

 ...
  <1><dd>: Abbrev Number: 7 (DW_TAG_module)
     <de>   DW_AT_decl_line   : 46
     <df>   DW_AT_decl_file   : 1
     <e0>   DW_AT_description : (indirect string, offset: 0x110): block
 data
     <e4>   DW_AT_high_pc     : 0x402bb7
     <ec>   DW_AT_low_pc      : 0x402bb7
 ...

The missing name leads to a crash in add_partial_symbol, during length
calculation.

gdb/ChangeLog:
2019-06-11  Bernhard Heckel  <bernhard.heckel@intel.com>

* dwarf2read.c (add_partial_symbol): Skip nameless modules.

gdb/testsuite/Changelog:
2019-06-11  Bernhard Heckel  <bernhard.heckel@intel.com>

* gdb.fortran/block-data.f: New.
* gdb.fortran/block-data.exp: New.

5 years agoAdd support for reporting Alpha and Vax symbol visibility in readelf.
Christos Zoulas [Tue, 11 Jun 2019 15:43:25 +0000 (16:43 +0100)]
Add support for reporting Alpha and Vax symbol visibility in readelf.

PR 24662
* readelf.c (get_alpha_symbol_other): New function.
(get_symbol_other): Use for Alpha symbols.
(is_32bit_pcrel_reloc): Add R_VAX_PCREL32.

5 years agoMove gdb's xmalloc and friends to new file
Tom Tromey [Wed, 29 May 2019 21:49:10 +0000 (15:49 -0600)]
Move gdb's xmalloc and friends to new file

When "common" becomes a library, linking will cause a symbol clash,
because "xmalloc" and some related symbols are defined in that
library, libiberty, and readline.

To work around this problem, this patch moves the clashing symbols to
a new file, which is then compiled separately for both gdb and
gdbserver.

gdb/ChangeLog
2019-06-11  Tom Tromey  <tom@tromey.com>

* common/common-utils.c (xmalloc, xrealloc, xcalloc)
(xmalloc_failed): Move to alloc.c.
* alloc.c: New file.
* Makefile.in (COMMON_SFILES): Add alloc.c.

gdb/gdbserver/ChangeLog
2019-06-11  Tom Tromey  <tom@tromey.com>

* Makefile.in (SFILES): Add alloc.c.
(OBS): Add alloc.o.
(IPA_OBJS): Add alloc-ipa.o.
(alloc-ipa.o): New target.
(%.o: ../%.c): New pattern rule.

5 years agoRemove linux-waitpid.c debugging code
Tom Tromey [Mon, 6 May 2019 00:28:13 +0000 (18:28 -0600)]
Remove linux-waitpid.c debugging code

The debugging code in linux-waitpid.c is one of the few remaining
spots that depends on the gdb/gdbserver difference.

My first thought was that this code is not extremely useful, so this
patch removes this code.  (However, if it is actually useful to
someone, we could make it work by introducing a new abstraction.)

gdb/ChangeLog
2019-06-11  Tom Tromey  <tom@tromey.com>

* nat/linux-waitpid.c: Don't include server.h.
(linux_debug): Remove.
(my_waitpid): Update.

5 years agoFix an unitinitalised local variable in decode_arm_unwind().
Christos Zoulas [Tue, 11 Jun 2019 13:36:47 +0000 (14:36 +0100)]
Fix an unitinitalised local variable in decode_arm_unwind().

PR 24661
* readelf.c (decode_arm_unwind): Ensure that the local variable
'addr' is always initialised.

5 years agoRemove trailing newlines from help text
Tom Tromey [Tue, 4 Jun 2019 12:17:09 +0000 (06:17 -0600)]
Remove trailing newlines from help text

I noticed recently that some command had a trailing newline in its
"help" output.  So, I temporarily hacked cli-decode.c to print
something when a new command was installed that had a trailing newline
in its help message, and wrote this patch, which removes all the ones
I could find this way.  (There could still be a few more in *-nat
files.)

Tested on x86-64 Fedora 29.

gdb/ChangeLog
2019-06-11  Tom Tromey  <tromey@adacore.com>

* infcall.c (_initialize_infcall): Remove trailing newline from
help.
* user-regs.c (_initialize_user_regs): Remove trailing newline
from help.
* typeprint.c (_initialize_typeprint): Remove trailing newline
from help.
* reverse.c (_initialize_reverse): Remove trailing newlines from
help.
* tracepoint.c (_initialize_tracepoint): Remove trailing newlines
from help.
* language.c (add_set_language_command): Remove trailing newline
from help.
* infcmd.c (_initialize_infcmd): Remove trailing newlines from
help.
* disasm.c (_initialize_disasm): Remove trailing newline from
help.
* top.c (init_main): Remove trailing newline from help.
* interps.c (_initialize_interpreter): Remove trailing newline
from help.
* btrace.c (_initialize_btrace): Remove trailing newlines from
help.
* breakpoint.c (_initialize_breakpoint): Remove trailing newline
from help.
* python/python.c (_initialize_python): Remove trailing newline
from help.
* spu-tdep.c (_initialize_spu_tdep): Remove trailing newlines from
help.
* tui/tui-win.c (_initialize_tui_win): Remove trailing newlines
from help.  Reformat some text.
* tui/tui-stack.c (_initialize_tui_stack): Remove trailing newline
from help.
* tui/tui-layout.c (_initialize_tui_layout): Remove trailing
newline from help.

5 years ago[gdb/testsuite] Fix remove-inferiors.exp FAIL with readnow board
Tom de Vries [Tue, 11 Jun 2019 11:54:10 +0000 (13:54 +0200)]
[gdb/testsuite] Fix remove-inferiors.exp FAIL with readnow board

We see this failure with the readnow board:
...
FAIL: gdb.multi/remove-inferiors.exp: load binary
...

When running with board readnow, an extra message "Expanding full symbols" is
emitted after the "Reading symbols" message, and the regexp corresponding to
the FAIL only allows the first message.

Fix this by allowing the extra message in the regexp.

gdb/testsuite/ChangeLog:

2019-06-11  Tom de Vries  <tdevries@suse.de>

PR testsuite/24521
* gdb.multi/remove-inferiors.exp: Allow "Expanding full symbols"
message.

5 years agoRemove shadowing from darwin-nat.c
Tom Tromey [Mon, 10 Jun 2019 20:49:04 +0000 (22:49 +0200)]
Remove shadowing from darwin-nat.c

Building on Darwin with gcc showed that darwin-nat.c had some
shadowing variable declarations.  This removes them.

gdb/ChangeLog
2019-06-11  Tom Tromey  <tromey@adacore.com>

* darwin-nat.c (darwin_decode_exception_message)
(darwin_decode_message, darwin_nat_target::kill): Fix shadowing.

5 years ago[gdb/testsuite] Fix main high_pc in nonvar-access.exp
Tom de Vries [Tue, 11 Jun 2019 11:22:27 +0000 (13:22 +0200)]
[gdb/testsuite] Fix main high_pc in nonvar-access.exp

When running gdb.dwarf2/nonvar-access.exp with board readnow, we have:
...
FAIL: gdb.dwarf2/nonvar-access.exp: print/x def_implicit_s
...
and 12 more similar failures.

I've tracked this down to the range of main being hardcoded to
[_main, _main+0x10000) in the dwarf assembly:
...
            DW_TAG_subprogram {
                {name main}
                {DW_AT_external 1 flag}
                {low_pc [gdb_target_symbol main] DW_FORM_addr}
{high_pc [gdb_target_symbol main]+0x10000 DW_FORM_addr}
            } {
...
which overlaps with the .debug_info for the elf-init.c CU (containing
__libc_csu_init and __libc_csu_fini).

Fix this by using function_range to find the actual range of main.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-06-11  Tom de Vries  <tdevries@suse.de>

PR testsuite/24521
* gdb.dwarf2/nonvar-access.exp: Fix main high_pc.

5 years ago[gdb/testsuite] Add readnow.exp
Tom de Vries [Tue, 11 Jun 2019 07:42:56 +0000 (09:42 +0200)]
[gdb/testsuite] Add readnow.exp

Add a target board to test -readnow.

gdb/testsuite/ChangeLog:

2019-06-11  Tom de Vries  <tdevries@suse.de>

* boards/readnow.exp: New file.

5 years agoAutomatic date update in version.in
GDB Administrator [Tue, 11 Jun 2019 00:00:19 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agogdb: Check for not allocated/associated values during array slicing
Andrew Burgess [Thu, 23 May 2019 18:49:41 +0000 (19:49 +0100)]
gdb: Check for not allocated/associated values during array slicing

When extracting an array slice we should give up if the array is
not-allocated or not-associated.  For Fortran, at least in gfortran
compiled code, the upper and lower bounds are undefined if the array
is not allocated or not associated, in which case performing checks
against these bounds will result in undefined behaviour.

Better then to throw an error if we try to slice such an array.  This
changes the error message that the user will receive in these
cases (if they got an error message before).  Previously they may have
gotten "slice out of range" now they'll get "array not allocated" or
"array not associated".

gdb/ChangeLog:

* valops.c (value_slice): Check for not allocated or not
associated values.

gdb/testsuite/ChangeLog:

* gdb.fortran/vla-sizeof.exp: Update expected results.

5 years ago[gdb] Fix heap-buffer-overflow in cp_find_first_component_aux
Tom de Vries [Mon, 10 Jun 2019 18:27:09 +0000 (20:27 +0200)]
[gdb] Fix heap-buffer-overflow in cp_find_first_component_aux

When compiling gdb with '-lasan -fsanitizer=address' and running tests with:
- export ASAN_OPTIONS="detect_leaks=0:alloc_dealloc_mismatch=0",
- target board cc-with-gdb-index,
- the "[gdb/testsuite] Fix gdb.base/break-probes.exp with native-gdbserver"
  commit reverted to avoid running into PR24617,
we get with gdb.arch/amd64-init-x87-values.exp:
...
==31229==ERROR: AddressSanitizer: heap-buffer-overflow on address \
  0x62500098c93c at pc 0x000000bcc748 bp 0x7ffe39487660 sp 0x7ffe39487658
READ of size 1 at 0x62500098c93c thread T0
    #0 0xbcc747 in cp_find_first_component_aux src/gdb/cp-support.c:999
    #1 0xbcc6e9 in cp_find_first_component(char const*) \
                   src/gdb/cp-support.c:977
    #2 0xcc2cf3 in mapped_index_base::build_name_components() \
                   src/gdb/dwarf2read.c:4499
    #3 0xcc3322 in dw2_expand_symtabs_matching_symbol src/gdb/dwarf2read.c:4552
    #4 0xcc817f in dw2_expand_symtabs_matching src/gdb/dwarf2read.c:5228
    #5 0xfe8f48 in iterate_over_all_matching_symtabs src/gdb/linespec.c:1147
    #6 0x1003506 in add_matching_symbols_to_info src/gdb/linespec.c:4413
    #7 0xffe21b in find_function_symbols src/gdb/linespec.c:3886
    #8 0xffe4a2 in find_linespec_symbols src/gdb/linespec.c:3914
    #9 0xfee3ad in linespec_parse_basic src/gdb/linespec.c:1865
    #10 0xff5128 in parse_linespec src/gdb/linespec.c:2655
    #11 0xff8872 in event_location_to_sals src/gdb/linespec.c:3150
    #12 0xff90a8 in decode_line_full(event_location const*, int, \
                    program_space*, symtab*, int, linespec_result*, \
    char const*, char const*) src/gdb/linespec.c:3230
    #13 0x9ce449 in parse_breakpoint_sals src/gdb/breakpoint.c:9057
    #14 0x9ea022 in create_sals_from_location_default src/gdb/breakpoint.c:13708
    #15 0x9e2c1f in bkpt_create_sals_from_location src/gdb/breakpoint.c:12514
    #16 0x9cff06 in create_breakpoint(gdbarch*, event_location const*, \
                    char const*, int, char const*, int, int, bptype, int, \
    auto_boolean, breakpoint_ops const*, int, int, int, \
    unsigned int) src/gdb/breakpoint.c:9238
    #17 0x9d114a in break_command_1 src/gdb/breakpoint.c:9402
    #18 0x9d1b60 in break_command(char const*, int) src/gdb/breakpoint.c:9473
    #19 0xac96aa in do_const_cfunc src/gdb/cli/cli-decode.c:106
    #20 0xad0e5a in cmd_func(cmd_list_element*, char const*, int) \
                    src/gdb/cli/cli-decode.c:1892
    #21 0x15226f6 in execute_command(char const*, int) src/gdb/top.c:630
    #22 0xddde37 in command_handler(char const*) src/gdb/event-top.c:586
    #23 0xdde7c1 in command_line_handler(std::unique_ptr<char, \
                    gdb::xfree_deleter<char> >&&) src/gdb/event-top.c:773
    #24 0xddc9e8 in gdb_rl_callback_handler src/gdb/event-top.c:217
    #25 0x16f2198 in rl_callback_read_char src/readline/callback.c:220
    #26 0xddc5a1 in gdb_rl_callback_read_char_wrapper_noexcept \
                    src/gdb/event-top.c:175
    #27 0xddc773 in gdb_rl_callback_read_char_wrapper src/gdb/event-top.c:192
    #28 0xddd9f5 in stdin_event_handler(int, void*) src/gdb/event-top.c:514
    #29 0xdd7d8f in handle_file_event src/gdb/event-loop.c:731
    #30 0xdd8607 in gdb_wait_for_event src/gdb/event-loop.c:857
    #31 0xdd629c in gdb_do_one_event() src/gdb/event-loop.c:321
    #32 0xdd6344 in start_event_loop() src/gdb/event-loop.c:370
    #33 0x10a7715 in captured_command_loop src/gdb/main.c:331
    #34 0x10aa548 in captured_main src/gdb/main.c:1173
    #35 0x10aa5d8 in gdb_main(captured_main_args*) src/gdb/main.c:1188
    #36 0x87bd35 in main src/gdb/gdb.c:32
    #37 0x7f16e1434f89 in __libc_start_main (/lib64/libc.so.6+0x20f89)
    #38 0x87bb49 in _start (build/gdb/gdb+0x87bb49)

0x62500098c93c is located 0 bytes to the right of 8252-byte region \
  [0x62500098a900,0x62500098c93c)
allocated by thread T0 here:
    #0 0x7f16e359a600 in malloc (/usr/lib64/libasan.so.5+0xeb600)
    #1 0x1742ddf in bfd_malloc src/bfd/libbfd.c:275
    #2 0x1738824 in bfd_get_full_section_contents src/bfd/compress.c:253
    #3 0xe30044 in gdb_bfd_map_section(bfd_section*, unsigned long*) \
                   src/gdb/gdb_bfd.c:704
    #4 0xcb56bf in dwarf2_read_section(objfile*, dwarf2_section_info*) \
                   src/gdb/dwarf2read.c:2539
    #5 0xd5bcd0 in get_gdb_index_contents_from_section<dwarf2_per_objfile> \
                   src/gdb/dwarf2read.c:6217
    #6 0xd7fc7d in gdb::function_view<gdb::array_view<unsigned char const> \
                   (...) const src/gdb/common/function-view.h:284
    #7 0xd7fddd in gdb::function_view<gdb::array_view<unsigned char const> \
                   (...) src/gdb/common/function-view.h:278
    #8 0xd730cf in gdb::function_view<gdb::array_view<unsigned char const> \
                   (...) const src/gdb/common/function-view.h:247
    #9 0xcbc7ee in dwarf2_read_gdb_index src/gdb/dwarf2read.c:3582
    #10 0xcce731 in dwarf2_initialize_objfile(objfile*, dw_index_kind*) \
                    src/gdb/dwarf2read.c:6297
    #11 0xdb88c4 in elf_symfile_read src/gdb/elfread.c:1256
    #12 0x141262a in read_symbols src/gdb/symfile.c:798
    #13 0x14140a7 in syms_from_objfile_1 src/gdb/symfile.c:1000
    #14 0x1414393 in syms_from_objfile src/gdb/symfile.c:1017
    #15 0x1414fb7 in symbol_file_add_with_addrs src/gdb/symfile.c:1124
    #16 0x14159b7 in symbol_file_add_from_bfd(bfd*, char const*, \
                     enum_flags<symfile_add_flag>, std::vector<other_sections, \
             std::allocator<other_sections> >*, \
     enum_flags<objfile_flag>, objfile*) src/gdb/symfile.c:1203
    #17 0x1415b6c in symbol_file_add(char const*,
                     enum_flags<symfile_add_flag>, std::vector<other_sections, \
     std::allocator<other_sections> >*, \
     enum_flags<objfile_flag>) src/gdb/symfile.c:1216
    #18 0x1415f2f in symbol_file_add_main_1 src/gdb/symfile.c:1240
    #19 0x1418599 in symbol_file_command(char const*, int) \
                     src/gdb/symfile.c:1675
    #20 0xde2fa6 in file_command src/gdb/exec.c:433
    #21 0xac96aa in do_const_cfunc src/gdb/cli/cli-decode.c:106
    #22 0xad0e5a in cmd_func(cmd_list_element*, char const*, int) \
                    src/gdb/cli/cli-decode.c:1892
    #23 0x15226f6 in execute_command(char const*, int) src/gdb/top.c:630
    #24 0xddde37 in command_handler(char const*) src/gdb/event-top.c:586
    #25 0xdde7c1 in command_line_handler(std::unique_ptr<char, \
                    gdb::xfree_deleter<char> >&&) src/gdb/event-top.c:773
    #26 0xddc9e8 in gdb_rl_callback_handler src/gdb/event-top.c:217
    #27 0x16f2198 in rl_callback_read_char src/readline/callback.c:220
    #28 0xddc5a1 in gdb_rl_callback_read_char_wrapper_noexcept \
                    src/gdb/event-top.c:175
    #29 0xddc773 in gdb_rl_callback_read_char_wrapper src/gdb/event-top.c:192

SUMMARY: AddressSanitizer: heap-buffer-overflow src/gdb/cp-support.c:999 in \
  cp_find_first_component_aux
Shadow bytes around the buggy address:
  0x0c4a801298d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c4a801298e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c4a801298f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c4a80129900: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c4a80129910: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c4a80129920: 00 00 00 00 00 00 00[04]fa fa fa fa fa fa fa fa
  0x0c4a80129930: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c4a80129940: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c4a80129950: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c4a80129960: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c4a80129970: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==31229==ABORTING
...

The problem happens as follows.

The executable amd64-init-x87-values gets an index (due to target board
cc-with-gdb-index), which looks as follows:
...
Hex dump of section '.gdb_index':
  0x00000000 08000000 18000000 28000000 28000000 ........(...(...
  0x00000010 3c000000 3c200000 00000000 00000000 <...< ..........
  0x00000020 2e000000 00000000 d4004000 00000000 ..........@.....
  0x00000030 db004000 00000000 00000000 00000000 ..@.............
  0x00000040 00000000 00000000 00000000 00000000 ................
  0x00000050 00000000 00000000 00000000 00000000 ................
  ... more zeroes ...
  0x00002010 00000000 00000000 00000000 00000000 ................
  0x00002020 00000000 00000000 00000000 00000000 ................
  0x00002030 00000000 00000000 00000000          ............
...

The structure of this index is:
...
header       : [0x0, 0x18)     : size 0x18
culist       : [0x18 ,0x28)    : size 0x10
typesculist  : [0x28, 0x28)    : size 0x0
adress area  : [0x28, 0x3c)    : size 0x14
symbol table : [0x3c, 0x203c)  : size 0x2000
constant pool: [0x203c, 0x203c): size 0x0
EOF          : 0x203c
...

Note that the symbol table consists entirely of empty slots (where an empty
slot is a pair of 32-bit zeroes), and that the constant pool is empty.

The problem happens here in mapped_index_base::build_name_components:
...
  auto count = this->symbol_name_count ();
  for (offset_type idx = 0; idx < count; idx++)
    {
      if (this->symbol_name_slot_invalid (idx))
continue;

      const char *name = this->symbol_name_at (idx);
...
when accessing the slot at idx == 0 in the symbol table,
symbol_name_slot_invalid returns false so we calculate name, which is
calculated using 'constant_pool + symbol_table[idx].name', which means we get
name == constant_pool.  And given that the constant pool is empty, name now
points past the memory allocated for the index, and when we access name[0] for
the first time in cp_find_first_component_aux, we run into the
heap-buffer-overflow.

Fix this by fixing the definition of symbol_name_slot_invalid:
...
-    return bucket.name == 0 && bucket.vec;
+    return bucket.name == 0 && bucket.vec == 0;
...

Tested on x86_64-linux.

gdb/ChangeLog:

2019-06-10  Tom de Vries  <tdevries@suse.de>

PR gdb/24618
* dwarf2read.c (struct mapped_index::symbol_name_slot_invalid): Make
sure an empty slot (defined by a 32-bit zero pair) is recognized as
invalid.

5 years ago[gdb] Fix dynamic-stack-buffer-overflow in linespec_lexer_lex_string
Tom de Vries [Mon, 10 Jun 2019 18:17:14 +0000 (20:17 +0200)]
[gdb] Fix dynamic-stack-buffer-overflow in linespec_lexer_lex_string

When compiling gdb with '-lasan -fsanitizer=address' and running tests with
'export ASAN_OPTIONS="detect_leaks=0:alloc_dealloc_mismatch=0"', I run into:
...
ERROR: GDB process no longer exists
UNRESOLVED: gdb.linespec/cpls-abi-tag.exp: \
  test_abi_tag: completion: at tag: tab complete "b test_abi_tag_function[abi:"
...

In more detail:
...
==3637==ERROR: AddressSanitizer: dynamic-stack-buffer-overflow on address \
  0x7fff5952bbdd at pc 0x000000fe5c57 bp 0x7fff5952af30 sp 0x7fff5952af28
READ of size 1 at 0x7fff5952bbdd thread T0
    #0 0xfe5c56 in linespec_lexer_lex_string src/gdb/linespec.c:727
    #1 0xfe7473 in linespec_lexer_lex_one src/gdb/linespec.c:946
    #2 0xfe799d in linespec_lexer_consume_token src/gdb/linespec.c:982
    #3 0xff446d in parse_linespec src/gdb/linespec.c:2564
    #4 0xff78be in linespec_complete(completion_tracker&, char const*, \
                   symbol_name_match_type) src/gdb/linespec.c:2961
    #5 0xb9299c in complete_address_and_linespec_locations \
                   src/gdb/completer.c:573
    #6 0xb93e90 in location_completer(cmd_list_element*, completion_tracker&, \
                   char const*, char const*) src/gdb/completer.c:919
    #7 0xb940c5 in location_completer_handle_brkchars src/gdb/completer.c:956
    #8 0xb957ec in complete_line_internal_normal_command \
                   src/gdb/completer.c:1208
    #9 0xb96507 in complete_line_internal_1 src/gdb/completer.c:1430
    #10 0xb965c2 in complete_line_internal src/gdb/completer.c:1449
    #11 0xb98630 in gdb_completion_word_break_characters_throw \
                    src/gdb/completer.c:1862
    #12 0xb98838 in gdb_completion_word_break_characters() \
                    src/gdb/completer.c:1897
    #13 0x16c6362 in _rl_find_completion_word src/readline/complete.c:943
    #14 0x16ca8d0 in rl_complete_internal src/readline/complete.c:1843
    #15 0x16c460c in rl_complete src/readline/complete.c:408
    #16 0x16b3368 in _rl_dispatch_subseq src/readline/readline.c:774
    #17 0x16b3092 in _rl_dispatch src/readline/readline.c:724
    #18 0x16b2939 in readline_internal_char src/readline/readline.c:552
    #19 0x16f1fb0 in rl_callback_read_char src/readline/callback.c:201
    #20 0xddc5a1 in gdb_rl_callback_read_char_wrapper_noexcept \
                    src/gdb/event-top.c:175
    #21 0xddc773 in gdb_rl_callback_read_char_wrapper src/gdb/event-top.c:192
    #22 0xddd9f5 in stdin_event_handler(int, void*) src/gdb/event-top.c:514
    #23 0xdd7d8f in handle_file_event src/gdb/event-loop.c:731
    #24 0xdd8607 in gdb_wait_for_event src/gdb/event-loop.c:857
    #25 0xdd629c in gdb_do_one_event() src/gdb/event-loop.c:321
    #26 0xdd6344 in start_event_loop() src/gdb/event-loop.c:370
    #27 0x10a7715 in captured_command_loop src/gdb/main.c:331
    #28 0x10aa548 in captured_main src/gdb/main.c:1173
    #29 0x10aa5d8 in gdb_main(captured_main_args*) src/gdb/main.c:1188
    #30 0x87bd35 in main src/gdb/gdb.c:32
    #31 0x7fb0364c6f89 in __libc_start_main (/lib64/libc.so.6+0x20f89)
    #32 0x87bb49 in _start (build/gdb/gdb+0x87bb49)

Address 0x7fff5952bbdd is located in stack of thread T0 at offset 557 in frame
    #0 0xb93702 in location_completer(cmd_list_element*, completion_tracker&, \
                   char const*, char const*) src/gdb/completer.c:831

  This frame has 4 object(s):
    [32, 40) 'copy'
    [96, 104) 'location'
    [160, 168) 'text'
    [224, 256) 'completion_info' <== Memory access at offset 557 overflows \
                                    this variable
HINT: this may be a false positive if your program uses some custom stack \
      unwind mechanism or swapcontext
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: dynamic-stack-buffer-overflow \
         src/gdb/linespec.c:727 in linespec_lexer_lex_string
Shadow bytes around the buggy address:
  0x10006b29d720: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10006b29d730: 00 00 00 00 00 00 f1 f1 f1 f1 00 f2 f2 f2 f2 f2
  0x10006b29d740: f2 f2 00 f2 f2 f2 f2 f2 f2 f2 00 f2 f2 f2 f2 f2
  0x10006b29d750: f2 f2 00 00 00 00 f3 f3 f3 f3 00 00 00 00 00 00
  0x10006b29d760: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x10006b29d770: 00 00 00 00 ca ca ca ca 00 00 00[05]cb cb cb cb
  0x10006b29d780: 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1
  0x10006b29d790: 00 f2 f2 f2 f2 f2 f2 f2 00 f2 f2 f2 f3 f3 f3 f3
  0x10006b29d7a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10006b29d7b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10006b29d7c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==3637==ABORTING
...

The problem happens in linespec_lexer_lex_string when lexing
"b test_abi_tag_function[abi:\0" (using a notation where we make the implicit
terminating \0 explicit).

We arrrive here with (PARSER_STREAM (parser)) == ":\0":
...
             /* Do not tokenize ABI tags such as "[abi:cxx11]".  */
             else if (PARSER_STREAM (parser) - start > 4
                      && startswith (PARSER_STREAM (parser) - 4, "[abi"))
               ++(PARSER_STREAM (parser));
...
and consume ':', after which we end up here and consume '\0':
...
         /* Advance the stream.  */
         ++(PARSER_STREAM (parser));
...
after which (PARSER_STREAM (parser)) points past the end of the string.

Fix this by removing the first "++(PARSER_STREAM (parser))", and add an assert
to the second one to detect moving past the end-of-string.

Build and tested on x86_64-linux.

gdb/ChangeLog:

2019-06-10  Tom de Vries  <tdevries@suse.de>

PR gdb/24611
* linespec.c (linespec_lexer_lex_string): Remove incorrect
"++(PARSER_STREAM (parser))" for "[abi"-prefixed colon.  Add assert.

5 years ago[gdb/symtab] Fix symbol loading performance regression
Tom de Vries [Mon, 10 Jun 2019 18:05:04 +0000 (20:05 +0200)]
[gdb/symtab] Fix symbol loading performance regression

The commit "[gdb/symtab] Fix language of duplicate static minimal symbol"
introduces a performance regression, when loading a cc1 executable build with
-O0 -g and gcc 7.4.0.  The performance regression, measured in 'real' time is
about 175%.

The slower execution comes from the fact that the fix in symbol_set_names
makes the call to symbol_find_demangled_name unconditional.

Fix this by reverting the commit, and redoing the fix as follows.

Recapturing the original problem, the first time symbol_set_names is called
with gsymbol.language == lang_auto and linkage_name == "_ZL3foov", the name is
not present in the per_bfd->demangled_names_hash hash table, so
symbol_find_demangled_name is called to demangle the name, after which the
mangled/demangled pair is added to the hashtable.  The call to
symbol_find_demangled_name also sets gsymbol.language to lang_cplus.
The second time symbol_set_names is called with gsymbol.language == lang_auto
and linkage_name == "_ZL3foov", the name is present in the hash table, so the
demangled name from the hash table is used.  However, the language of the
symbol remains lang_auto.

Fix this by adding a field language in struct demangled_name_entry, and using
the field in symbol_set_names to set the language of gsymbol, if necessary.

Tested on x86_64-linux.

gdb/ChangeLog:

2019-06-10  Tom de Vries  <tdevries@suse.de>

PR symtab/24545
* symtab.c (struct demangled_name_entry): Add language field.
(symbol_set_names):  Revert "[gdb/symtab] Fix language of duplicate
static minimal symbol".  Set and use language field.

5 years agoFix printing large decimal values in strings.
Nick Clifton [Mon, 10 Jun 2019 14:30:02 +0000 (15:30 +0100)]
Fix printing large decimal values in strings.

PR 24651
* strings.c (print_strings): Use %u to print unsigned values in
decimal.

5 years agoUpdate help text in ada-lang.c
Tom Tromey [Mon, 3 Jun 2019 15:25:39 +0000 (09:25 -0600)]
Update help text in ada-lang.c

I noticed that the "catch assert" help text erroneously claimed to
accept an argument, and while fixing this I went ahead and added
"Usage" text and made other minor updates to the commands in
ada-lang.c.

Tested on x86-64 Fedora 29.

gdb/ChangeLog
2019-06-10  Tom Tromey  <tromey@adacore.com>

* ada-lang.c (_initialize_ada_language): Update help text.

5 years agoRemove newlines from warnings
Tom Tromey [Mon, 3 Jun 2019 14:07:29 +0000 (08:07 -0600)]
Remove newlines from warnings

ARI pointed out that a recent patch introduced a call to "warning"
with a string that ended in a newline:

    https://sourceware.org/ml/gdb-patches/2019-06/msg00000.html

This is generally forbidden, I believe, because warning adds its own
newline.

This patch removes all of the trailing newlines I was able to find.  I
searched for 'warning (.*\\n"' and then fixed the ones where the
newline appeared at the end of the string (some had internal
newlines).

Tested on x86-64 Fedora 29.

gdb/ChangeLog
2019-06-10  Tom Tromey  <tromey@adacore.com>

* m32c-tdep.c (m32c_m16c_address_to_pointer): Don't end warning
with a newline.
* guile/guile.c (handle_boot_error): Don't end warning with a
newline.
* cli/cli-cmds.c (exit_status_set_internal_vars): Don't end
warning with a newline.
* s12z-tdep.c (s12z_skip_prologue): Don't end warning with a
newline.
(s12z_frame_cache): Likewise.
* dwarf-index-cache.c (index_cache::store): Don't end warning with
a newline.
* solib-svr4.c (disable_probes_interface): Don't end warning with
a newline.
* nat/fork-inferior.c (fork_inferior): Don't end warning with a
newline.
* python/python.c (do_finish_initialization): Don't end warning
with a newline.

gdb/gdbserver/ChangeLog
2019-06-10  Tom Tromey  <tromey@adacore.com>

* remote-utils.c (look_up_one_symbol, relocate_instruction): Don't
end warning with a newline.
* linux-s390-low.c (s390_get_wordsize): Don't end warning with a
newline.
* thread-db.c (attach_thread): Don't end warning with a newline.
(thread_db_notice_clone): Likewise.
* tracepoint.c (gdb_agent_helper_thread): Don't end warning with a
newline.
* linux-x86-low.c (x86_get_min_fast_tracepoint_insn_len): Don't
end warning with a newline.

5 years agoAdd support for NetBSD/sh3 core file sections. Merge multiple copies of auxv section...
Christos Zoulas [Mon, 10 Jun 2019 13:41:35 +0000 (14:41 +0100)]
Add support for NetBSD/sh3 core file sections.  Merge multiple copies of auxv section creation into one function.

PR 24650
* elf.c (elfcore_make_auxv_note_section): New function.
(elfcore_grok_note): Use it.
(elfcore_grok_freebsd_note): Likewise.
(elfcore_grok_openbsd_note): Likewise.
(elfcore_grok_netbsd_note): Likewise.  Plus add support for
NT_NETBSDCORE_AUXV notes.

5 years agoUse gdbpy_enter in py-breakpoint.c
Tom Tromey [Fri, 7 Jun 2019 22:08:47 +0000 (16:08 -0600)]
Use gdbpy_enter in py-breakpoint.c

A few spots in py-breakpoint.c acquire the GIL manually.  However,
because these spots generate events, and because events are expected
to be arbitrary gdb-flavored Python code, it's important to use
gdbpy_enter instead, in order to ensure that the other gdb-related
Python globals are set correctly.

This patch makes this change.  Tested on x86-64 Fedora 29.

gdb/ChangeLog
2019-06-10  Tom Tromey  <tom@tromey.com>

* python/py-breakpoint.c (gdbpy_breakpoint_created)
(gdbpy_breakpoint_deleted, gdbpy_breakpoint_modified): Use
gdbpy_enter.

5 years agoDelay allocation of dbx_symfile_info
Tom Tromey [Fri, 7 Jun 2019 21:01:50 +0000 (15:01 -0600)]
Delay allocation of dbx_symfile_info

I noticed that elfread.c always allocates a dbx_symfile_info, even
though this is only ever needed in the unusual case of reading stabs
in ELF.

This patch moves the allocation into dbxread.c, and applies the same
treatment to similar code in coffread.c.

Regression tested on x86-64 Fedora 29.

gdb/ChangeLog
2019-06-10  Tom Tromey  <tromey@adacore.com>

* elfread.c (elf_read_minimal_symbols): Don't set the dbx objfile
data.
(elf_new_init): Don't call stabsread_new_init.
* dbxread.c (coffstab_build_psymtabs): Set dbx objfile data.
(elfstab_build_psymtabs): Likewise.  Call stabsread_new_init.
* coffread.c (coff_symfile_init): Don't set the dbx objfile data.

5 years agoTidy up ar_open by using asprintf to replace xmalloc and sprintf.
Christos Zoulas [Mon, 10 Jun 2019 12:15:23 +0000 (13:15 +0100)]
Tidy up ar_open by using asprintf to replace xmalloc and sprintf.

PR 24649
* arsup.c (ar_open): Use asprintf in place of xmalloc and
sprintf.

5 years agoFix a missing include of <string>
Martin Liska [Fri, 7 Jun 2019 05:36:52 +0000 (07:36 +0200)]
Fix a missing include of <string>

gold/ChangeLog:

2019-06-07  Martin Liska  <mliska@suse.cz>

* errors.h: Include string.

5 years ago[gdb/symtab] Support DW_AT_main_subprogram with -readnow.
Tom de Vries [Mon, 10 Jun 2019 07:28:30 +0000 (09:28 +0200)]
[gdb/symtab] Support DW_AT_main_subprogram with -readnow.

DW_AT_main_subprogram is supported in normal mode in read_partial_die, but not
in -readnow mode.

Fix this by adding support for DW_AT_main_subprogram in read_func_scope.

Tested on x86_64-linux with native and RFC target board readnow (
https://sourceware.org/ml/gdb-patches/2019-05/msg00073.html ).

gdb/ChangeLog:

2019-06-10  Tom de Vries  <tdevries@suse.de>

PR symtab/16264
PR symtab/24517
* dwarf2read.c (read_func_scope): Handle DW_AT_main_subprogram.

5 years agoAutomatic date update in version.in
GDB Administrator [Mon, 10 Jun 2019 00:00:20 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoAutomatic date update in version.in
GDB Administrator [Sun, 9 Jun 2019 00:01:03 +0000 (00:01 +0000)]
Automatic date update in version.in

5 years agoAutomatic date update in version.in
GDB Administrator [Sat, 8 Jun 2019 00:00:34 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoLD/doc: Clarify `-rpath' option's semantics WRT link-time dependencies
Maciej W. Rozycki [Fri, 7 Jun 2019 18:25:21 +0000 (19:25 +0100)]
LD/doc: Clarify `-rpath' option's semantics WRT link-time dependencies

Mention in the description of the `-rpath' LD option the restrictions
the option has with respect to searching link-time dependencies of
shared objects referred in the link.  Previously these restrictions were
only documented along with the `-rpath-link' option, which may not be
the place one would consider when looking for the semantics of `-rpath'.

Copy the relevant part of the `-rpath-link' option description then,
splitting the now overlong paragraph into three, for legibility.

ld/
* ld.texi (Options): Also document `-rpath' option restrictions
in the description of the option itself.

5 years agolibctf: avoid strndup
Nick Alcock [Thu, 6 Jun 2019 13:10:08 +0000 (14:10 +0100)]
libctf: avoid strndup

Not all platforms have it.  Use libiberty xstrndup() instead.

(The include of libiberty.h happens in an unusual place due to the
requirements of synchronization of most source files between this
project and another that does not use libiberty.  It serves to pull
libiberty.h in for all source files in libctf/, which does the trick.)

Tested on x86_64-pc-linux-gnu, x86_64-unknown-freebsd12.0,
sparc-sun-solaris2.11, i686-pc-cygwin, i686-w64-mingw32.

libctf/
* ctf-decls.h: Include <libiberty.h>.
* ctf-lookup.c (ctf_lookup_by_name): Call xstrndup(), not strndup().

5 years agolibctf: explicitly cast more size_t types used in printf()s
Nick Alcock [Thu, 6 Jun 2019 12:59:56 +0000 (13:59 +0100)]
libctf: explicitly cast more size_t types used in printf()s

Unsigned long will always be adequate (the only cases involving an
ssize_t are cases in which no error can be generated, or in which
negative output would require a seriously corrupted file: the latter has
been rewritten on a branch in any case).

Tested on x86_64-pc-linux-gnu, x86_64-unknown-freebsd12.0,
sparc-sun-solaris2.11, i686-pc-cygwin, i686-w64-mingw32.

libctf/
* ctf-dump.c (ctf_dump_format_type): Cast size_t's used in printf()s.
(ctf_dump_objts): Likewise.
(ctf_dump_funcs): Likewise.
(ctf_dump_member): Likewise.
(ctf_dump_str): Likewise.

5 years agolibctf: mark various args as unused in the !HAVE_MMAP case
Nick Alcock [Thu, 6 Jun 2019 12:59:28 +0000 (13:59 +0100)]
libctf: mark various args as unused in the !HAVE_MMAP case

Tested on x86_64-pc-linux-gnu, x86_64-unknown-freebsd12.0,
sparc-sun-solaris2.11, i686-pc-cygwin, i686-w64-mingw32.

libctf/
* ctf-archive.c (arc_mmap_header): Mark fd as potentially unused.
* ctf-subr.c (ctf_data_protect): Mark both args as potentially unused.

5 years agoAutomatic date update in version.in
GDB Administrator [Fri, 7 Jun 2019 00:00:14 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoApply substitute-path to relative filenames as well
Руслан Ижбулатов [Thu, 28 Feb 2019 10:25:41 +0000 (10:25 +0000)]
Apply substitute-path to relative filenames as well

When source file path is relative to the build directory (which
is considered a good practice and is enforced in certain buildsystems,
such as meson), gdb only applies substitute-path to the build directory
path. Then gdb appends the source file path to the rewritten build
directory path, and tries to access that.

This fails if either two of the following conditions are true:
a) The user didn't specify substitute-path for the build directory.
   This is highly likely, since path substitution for build directories
   is not documented anywhere, and since gdb does not tell[0] the user
   the path to the build directory, just the source file path.
b) The source file path changed.
   This can also easily happen, since a source path that is relative
   to the build directory can include any number of directory names
   that are not part of the program source tree (starting with the
   name of the root directory of the source tree). Gdb will not apply
   substitute-path to that relative path, thus there is no way for
   the user to tell gdb about these changes.

This commit changes the code to apply substitute-path to all filenames,
both relative and absolute. This way it is possible to do things like:

set substitute-path ../foobar-1.0 /src/my/foobar-1.0

which is completely in line with the user expectations.

This might break unusual cases where build directory path is also
relative (is that even possible?) and happens to match the path
to the source directory (i.e. happens to match a substitution rule).

[0]: There's a "maintenance info symtabs" command that does show the names
     of the build directories, but normal users are not required to
     know or use that.

gdb/ChangeLog
2019-06-06  Руслан Ижбулатов <lrn1986@gmail.com>

* source.c (find_and_open_source): Also rewrite relative file
names.

5 years agoAdd thread-exit annotation.
Amos Bird [Thu, 6 Jun 2019 17:10:14 +0000 (01:10 +0800)]
Add thread-exit annotation.

gdb/ChangeLog
2019-04-26  Amos Bird  <amosbird@gmail.com>

* annotate.c (annotate_thread_exited): Add "thread-exited"
annotation.

gdb/doc/ChangeLog
2019-06-06  Amos Bird  <amosbird@gmail.com>

* annotate.texinfo (Multi-threaded Apps): Add entry for thread-exited
annotation.

gdb/testsuite/ChangeLog
2019-06-06  Amos Bird  <amosbird@gmail.com>

* gdb.base/annota1.exp (thread_switch): Add test for
thread-exited annotation.

5 years agogas: Add .enqcmd and noenqcmd directives
H.J. Lu [Thu, 6 Jun 2019 14:57:52 +0000 (07:57 -0700)]
gas: Add .enqcmd and noenqcmd directives

2019-06-06  Lili Cui  <lili.cui@intel.com>

* config/tc-i386.c (cpu_arch): Add .enqcmd.
(cpu_noarch): Add noenqcmd.
* doc/c-i386.texi: Document noenqcmd.

5 years agogas: Correct ChangeLog for commit 5d79adc4b22b0abd
H.J. Lu [Thu, 6 Jun 2019 14:55:40 +0000 (07:55 -0700)]
gas: Correct ChangeLog for commit 5d79adc4b22b0abd

5 years agoAdd timestamps to "maint time" output
Tom Tromey [Thu, 11 Apr 2019 17:26:02 +0000 (11:26 -0600)]
Add timestamps to "maint time" output

Currently "maint time" will print the amount of time a command took.
Sometimes, though, it's useful to have a timestamp as well -- for
example if one is correlating a gdb log with some other log.

This patch adds a timestamp to the start and end of each command when
this setting is in effect.

This also removes a "//" comment and changes scoped_command_stats to
use DISABLE_COPY_AND_ASSIGN; two minor things I noticed while working
on the patch.

Tested on x86-64 Fedora 29.

gdb/ChangeLog
2019-06-06  Tom Tromey  <tromey@adacore.com>

* maint.h (class scoped_command_stats): Use
DISABLE_COPY_AND_ASSIGN.
<print_time>: New method.
* maint.c (scoped_command_stats, ~scoped_command_stats): Call
print_time.
(scoped_command_stats::print_time): New method.

gdb/testsuite/ChangeLog
2019-06-06  Tom Tromey  <tromey@adacore.com>

* gdb.base/maint.exp: Expect command started/finished output.

5 years ago[BFD, AArch64] Fix PT_GNU_PROPERTY alignment issue
Sudakshina Das [Thu, 6 Jun 2019 11:27:41 +0000 (12:27 +0100)]
[BFD, AArch64] Fix PT_GNU_PROPERTY alignment issue

If the new GNU property section was being created by the linker
(this will happen only if none of the inputs have any GNU property
section but the command line to the linker forces a bti with
--force-bti), the alignment of the section and hence the program
header of PT_GNU_PROPERTY type was not being set correctly. This
patch fixes this issue.

bfd/ChangeLog:

2019-06-06  Sudakshina Das  <sudi.das@arm.com>

* elfxx-aarch64.c (_bfd_aarch64_elf_link_setup_gnu_properties): Set
alignment of the new gnu property section.

ld/ChangeLog:

2019-06-06  Sudakshina Das  <sudi.das@arm.com>

* testsuite/ld-aarch64/aarch64-elf.exp: Add new tests.
* testsuite/ld-aarch64/property-bti-pac4-a.d: New test.
* testsuite/ld-aarch64/property-bti-pac4-b.d: New test.
* testsuite/ld-aarch64/property-bti-pac4.s: New test.

5 years ago[LD, AArch64] Move ELF options behind -z
Sudakshina Das [Thu, 6 Jun 2019 11:21:14 +0000 (12:21 +0100)]
[LD, AArch64] Move ELF options behind -z

This patch moves the current AArch64 ld options of --force-bti
and --pac-plt to -z force-bti and -z pac-plt since these are
ELF specific options.

*** bfd/ChangeLog ***

2019-06-06  Sudakshina Das  <sudi.das@arm.com>

* bfd-in.h: Change comment.
* bfd-in2.h: Regenerate.
* elfnn-aarch64.c (elfNN_aarch64_merge_gnu_properties): Update warning.
* elfxx-aarch64.c (_bfd_aarch64_elf_link_setup_gnu_properties):
Likwise.

*** ld/ChangeLog ***

2019-06-06  Sudakshina Das  <sudi.das@arm.com>

* NEWS: Update options names.
* emultempl/aarch64elf.em (OPTION_FORCE_BTI, OPTION_PAC_PLT): Remove.
(PARSE_AND_LIST_LONGOPTS): Remove force-bti and pac-plt.
(PARSE_AND_LIST_OPTIONS): Update to -z.
(PARSE_AND_LIST_ARGS_CASE_Z_AARCH64): New.
(PARSE_AND_LIST_ARGS_CASE_Z): Add PARSE_AND_LIST_ARGS_CASE_Z_AARCH64.
(PARSE_AND_LIST_ARGS_CASES): Move cases for these options.
* testsuite/ld-aarch64/bti-pac-plt-1.d: Update option.
* testsuite/ld-aarch64/bti-pac-plt-2.d: Likewise.
* testsuite/ld-aarch64/bti-plt-1.d: Likewise.
* testsuite/ld-aarch64/bti-plt-2.d: Likewise.
* testsuite/ld-aarch64/bti-plt-3.d: Likewise.
* testsuite/ld-aarch64/bti-plt-4.d: Likewise.
* testsuite/ld-aarch64/bti-plt-6.d: Likewise.
* testsuite/ld-aarch64/bti-plt-7.d: Likewise.
* testsuite/ld-aarch64/bti-warn.d: Likewise.
* testsuite/ld-aarch64/pac-plt-1.d: Likewise.
* testsuite/ld-aarch64/pac-plt-2.d: Likewise.

5 years agoAutomatic date update in version.in
GDB Administrator [Thu, 6 Jun 2019 00:00:21 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoi386: Check vector length for EVEX vextractfXX and vinsertfXX
H.J. Lu [Wed, 5 Jun 2019 17:27:08 +0000 (10:27 -0700)]
i386: Check vector length for EVEX vextractfXX and vinsertfXX

Since not all vector lengths are supported by EVEX vextractfXX and
vinsertfXX, decode them only with supported vector lengths.

gas/

PR binutils/24633
* testsuite/gas/i386/disassem.s: Add tests for invalid vector
lengths for EVEX vextractfXX and vinsertfXX.
* testsuite/gas/i386/x86-64-disassem.s: Likewise.
* testsuite/gas/i386/disassem.d: Updated.
* testsuite/gas/i386/x86-64-disassem.d: Likewise.

opcodes/

PR binutils/24633
* i386-dis-evex.h (evex_table): Update EVEX_W_0F3A18_P_2,
EVEX_W_0F3A19_P_2, EVEX_W_0F3A1A_P_2 and EVEX_W_0F3A1B_P_2.
(evex_len_table): EVEX_LEN_0F3A18_P_2_W_0,
EVEX_LEN_0F3A18_P_2_W_1, EVEX_LEN_0F3A19_P_2_W_0,
EVEX_LEN_0F3A19_P_2_W_1, EVEX_LEN_0F3A1A_P_2_W_0,
EVEX_LEN_0F3A1A_P_2_W_1, EVEX_LEN_0F3A1B_P_2_W_0,
EVEX_LEN_0F3A1B_P_2_W_1.
* i386-dis.c (EVEX_LEN_0F3A18_P_2_W_0): New enum.
(EVEX_LEN_0F3A18_P_2_W_1): Likewise.
(EVEX_LEN_0F3A19_P_2_W_0): Likewise.
(EVEX_LEN_0F3A19_P_2_W_1): Likewise.
(EVEX_LEN_0F3A1A_P_2_W_0): Likewise.
(EVEX_LEN_0F3A1A_P_2_W_1): Likewise.
(EVEX_LEN_0F3A1B_P_2_W_0): Likewise.
(EVEX_LEN_0F3A1B_P_2_W_1): Likewise.

5 years agolibctf: eschew %zi format specifier
Nick Alcock [Wed, 5 Jun 2019 12:34:36 +0000 (13:34 +0100)]
libctf: eschew %zi format specifier

Too many platforms don't support it, and we can always safely use %lu or
%li anyway, because the only uses are in debugging output.

libctf/
* ctf-archive.c (ctf_arc_write): Eschew %zi format specifier.
(ctf_arc_open_by_offset): Likewise.
* ctf-create.c (ctf_add_type): Likewise.

5 years agogdb/testsuite: Improve comments in recently added test
Andrew Burgess [Wed, 5 Jun 2019 09:33:54 +0000 (10:33 +0100)]
gdb/testsuite: Improve comments in recently added test

Remove the use of 'I' within some comments in a recently added test.

gdb/testsuite/ChangeLog:

* gdb.arch/riscv-unwind-long-insn-6.s: Remove use of 'I' in
comment.
* gdb.arch/riscv-unwind-long-insn-8.s: Likewise.

5 years agogdb/riscv: Don't error when decoding a 6 or 8 byte instruction
Andrew Burgess [Tue, 4 Jun 2019 09:30:41 +0000 (10:30 +0100)]
gdb/riscv: Don't error when decoding a 6 or 8 byte instruction

If the RISC-V prologue scanner finds a 6 or 8 byte instruction we
currently throw an internal error, which is not great for the user.

A mechanism already exists in the prologue scanner to leave
instructions marked as unknown so that we can stop the prologue scan
without raising an error, this is used for all 2 and 4 byte
instructions that are not part of the small set the prologue scanner
actually understands.

This commit changes GDB so that all 6 and 8 byte instructions are
marked as unknown, rather than causing an error.

gdb/ChangeLog:

* riscv-tdep.c (riscv_insn::decode): Gracefully ignore
instructions of lengths 6 or 8 bytes.

gdb/testsuite/ChangeLog:

* gdb.arch/riscv-unwind-long-insn-6.s: New file.
* gdb.arch/riscv-unwind-long-insn-8.s: New file.
* gdb.arch/riscv-unwind-long-insn.c: New file.
* gdb.arch/riscv-unwind-long-insn.exp: New file.

5 years agoAutomatic date update in version.in
GDB Administrator [Wed, 5 Jun 2019 00:00:20 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoIntroduce and use make_unique_xstrdup
Pedro Alves [Tue, 4 Jun 2019 21:40:54 +0000 (22:40 +0100)]
Introduce and use make_unique_xstrdup

Adds an utility function to make it shorter to write the common case
of wrapping an xstrdup with a unique_xmalloc_ptr, and uses it
throughout.

Note: I tried to put this in common/common-utils.h near skip_spaces,
etc. but that is included in common/common-defs.h before
common/gdb_unique_ptr.h is included, so it would fail to compile
because gdb::unique_xmalloc_ptr isn't defined at that point yet.  I
tried moving the gdb_unique_ptr.h inclusion before common-utils.h, but
that doesn't work because gdb_unique_ptr.h depends on common-utils.h
for xfree.

gdb/ChangeLog:
2019-06-04  Pedro Alves  <palves@redhat.com>

* common/gdb_unique_ptr.h (make_unique_xstrdup): New.

* ada-lang.c (catch_ada_completer): Use make_unique_xstrdup.
* breakpoint.c (condition_completer): Likewise.
* cli/cli-dump.c (scan_expression): Likewise.
* common/filestuff.c (mkdir_recursive): Likewise.
* common/gdb_tilde_expand.c (gdb_tilde_expand_up)
* common/pathstuff.c (gdb_realpath, gdb_realpath_keepfile)
(gdb_abspath): Likewise.
* compile/compile-cplus-types.c
(compile_cplus_instance::decl_name): Likewise.
* completer.c (complete_explicit_location):
(signal_completer, reg_or_group_completer_1): Likewise.
* cp-support.c (cp_remove_params_if_any): Likewise.
* fbsd-tdep.c (fbsd_core_vnode_path): Likewise.
* guile/scm-safe-call.c (gdbscm_safe_eval_string): Likewise.
* infcmd.c (strip_bg_char): Likewise.
* linespec.c (copy_token_string): Likewise.
* mi/mi-main.c (output_cores): Likewise.
* psymtab.c (psymtab_search_name):
* symfile.c (test_set_ext_lang_command): Likewise.
* target.c (target_fileio_read_stralloc): Likewise.
* tui/tui-regs.c (tui_reggroup_completer): Likewise.
* value.c (complete_internalvar): Likewise.

gdb/gdbserver/ChangeLog:
2019-06-04  Pedro Alves  <palves@redhat.com>

* server.c (captured_main): Use make_unique_xstrdup.

5 years agoFix paths to ChangeLog files
Pedro Alves [Tue, 4 Jun 2019 21:44:36 +0000 (22:44 +0100)]
Fix paths to ChangeLog files

5 years agoUse CHAR_BIT instead of NBBY in libctf
Tom Tromey [Tue, 4 Jun 2019 18:16:57 +0000 (12:16 -0600)]
Use CHAR_BIT instead of NBBY in libctf

On x86-64 Fedora 29, I tried to build a mingw-hosted gdb that targets
ppc-linux.  You can do this with:

    ../binutils-gdb/configure --host=i686-w64-mingw32 --target=ppc-linux \
        --disable-{binutils,gas,gold,gprof,ld}

The build failed with these errors in libctf:

In file included from ../../binutils-gdb/libctf/ctf-create.c:20:
../../binutils-gdb/libctf/ctf-create.c: In function 'ctf_add_encoded':
../../binutils-gdb/libctf/ctf-create.c:803:59: error: 'NBBY' undeclared (first use in this function)
   dtd->dtd_data.ctt_size = clp2 (P2ROUNDUP (ep->cte_bits, NBBY) / NBBY);
                                                           ^~~~
../../binutils-gdb/libctf/ctf-impl.h:254:42: note: in definition of macro 'P2ROUNDUP'
 #define P2ROUNDUP(x, align)  (-(-(x) & -(align)))
                                          ^~~~~
../../binutils-gdb/libctf/ctf-create.c:803:59: note: each undeclared identifier is reported only once for each function it appears in
   dtd->dtd_data.ctt_size = clp2 (P2ROUNDUP (ep->cte_bits, NBBY) / NBBY);
                                                           ^~~~
../../binutils-gdb/libctf/ctf-impl.h:254:42: note: in definition of macro 'P2ROUNDUP'
 #define P2ROUNDUP(x, align)  (-(-(x) & -(align)))
                                          ^~~~~
../../binutils-gdb/libctf/ctf-create.c: In function 'ctf_add_slice':
../../binutils-gdb/libctf/ctf-create.c:862:59: error: 'NBBY' undeclared (first use in this function)
   dtd->dtd_data.ctt_size = clp2 (P2ROUNDUP (ep->cte_bits, NBBY) / NBBY);
                                                           ^~~~
../../binutils-gdb/libctf/ctf-impl.h:254:42: note: in definition of macro 'P2ROUNDUP'
 #define P2ROUNDUP(x, align)  (-(-(x) & -(align)))
                                          ^~~~~
../../binutils-gdb/libctf/ctf-create.c: In function 'ctf_add_member_offset':
../../binutils-gdb/libctf/ctf-create.c:1341:21: error: 'NBBY' undeclared (first use in this function)
      off += lsize * NBBY;
                     ^~~~
../../binutils-gdb/libctf/ctf-create.c: In function 'ctf_add_type':
../../binutils-gdb/libctf/ctf-create.c:1822:16: warning: unknown conversion type character 'z' in format [-Wformat=]
   ctf_dprintf ("Conflict for type %s against ID %lx: "
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../binutils-gdb/libctf/ctf-create.c:1823:35: note: format string is defined here
         "union size differs, old %zi, new %zi\n",
                                   ^
../../binutils-gdb/libctf/ctf-create.c:1822:16: warning: unknown conversion type character 'z' in format [-Wformat=]
   ctf_dprintf ("Conflict for type %s against ID %lx: "
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../binutils-gdb/libctf/ctf-create.c:1823:44: note: format string is defined here
         "union size differs, old %zi, new %zi\n",
                                            ^
../../binutils-gdb/libctf/ctf-create.c:1822:16: warning: too many arguments for format [-Wformat-extra-args]
   ctf_dprintf ("Conflict for type %s against ID %lx: "
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This patch fixes the actual errors in here.  I did not try to fix the
printf warnings, though I think someone ought to.

Ok?

libctf/ChangeLog
2019-06-04  Tom Tromey  <tromey@adacore.com>

* ctf-create.c (ctf_add_encoded, ctf_add_slice)
(ctf_add_member_offset): Use CHAR_BIT, not NBBY.

5 years agoi386: Check for reserved VEX.vvvv and EVEX.vvvv
H.J. Lu [Tue, 4 Jun 2019 19:45:20 +0000 (12:45 -0700)]
i386: Check for reserved VEX.vvvv and EVEX.vvvv

If VEX.vvvv and EVEX.vvvv are reserved, they must be all 1s, which are
all 0s in inverted form.  Add check for unused VEX.vvvv and EVEX.vvvv
when disassembling VEX and EVEX instructions.

gas/

PR binutils/24626
* testsuite/gas/i386/disassem.s: Add tests for reserved VEX.vvvv
and EVEX.vvvv.
* testsuite/gas/i386/x86-64-disassem.s: Likewise.
* testsuite/gas/i386/disassem.d: Updated.
* testsuite/gas/i386/x86-64-disassem.d: Likewise.

opcodes/

PR binutils/24626
* i386-dis.c (print_insn): Check for unused VEX.vvvv and
EVEX.vvvv when disassembling VEX and EVEX instructions.
(OP_VEX): Set vex.register_specifier to 0 after readding
vex.register_specifier.
(OP_Vex_2src_1): Likewise.
(OP_Vex_2src_2): Likewise.
(OP_LWP_E): Likewise.
(OP_EX_Vex): Don't check vex.register_specifier.
(OP_XMM_Vex): Likewise.

5 years agolibctf: work on platforms without O_CLOEXEC.
Nick Alcock [Tue, 4 Jun 2019 14:04:49 +0000 (15:04 +0100)]
libctf: work on platforms without O_CLOEXEC.

(Not tested on any such platforms, since I don't have access to any at
the moment.  Testing encouraged.)

libctf/
* configure.ac: Check for O_CLOEXEC.
* ctf-decls.h (O_CLOEXEC): Define (to 0), if need be.
* config.h.in: Regenerate.

5 years agolibctf: look for BSD versus GNU qsort_r signatures
Nick Alcock [Mon, 3 Jun 2019 13:02:09 +0000 (14:02 +0100)]
libctf: look for BSD versus GNU qsort_r signatures

We cannot just look for any declaration of qsort_r, because some
operating systems have a qsort_r that has a different prototype
but which still has a pair of pointers in the right places (the last two
args are interchanged): so use AC_LINK_IFELSE to check for both
known variants of qsort_r(), and swap their args into a consistent order
in a suitable inline function.  (The code for this is taken almost
unchanged from gnulib.)

(Now we are not using AC_LIBOBJ any more, we can use a better name for
the qsort_r replacement as well.)

libctf/
* qsort_r.c: Rename to...
* ctf-qsort_r.c: ... this.
(_quicksort): Define to ctf_qsort_r.
* ctf-decls.h (qsort_r): Remove.
(ctf_qsort_r): Add.
(struct ctf_qsort_arg): New, transport the real ARG and COMPAR.
(ctf_qsort_compar_thunk): Rearrange the arguments to COMPAR.
* Makefile.am (libctf_a_LIBADD): Remove.
(libctf_a_SOURCES): New, add ctf-qsort_r.c.
* ctf-archive.c (ctf_arc_write): Call ctf_qsort_r, not qsort_r.
* ctf-create.c (ctf_update): Likewise.
* configure.ac: Check for BSD versus GNU qsort_r signature.
* Makefile.in: Regenerate.
* config.h.in: Likewise.
* configure: Likewise.

5 years agolibctf: fix use-after-free in function dumping
Nick Alcock [Mon, 3 Jun 2019 19:26:02 +0000 (20:26 +0100)]
libctf: fix use-after-free in function dumping

This is actually a free-before-initializing (i.e. a free of garbage).

libctf/
* ctf-dump.c (ctf_dump_funcs): Free in the right place.

5 years agolibctf: fix the type of ctf_enum.cte_value
Nick Alcock [Mon, 3 Jun 2019 10:38:08 +0000 (11:38 +0100)]
libctf: fix the type of ctf_enum.cte_value

This stops the file format from depending on the size of the host int.
(It does mean that we cannot encode enums with a value > 2^32 on
platforms with an int > 2^32: this will be fixed in the next format
revision.)

include/
* ctf.h (ctf_enum.cte_value): Fix type to int32_t.

5 years agoEnable Intel AVX512_VP2INTERSECT insn
H.J. Lu [Tue, 4 Jun 2019 15:58:21 +0000 (08:58 -0700)]
Enable Intel AVX512_VP2INTERSECT insn

This patch enables support for VP2INTERSECT in binutils.  Please refer to

https://software.intel.com/sites/default/files/managed/c5/15/architecture-instruction-set-extensions-programming-reference.pdf

for VP2INTERSECT details.

Make check-gas is ok.

gas/

2019-06-04  Igor Tsimbalist  <igor.v.tsimbalist@intel.com>
    Lili Cui  <lili.cui@intel.com>

* config/tc-i386.c (cpu_arch): Add .avx512_vp2intersect.
(cpu_noarch): Likewise.
* doc/c-i386.texi: Document avx512_vp2intersect.
* testsuite/gas/i386/i386.exp: Run vp2intersect tests.
* testsuite/gas/i386/vp2intersect-intel.d: New test.
* testsuite/gas/i386/vp2intersect.d: Likewise.
* testsuite/gas/i386/vp2intersect.s: Likewise.
* testsuite/gas/i386/vp2intersect-inval-bcast.l: Likewise.
* testsuite/gas/i386/vp2intersect-inval-bcast.s: Likewise.
* testsuite/gas/i386/x86-64-vp2intersect-intel.d: Likewise.
* testsuite/gas/i386/x86-64-vp2intersect.d: Likewise.
* testsuite/gas/i386/x86-64-vp2intersect.s: Likewise.
* testsuite/gas/i386/x86-64-vp2intersect-inval-bcast.l: Likewise.
* testsuite/gas/i386/x86-64-vp2intersect-inval-bcast.s: Likewise.

opcodes/

2019-06-04  Igor Tsimbalist  <igor.v.tsimbalist@intel.com>
    Lili Cui  <lili.cui@intel.com>

* i386-dis.c (enum): Add PREFIX_EVEX_0F3868, EVEX_W_0F3868_P_3.
* i386-dis-evex.h (evex_table): Add AVX512_VP2INTERSECT
instructions.
* i386-gen.c (cpu_flag_init): Add CPU_AVX512_VP2INTERSECT_FLAGS,
CPU_ANY_AVX512_VP2INTERSECT_FLAGS.
(cpu_flags): Add CpuAVX512_VP2INTERSECT.
* i386-opc.h (enum): Add CpuAVX512_VP2INTERSECT.
(i386_cpu_flags): Add cpuavx512_vp2intersect.
* i386-opc.tbl: Add AVX512_VP2INTERSECT insns.
* i386-init.h: Regenerated.
* i386-tbl.h: Likewise.

5 years agoAdd support for Intel ENQCMD[S] instructions
H.J. Lu [Tue, 4 Jun 2019 15:50:10 +0000 (08:50 -0700)]
Add support for Intel ENQCMD[S] instructions

This patch enables support for ENQCMD[S] in binutils.  Please refer to

https://software.intel.com/sites/default/files/managed/c5/15/architecture-instruction-set-extensions-programming-reference.pdf

for ENQCMD[S] details.

Make check-gas is ok.

gas/ChangeLog:

2019-06-04  Xuepeng Guo  <xuepeng.guo@intel.com>
    Lili Cui  <lili.cui@intel.com>

* doc/c-i386.texi: Document enqcmd.
* testsuite/gas/i386/enqcmd-intel.d: New file.
* testsuite/gas/i386/enqcmd-inval.l: Likewise.
* testsuite/gas/i386/enqcmd-inval.s: Likewise.
* testsuite/gas/i386/enqcmd.d: Likewise.
* testsuite/gas/i386/enqcmd.s: Likewise.
* testsuite/gas/i386/x86-64-enqcmd-intel.d: Likewise.
* testsuite/gas/i386/x86-64-enqcmd-inval.l: Likewise.
* testsuite/gas/i386/x86-64-enqcmd-inval.s: Likewise.
* testsuite/gas/i386/x86-64-enqcmd.d: Likewise.
* testsuite/gas/i386/x86-64-enqcmd.s: Likewise.
* testsuite/gas/i386/i386.exp: Run enqcmd-intel, enqcmd-inval,
enqcmd, x86-64-enqcmd-intel, x86-64-enqcmd-inval,
and x86-64-enqcmd.

opcodes/ChangeLog:

2019-06-04  Xuepeng Guo  <xuepeng.guo@intel.com>
    Lili Cui  <lili.cui@intel.com>

* i386-dis.c (enum): Add MOD_0F38F8_PREFIX_1 and
MOD_0F38F8_PREFIX_3.
(prefix_table): New instructions (see prefix above).
(mod_table): New instructions (see prefix above).
* i386-gen.c (cpu_flag_init): Add entries for enqcmd.
(cpu_flags): Add a bitfield for enqmcd.
* i386-init.h: Regenerated.
* i386-opc.h (enum): Add CpuENQCMD.
(i386_cpu_flags): Add a bitfield for cpuenqcmd.
* i386-opc.tbl: Add enqcmd and enqcmds instructions.
* i386-init.h: Regenerated.
* i386-tbl.h: Regenerated.

5 years agoAdd an objfile getter to gdb.Type
Christian Biesinger via gdb-patches [Thu, 23 May 2019 21:37:29 +0000 (16:37 -0500)]
Add an objfile getter to gdb.Type

This allows users of the Python API to find the objfile where a type
was defined.

gdb/ChangeLog:

gdb/ChangeLog
2019-06-04  Christian Biesinger  <cbiesinger@google.com>

Add objfile property to gdb.Type.
* gdb/NEWS: Mention Python API addition.
* gdb/python/py-type.c (typy_get_objfile): New method.

gdb/doc/ChangeLog
2019-06-04  Christian Biesinger  <cbiesinger@google.com>

* gdb/doc/python.texi: Document new gdb.Type.objfile property.

gdb/testsuite/ChangeLog
2019-06-04  Christian Biesinger  <cbiesinger@google.com>

* gdb/testsuite/gdb.python/py-type.exp: Test for new
  gdb.Type.objfile property.

5 years agoRemove an unnecessary set of parentheses in the arm-dis.c source file.
Alan Hayward [Tue, 4 Jun 2019 13:25:08 +0000 (14:25 +0100)]
Remove an unnecessary set of parentheses in the arm-dis.c source file.

* arm-dis.c (is_mve_unpredictable): Remove spurious paranthesis.

5 years agoAutomatic date update in version.in
GDB Administrator [Tue, 4 Jun 2019 00:00:13 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoDocument in NEWS and gdb.texinfo the "help", "apropos" and "show style" changes.
Philippe Waroquiers [Mon, 3 Jun 2019 19:51:56 +0000 (21:51 +0200)]
Document in NEWS and gdb.texinfo the "help", "apropos" and "show style" changes.

5 years agoUpdate tests following changes to "help" and "apropos"
Philippe Waroquiers [Mon, 3 Jun 2019 19:50:22 +0000 (21:50 +0200)]
Update tests following changes to "help" and "apropos"

Factorizes the testing of the help output, by having a single place
that defines the common help trailer and/or prefix messages.

5 years agoImprove usability and/or readibility of help and apropos output.
Philippe Waroquiers [Fri, 31 May 2019 12:00:47 +0000 (14:00 +0200)]
Improve usability and/or readibility of help and apropos output.

The "help" command can output long list of command names or classes.
Use the title style to style the command names or classes to make
the output more readable.

Similarly, change "apropos" command to also style the command names.

It is sometimes unclear why "apropos REGEXP" lists some commands,
and then the user has to manually do 'help command' for all commands
listed by "apropos" to see more details about the matching commands.

=> Add an optional flag -v so that "apropos -v REGEXP":
  * outputs the full documentation of matching commands.
  * highlights the documentation parts matching REGEXP.

5 years agoAdd highlight style, title style, fputs_highlighted. Improve 'show style'
Philippe Waroquiers [Fri, 31 May 2019 11:47:37 +0000 (13:47 +0200)]
Add highlight style, title style, fputs_highlighted. Improve 'show style'

Have 'show style' and its subcommands using a style to style its output.
This allows the GDB user or developer to use 'show style' to visually see
with one command how all the current styles look like.

Add 2 new styles highlight style, title style and fputs_highlighted function.

Highlight style is used by fputs_highlighted to highlight the parts of
its char *STR argument that match a HIGHLIGHT regexp.
This (and the title style) will be used in a following patch.

5 years agoRevert patch that disables building libctf for non-ELF based targets.
Nick Clifton [Mon, 3 Jun 2019 15:28:15 +0000 (16:28 +0100)]
Revert patch that disables building libctf for non-ELF based targets.

Revert:
binutls 2019-05-29  Nick Clifton  <nickc@redhat.com>

* configure.ac (LIBCTF): Export.  Set to empty for non-ELF based
targets.
(HAVE_LIBCTF): Define if libctf support is available.
* Makefile.am (LIBCTF): Set value to @LIBCTF@.
* objdump.c: Make CTF code conditional upon HAVE_LIBCTF being
defined.
* readelf.c: Likewise.
* configure: Regenerate.
* Makefile.in: Regenerate.
* config.in: Regenerate.

top 2019-05-29  Nick Clifton  <nickc@redhat.com>

* configure.ac (noconfigdirs): Add libctf if the target does not use
the ELF file format.
* configure: Regenerate.

5 years agoDon't waste space in prefix_opcd_indices
Alan Modra [Mon, 3 Jun 2019 02:16:04 +0000 (11:46 +0930)]
Don't waste space in prefix_opcd_indices

* ppc-dis.c (prefix_opcd_indices): Correct size.

5 years agoAutomatic date update in version.in
GDB Administrator [Mon, 3 Jun 2019 00:00:54 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoRemove fromhex implementation from gdbreplay
Tom Tromey [Sat, 1 Jun 2019 15:16:04 +0000 (09:16 -0600)]
Remove fromhex implementation from gdbreplay

gdbreplay had its own implementation of fromhex.  This patch changes
it to use the one in common/.

gdb/gdbserver/ChangeLog
2019-06-02  Tom Tromey  <tom@tromey.com>

* gdbreplay.c (fromhex): Remove.
* Makefile.in (GDBREPLAY_OBS): Add rsp-low.o.

5 years agoAutomatic date update in version.in
GDB Administrator [Sun, 2 Jun 2019 00:01:00 +0000 (00:01 +0000)]
Automatic date update in version.in

5 years agoAutomatic date update in version.in
GDB Administrator [Sat, 1 Jun 2019 00:00:23 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoNEWS and documentation for | (pipe) command.
Philippe Waroquiers [Sat, 4 May 2019 13:39:27 +0000 (15:39 +0200)]
NEWS and documentation for | (pipe) command.

gdb/ChangeLog
* NEWS: Mention new pipe command and new convenience variables.

gdb/doc/ChangeLog
* gdb.texinfo (Shell Commands): Document pipe command.
(Logging Output): Add a reference to pipe command.
(Convenience Variables): Document $_shell_exitcode and
$_shell_exitstatus.

5 years agoTest the | (pipe) command.
Philippe Waroquiers [Sat, 20 Apr 2019 20:17:17 +0000 (22:17 +0200)]
Test the | (pipe) command.

gdb/testsuite/ChangeLog
2019-05-31  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* gdb.base/shell.exp: Test pipe command, $_shell_exitcode,
$_shell_exitsignal.
* gdb.base/default.exp: Update for new convenience variables.

5 years agoImplement | (pipe) command.
Philippe Waroquiers [Sat, 20 Apr 2019 12:14:23 +0000 (14:14 +0200)]
Implement | (pipe) command.

The pipe command allows to run a GDB command, and pipe its output
to a shell command:
  (gdb) help pipe
  Send the output of a gdb command to a shell command.
  Usage: | [COMMAND] | SHELL_COMMAND
  Usage: | -d DELIM COMMAND DELIM SHELL_COMMAND
  Usage: pipe [COMMAND] | SHELL_COMMAND
  Usage: pipe -d DELIM COMMAND DELIM SHELL_COMMAND

  Executes COMMAND and sends its output to SHELL_COMMAND.

  The -d option indicates to use the string DELIM to separate COMMAND
  from SHELL_COMMAND, in alternative to |.  This is useful in
  case COMMAND contains a | character.

  With no COMMAND, repeat the last executed command
  and send its output to SHELL_COMMAND.
  (gdb)

For example:
  (gdb) pipe print some_data_structure | grep -B3 -A3 something

The pipe character is defined as an alias for pipe command, so that
the above can be typed as:
  (gdb) | print some_data_structure | grep -B3 -A3 something

If no GDB COMMAND is given, then the previous command is relaunched,
and its output is sent to the given SHELL_COMMAND.

This also defines convenience vars $_shell_exitcode and $_shell_exitsignal
to record the exit code and exit signal of the last shell command
launched by GDB e.g. by "shell", "pipe", ...

gdb/ChangeLog
2019-05-31  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* cli/cli-cmds.c (pipe_command): New function.
(_initialize_cli_cmds): Call add_com for pipe_command.
Define | as an alias for pipe.
(exit_status_set_internal_vars): New function.
(shell_escape): Call exit_status_set_internal_vars.
cli/cli-decode.c (find_command_name_length): Recognize | as
a single character command.

5 years agoAdd function execute_command_to_ui_file
Philippe Waroquiers [Fri, 26 Apr 2019 18:52:16 +0000 (20:52 +0200)]
Add function execute_command_to_ui_file

2019-05-31  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* gdbcmd.h (execute_command_to_ui_file): New declaration.
top.c (execute_command_to_ui_file): New function, mostly a copy
of execute_command_to_string.
(execute_command_to_string): Implement by calling
execute_command_to_ui_file.

5 years agoAdd previous_saved_command_line to allow a command to repeat a previous command.
Philippe Waroquiers [Sat, 20 Apr 2019 12:02:29 +0000 (14:02 +0200)]
Add previous_saved_command_line to allow a command to repeat a previous command.

Currently, a previous command can be repeated when the user types an
empty line.  This is implemented in handle_line_of_input by
returning saved_command_line in case an empty line has been input.

If we want a command to repeat the previous command, we need to save
the previous saved_command_line, as when a command runs, the saved_command_line
already contains the current command line of the command being executed.

As suggested by Tom, the previous_saved_command_line is made static.
At the same time, saved_command_line is also made static.
The support functions/variables for the repeat command logic are now all
located inside top.c.

gdb/ChangeLog
2019-05-31  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* top.h (saved_command_line): Remove declaration.
* top.c (previous_saved_command_line, previous_repeat_arguments):
New variables.
(saved_command_line): Make static, define together with other
'repeat variables'.
(dont_repeat): Clear repeat_arguments.
(repeat_previous, get_saved_command_line, save_command_line):
New functions.
(gdb_init): Initialize saved_command_line
and previous_saved_command_line.
* main.c (captured_main_1): Remove saved_command_line initialization.
* event-top.c (handle_line_of_input): Update to use
the new 'repeat' related functions instead of direct access to
saved_command_line.
* command.h (repeat_previous, get_saved_command_line,
save_command_line): New declarations.
(dont_repeat): Add comment.

5 years agolibctf: fix a number of build problems found on Solaris and NetBSD
Jose E. Marchesi [Fri, 31 May 2019 09:10:51 +0000 (11:10 +0200)]
libctf: fix a number of build problems found on Solaris and NetBSD

- Use of nonportable <endian.h>
- Use of qsort_r
- Use of zlib without appropriate magic to pull in the binutils zlib
- Use of off64_t without checking (fixed by dropping the unused fields
  that need off64_t entirely)
- signedness problems due to long being too short a type on 32-bit
  platforms: ctf_id_t is now 'unsigned long', and CTF_ERR must be
  used only for functions that return ctf_id_t
- One lingering use of bzero() and of <sys/errno.h>

All fixed, using code from gnulib where possible.

Relatedly, set cts_size in a couple of places it was missed
(string table and symbol table loading upon ctf_bfdopen()).

binutils/
* objdump.c (make_ctfsect): Drop cts_type, cts_flags, and
cts_offset.
* readelf.c (shdr_to_ctf_sect): Likewise.
include/
* ctf-api.h (ctf_sect_t): Drop cts_type, cts_flags, and cts_offset.
(ctf_id_t): This is now an unsigned type.
(CTF_ERR): Cast it to ctf_id_t.  Note that it should only be used
for ctf_id_t-returning functions.
libctf/
* Makefile.am (ZLIB): New.
(ZLIBINC): Likewise.
(AM_CFLAGS): Use them.
(libctf_a_LIBADD): New, for LIBOBJS.
* configure.ac: Check for zlib, endian.h, and qsort_r.
* ctf-endian.h: New, providing htole64 and le64toh.
* swap.h: Code style fixes.
(bswap_identity_64): New.
* qsort_r.c: New, from gnulib (with one added #include).
* ctf-decls.h: New, providing a conditional qsort_r declaration,
and unconditional definitions of MIN and MAX.
* ctf-impl.h: Use it.  Do not use <sys/errno.h>.
(ctf_set_errno): Now returns unsigned long.
* ctf-util.c (ctf_set_errno): Adjust here too.
* ctf-archive.c: Use ctf-endian.h.
(ctf_arc_open_by_offset): Use memset, not bzero.  Drop cts_type,
cts_flags and cts_offset.
(ctf_arc_write): Drop debugging dependent on the size of off_t.
* ctf-create.c: Provide a definition of roundup if not defined.
(ctf_create): Drop cts_type, cts_flags and cts_offset.
(ctf_add_reftype): Do not check if type IDs are below zero.
(ctf_add_slice): Likewise.
(ctf_add_typedef): Likewise.
(ctf_add_member_offset): Cast error-returning ssize_t's to size_t
when known error-free.  Drop CTF_ERR usage for functions returning
int.
(ctf_add_member_encoded): Drop CTF_ERR usage for functions returning
int.
(ctf_add_variable): Likewise.
(enumcmp): Likewise.
(enumadd): Likewise.
(membcmp): Likewise.
(ctf_add_type): Likewise.  Cast error-returning ssize_t's to size_t
when known error-free.
* ctf-dump.c (ctf_is_slice): Drop CTF_ERR usage for functions
returning int: use CTF_ERR for functions returning ctf_type_id.
(ctf_dump_label): Likewise.
(ctf_dump_objts): Likewise.
* ctf-labels.c (ctf_label_topmost): Likewise.
(ctf_label_iter): Likewise.
(ctf_label_info): Likewise.
* ctf-lookup.c (ctf_func_args): Likewise.
* ctf-open.c (upgrade_types): Cast to size_t where appropriate.
(ctf_bufopen): Likewise.  Use zlib types as needed.
* ctf-types.c (ctf_member_iter): Drop CTF_ERR usage for functions
returning int.
(ctf_enum_iter): Likewise.
(ctf_type_size): Likewise.
(ctf_type_align): Likewise.  Cast to size_t where appropriate.
(ctf_type_kind_unsliced): Likewise.
(ctf_type_kind): Likewise.
(ctf_type_encoding): Likewise.
(ctf_member_info): Likewise.
(ctf_array_info): Likewise.
(ctf_enum_value): Likewise.
(ctf_type_rvisit): Likewise.
* ctf-open-bfd.c (ctf_bfdopen): Drop cts_type, cts_flags and
cts_offset.
(ctf_simple_open): Likewise.
(ctf_bfdopen_ctfsect): Likewise.  Set cts_size properly.
* Makefile.in: Regenerate.
* aclocal.m4: Likewise.
* config.h: Likewise.
* configure: Likewise.

5 years agoAutomatic date update in version.in
GDB Administrator [Fri, 31 May 2019 00:00:14 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoRISC-V: Fix lui argument parsing.
Jim Wilson [Thu, 30 May 2019 22:23:10 +0000 (15:23 -0700)]
RISC-V: Fix lui argument parsing.

This fixes a bug reported on the riscv.org sw-dev mailing list.  This
rejects "lui x1,symbol", as a symbol should only be accepted here when
used inside %hi().  Without the fix, this gets assembled as "lui x1,0"
with no relocation which is clearly wrong.

gas/
* config/tc-riscv.c (riscv_ip) <'u'>: Move O_constant check inside if
statement.  Delete O_symbol and O_constant check after if statement.
* testsuite/gas/riscv/auipc-parsing.s: Test lui with missing %hi.
* testsuite/gas/riscv/auipc-parsing.l: Update.

5 years agoTwo comment fixes in gdbtypes.h
Tom Tromey [Thu, 30 May 2019 14:50:22 +0000 (08:50 -0600)]
Two comment fixes in gdbtypes.h

This fixes a couple of comments in gdbtypes.h.  One comment had a
typo; and another comment referred to "Moto", which is presumably some
long-gone Motorola-related project.

Tested by rebuilding.

gdb/ChangeLog
2019-05-30  Tom Tromey  <tromey@adacore.com>

* gdbtypes.h (struct range_bounds) <flag_upper_bound_is_count>:
Fix comment.
(TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED): Rewrite comment.

5 years agoInitialize variable word in complete
Jan Vrany [Thu, 30 May 2019 12:04:26 +0000 (13:04 +0100)]
Initialize variable word in complete

The complete function should set parameter word to the end of the
word to complete. However, completion_find_completion_word may fail,
leaving word uninitialized.

To make sure word is always set, initialize it to the completion point
which is the end of the line parameter.

gdb/Changelog

PR cli/24587
* completer.c (complete): Initialize variable word.

5 years agoRevert "Sync top level files with versions from gcc."
Nick Clifton [Thu, 30 May 2019 10:17:19 +0000 (11:17 +0100)]
Revert "Sync top level files with versions from gcc."

This reverts commit f948b2de97884bfb4e5fc11d40a6bea9e0b096ae.

5 years agoHarmonize readelf's output for version sections.
Nick Clifton [Thu, 30 May 2019 09:17:29 +0000 (10:17 +0100)]
Harmonize readelf's output for version sections.

PR 24627
binutils * readelf.c (process_version_sections): Add 0x prefix to address
display.  Correct indentation.

ld * testsuite/ld-elf/ver_def.vd: Update expected output.

5 years agoAutomatic date update in version.in
GDB Administrator [Thu, 30 May 2019 00:00:14 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoDon't crash is dwarf_decode_macro_bytes's 'body' is NULL, even when '!is_define'
Sergio Durigan Junior [Wed, 29 May 2019 14:36:57 +0000 (10:36 -0400)]
Don't crash is dwarf_decode_macro_bytes's 'body' is NULL, even when '!is_define'

Ref.: https://bugzilla.redhat.com/show_bug.cgi?id=1715008

On commit 7bede82892a06e6c26989803e70f53697392dcf9 ("Don't crash if
dwarf_decode_macro_bytes's 'body' is NULL"), I was too strict when
checking if 'body' is NULL: the check only comprised the case when
'is_define' is true.  However, the corruption of .debug_macro by
rpmbuild's "debugedit" also affects the case when 'is_define' is
false, i.e., when the macro is being undefined.

This commit improves the check and covers both cases now.  This has
been tested on Fedora 30 with a problematic debuginfo, and I don't see
a segfault anymore.

OK to push?

gdb/ChangeLog:
2019-05-29  Sergio Durigan Junior  <sergiodj@redhat.com>

Ref.: https://bugzilla.redhat.com/show_bug.cgi?id=1708192
Ref.: https://bugzilla.redhat.com/show_bug.cgi?id=1715008
* dwarf2read.c (dwarf_decode_macro_bytes): Move check to see if
'body' is NULL to the outter 'if', protecting the '!is_define'
situation as well.

5 years agoFix failure in gdb.ada/complete.exp
Tom Tromey [Tue, 28 May 2019 16:55:59 +0000 (10:55 -0600)]
Fix failure in gdb.ada/complete.exp

I noticed a failure in gdb.ada/complete.exp when testing locally:

    FAIL: gdb.ada/complete.exp: complete break ada

This failed due to this output:

    [...]
    break ada/generated/gnatvsn.ads
    break ada/libgnat/s-excmac.ads
    break ada/sdefault.adb
    break ada/snames.adb
    break ada/snames.ads

This patch updates the regexp to allow "/" and "-" to appear.

gdb/testsuite/ChangeLog
2019-05-29  Tom Tromey  <tromey@adacore.com>

* gdb.ada/complete.exp (test_gdb_no_completion): Add "/" and "-"
to "break complete ada" test case's regexp.

5 years agoMake some DWARF complaints clearer
Tom Tromey [Wed, 22 May 2019 13:08:49 +0000 (09:08 -0400)]
Make some DWARF complaints clearer

I noticed that the complaint in partial_die_parent_scope was not using
dwarf_tag_name, so I changed that.  Then I noticed that dwarf_tag_name
does not show the numeric value for an unrecognized tag, so I changed
that function and all the related functions to do so.

gdb/ChangeLog
2019-05-29  Tom Tromey  <tromey@adacore.com>

* dwarf2read.c (partial_die_parent_scope): Call dwarf_tag_name.
(dwarf_unknown): New function.
(dwarf_tag_name, dwarf_attr_name, dwarf_form_name)
(dwarf_type_encoding_name): Use dwarf_unknown.

5 years agoFix crash in cp_print_value_fields
Tom Tromey [Wed, 29 May 2019 15:34:50 +0000 (09:34 -0600)]
Fix crash in cp_print_value_fields

PR c++/20020 concerns a crash in cp_print_value_fields.  The immediate
cause is that cp_print_value_fields does not handle the case where
value_static_field fails.  This is fixed in this patch by calling
cp_print_static_field from the "try" block.

Digging a bit deeper, the error occurs because GCC does not emit a
DW_AT_const_value for a static constexpr member appearing in a
template class.  I've filed a GCC bug for this.

Tested on x86-64 Fedora 29.

gdb/ChangeLog
2019-05-29  Tom Tromey  <tromey@adacore.com>

PR c++/20020:
* cp-valprint.c (cp_print_value_fields): Call
cp_print_static_field inside "try".

gdb/testsuite/ChangeLog
2019-05-29  Tom Tromey  <tromey@adacore.com>

PR c++/20020:
* gdb.cp/constexpr-field.exp: New file.
* gdb.cp/constexpr-field.cc: New file.

5 years agos12z genelf.em
Alan Modra [Wed, 29 May 2019 13:26:30 +0000 (22:56 +0930)]
s12z genelf.em

This changes s12z to use generic.em and genelf.em, which is more
suited to targets that use the generic linker hash table.  A tweak or
two to some testsuite predicates then gives a clean testsuite result
on the target.

PR 24596
binutils/
* testsuite/lib/binutils-common.exp (supports_gnu_unique): Add
s12z to targets not supporting this feature.
ld/
* emulparams/m9s12zelf.sh (TEMPLATE_NAME): Set to generic.
(EXTRA_EM_FILE): Define to genelf.
* testsuite/lib/ld-lib.exp (uses_genelf): Add s12z.

5 years agoSupport tcl procedure calls in run_dump_test xfail
Alan Modra [Wed, 29 May 2019 13:24:37 +0000 (22:54 +0930)]
Support tcl procedure calls in run_dump_test xfail

Also support tcl procedure calls in the run_ld_link_tests and
run_ld_link_exec_tests optional "xfail" args.  Implements "is_generic"
and renames "is_generic_elf" to "uses_genelf", then uses these procs
in lots of ld tests.

moxie-elf  -FAIL: ld-elf/orphan3
mt-elf  -FAIL: ld-elf/merge
s12z-elf  -FAIL: ld-discard/extern
s12z-elf  -FAIL: ld-discard/start
s12z-elf  -FAIL: ld-discard/static
s12z-elf  -FAIL: PR ld/21703
s12z-elf  -FAIL: PR ld/21703 -r
s12z-elf  -FAIL: Symbol flags copy
s12z-elf  -FAIL: ld-elf/group1
s12z-elf  -FAIL: ld-elf/group3b
s12z-elf  -FAIL: ld-elf/group8a
s12z-elf  -FAIL: ld-elf/group8b
s12z-elf  -FAIL: ld-elf/group9a
s12z-elf  -FAIL: ld-elf/group9b
s12z-elf  -FAIL: ld-elf/linkonce2
s12z-elf  -FAIL: ld-elf/merge2
s12z-elf  -FAIL: ld-elf/merge3
s12z-elf  -FAIL: ld-elf/pr12851
s12z-elf  -FAIL: ld-elf/pr17550c
s12z-elf  -FAIL: ld-elf/pr17550d
s12z-elf  -FAIL: ld-elf/pr22677
s12z-elf  -FAIL: ld-elf/pr22836-1a
s12z-elf  -FAIL: ld-elf/pr22836-1b
s12z-elf  -FAIL: ld-elf/warn1
s12z-elf  -FAIL: ld-elf/warn3

binutils/
* testsuite/lib/binutils-common.exp (run_dump_test): Support
tcl procedures for xfail args.
ld/
* testsuite/lib/ld-lib.exp (run_ld_link_tests): Support procedure
calls in optional "xfail" args.
(run_ld_link_exec_tests): Likewise.
(is_generic): New.
(uses_genelf): Rename from is_generic_elf.  Delete bogus semicolons.
* testsuite/ld-scripts/align.exp: Rename is_generic_elf call.
* testsuite/ld-elf/elf.exp: Use is_generic and uses_genelf.  Delete
xfail_implib var.
* testsuite/ld-elf/sec64k.exp: Use is_generic.
* testsuite/ld-elf/shared.exp: Likewise.
* testsuite/ld-discard/extern.d: Use is_generic in xfail.
* testsuite/ld-discard/start.d: Likewise.
* testsuite/ld-discard/static.d: Likewise.
* testsuite/ld-elf/attributes.d: Likewise.
* testsuite/ld-elf/group1.d: Likewise.
* testsuite/ld-elf/group3b.d: Likewise.
* testsuite/ld-elf/group8a.d: Likewise.
* testsuite/ld-elf/group8b.d: Likewise.
* testsuite/ld-elf/group9a.d: Likewise.
* testsuite/ld-elf/group9b.d: Likewise.
* testsuite/ld-elf/linkonce2.d: Likewise.
* testsuite/ld-elf/merge2.d: Likewise.
* testsuite/ld-elf/merge3.d: Likewise.
* testsuite/ld-elf/pr12851.d: Likewise.
* testsuite/ld-elf/pr12975.d: Likewise.
* testsuite/ld-elf/pr13177.d: Likewise.
* testsuite/ld-elf/pr13195.d: Likewise.
* testsuite/ld-elf/pr17550c.d: Likewise.
* testsuite/ld-elf/pr17550d.d: Likewise.
* testsuite/ld-elf/pr17615.d: Likewise.
* testsuite/ld-elf/pr21562a.d: Likewise.
* testsuite/ld-elf/pr21562b.d: Likewise.
* testsuite/ld-elf/pr21562c.d: Likewise.
* testsuite/ld-elf/pr21562d.d: Likewise.
* testsuite/ld-elf/pr21562i.d: Likewise.
* testsuite/ld-elf/pr21562j.d: Likewise.
* testsuite/ld-elf/pr21562k.d: Likewise.
* testsuite/ld-elf/pr21562l.d: Likewise.
* testsuite/ld-elf/pr21562m.d: Likewise.
* testsuite/ld-elf/pr21562n.d: Likewise.
* testsuite/ld-elf/pr22677.d: Likewise.
* testsuite/ld-elf/pr22836-1a.d: Likewise.
* testsuite/ld-elf/pr22836-1b.d: Likewise.
* testsuite/ld-elf/warn3.d: Likewise.
* testsuite/ld-elf/warn1.d: Likewise and xfail sparc solaris
targets rather than notarget.
* testsuite/ld-elf/compressed1d.d: Use uses_genelf in xfail.
* testsuite/ld-elf/orphan-10.d: Likewise.
* testsuite/ld-elf/orphan-9.d: Likewise.
* testsuite/ld-elf/orphan-region.d: Likewise.
* testsuite/ld-elf/orphan.d: Likewise.
* testsuite/ld-elf/orphan3.d: Likewise.
* testsuite/ld-elf/pr20528a.d: Likewise.
* testsuite/ld-elf/pr20528b.d: Likewise.
* testsuite/ld-elf/pr23658-1a.d: Likewise.
* testsuite/ld-elf/pr23658-1b.d: Likewise.
* testsuite/ld-elf/pr349.d: Likewise.
* testsuite/ld-elf/warn2.d: Likewise and xfail sparc solaris
targets rather than notarget.
* testsuite/ld-elf/merge.d: Correct ms1-*-* to mt-*-*.

5 years agoAdd new GCC 9 warnings to warnings.m4
Tom Tromey [Fri, 10 May 2019 15:25:19 +0000 (09:25 -0600)]
Add new GCC 9 warnings to warnings.m4

GCC 9 has a few new warnings that aren't enabled in the gdb build by
default: -Wdeprecated-copy, -Wdeprecated-copy-dtor, and
-Wredundant-move.  This patch enables them all.

Tested by rebuilding with a new GCC (git master) on x86-64 Fedora 29.

gdb/ChangeLog
2019-05-29  Tom Tromey  <tromey@adacore.com>

* inflow.c (struct terminal_info): Add default operator=.
* configure: Rebuild.
* warning.m4 (AM_GDB_WARNINGS): Add -Wdeprecated-copy,
-Wdeprecated-copy-dtor, -Wredundant-move.

gdb/gdbserver/ChangeLog
2019-05-29  Tom Tromey  <tromey@adacore.com>

* configure: Rebuild.

5 years agoAdd "set print finish"
Tom Tromey [Wed, 15 May 2019 19:06:59 +0000 (13:06 -0600)]
Add "set print finish"

A user wanted to be able to disable the display of the value when
using "finish" -- but still have the value entered into the value
history in case it was useful later on.  Part of the rationale here is
that sometimes the value might be quite large, or expensive to display
(in their case this was compounded by a rogue pretty-printer).

This patch implements this idea.

gdb/ChangeLog
2019-05-29  Tom Tromey  <tromey@adacore.com>

* NEWS: Add entry.
* infcmd.c (print_return_value_1): Handle finish_print
option.
(show_print_finish): New function.
(_initialize_infcmd): Add "set/show print finish" commands.
* valprint.c (user_print_options): Initialize new member.
* valprint.h (struct value_print_options) <finish_print>: New
member.

gdb/doc/ChangeLog
2019-05-29  Tom Tromey  <tromey@adacore.com>

* gdb.texinfo (Continuing and Stepping): Document new
commands.

gdb/testsuite/ChangeLog
2019-05-29  Tom Tromey  <tromey@adacore.com>

* gdb.base/finish.exp (finish_no_print): New proc.
(finish_tests): Call it.

5 years agoUpdate release tools with libctf support.
Nick Clifton [Wed, 29 May 2019 11:49:13 +0000 (12:49 +0100)]
Update release tools with libctf support.

top * src-release.sh (do_proto_toplev): Add libctf to list of
directories that can be disabled.

binutils* README-how-to-make-a-release: Add libctf to list of directories
that need updates in their ChangeLogs.

5 years agoSync top level files with versions from gcc.
Nick Clifton [Wed, 29 May 2019 11:43:42 +0000 (12:43 +0100)]
Sync top level files with versions from gcc.

top * Makefile.def (target_modules): Add libphobos.
(flags_to_pass): Add GDC, GDCFLAGS, GDC_FOR_TARGET and
GDCFLAGS_FOR_TARGET.
(dependencies): Make libphobos depend on libatomic, libbacktrace
configure, and zlib configure.
(language): Add language d.
* Makefile.in: Rebuild.
* Makefile.tpl (BUILD_EXPORTS): Add GDC and GDCFLAGS.
(HOST_EXPORTS): Add GDC.
(POSTSTAGE1_HOST_EXPORTS): Add GDC and GDC_FOR_BUILD.
(BASE_TARGET_EXPORTS): Add GDC.
(GDC_FOR_BUILD, GDC, GDCFLAGS): New variables.
(GDC_FOR_TARGET, GDC_FLAGS_FOR_TARGET): New variables.
(EXTRA_HOST_FLAGS): Add GDC.
(STAGE1_FLAGS_TO_PASS): Add GDC.
(EXTRA_TARGET_FLAGS): Add GDC and GDCFLAGS.
* config-ml.in: Treat GDC and GDCFLAGS like other compiler/flag
environment variables.
* configure: Rebuild.
* configure.ac: Add target-libphobos to target_libraries.  Set and
substitute GDC_FOR_BUILD and GDC_FOR_TARGET.

5 years agoDo not build libctf for targets that do not use the ELF file format.
Nick Clifton [Wed, 29 May 2019 10:31:16 +0000 (11:31 +0100)]
Do not build libctf for targets that do not use the ELF file format.

top * configure.ac (noconfigdirs): Add libctf if the target does not use
the ELF file format.
* configure: Regenerate.

binutils* configure.ac (LIBCTF): Export.  Set to empty for non-ELF based
targets.
(HAVE_LIBCTF): Define if libctf support is available.
* Makefile.am (LIBCTF): Set value to @LIBCTF@.
* objdump.c: Make CTF code conditional upon HAVE_LIBCTF being
defined.
* readelf.c: Likewise.
* configure: Regenerate.
* Makefile.in: Regenerate.
* config.in: Regenerate.

5 years agoFix libctf build on non-ELF targets.
Nick Alcock [Wed, 29 May 2019 09:11:37 +0000 (11:11 +0200)]
Fix libctf build on non-ELF targets.

All machinery works as on ELF, except for automatic loading of ELF
string and symbol tables in the BFD-style open machinery.

        * Makefile.def (dependencies): configure-libctf depends on all-bfd
        and all its deps.
        * Makefile.in: Regenerated.

libctf/
        * configure.in: Check for bfd_section_from_elf_index.
        * configure: Regenerate.
        * config.h.in [HAVE_BFD_ELF]: Likewise.
        * libctf/ctf_open_bfd (ctf_bfdopen_ctfsect): Use it.
        abfd is potentially unused now.

5 years agoAutomatic date update in version.in
GDB Administrator [Wed, 29 May 2019 00:00:28 +0000 (00:00 +0000)]
Automatic date update in version.in

5 years agoMIPS/LD: Skip overflow check for %pcrel_hi relocations
Faraz Shahbazker [Fri, 24 May 2019 01:16:08 +0000 (18:16 -0700)]
MIPS/LD: Skip overflow check for %pcrel_hi relocations

Overflow checks were removed for all hi16 relocations except PC-relative
high relocations per PR ld/16720.  Remove overflow checks from %pcrel_hi
relocations so that we can correctly handle negative offsets from PC.

bfd/
* elfxx-mips.c (mips_elf_calculate_relocation) <R_MIPS_PCHI16>:
Remove overflow check.

ld/
* testsuite/ld-mips-elf/undefweak-overflow.s: Remove test case
for pcrel_hi/pcrel_lo.
* testsuite/ld-mips-elf/undefweak-overflow.d: Update to match.
* testsuite/ld-mips-elf/reloc-pcrel-r6.s: New test source.
* testsuite/ld-mips-elf/reloc-pcrel-r6.d: New test linker script.
* testsuite/ld-mips-elf/reloc-pcrel-r6.ld: New test.
* testsuite/ld-mips-elf/mips-elf.exp: Run the new test.

5 years agox86: Add CheckRegSize to AVX512_BF16 instructions with Disp8ShiftVL
H.J. Lu [Tue, 28 May 2019 17:05:28 +0000 (10:05 -0700)]
x86: Add CheckRegSize to AVX512_BF16 instructions with Disp8ShiftVL

For AVX512 instructions with Disp8ShiftVL and Broadcast, we may need to
add CheckRegSize to check if broadcast matches the destination register
size.

gas/

PR gas/24625
* testsuite/gas/i386/inval-avx512f.s: Add tests for AVX512_BF16
instructions with invalid broadcast.
* testsuite/gas/i386/x86-64-inval-avx512f.s: Likewise.
* testsuite/gas/i386/inval-avx512f.l: Updated.
* testsuite/gas/i386/x86-64-inval-avx512f.l: Likewise.

opcodes/

PR gas/24625
* i386-opc.tbl: Add CheckRegSize to AVX512_BF16 instructions with
Disp8ShiftVL.
* i386-tbl.h: Regenerated.