]> git.ipfire.org Git - thirdparty/binutils-gdb.git/log
thirdparty/binutils-gdb.git
4 years ago[gdb/testsuite] Compile gdb.dwarf2/dw2-error.exp quietly
Tom de Vries [Fri, 24 Apr 2020 11:21:49 +0000 (13:21 +0200)] 
[gdb/testsuite] Compile gdb.dwarf2/dw2-error.exp quietly

When running test-case gdb.dwarf2/dw2-error.exp with target board
cc-with-gdb-index, we get:
...
Running src/gdb/testsuite/gdb.dwarf2/dw2-error.exp ...
gdb compile failed, Dwarf Error: wrong version in compilation unit header \
  (is 153, should be 2, 3, 4 or 5) [in module \
  build/gdb/testsuite/outputs/gdb.dwarf2/dw2-error/.tmp/dw2-error]
...
and similar for target board cc-with-debug-names.

Be less verbose by adding "quiet" to the compile flags.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-04-24  Tom de Vries  <tdevries@suse.de>

* gdb.dwarf2/dw2-error.exp: Add quiet to compile flags.

4 years ago[gdb/testsuite] Reduce errors after gdb exit in default_gdb_start
Tom de Vries [Fri, 24 Apr 2020 10:21:49 +0000 (12:21 +0200)] 
[gdb/testsuite] Reduce errors after gdb exit in default_gdb_start

When running test-case gdb.base/readnever.exp with target board readnow, and
without commit 96038148d0e "[gdb/testsuite] Skip gdb.base/readnever.exp with
target board readnow", we run into a bunch of errors, starting with:
...
spawn gdb -nw -nx -data-directory data-directory -ex set sysroot -readnow \
  --readnever^M
gdb: '--readnow' and '--readnever' cannot be specified simultaneously^M
ERROR: : spawn id exp9 not open
    while executing
"expect {
-i exp9 -timeout 10
        -re "$gdb_prompt $" {
            verbose "Setting height to 0." 2
        }
...

The illegal combination of --readnow and --readnever causes gdb to start,
print an error message and exit.  There's a gdb_expect in default_gdb_start
that is supposed to detect the initial gdb prompt and handle related problems,
but since there's no eof case it succeeds, and default_gdb_start continues as
if the gdb prompt had been detected, causing the error above.

Fix this by adding an eof case to the gdb_expect, such that we have the more
accurate:
...
ERROR: (eof) GDB never initialized.
...

Further errors are triggered in clean_restart, because we're not testing for
gdb_start success.  Fix this by detecting gdb_start failure, and bailing out.

Finally, we're running into further errors in gdb.base/readnever.exp because
we're not testing for clean_restart success.  Fix this by making clean_restart
return -1 upon error, and testing for this.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-04-24  Tom de Vries  <tdevries@suse.de>

* lib/gdb.exp (default_gdb_start): Handle eof.
(clean_restart): Detect and handle gdb_start failure.  Return -1 upon
failure.
* gdb.base/readnever.exp: Handle clean_restart failure.

4 years ago[gdb/contrib] Use temp dir for gdb-add-index in cc-with-tweaks.sh
Tom de Vries [Fri, 24 Apr 2020 09:31:06 +0000 (11:31 +0200)] 
[gdb/contrib] Use temp dir for gdb-add-index in cc-with-tweaks.sh

When running test-case gdb.dwarf2/gdb-index.exp cleanly by issuing this
command:
...
$ rm -Rf build/gdb/testsuite/outputs/gdb.dwarf2/gdb-index
...
before running, it passes both with native and target board
cc-with-gdb-index.

But when we run the test-case first with native and then with
cc-with-gdb-index without intermediate cleanup, we get instead:
...
 Running src/gdb/testsuite/gdb.dwarf2/gdb-index.exp ...
 gdb compile failed, cc-with-tweaks.sh: Index file \
   build/gdb/testsuite/outputs/gdb.dwarf2/gdb-index/gdb-index.gdb-index \
   exists, won't clobber.

                 === gdb Summary ===

 # of untested testcases         1
...

What happens is that the native run produces a file
build/gdb/testsuite/outputs/gdb.dwarf2/gdb-index/gdb-index.gdb-index, which
causes gdb/contrib/cc-with-tweaks.sh to hit this code:
...
index_file="${output_file}.gdb-index"
if [ "$want_index" = true ] && [ -f "$index_file" ]
then
    echo "$myname: Index file $index_file exists, won't clobber." >&2
    exit 1
fi
...

The gdb-add-index script has a problem that it uses temp files alongside the
executable, filed as PR25843.

The code in cc-with-tweaks.sh attempts to detect the case that creating such a
temp file would overwrite an pre-existing file.  It however does this only for
a single file, while gdb-add-index uses more temporary files:
- <exec>.gdb-index
- <exec>.debug_names
- <exec>.debug_str
- <exec>.debug_str.merge
- <exec>.debug_str.err

Fix this by working around PR25843 in a more generic way:
- move the executable into a temp directory
- execute gdb-add-index, allowing it to create any temp file alongside the
  executable in the temp directory
- move the executable back to the original location

Tested on x86_64-linux, with target board cc-with-debug-index.

gdb/ChangeLog:

2020-04-24  Tom de Vries  <tdevries@suse.de>

* contrib/cc-with-tweaks.sh: Remove <exec>.gdb-index file handling.
Run gdb-add-index inside temp dir.

4 years agoreadelf: memory leaks in process_dynamic_section
Alan Modra [Fri, 24 Apr 2020 00:21:38 +0000 (09:51 +0930)] 
readelf: memory leaks in process_dynamic_section

This fixes some code that assumed only one PT_LOAD would contain
DT_SYMTAB.  Which is normally the case, but fuzzers thoroughly mess
with object files.

* readelf.c (get_num_dynamic_syms): Check for nbuckets and nchains
non-zero.
(process_dynamic_section): Call get_num_dynamic_syms once rather
than in segment loop.  Break out of segment loop on a successful
load of dynamic symbols.  Formatting.
(process_object): Return error status from process_dynamic_section.

4 years agoAutomatic date update in version.in
GDB Administrator [Fri, 24 Apr 2020 00:00:20 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 years agoFix infinite loop in is_linked_with_cygwin_dll
Tom Tromey [Thu, 23 Apr 2020 18:15:28 +0000 (12:15 -0600)] 
Fix infinite loop in is_linked_with_cygwin_dll

There were some Windows timeouts after the last merge.  Debugging
showed that these were caused by an infinite loop in
is_linked_with_cygwin_dll when reading C:\Windows\SysWOW64\win32u.dll.

This patch fixes the problem by ensuring that the loop always makes
progress.

gdb/ChangeLog
2020-04-23  Tom Tromey  <tromey@adacore.com>

* windows-tdep.c (is_linked_with_cygwin_dll): Always update "iter"
in loop.

4 years agoFix inline frame unwinding breakage
Luis Machado [Tue, 14 Apr 2020 20:26:22 +0000 (17:26 -0300)] 
Fix inline frame unwinding breakage

There has been some breakage for aarch64-linux, arm-linux and s390-linux in
terms of inline frame unwinding. There may be other targets, but these are
the ones i'm aware of.

The following testcases started to show numerous failures and trigger internal
errors in GDB after commit 1009d92fc621bc4d017029b90a5bfab16e17fde5,
"Find tailcall frames before inline frames".

gdb.opt/inline-break.exp
gdb.opt/inline-cmds.exp
gdb.python/py-frame-inline.exp
gdb.reverse/insn-reverse.exp

The internal errors were of this kind:

binutils-gdb/gdb/frame.c:579: internal-error: frame_id get_frame_id(frame_info*): Assertion `fi->level == 0' failed.

After a lengthy investigation to try and find the cause of these assertions,
it seems we're dealing with some fragile/poorly documented code to handle inline
frames and we are attempting to unwind from this fragile section of code.

Before commit 1009d92fc621bc4d017029b90a5bfab16e17fde5, the tailcall sniffer
was invoked from dwarf2_frame_prev_register. By the time we invoke the
dwarf2_frame_prev_register function, we've probably already calculated the
frame id (via compute_frame_id).

After said commit, the call to dwarf2_tailcall_sniffer_first was moved to
dwarf2_frame_cache. This is very early in a frame creation process, and
we're still calculating the frame ID (so compute_frame_id is in the call
stack).

This would be fine for regular frames, but the above testcases all deal
with some inline frames.

The particularity of inline frames is that their frame ID's depend on
the previous frame's ID, and the previous frame's ID relies in the inline
frame's registers. So it is a bit of a messy situation.

We have comments in various parts of the code warning about some of these
particularities.

In the case of dwarf2_tailcall_sniffer_first, we attempt to unwind the PC,
which goes through various functions until we eventually invoke
frame_unwind_got_register. This function will eventually attempt to create
a lazy value for a particular register, and this lazy value will require
a valid frame ID.  Since the inline frame doesn't have a valid frame ID
yet (remember we're still calculating the previous frame's ID so we can tell
what the inline frame ID is) we will call compute_frame_id for the inline
frame (level 0).

We'll eventually hit the assertion above, inside get_frame_id:

--
      /* If we haven't computed the frame id yet, then it must be that
         this is the current frame.  Compute it now, and stash the
         result.  The IDs of other frames are computed as soon as
         they're created, in order to detect cycles.  See
         get_prev_frame_if_no_cycle.  */
      gdb_assert (fi->level == 0);
--

It seems to me we shouldn't have reached this assertion without having the
inline frame ID already calculated. In fact, it seems we even start recursing
a bit when we invoke get_prev_frame_always within inline_frame_this_id. But
a check makes us quit the recursion and proceed to compute the id.

Here's the call stack for context:

 #0  get_prev_frame_always_1 (this_frame=0xaaaaab85a670) at ../../../repos/binutils-gdb/gdb/frame.c:2109
 RECURSION - #1  0x0000aaaaaae1d098 in get_prev_frame_always (this_frame=0xaaaaab85a670) at ../../../repos/binutils-gdb/gdb/frame.c:2124
 #2  0x0000aaaaaae95768 in inline_frame_this_id (this_frame=0xaaaaab85a670, this_cache=0xaaaaab85a688, this_id=0xaaaaab85a6d0)
     at ../../../repos/binutils-gdb/gdb/inline-frame.c:165
 #3  0x0000aaaaaae1916c in compute_frame_id (fi=0xaaaaab85a670) at ../../../repos/binutils-gdb/gdb/frame.c:550
 #4  0x0000aaaaaae19318 in get_frame_id (fi=0xaaaaab85a670) at ../../../repos/binutils-gdb/gdb/frame.c:582
 #5  0x0000aaaaaae13480 in value_of_register_lazy (frame=0xaaaaab85a730, regnum=30) at ../../../repos/binutils-gdb/gdb/findvar.c:296
 #6  0x0000aaaaaae16c00 in frame_unwind_got_register (frame=0xaaaaab85a730, regnum=30, new_regnum=30) at ../../../repos/binutils-gdb/gdb/frame-unwind.c:268
 #7  0x0000aaaaaad52604 in dwarf2_frame_prev_register (this_frame=0xaaaaab85a730, this_cache=0xaaaaab85a748, regnum=30)
     at ../../../repos/binutils-gdb/gdb/dwarf2/frame.c:1296
 #8  0x0000aaaaaae1ae68 in frame_unwind_register_value (next_frame=0xaaaaab85a730, regnum=30) at ../../../repos/binutils-gdb/gdb/frame.c:1229
 #9  0x0000aaaaaae1b304 in frame_unwind_register_unsigned (next_frame=0xaaaaab85a730, regnum=30) at ../../../repos/binutils-gdb/gdb/frame.c:1320
 #10 0x0000aaaaaab76574 in aarch64_dwarf2_prev_register (this_frame=0xaaaaab85a730, this_cache=0xaaaaab85a748, regnum=32)
     at ../../../repos/binutils-gdb/gdb/aarch64-tdep.c:1114
 #11 0x0000aaaaaad52724 in dwarf2_frame_prev_register (this_frame=0xaaaaab85a730, this_cache=0xaaaaab85a748, regnum=32)
     at ../../../repos/binutils-gdb/gdb/dwarf2/frame.c:1316
 #12 0x0000aaaaaae1ae68 in frame_unwind_register_value (next_frame=0xaaaaab85a730, regnum=32) at ../../../repos/binutils-gdb/gdb/frame.c:1229
 #13 0x0000aaaaaae1b304 in frame_unwind_register_unsigned (next_frame=0xaaaaab85a730, regnum=32) at ../../../repos/binutils-gdb/gdb/frame.c:1320
 #14 0x0000aaaaaae16a84 in default_unwind_pc (gdbarch=0xaaaaab81edc0, next_frame=0xaaaaab85a730) at ../../../repos/binutils-gdb/gdb/frame-unwind.c:223
 #15 0x0000aaaaaae32124 in gdbarch_unwind_pc (gdbarch=0xaaaaab81edc0, next_frame=0xaaaaab85a730) at ../../../repos/binutils-gdb/gdb/gdbarch.c:3074
 #16 0x0000aaaaaad4f15c in dwarf2_tailcall_sniffer_first (this_frame=0xaaaaab85a730, tailcall_cachep=0xaaaaab85a830, entry_cfa_sp_offsetp=0x0)
     at ../../../repos/binutils-gdb/gdb/dwarf2/frame-tailcall.c:388
 #17 0x0000aaaaaad520c0 in dwarf2_frame_cache (this_frame=0xaaaaab85a730, this_cache=0xaaaaab85a748) at ../../../repos/binutils-gdb/gdb/dwarf2/frame.c:1190
 #18 0x0000aaaaaad52204 in dwarf2_frame_this_id (this_frame=0xaaaaab85a730, this_cache=0xaaaaab85a748, this_id=0xaaaaab85a790)
     at ../../../repos/binutils-gdb/gdb/dwarf2/frame.c:1218
 #19 0x0000aaaaaae1916c in compute_frame_id (fi=0xaaaaab85a730) at ../../../repos/binutils-gdb/gdb/frame.c:550
 #20 0x0000aaaaaae1c958 in get_prev_frame_if_no_cycle (this_frame=0xaaaaab85a670) at ../../../repos/binutils-gdb/gdb/frame.c:1927
 #21 0x0000aaaaaae1cc44 in get_prev_frame_always_1 (this_frame=0xaaaaab85a670) at ../../../repos/binutils-gdb/gdb/frame.c:2006
 FIRST CALL - #22 0x0000aaaaaae1d098 in get_prev_frame_always (this_frame=0xaaaaab85a670) at ../../../repos/binutils-gdb/gdb/frame.c:2124
 #23 0x0000aaaaaae18f68 in skip_artificial_frames (frame=0xaaaaab85a670) at ../../../repos/binutils-gdb/gdb/frame.c:495
 #24 0x0000aaaaaae193e8 in get_stack_frame_id (next_frame=0xaaaaab85a670) at ../../../repos/binutils-gdb/gdb/frame.c:596
 #25 0x0000aaaaaae87a54 in process_event_stop_test (ecs=0xffffffffefc8) at ../../../repos/binutils-gdb/gdb/infrun.c:6857
 #26 0x0000aaaaaae86bdc in handle_signal_stop (ecs=0xffffffffefc8) at ../../../repos/binutils-gdb/gdb/infrun.c:6381
 #27 0x0000aaaaaae84fd0 in handle_inferior_event (ecs=0xffffffffefc8) at ../../../repos/binutils-gdb/gdb/infrun.c:5578
 #28 0x0000aaaaaae81588 in fetch_inferior_event (client_data=0x0) at ../../../repos/binutils-gdb/gdb/infrun.c:4020
 #29 0x0000aaaaaae5f7fc in inferior_event_handler (event_type=INF_REG_EVENT, client_data=0x0) at ../../../repos/binutils-gdb/gdb/inf-loop.c:43
 #30 0x0000aaaaaae8d768 in infrun_async_inferior_event_handler (data=0x0) at ../../../repos/binutils-gdb/gdb/infrun.c:9377
 #31 0x0000aaaaaabff970 in check_async_event_handlers () at ../../../repos/binutils-gdb/gdb/async-event.c:291
 #32 0x0000aaaaab27cbec in gdb_do_one_event () at ../../../repos/binutils-gdb/gdbsupport/event-loop.cc:194
 #33 0x0000aaaaaaef1894 in start_event_loop () at ../../../repos/binutils-gdb/gdb/main.c:356
 #34 0x0000aaaaaaef1a04 in captured_command_loop () at ../../../repos/binutils-gdb/gdb/main.c:416
 #35 0x0000aaaaaaef3338 in captured_main (data=0xfffffffff1f0) at ../../../repos/binutils-gdb/gdb/main.c:1254
 #36 0x0000aaaaaaef33a0 in gdb_main (args=0xfffffffff1f0) at ../../../repos/binutils-gdb/gdb/main.c:1269
 #37 0x0000aaaaaab6e0dc in main (argc=6, argv=0xfffffffff348) at ../../../repos/binutils-gdb/gdb/gdb.c:32

The following patch addresses this by using a function that unwinds the PC
from the next (inline) frame directly as opposed to creating a lazy value
that is bound to the next frame's ID (still not computed).

gdb/ChangeLog:

2020-04-23  Luis Machado  <luis.machado@linaro.org>

* dwarf2/frame-tailcall.c (dwarf2_tailcall_sniffer_first): Use
get_frame_register instead of gdbarch_unwind_pc.

4 years ago[gdb/symtab] Prefer def over decl (inter-CU case, with context)
Tom de Vries [Thu, 23 Apr 2020 13:42:47 +0000 (15:42 +0200)] 
[gdb/symtab] Prefer def over decl (inter-CU case, with context)

This is a follow-up patch on "[PATCH][gdb/symtab] Prefer def over decl
(inter-CU case)" (
https://sourceware.org/pipermail/gdb-patches/2020-April/167489.html ).

Consider the test-case from that patch.  It contains a decl and def of var a
in different CUs, and tests whether var a can be printed using the def, even
if the decl is found first.

However, the test-case does this in a contextless environment, so if we add to
the test-case like this to set the context to the CU containing main:
...
 gdb_test "p a" { = \{1, 2\}}
+
+if ![runto_main] then {
+    fail "can't run to main"
+    return 0
+}
+
+gdb_test "p a" { = \{1, 2\}}
...
then the second test fails, because the decl is found in the context.

Fix this by preferring defs over decls in lookup_global_symbol.

Build and reg-tested on x86_64-linux.

gdb/ChangeLog:

2020-04-23  Tom de Vries  <tdevries@suse.de>

* symtab.c (lookup_global_symbol): Prefer def over decl.

gdb/testsuite/ChangeLog:

2020-04-23  Tom de Vries  <tdevries@suse.de>

* gdb.base/decl-before-def.exp: Run to main and print a again.

4 years ago[gdb/symtab] Prefer def over decl (inter-CU case)
Tom de Vries [Thu, 23 Apr 2020 13:42:47 +0000 (15:42 +0200)] 
[gdb/symtab] Prefer def over decl (inter-CU case)

When running test-case gdb.threads/tls.exp with target board -readnow, we
have:
...
(gdb) print a_thread_local^M
Cannot find thread-local storage for process 0, executable file tls/tls:^M
Cannot find thread-local variables on this target^M
(gdb) FAIL: gdb.threads/tls.exp: print a_thread_local
...
while with native we have:
...
(gdb) print a_thread_local^M
Cannot read `a_thread_local' without registers^M
(gdb) PASS: gdb.threads/tls.exp: print a_thread_local
...

The difference in behaviour can be explained as follows.  Without -readnow, we
have two a_thread_locals, the def and the decl, each in a different CU:
...
$ gdb -batch outputs/gdb.threads/tls/tls \
    -ex "maint expand-symtabs" \
    -ex "print a_thread_local" \
    -ex "maint print symbols" \
    | grep "a_thread_local;"
Cannot read `a_thread_local' without registers
 int a_thread_local; computed at runtime
 int a_thread_local; unresolved
...
and with -readnow, we have the opposite order:
...
$ gdb -readnow -batch outputs/gdb.threads/tls/tls  \
    -ex "maint expand-symtabs" \
    -ex "print a_thread_local" \
    -ex "maint print symbols" \
    | grep "a_thread_local;"
Cannot find thread-local storage for process 0, executable file tls/tls:
Cannot find thread-local variables on this target
 int a_thread_local; unresolved
 int a_thread_local; computed at runtime
...

Fix the FAIL by preferring the def over the decl (something we already do
intra-CU since the fix for PR24971, commit 93e55f0a03 "[gdb/symtab] Prefer var
def over decl").

Build and reg-tested on x86_64-linux.

gdb/ChangeLog:

2020-04-23  Tom de Vries  <tdevries@suse.de>

PR symtab/25807
* block.c (best_symbol, better_symbol): Promote to external.
* block.h (best_symbol, better_symbol): Declare.
* symtab.c (lookup_symbol_in_objfile_symtabs): Prefer def over
decl.

gdb/testsuite/ChangeLog:

2020-04-23  Tom de Vries  <tdevries@suse.de>

* gdb.base/decl-before-def-decl.c: New test.
* gdb.base/decl-before-def-def.c: New test.
* gdb.base/decl-before-def.exp: New file.

4 years agoFix Ada crash with .debug_names
Tom Tromey [Thu, 23 Apr 2020 13:19:43 +0000 (07:19 -0600)] 
Fix Ada crash with .debug_names

PR ada/25837 points out a crash in the gdb testsuite when .debug_names
is used.  You can reproduce like:

    runtest --target_board=cc-with-debug-names \
        gdb.ada/big_packed_array.exp

The bug was introduced by commit e0802d599 ("Avoid copying in
lookup_name_info").  The problem is that the return type of
language_lookup_name changed, but in a way that didn't cause existing
callers to trigger a compilation error.  Previously, it returned a
"const string &", but after it returned a "const char *".  This caused
a string to be created in dw2_expand_symtabs_matching_symbol, but one
that had too short of a lifetime; so eventually the matcher cache
would wind up with invalid data.

This patch fixes the problem by updating the callers to use the new
type.

Tested on x86-64 Fedora 30.

gdb/ChangeLog
2020-04-23  Tom Tromey  <tromey@adacore.com>

PR ada/25837:
* dwarf2/read.c (dw2_expand_symtabs_matching_symbol): Store a
"const char *", not a "const std::string &".
<name_and_matcher::operator==>: Update.
* unittests/lookup_name_info-selftests.c: Change type of
"result".

4 years agoRemove iterate_over_inferiors
Tom Tromey [Thu, 23 Apr 2020 12:26:31 +0000 (06:26 -0600)] 
Remove iterate_over_inferiors

The last caller of iterate_over_inferiors is darwin-nat.c.  This patch
removes the calls from this file, and then remove
iterate_over_inferiors.

In general I think "external iteration" is to be preferred in gdb, the
main benefit being that the code is easier to read.

I rebuilt this on Darwin.  I seem to only have access to Darwin
systems where gdb does not yet work :-(, so I can't run the test
suite.

gdb/ChangeLog
2020-04-23  Tom Tromey  <tom@tromey.com>

* inferior.h (iterate_over_inferiors): Don't declare.
* inferior.c (iterate_over_inferiors): Remove.
* darwin-nat.c (find_inferior_task_it, find_inferior_pid_it):
Remove.
(darwin_find_inferior_by_task, darwin_find_inferior_by_pid): Don't
use iterate_over_inferiors.
(darwin_resume_inferior_it)
(struct resume_inferior_threads_param)
(darwin_resume_inferior_threads_it): Remove.
(darwin_nat_target::resume): Don't use iterate_over_inferiors.

Change-Id: Ib2fdf2c98e40f13156ff869ed3173d5f1fdae7ea

4 years agoarc: Add support for ARC HS extra registers in core files
Anton Kolesov [Mon, 15 May 2017 13:17:29 +0000 (16:17 +0300)] 
arc: Add support for ARC HS extra registers in core files

When a coredump is generated, there are a few registers in
ARC HS that are put under a special section, namely ".reg-v2".
It is for backward compatibility reasons with older tools that
we have decided not to extend the generic ".reg" section.

This patch makes it possible to display the information better
regarding that section.  Compare the output of "readelf" without
and with these changes:

$ readelf -n core     # without the patch
  ...
  LINUX    0x0000000c  Unknown note type: (0x00000600)
   description data: 78 08 00 00 2f 6c 64 2d 75 43 6c 69

$ readelf -n core     # with the patch
  ...
  LINUX    0x0000000c  NT_ARC_V2 (ARC HS accumulator/extra registers)
   description data: 78 08 00 00 2f 6c 64 2d 75 43 6c 69

In another commit (soon to be submitted), GDB will makes use of these
changes to parse the extra section and its registers.

bfd/ChangeLog
2020-03-26  Anton Kolesov  <anton.kolesov@synopsys.com>

* elf-bfd.h (elfcore_write_arc_v2): Add prototype.
* elf.c (elfcore_grok_arc_v2): New function.
(elfcore_grok_note): Call the new function to handle the corresponding
note.
(elfcore_write_arc_v2): New function.
(elfcore_write_register_note): Call the new function to handle the
corresponding pseudo-sections.

binutils/ChangeLog
2020-03-26  Anton Kolesov  <anton.kolesov@synopsys.com>

* readelf.c (get_note_type): Handle NT_ARC_V2.

include/elf/ChangeLog
2020-03-26  Anton Kolesov  <anton.kolesov@synopsys.com>

* common.h (NT_ARC_V2): New macro definitions.

4 years ago[gdb/testsuite] Skip gdb.base/readnever.exp with target board readnow
Tom de Vries [Thu, 23 Apr 2020 07:26:02 +0000 (09:26 +0200)] 
[gdb/testsuite] Skip gdb.base/readnever.exp with target board readnow

When running test-case gdb.base/readnever.exp with target board readnow, we
have:
...
spawn gdb -nw -nx -data-directory data-directory -ex set sysroot -readnow \
  --readnever^M
gdb: '--readnow' and '--readnever' cannot be specified simultaneously^M
ERROR: : spawn id exp19 not open
...

Fix this by skipping the test when -readnow/--readnow is detected in
GDBFLAGS.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-04-23  Tom de Vries  <tdevries@suse.de>

* gdb.base/readnever.exp: Skip if GDBFLAGS contain -readnow/--readnow.

4 years ago[gdb/symtab] Fix disassembly of non-contiguous functions
Tom de Vries [Thu, 23 Apr 2020 07:07:50 +0000 (09:07 +0200)] 
[gdb/symtab] Fix disassembly of non-contiguous functions

When running test-case gdb.dwarf2/dw2-ranges-func.exp with target board
readnow, we have:
...
FAIL: gdb.dwarf2/dw2-ranges-func.exp: disassemble foo (pattern 2)
...

The function foo consists of two ranges:
...
 <1><12f>: Abbrev Number: 7 (DW_TAG_subprogram)
    <130>   DW_AT_external    : 1
    <131>   DW_AT_name        : foo
    <135>   DW_AT_ranges      : 0x40
...
which are listed here:
...
    00000040 00000000004004c1 00000000004004dc
    00000040 00000000004004ae 00000000004004ba
...

Normally the disassemble instruction lists both ranges, but with -readnow it
only lists the first.

This is due to function find_pc_partial_function, which only interacts with
partial symtabs, but not with expanded ones.

Fix this by using find_pc_sect_compunit_symtab in find_pc_partial_function.

Tested on x86_64, with native and target board readnow.

This fixes 19 FAILs for target board readnow, in test-cases
gdb.arch/amd64-entry-value.exp, gdb.base/multi-forks.exp,
gdb.dwarf2/dw2-ranges-func.exp and gdb.linespec/skip-two.exp.

gdb/ChangeLog:

2020-04-23  Tom de Vries  <tdevries@suse.de>

* blockframe.c (find_pc_partial_function): Use
find_pc_sect_compunit_symtab rather than
objfile->sf->qf->find_pc_sect_compunit_symtab.

4 years agoxtensa: fix PR ld/25861
Max Filippov [Mon, 20 Apr 2020 02:04:41 +0000 (19:04 -0700)] 
xtensa: fix PR ld/25861

Introduce new relaxations XTENSA_PDIFF{8,16,32} for positive differences
(subtracted symbol precedes diminished symbol) and XTENSA_NDIFF{8,16,32}
for negative differences (subtracted symbol follows diminished symbol).
Don't generate XTENSA_DIFF relocations in the assembler, generate
XTENSA_PDIFF or XTENSA_NDIFF based on relative symbol position.

Handle XTENSA_DIFF in BFD for compatibility with old object files.
Handle XTENSA_PDIFF and XTENSA_NDIFF in BFD, treating difference value
as unsigned.

2020-04-22  Max Filippov  <jcmvbkbc@gmail.com>
bfd/
* bfd-in2.h: Regenerated.
* elf32-xtensa.c (elf_howto_table): New entries for
R_XTENSA_PDIFF{8,16,32} and R_XTENSA_NDIFF{8,16,32}.
(elf_xtensa_reloc_type_lookup, elf_xtensa_do_reloc)
(relax_section): Add cases for R_XTENSA_PDIFF{8,16,32} and
R_XTENSA_NDIFF{8,16,32}.
* libbfd.h (bfd_reloc_code_real_names): Add names for
BFD_RELOC_XTENSA_PDIFF{8,16,32} and
BFD_RELOC_XTENSA_NDIFF{8,16,32}.
* reloc.c: Add documentation for BFD_RELOC_XTENSA_PDIFF{8,16,32}
and BFD_RELOC_XTENSA_NDIFF{8,16,32}.

binutils/
* readelf.c (is_none_reloc): Recognize
BFD_RELOC_XTENSA_PDIFF{8,16,32} and
BFD_RELOC_XTENSA_NDIFF{8,16,32}.

gas/
* config/tc-xtensa.c (md_apply_fix): Replace
BFD_RELOC_XTENSA_DIFF{8,16,32} generation with
BFD_RELOC_XTENSA_PDIFF{8,16,32} and
BFD_RELOC_XTENSA_NDIFF{8,16,32} generation.
* testsuite/gas/xtensa/loc.d: Replace BFD_RELOC_XTENSA_DIFF16
with BFD_RELOC_XTENSA_PDIFF16 in the expected output.

include/
* elf/xtensa.h (elf_xtensa_reloc_type): New entries for
R_XTENSA_PDIFF{8,16,32} and R_XTENSA_NDIFF{8,16,32}.

ld/
* testsuite/ld-xtensa/relax-loc.d: New test definition.
* testsuite/ld-xtensa/relax-loc.s: New test source.
* testsuite/ld-xtensa/xtensa.exp (relax-loc): New test.

4 years agoAutomatic date update in version.in
GDB Administrator [Thu, 23 Apr 2020 00:00:10 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 years agoAdd myself as maintainer for PDP11.
Stephen Casner [Wed, 22 Apr 2020 20:30:36 +0000 (13:30 -0700)] 
Add myself as maintainer for PDP11.

4 years agoFix search of large memory area in gdbserver
Hannes Domani [Wed, 22 Apr 2020 17:05:07 +0000 (19:05 +0200)] 
Fix search of large memory area in gdbserver

If the search area is bigger than SEARCH_CHUNK_SIZE (16000), then you get
an error in gdbserver:
gdb: (gdb) find /w 0x3c43f0,+20000,0x04030201
gdb: Pattern not found.
gdbserver: Unable to access 3997 bytes of target memory at 0x3c8273, halting search.

The return value of any additional gdb_read_memory calls were compared with the
wrong value, this fixes it.

gdbserver/ChangeLog:

2020-04-22  Hannes Domani  <ssbssa@yahoo.de>

* server.cc (handle_search_memory_1): Fix gdb_read_memory return value
comparison.

4 years agoRemove Chris Faylor as the ix86 PE maintainer.
Nick Clifton [Wed, 22 Apr 2020 15:47:34 +0000 (16:47 +0100)] 
Remove Chris Faylor as the ix86 PE maintainer.

* MAINTAINERS: Remove Chris Faylor as the ix86 PE maintainer.

4 years agoFor relative paths in INPUT() and GROUP(), search the directory of the current linker...
Fangrui Song [Wed, 22 Apr 2020 15:20:02 +0000 (16:20 +0100)] 
For relative paths in INPUT() and GROUP(), search the directory of the current linker script before searching other paths.

PR ld/25806
* ldlang.h (struct lang_input_statement_struct): Add extra_search_path.
* ldlang.c (current_input_file): New.
(ldirname): New.
(new_afile): Add from_filename parameter. Set extra_search_path.
(lang_add_input_file): Pass current_input_file to new_afile.
(load_symbols): Set current_input_file.

4 years ago.symver fixes
Alan Modra [Wed, 22 Apr 2020 02:22:13 +0000 (11:52 +0930)] 
.symver fixes

* config/obj-elf.c (elf_frob_symbol): Unconditionally remove
symbol for ".symver .. remove".
* doc/as.texi (.symver): Update.
* testsuite/gas/symver/symver11.s: Make foo weak.
* testsuite/gas/symver/symver11.d: Expect an error.
* testsuite/gas/symver/symver7.d: Allow other random symbols.

4 years ago[gdb/testsuite] Fix .debug_ranges in gdb.mi/dw2-ref-missing-frame-func.c
Tom de Vries [Wed, 22 Apr 2020 12:38:35 +0000 (14:38 +0200)] 
[gdb/testsuite] Fix .debug_ranges in gdb.mi/dw2-ref-missing-frame-func.c

While investigating PR25862 (an assertion failure with target board
cc-with-debug-names), I noticed that the .debug_aranges section in
gdb.mi/dw2-ref-missing-frame-func.c contains a hardcoded 0:
...
"      .4byte  0 \n" // .Ldebug_info0 - Offset of Compilation Unit Info
...

So when looking for an address in the range 0x4004a7-0x4004bf, we should find
the CU at 0xc7:
...
  Compilation Unit @ offset 0xc7:
   Length:        0xba (32-bit)
   Version:       2
   Abbrev Offset: 0x64
   Pointer Size:  4
 <0><d2>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <d3>   DW_AT_high_pc     : 0x4004bf
    <d7>   DW_AT_low_pc      : 0x4004a7
    <db>   DW_AT_name        : file1.txt
    <e5>   DW_AT_producer    : GNU C 3.3.3
    <f1>   DW_AT_language    : 1        (ANSI C)
...
but instead the .debug_aranges entry points us to the CU at 0x0:
...
  Length:                   28
  Version:                  2
  Offset into .debug_info:  0x0
  Pointer Size:             4
  Segment Size:             0

    Address    Length
    004004a7 00000018
    00000000 00000000
...

Fix this by using a label to refer to the start of the CU, similar to how
that's done for gdb.dlang/watch-loc.c in the fix for PR24522:
...
"      .4byte  .Lcu1_begin\n" // .Ldebug_info0 - Offset of Compilation Unit Info
...

The label marks the start of the empty .debug_info section for
dw2-ref-missing-frame-func.c, which is supposed to merge with the .debug_info
section in dw2-ref-missing-frame.S, so in order for that to work, we need to
make sure dw2-ref-missing-frame-func.o comes before dw2-ref-missing-frame.o in
the link line.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-04-22  Tom de Vries  <tdevries@suse.de>

* gdb.mi/dw2-ref-missing-frame-func.c (.debug_aranges): Fix
debug_info_offset.
* gdb.mi/dw2-ref-missing-frame.exp: Make sure $objfuncfile comes
before $objsfile in the line line.

4 years agoCorrect mingw target select
Alan Modra [Wed, 22 Apr 2020 11:39:31 +0000 (21:09 +0930)] 
Correct mingw target select

x86_64-w64-mingw32  +FAIL: ld-scripts/default-script1
x86_64-w64-mingw32  +FAIL: ld-scripts/default-script2
x86_64-w64-mingw32  +FAIL: ld-scripts/default-script3
x86_64-w64-mingw32  +FAIL: ld-scripts/default-script4

* testsuite/ld-scripts/default-script1.d: Correct mingw skip.
* testsuite/ld-scripts/default-script2.d: Likewise.
* testsuite/ld-scripts/default-script3.d: Likewise.
* testsuite/ld-scripts/default-script4.d: Likewise.

4 years agoreadelf: move file related static vars to filedata
Alan Modra [Wed, 22 Apr 2020 05:19:39 +0000 (14:49 +0930)] 
readelf: move file related static vars to filedata

The idea here is to get rid of a lot of file related static vars used
to pass data around, in order to not have stale data about one object
file persisting to the next one.

* readelf.c (archive_file_offset, archive_file_size, dynamic_addr),
(dynamic_size, dynamic_nent, dynamic_strings, dynamic_strings_length),
(num_dynamic_syms, nbuckets, nchains, buckets, chains),
(ngnubuckets, gnubuckets, gnuchains, mipsxlat, ngnuchains),
(gnusymidx, dynamic_symbols, dynamic_syminfo, dynamic_syminfo_offset),
(dynamic_syminfo_nent, program_interpreter, dynamic_info),
(dynamic_info_DT_GNU_HASH, dynamic_info_DT_MIPS_XHASH, version_info),
(dynamic_section, symtab_shndx_list, group_count, section_groups),
(section_headers_groups): Move to struct filedata.  Update use
throughout file.

4 years agoreadelf: cmdline data
Alan Modra [Wed, 22 Apr 2020 05:09:53 +0000 (14:39 +0930)] 
readelf: cmdline data

Don't use a struct filedata for cmdline, which only needs two of the
filedata fields.

* readelf.c (struct dump_data): New, used..
(cmdline): ..here, and..
(struct filedata): ..here.  Adjust all uses.
(request_dump_bynumber, request_dump, parse_args): Pass in a
struct dump_data* rather than Filedata*.  Adjust callers.
(main): Don't set cmdline.file_name.

4 years ago[gdb/testsuite] Fix .debug_aranges in gdb.dlang/watch-loc.c
Tom de Vries [Wed, 22 Apr 2020 11:17:32 +0000 (13:17 +0200)] 
[gdb/testsuite] Fix .debug_aranges in gdb.dlang/watch-loc.c

While investigating PR25862 (an assertion failure with target board
cc-with-debug-names), I noticed that the .debug_aranges section in
gdb.dlang/watch-loc.c contains a hardcoded 0x1000:
...
"      .4byte  _Dmain \n"      // Address
"      .4byte  0x1000 \n"      // Length
...

Fix this by using the actual length of _Dmain, along the lines of how that
is done in gdb.mi/dw2-ref-missing-frame-func.c:
...
"      .4byte  _Dmain_end - _Dmain \n" // Length
...
such that the .debug_aranges entry:
...
    Address    Length
    004004a7 0000000b
    00000000 00000000
...
matches the addresses found in the corresponding CU:
...
 <2><fd>: Abbrev Number: 6 (DW_TAG_subprogram)
    <fe>   DW_AT_name        : _Dmain
    <105>   DW_AT_low_pc      : 0x4004a7
    <10d>   DW_AT_high_pc     : 0x4004b2
...

With this fix the assertion failure is no longer triggered for
gdb.dlang/watch-loc.exp.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-04-22  Tom de Vries  <tdevries@suse.de>

* gdb.dlang/watch-loc.c (.debug_aranges): Fix _Dmain length.

4 years agoChangeLog entries for my last changes.
Mihails Strasuns [Wed, 22 Apr 2020 09:01:04 +0000 (11:01 +0200)] 
ChangeLog entries for my last changes.

4 years ago[gdb/symtab] Store external var decls in psymtab
Tom de Vries [Wed, 22 Apr 2020 06:38:44 +0000 (08:38 +0200)] 
[gdb/symtab] Store external var decls in psymtab

Consider a test-case consisting of source file test.c:
...
extern int aaa;
int
main (void)
{
  return 0;
}
...
and test-2.c:
...
int aaa = 33;
...
compiled with debug info only for test.c:
...
$ gcc -c test.c -g; gcc -c test2.c; gcc test.o test2.o -g
...

When trying to print aaa, we get:
...
$ gdb -batch a.out -ex "print aaa"
'aaa' has unknown type; cast it to its declared type
...
but with -readnow we have:
...
$ gdb -readnow -batch a.out -ex "print aaa"
$1 = 33
...

In the -readnow case, the symbol for aaa in the full symtab has
LOC_UNRESOLVED, and the symbol type is combined with the minimal symbol
address, to read the value and print it without cast.

Without the -readnow, we create partial symbols, but the aaa decl is missing
from the partial symtabs, so we find it only in the minimal symbols, resulting
in the cast request.  If the aaa decl would have been in the partial symtabs,
it would have been found, and the full symtab would have been expanded, after
which things would be as with -readnow.

The function add_partial_symbol has a comment on the LOC_UNRESOLVED +
minimal symbol addres construct at DW_TAG_variable handling:
...
      else if (pdi->is_external)
{
  /* Global Variable.
     Don't enter into the minimal symbol tables as there is
     a minimal symbol table entry from the ELF symbols already.
     Enter into partial symbol table if it has a location
     descriptor or a type.
     If the location descriptor is missing, new_symbol will create
     a LOC_UNRESOLVED symbol, the address of the variable will then
     be determined from the minimal symbol table whenever the variable
     is referenced.
...
but it's not triggered due to this test in scan_partial_symbols:
...
            case DW_TAG_variable:
    ...
              if (!pdi->is_declaration)
                {
                  add_partial_symbol (pdi, cu);
                }
...

Fix this in scan_partial_symbols by allowing external variable decls to be
added to the partial symtabs.

Build and reg-tested on x86_64-linux.

The patch caused this regression:
...
(gdb) print a_thread_local^M
Cannot find thread-local storage for process 0, executable file tls/tls:^M
Cannot find thread-local variables on this target^M
(gdb) FAIL: gdb.threads/tls.exp: print a_thread_local
...
while without the patch we have:
...
(gdb) print a_thread_local^M
Cannot read `a_thread_local' without registers^M
(gdb) PASS: gdb.threads/tls.exp: print a_thread_local
...

However, without the patch but with -readnow we have the same FAIL as with the
patch (filed as PR25807).  In other words, the patch has the effect that we
get the same result with and without -readnow.

This can be explained as follows.  Without the patch, and without -readnow, we
have two a_thread_locals, the def and the decl:
...
$ gdb -batch outputs/gdb.threads/tls/tls \
    -ex "maint expand-symtabs" \
    -ex "print a_thread_local" \
    -ex "maint print symbols" \
    | grep "a_thread_local;"
Cannot read `a_thread_local' without registers
 int a_thread_local; computed at runtime
 int a_thread_local; unresolved
...
while without the patch and with -readnow, we have the opposite order:
...
$ gdb -readnow -batch outputs/gdb.threads/tls/tls  \
    -ex "maint expand-symtabs" \
    -ex "print a_thread_local" \
    -ex "maint print symbols" \
    | grep "a_thread_local;"
Cannot find thread-local storage for process 0, executable file tls/tls:
Cannot find thread-local variables on this target
 int a_thread_local; unresolved
 int a_thread_local; computed at runtime
...

With the patch we have the same order with and without -readnow, but just a
different one than before without -readnow.

Mark the "Cannot find thread-local variables on this target" variant a PR25807
kfail.

gdb/ChangeLog:

2020-04-22  Tom de Vries  <tdevries@suse.de>

PR symtab/25764
* dwarf2/read.c (scan_partial_symbols): Allow external variable decls
in psymtabs.

gdb/testsuite/ChangeLog:

2020-04-22  Tom de Vries  <tdevries@suse.de>

PR symtab/25764
* gdb.base/psym-external-decl-2.c: New test.
* gdb.base/psym-external-decl.c: New test.
* gdb.base/psym-external-decl.exp: New file.
* gdb.threads/tls.exp: Add PR25807 kfail.

4 years ago[gdb/symtab] Find filename in shared psymtab
Tom de Vries [Wed, 22 Apr 2020 06:24:11 +0000 (08:24 +0200)] 
[gdb/symtab] Find filename in shared psymtab

When running test-case gdb.ada/dgopt.exp with target board
unix/-flto/-O0/-flto-partition=none/-ffat-lto-objects and gcc-8, gcc-9 or
gcc-10, and the fix for PR25700, we run into this regression:
...
(gdb) list x.adb:16, 16^M
No source file named x.adb.^M
(gdb) FAIL: gdb.ada/dgopt.exp: list x.adb:16, 16
...

The reason for the failure is that without the fix for PR25700, we
have an unshared psymtab:
...
  { psymtab gdb.ada/dgopt/x.adb ((struct partial_symtab *) $hex)^M
    readin no^M
    fullname (null)^M
    text addresses 0x0 -- 0x0^M
    psymtabs_addrmap_supported yes^M
    globals (none)^M
    statics (none)^M
    dependencies (none)^M
  }^M
...
and a shared psymtab (with user field set):
...
  { psymtab gdb.ada/dgopt/x.adb ((struct partial_symtab *) $hex)^M
    readin no^M
    fullname (null)^M
    text addresses 0x0 -- 0x0^M
    psymtabs_addrmap_supported yes^M
    globals (none)^M
    statics (none)^M
    user <artificial>@0x159a ((struct partial_symtab *) 0x37b57c0)^M
    dependencies (none)^M
  }^M
...

The fix for PR25700 removes the unshared psymtab.

Then when trying to find a psymtab matching x.adb in
psym_map_symtabs_matching_filename, we run into this continue for the shared
psymtab:
...
  for (partial_symtab *pst : require_partial_symbols (objfile, true))
    {
      /* We can skip shared psymtabs here, because any file name will be
        attached to the unshared psymtab.  */
      if (pst->user != NULL)
       continue;
...
and consequently cannot find the file.

Fix this by not skipping the shared symtab in
psym_map_symtabs_matching_filename.

Build and reg-tested on x86_64-linux.

gdb/ChangeLog:

2020-04-22  Tom de Vries  <tdevries@suse.de>

PR symtab/25801
* psymtab.c (psym_map_symtabs_matching_filename): Don't skip shared
symtabs.

gdb/testsuite/ChangeLog:

2020-04-22  Tom de Vries  <tdevries@suse.de>

PR symtab/25801
* gdb.dwarf2/imported-unit.exp: Test that we can get imported_unit.c
in "info source" output.

4 years ago[gdb/symtab] Don't create duplicate psymtab for forward-imported CU
Tom de Vries [Wed, 22 Apr 2020 06:09:45 +0000 (08:09 +0200)] 
[gdb/symtab] Don't create duplicate psymtab for forward-imported CU

Consider the executable generated for test-case gdb.dwarf2/imported-unit.exp.

When loading the executable using various tracing:
...
$ gdb \
  outputs/gdb.dwarf2/imported-unit/imported-unit \
  -batch \
  -iex "set verbose on" \
  -iex "set debug symtab-create 1"
  ...
Created psymtab 0x213f380 for module <artificial>@0xc7.
Created psymtab 0x20e7b00 for module imported_unit.c.
Created psymtab 0x215da20 for module imported_unit.c.
Created psymtab 0x2133630 for module elf-init.c.
Created psymtab 0x215b910 for module ../sysdeps/x86_64/crtn.S.
...
we notice that there are two psymtabs generated for imported_unit.c.

This is due to the following: in dwarf2_build_psymtabs_hard we loop over CUs
and generate partial symtabs for those, and if we encounter an import of
another CU, we also generate a partial symtab for that one, unless already
created.

This works well with backward import references:
- the imported CU is read
- then the importing CU is read
- the import is encountered, but the imported CU is already read, so
  we're done.

But with forward import references, we have instead:
- the importing CU is read
- the import is encountered, and the imported CU is read
- the imported CU is read once more

Fix this by skipping already created psymtabs in the loop in
dwarf2_build_psymtabs_hard.

Tested on x86_64-linux, with native and target board
unix/-flto/-O0/-flto-partition=none/-ffat-lto-objects.

This causes this regression with the target board:
...
FAIL: gdb.ada/dgopt.exp: list x.adb:16, 16
...
which I consider a seperate PR, filed as PR25801 - "Filename of shared psymtab
is ignored".

gdb/ChangeLog:

2020-04-22  Tom de Vries  <tdevries@suse.de>

PR symtab/25700
* dwarf2/read.c (dwarf2_build_psymtabs_hard): Don't create psymtab for
CU if already created.

gdb/testsuite/ChangeLog:

2020-04-22  Tom de Vries  <tdevries@suse.de>

PR symtab/25700
* gdb.dwarf2/imported-unit.exp: Verify that there's only one partial
symtab for imported_unit.c.

4 years agosymver11.s: Add ".balign 8"
H.J. Lu [Wed, 22 Apr 2020 01:21:56 +0000 (18:21 -0700)] 
symver11.s: Add ".balign 8"

Add ".balign 8" to avoid

symver11.s:9: Error: misaligned data

for sh targets.

* testsuite/gas/symver/symver11.s: Add ".balign 8".

4 years agoAutomatic date update in version.in
GDB Administrator [Wed, 22 Apr 2020 00:00:10 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 years agoFix compilation errors with clang in gdb.base/advance.c
Gary Benson [Tue, 21 Apr 2020 15:56:09 +0000 (16:56 +0100)] 
Fix compilation errors with clang in gdb.base/advance.c

Clang fails to compile the above file, with the following errors:
  warning: control reaches end of non-void function [-Wreturn-type]
  warning: too many arguments in call to 'func'

This prevents the following testcases from executing:
  gdb.base/advance.exp
  gdb.base/until-nodebug.exp

gdb/testsuite/ChangeLog:

* gdb.base/advance.c (func): New argument, to match call site.
(func2, func3): Add return statements.

4 years agogdb/infrun: switch the context before 'displaced_step_restore'
Tankut Baris Aktemur [Tue, 21 Apr 2020 15:24:03 +0000 (17:24 +0200)] 
gdb/infrun: switch the context before 'displaced_step_restore'

In infrun.c's 'displaced_step_fixup', as part of the 'finish_step_over'
flow, switch to the eventing thread *before* calling
'displaced_step_restore', because down in the flow ptid-dependent
memory accesses are used via current_inferior() and current_top_target().

Without this patch, the problem is exposed with the scenario below:

   $ gdb -q
   (gdb) maint set target-non-stop on
   (gdb) file a.out
   Reading symbols from a.out...
   (gdb) set remote exec-file a.out
   (gdb) target extended-remote | gdbserver --once --multi -
   ...
   (gdb) add-inferior
   [New inferior 2]
   Added inferior 2 on connection 1 (extended-remote ...)
   (gdb) inferior 2
   [Switching to inferior 2 [<null>] (<noexec>)]
   (gdb) file a.out
   Reading symbols from a.out...
   (gdb) set remote exec-file a.out
   (gdb) run
   ...
   Cannot access memory at address 0x555555555042
   (gdb)

The problem is, down inside 'displaced_step_restore', GDB wants to
access the memory for inferior 2 because of an internal breakpoint.
However, the current inferior and inferior_ptid are out of sync.
While inferior_ptid correctly points to the process of inf 2 that was
just started, current_inferior points to inf 1.  Then, the attempt to
access the memory fails, because target_has_execution results in false
since inf 1 was not started.  I was not able to simplify the failing
scenario, but it shows the problem.

After this patch, we get

  ... same steps above...
  (gdb) run
  ...
  [Inferior 2 (process 28652) exited normally]
  (gdb)

Regression-tested on X86_64 Linux with `make check`s default board file
and also `--target_board=native-extended-gdbserver`.  In fact, the bug
fixed by this patch was exposed when using the native-extended-gdbserver
board file.

gdb/ChangeLog:
2020-04-21  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

* infrun.c (displaced_step_fixup): Switch to the event_thread
before calling displaced_step_restore, not after.

gdb/testsuite/ChangeLog:
2020-04-21  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

* gdb.multi/run-only-second-inf.c: New file.
* gdb.multi/run-only-second-inf.exp: New file.

4 years agoDisallow PC relative for CMPI on MC68000/10
Andreas Schwab [Sat, 18 Apr 2020 12:32:39 +0000 (14:32 +0200)] 
Disallow PC relative for CMPI on MC68000/10

The MC68000/10 decodes the second operand of CMPI strictly as destination
operand, which disallows PC relative addressing, even though the insn
doesn't write to the operand.  This restriction has only been lifted for
the MC68020+ and CPU32.

opcodes:
PR 25848
* m68k-opc.c (m68k_opcodes): Allow pc-rel for second operand of
cmpi only on m68020up and cpu32.

gas:
PR 25848
* testsuite/gas/m68k/operands.s: Add tests for cmpi.
* testsuite/gas/m68k/operands.d: Update.
* testsuite/gas/m68k/op68000.d: Update for new error messages.

4 years agoBFD: Exclude sections with no content from compress check.
Tamar Christina [Tue, 21 Apr 2020 14:16:21 +0000 (15:16 +0100)] 
BFD: Exclude sections with no content from compress check.

The check in bfd_get_full_section_contents is trying to check that we don't
allocate more space for a section than the size of the section is on disk.

Previously we excluded linker created sections since they didn't have a size on
disk.  However we also need to exclude sections with no content as well such as
the BSS section.  Space for these would not have been allocated by the assembler
and so the check would incorrectly fail.

bfd/ChangeLog:

PR binutils/24753
* compress.c (bfd_get_full_section_contents): Exclude sections with no
content.

gas/ChangeLog:

PR binutils/24753
* testsuite/gas/arm/pr24753.d: New test.
* testsuite/gas/arm/pr24753.s: New test.

4 years agoFix linker tests to work with 16-bit targets.
Stephen Casner [Tue, 21 Apr 2020 14:10:52 +0000 (15:10 +0100)] 
Fix linker tests to work with 16-bit targets.

PR 25829
* testsuite/ld-scripts/script.exp (check_script)
(extract_symbol_test): Make test addresses fit in 16 bits.
* testsuite/ld-scripts/memory.t: Likewise.
* testsuite/ld-scripts/memory_sym.t (TXT_LENGTH): Likewise.
* testsuite/ld-scripts/default-script.t (_START): Likewise.
* testsuite/ld-scripts/default-script1.d: Likewise.
* testsuite/ld-scripts/default-script2.d: Likewise.
* testsuite/ld-scripts/default-script3.d: Likewise.
* testsuite/ld-scripts/default-script4.d: Likewise.
* testsuite/ld-scripts/empty-address-1.t: Likewise.
* testsuite/ld-scripts/empty-address-1.d: Likewise.
* testsuite/ld-scripts/empty-address-2a.d: Likewise.
* testsuite/ld-scripts/empty-address-2b.d: Likewise.
* testsuite/ld-misc/start.s: .long -> .dc.a to allow relocation to
fit target address size.
  * testsuite/ld-scripts/empty-address-1.s: Likewise.
* testsuite/ld-scripts/empty-address-2.s: Likewise.

4 years agogdb, btrace: make record-btrace per-inferior
Markus Metzger [Fri, 13 Mar 2020 07:52:49 +0000 (08:52 +0100)] 
gdb, btrace: make record-btrace per-inferior

When there is more than one inferior, the "record btrace" command should
only apply to the current inferior.

gdb/ChangeLog:

2020-03-19  Markus Metzger  <markus.t.metzger@intel.com>

* record-btrace.c (record_btrace_enable_warn): Ignore thread if
its inferior is not recorded by us.
(record_btrace_target_open): Replace call to all_non_exited_threads ()
with call to current_inferior ()->non_exited_threads ().
(record_btrace_target::stop_recording): Likewise.
(record_btrace_target::close): Likewise.
(record_btrace_target::wait): Likewise.
(record_btrace_target::record_stop_replaying): Likewise.

gdb/testsuite/ChangeLog:

2020-03-19  Markus Metzger  <markus.t.metzger@intel.com>

* gdb.btrace/multi-inferior.c: New test.
* gdb.btrace/multi-inferior.exp: New file.

4 years agogdb, btrace: diagnose double and failed enable
Markus Metzger [Fri, 13 Mar 2020 08:58:10 +0000 (09:58 +0100)] 
gdb, btrace: diagnose double and failed enable

GDB silently ignores attempts to enable branch tracing on a thread that is
already recorded.  This shouldn't happen as recording is enabled exactly
once:

  - when the btrace record target is opened for existing threads
  - when a new thread is added while the btrace record target is pushed

GDB also silently ignores if recording is disabled on threads that were not
recorded.  This shouldn't happen, either, since when stopping recording,
we only disable recording on threads that were recorded.

GDB further silently ignores if recording was not enabled by the
corresponding target method.  Also this shouldn't happen since the target
is supposed to already throw an error if recording cannot be enabled.
This new error in btrace_enable catches cases where the target silently
failed to enable recording.

Throw an error in those cases.

This allows us to detect an actual issue more easily.  It will be
addressed in the next patch.

gdb/ChangeLog:

2020-03-19  Markus Metzger  <markus.t.metzger@intel.com>

* btrace.c (btrace_enable): Throw an error on double enables and
when enabling recording fails.
(btrace_disable): Throw an error if the thread is not recorded.

4 years agogdb, btrace: forward fetch_registers for unknown threads
Markus Metzger [Wed, 18 Mar 2020 09:53:41 +0000 (10:53 +0100)] 
gdb, btrace: forward fetch_registers for unknown threads

In the record-btrace target, while replaying, we can only provide the PC
register.  The btrace state is stored in the thread_info.  So, when trying
to determine whether we are currently replaying, GDB calls
find_thread_ptid() to obtain the thread_info.  It also asserts that we do
have a thread_info.

For new threads, libthread-db may fetch registers before the thread is
known to GDB.  In this case, find_thread_ptid() returns nullptr and the
assertion fails.

Forward the fetch_registers request to the target beneath in that case.

gdb/ChangeLog:

2020-03-19  Markus Metzger  <markus.t.metzger@intel.com>

* record-btrace.c (record_btrace_target::fetch_registers): Forward
request if we do not have a thread_info.

gdb/testsuite/ChangeLog:

2020-03-19  Markus Metzger  <markus.t.metzger@intel.com>

* gdb.btrace/enable-new-thread.c: New test.
* gdb.btrace/enable-new-thread.exp: New file.

4 years ago[gdb] Fix hang after ext sigkill
Tom de Vries [Tue, 21 Apr 2020 13:45:57 +0000 (15:45 +0200)] 
[gdb] Fix hang after ext sigkill

Consider the test-case from this patch, compiled with pthread support:
...
$ gcc gdb/testsuite/gdb.threads/killed-outside.c -lpthread -g
...

After running to all_started, we can print pid:
...
$ gdb a.out -ex "b all_started" -ex run -ex "delete 1" -ex "p pid"
...
Reading symbols from a.out...
Breakpoint 1 at 0x40072b: file killed-outside.c, line 29.
Starting program: /data/gdb_versions/devel/a.out
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7ffff77fc700 (LWP 3155)]

Thread 1 "a.out" hit Breakpoint 1, all_started () at killed-outside.c:29
29      }
$1 = 3151
(gdb)
...

If we then kill the inferior using an external SIGKILL:
...
(gdb) shell kill -9 3151
...
and subsequently continue:
...
(gdb) c
Continuing.
Couldn't get registers: No such process.
Couldn't get registers: No such process.
(gdb) Couldn't get registers: No such process.
(gdb) Couldn't get registers: No such process.
(gdb) Couldn't get registers: No such process.
<repeat>
...
gdb hangs repeating the same warning.  Typing control-C no longer helps,
and we have to kill gdb.

This is a regression since commit 873657b9e8 "Preserve selected thread in
all-stop w/ background execution".  The commit adds a
scoped_restore_current_thread typed variable restore_thread to
fetch_inferior_event, and the hang is caused by the constructor throwing an
exception.

Fix this by catching the exception in the constructor.

Build and reg-tested on x86_64-linux.

gdb/ChangeLog:

2020-04-21  Tom de Vries  <tdevries@suse.de>

PR gdb/25471
* thread.c
(scoped_restore_current_thread::scoped_restore_current_thread): Catch
exception in get_frame_id.

gdb/testsuite/ChangeLog:

2020-04-21  Tom de Vries  <tdevries@suse.de>

PR gdb/25471
* gdb.threads/killed-outside.c: New test.
* gdb.threads/killed-outside.exp: New file.

4 years ago[gdb/testsuite] share jit-protocol.h by all jit tests
Mihails Strasuns [Fri, 14 Feb 2020 10:33:41 +0000 (11:33 +0100)] 
[gdb/testsuite] share jit-protocol.h by all jit tests

There was an existing jit-protocol.h defining common symbols needed for
JIT-supporting application, however, it was only used by few tests.
Others redeclared the same symbols.

This unifies all tests to use jit-protocol.h

gdb/testsuite/ChangeLog:

2020-02-18  Mihails Strasuns  <mihails.strasuns@intel.com>

* gdb.base/jit-attach-pie.c: Use jit-protocol.h.
* gdb.base/jit-elf-main.c: Use jit-protocol.h.
* gdb.base/jit-reader-host.c: Use jit-protocol.h.
* gdb.base/jit-reader-simple-jit.c: Use jit-protocol.h.
* gdb.base/jit-protocol.h: Update definitions to match all usage
  contexts.

4 years ago[gdb/testsuite] structured rename of jit test files
Mihails Strasuns [Tue, 11 Feb 2020 12:23:25 +0000 (13:23 +0100)] 
[gdb/testsuite] structured rename of jit test files

Reorganizes how JIT related test files to be more clear what are related
to JIT reader system tests and what use JIT from ELF objfiles. Those two
approaches are quite different in GDB implementation and require very
different test setup. Keeping distinction clear at the file name level
makes it easier to maintain the testsuite.

gdb/testsuite/ChangeLog:

2020-02-18  Mihails Strasuns  <mihails.strasuns@intel.com>

* gdb.base: Rename all jit related test and source files.

4 years ago[gdb/testsuite] allow more registers in gdb.base/jit-reader.exp
Mihails Strasuns [Tue, 11 Feb 2020 12:46:27 +0000 (13:46 +0100)] 
[gdb/testsuite] allow more registers in gdb.base/jit-reader.exp

Fixes jit-reader test failures on systems that have more registers than
expected by the current condition.

On Intel i9-7920X the following extra registers are printed:

k0             0x0                 0
k1             0x0                 0
k2             0x0                 0
k3             0x0                 0
k4             0x0                 0
k5             0x0                 0
k6             0x0                 0
k7             0x0                 0

gdb/testsuite/ChangeLog:

2020-02-18  Mihails Strasuns  <mihails.strasuns@intel.com>

* gdb.base/jit-reader.exp: Relax register output check.

4 years agogas: Extend .symver directive
H.J. Lu [Tue, 21 Apr 2020 12:33:04 +0000 (05:33 -0700)] 
gas: Extend .symver directive

Extend .symver directive to update visibility of the original symbol and
assign one original symbol to different versioned symbols:

  .symver foo, foo@VERS_1, local    # Change foo to a local symbol.
  .symver foo, foo@VERS_2, hidden   # Change foo to a hidden symbol.
  .symver foo, foo@@VERS_3, remove  # Remove foo from symbol table.
  .symver foo, bar@V1               # Assign foo to bar@V1 and baz@V2.
  .symver foo, baz@V2

PR gas/23840
PR gas/25295
* NEWS: Mention .symver extension.
* config/obj-elf.c (obj_elf_find_and_add_versioned_name): New
function.
(obj_elf_symver): Call obj_elf_find_and_add_versioned_name to
add a version name.  Add local, hidden and remove visibility
support.
(elf_frob_symbol): Handle the list of version names.  Update the
original symbol to local, hidden or remove it from the symbol
table.
(elf_frob_file_before_adjust): Handle the list of version names.
* config/obj-elf.h (elf_visibility): New.
(elf_versioned_name_list): Likewise.
(elf_obj_sy): Change local to bitfield. Add rename, bad_version
and visibility.  Change versioned_name pointer to struct
elf_versioned_name_list.
* doc/as.texi: Update .symver directive.
* testsuite/gas/symver/symver.exp: Run all *.d tests.  Add more
error checking tests.
* testsuite/gas/symver/symver6.d: New file.
* testsuite/gas/symver/symver7.d: Likewise.
* testsuite/gas/symver/symver7.s: Likewise.
* testsuite/gas/symver/symver8.d: Likewise.
* testsuite/gas/symver/symver8.s: Likewise.
* testsuite/gas/symver/symver9.s: Likewise.
* testsuite/gas/symver/symver9a.d: Likewise.
* testsuite/gas/symver/symver9b.d: Likewise.
* testsuite/gas/symver/symver10.s: Likewise.
* testsuite/gas/symver/symver10a.d: Likewise.
* testsuite/gas/symver/symver10b.d: Likewise.
* testsuite/gas/symver/symver11.d: Likewise.
* testsuite/gas/symver/symver11.s: Likewise.
* testsuite/gas/symver/symver12.d: Likewise.
* testsuite/gas/symver/symver12.s: Likewise.
* testsuite/gas/symver/symver13.d: Likewise.
* testsuite/gas/symver/symver13.s: Likewise.
* testsuite/gas/symver/symver14.d: Likewise.
* testsuite/gas/symver/symver14.l: Likewise.
* testsuite/gas/symver/symver15.d: Likewise.
* testsuite/gas/symver/symver15.l: Likewise.
* testsuite/gas/symver/symver6.l: Removed.
* testsuite/gas/symver/symver6.s: Updated.

4 years agoelf: Strip zero-sized dynamic sections
H.J. Lu [Tue, 21 Apr 2020 12:23:51 +0000 (05:23 -0700)] 
elf: Strip zero-sized dynamic sections

ELF size_dynamic_sections is called by the ELF backend linker after all
the linker input files have been seen but before the section sizes have
been set.  After the sections sizes have been set, target-specific,
global optimizations may make some dynamic sections zero-sized if they
are no longer needed.

Add ELF strip_zero_sized_dynamic_sections so that ELF backend linker can
strip zero-sized dynamic sections after the sections sizes have been set.

bfd/

PR ld/25849
* elf-bfd.h (elf_backend_data): Add
elf_backend_strip_zero_sized_dynamic_sections.
(_bfd_elf_strip_zero_sized_dynamic_sections): New prototype.
* elf64-alpha.c (elf_backend_strip_zero_sized_dynamic_sections):
New macro.
* elflink.c (_bfd_elf_strip_zero_sized_dynamic_sections): New
function.
* elfxx-target.h (elf_backend_strip_zero_sized_dynamic_sections):
New macro.
(elfNN_bed): Add elf_backend_strip_zero_sized_dynamic_sections.

ld/

PR ld/25849
* ldelfgen.c (ldelf_map_segments): Call
elf_backend_strip_zero_sized_dynamic_sections.
* testsuite/ld-alpha/tlsbinr.rd: Updated.

4 years agoalpha: Warn DT_TEXTREL with -M
H.J. Lu [Tue, 21 Apr 2020 12:20:11 +0000 (05:20 -0700)] 
alpha: Warn DT_TEXTREL with -M

This fixes:

FAIL: DT_TEXTREL map file warning

* elf64-alpha.c (alpha_elf_reloc_entry): Replace reltext with
sec.
(elf64_alpha_check_relocs): Set sec instead of reltext.  Warn
DT_TEXTREL with -M.
(elf64_alpha_calc_dynrel_sizes): Warn DT_TEXTREL with -M.

4 years agoUpdated Serbian translation for the BFD directory.
Nick Clifton [Tue, 21 Apr 2020 10:48:31 +0000 (11:48 +0100)] 
Updated Serbian translation for the BFD directory.

4 years agoSince the pdp11-aout target does not support gdb, gdbserver or gprof these should...
Stephen Casner [Tue, 21 Apr 2020 09:27:50 +0000 (10:27 +0100)] 
Since the pdp11-aout target does not support gdb, gdbserver or gprof these should be excluded in configure.

PR 25830
* configure.ac (noconfigdirs): Exclude gdb & gprof for pdp11.
* configure: Rebuild.

4 years agoRemove SH-5 remnants
Alan Modra [Tue, 21 Apr 2020 01:36:53 +0000 (11:06 +0930)] 
Remove SH-5 remnants

git commit 211dc24b87 removed most sh5 and sh64 SuperH support, after
they were obsoleted by git commit 2b213129c5.  This patch removes a
few remaining pieces that should have gone with 211dc24b87.

include/
* elf/sh.h (STO_SH5_ISA32, SHF_SH5_ISA32, SHF_SH5_ISA32_MIXED),
(SHT_SH5_CR_SORTED, STT_DATALABEL): Delete.
bfd/
* elf32-sh.c (sh_elf_relocate_section): Remove STO_SH5_ISA32
processing.

4 years agoAutomatic date update in version.in
GDB Administrator [Tue, 21 Apr 2020 00:00:11 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 years agoMark move constructors as "noexcept"
Tom Tromey [Mon, 20 Apr 2020 17:45:06 +0000 (11:45 -0600)] 
Mark move constructors as "noexcept"

I recently learned that move constructors generally should be marked
"noexcept".  This ensures that standard containers will move objects
when possible, rather than copy them.

This patch fixes the cases I could find.  Note that implicitly-defined
or defaulted move constructors will automatically do what you'd
expect; that is, they are noexcept if all the members have noexcept
move constructors.

While doing this, I noticed a couple of odd cases where the move
constructor seemed to assume that the object being constructed could
have state requiring destruction.  I've fixed these as well.  See
completion_result and scoped_mmap.

gdb/ChangeLog
2020-04-20  Tom Tromey  <tromey@adacore.com>

* python/python.c (struct gdbpy_event): Mark move constructor as
noexcept.
* python/py-tui.c (class gdbpy_tui_window_maker): Mark move
constructor as noexcept.
* completer.h (struct completion_result): Mark move constructor as
noexcept.
* completer.c (completion_result::completion_result): Use
initialization style.  Don't call reset_match_list.

gdbsupport/ChangeLog
2020-04-20  Tom Tromey  <tromey@adacore.com>

* scoped_mmap.h (scoped_mmap): Mark move constructor as noexcept.
Use initialization style.  Don't call destroy.
* scoped_fd.h (class scoped_fd): Mark move constructor as
noexcept.
* gdb_ref_ptr.h (class ref_ptr): Mark move constructor as
noexcept.

4 years agoUse support_nested_function_tests in gdb.base/nested-subp1.exp et al
Gary Benson [Mon, 20 Apr 2020 16:00:47 +0000 (17:00 +0100)] 
Use support_nested_function_tests in gdb.base/nested-subp1.exp et al

This commit updates gdb.base/nested-subp[1-3].exp to determine
whether whether nested functions are supported using the function
support_nested_function_tests.

gdb/testsuite/ChangeLog:

* gdb.base/nested-subp1.exp: Use support_nested_function_tests.
* gdb.base/nested-subp2.exp: Likewise.
* gdb.base/nested-subp3.exp: Likewise.

4 years agoDisable nested function tests for clang
Gary Benson [Mon, 20 Apr 2020 14:49:09 +0000 (15:49 +0100)] 
Disable nested function tests for clang

Clang does not support nested functions, and there are no plans to
change this.  This commit disables the three nested function tests
when using clang.

gdb/testsuite/ChangeLog:

* gdb.base/nested-subp1.exp: Disable test when using clang.
* gdb.base/nested-subp2.exp: Likewise.
* gdb.base/nested-subp3.exp: Likewise.

4 years agoAdd myself to gdb/MAINTAINERS
Mihails Strasuns [Mon, 20 Apr 2020 14:44:44 +0000 (16:44 +0200)] 
Add myself to gdb/MAINTAINERS

2020-04-20  Mihails Strasuns  <mihails.strasuns@intel.com>

* MAINTAINERS (Write After Approval): Add myself.

Change-Id: I3f412e328b42dea875a6d7cb74fc55415865f134

4 years agoFix ChangeLog entry for commit fa93cc8f35dbed69c3c47aa803686d87f2143779
Gary Benson [Mon, 20 Apr 2020 14:18:19 +0000 (15:18 +0100)] 
Fix ChangeLog entry for commit fa93cc8f35dbed69c3c47aa803686d87f2143779

4 years agogdb: fix tabs vs spaces in ChangeLog
Simon Marchi [Mon, 20 Apr 2020 14:17:57 +0000 (10:17 -0400)] 
gdb: fix tabs vs spaces in ChangeLog

4 years agoFix compilation error with clang in gdb/testsuite/gdb.cp/exception.cc
Gary Benson [Mon, 20 Apr 2020 14:05:01 +0000 (15:05 +0100)] 
Fix compilation error with clang in gdb/testsuite/gdb.cp/exception.cc

Clang fails to compile the above file, with the following error:
  warning: using directive refers to implicitly-defined namespace 'std'

This prevents the following testcase from executing:
  gdb.cp/exception.exp

4 years agoFix compilation error with clang in gdb/testsuite/gdb.trace/tspeed.c
Gary Benson [Mon, 20 Apr 2020 14:05:01 +0000 (15:05 +0100)] 
Fix compilation error with clang in gdb/testsuite/gdb.trace/tspeed.c

Clang fails to compile the above file, with the following error:
  warning: using the result of an assignment as a condition without
  parentheses [-Wparentheses]

This prevents the following testcase from executing:
  gdb.trace/tspeed.exp

4 years agoFix compilation error with clang in gdb/testsuite/gdb.base/jit-main.c
Gary Benson [Mon, 20 Apr 2020 14:05:01 +0000 (15:05 +0100)] 
Fix compilation error with clang in gdb/testsuite/gdb.base/jit-main.c

Clang fails to compile the above file, with the following error:
  warning: while loop has empty body [-Wempty-body]

This prevents the following testcases from executing:
  gdb.base/jit.exp
  gdb.base/jit-so.exp

4 years agoWhen bfd/pdp11.c was copied from bfd/aoutx.h, the #defines for external symbol types...
Stephen Casner [Mon, 20 Apr 2020 11:49:50 +0000 (12:49 +0100)] 
When bfd/pdp11.c was copied from bfd/aoutx.h, the #defines for external symbol types N_TEXT etc. were #undef'd and then #define'd with new values.  But N_STAB was not changed even though the new value for N_EXT overlapped with it.  This caused aout_link_write_symbols() to treat global symbols referenced in the source but defined in a linker script as undefined.

Separately, in translate_symbol_table() the 16-bit symbol values were sign extended to unsigned long (e.g., 64 bits) when they really should be treated as unsigned so the value remains 16 bits.

PR 25828
* pdp11.c (N_STAB): Modify value to avoid conflict with N_EXT
causing globals from linker script to be treated as debug symbols.
(translate_symbol_table): Don't sign-extend symbol values from 16
to 64 bits in nm output.

4 years ago[AArch64, Binutils] Add missing TSB instruction
Sudakshina Das [Mon, 20 Apr 2020 09:58:16 +0000 (10:58 +0100)] 
[AArch64, Binutils] Add missing TSB instruction

This patch implements the TSB instructions:
https://developer.arm.com/docs/ddi0596/f/base-instructions-alphabetic-order/
tsb-csync-trace-synchronization-barrier
Since TSB and PSB both use the same (and only) argument "CSYNC", this patch
reuses it for TSB. However, the same argument would imply different value
for CRm:Op2 which are anyway fixed values, so I have diverted the
inserter/extracter function to dummy versions instead of the "hint" version.
The operand checker part still uses the existing infratructure for
AARCH64_OPND_BARRIER_PSB to make sure the operand is parsed correctly.

gas/ChangeLog:

2020-04-20  Sudakshina Das  <sudi.das@arm.com>

* config/tc-aarch64.c (parse_barrier_psb): Update error messages
to include TSB.
* testsuite/gas/aarch64/system-2.d: Update -march and new tsb tests.
* testsuite/gas/aarch64/system-2.s: Add new tsb tests.
* testsuite/gas/aarch64/system.d: Update.

opcodes/ChangeLog:

2020-04-20  Sudakshina Das  <sudi.das@arm.com>

* aarch64-asm.c (aarch64_ins_none): New.
* aarch64-asm.h (ins_none): New declaration.
* aarch64-dis.c (aarch64_ext_none): New.
* aarch64-dis.h (ext_none): New declaration.
* aarch64-opc.c (aarch64_print_operand): Update case for
AARCH64_OPND_BARRIER_PSB.
* aarch64-tbl.h (aarch64_opcode_table): Add tsb.
(AARCH64_OPERANDS): Update inserter/extracter for
AARCH64_OPND_BARRIER_PSB to use new dummy functions.
* aarch64-asm-2.c: Regenerated.
* aarch64-dis-2.c: Regenerated.
* aarch64-opc-2.c: Regenerated.

4 years ago[AArch64, Binutils] Make hint space instructions valid for Armv8-a
Sudakshina Das [Mon, 20 Apr 2020 09:50:52 +0000 (10:50 +0100)] 
[AArch64, Binutils] Make hint space instructions valid for Armv8-a

There are a few instruction in AArch64 that are in the HINT space. Any of
these instructions should be accepted by the assembler/disassembler at any
architecture version. This patch fixes the existing instructions that are
not behaving accordingly.
I have used all of the instructions mentioned in the following to make the
changes:
https://developer.arm.com/docs/ddi0596/f/base-instructions-alphabetic-order/
hint-hint-instruction

gas/ChangeLog:

2020-04-20  Sudakshina Das  <sudi.das@arm.com>

* testsuite/gas/aarch64/bti.d: Update -march option.
* testsuite/gas/aarch64/illegal-bti.d: Remove.
* testsuite/gas/aarch64/illegal-bti.l: Remove.
* testsuite/gas/aarch64/illegal-ras-1.l: Remove esb.
* testsuite/gas/aarch64/illegal-ras-1.s: Remove esb.

opcodes/ChangeLog:

2020-04-20  Sudakshina Das  <sudi.das@arm.com>

* aarch64-tbl.h (aarch64_feature_bti, BTI, BTI_INSN): Remove.
(aarch64_feature_ras, RAS): Likewise.
(aarch64_feature_stat_profile, STAT_PROFILE): Likewise.
(aarch64_opcode_table): Update bti, xpaclri, pacia1716, pacib1716,
autia1716, autib1716, esb, psb, dgh, paciaz, paciasp, pacibz, pacibsp,
autiaz, autiasp, autibz, autibsp to be CORE_INSN.
* aarch64-asm-2.c: Regenerated.
* aarch64-dis-2.c: Regenerated.
* aarch64-opc-2.c: Regenerated.

4 years agofix typo last commit
Alan Modra [Mon, 20 Apr 2020 02:31:47 +0000 (12:01 +0930)] 
fix typo last commit

4 years agoreadelf: segfault at readelf.c:12227
Alan Modra [Mon, 20 Apr 2020 01:31:47 +0000 (11:01 +0930)] 
readelf: segfault at readelf.c:12227

This is another one where not cleaning up sufficiently after
processing one file can lead to errors when processing the next file.
We have ngnuchains non-zero but gnuchains NULL in the following:
  off < ngnuchains && (gnuchains[off] & 1) == 0

* readelf.c (process_symbol_table): Clear ngnuchains, ngnubuckets
and nbuckets.

4 years agoreadelf: segfaults fuzzing multiple object files
Alan Modra [Mon, 20 Apr 2020 00:24:46 +0000 (09:54 +0930)] 
readelf: segfaults fuzzing multiple object files

This patch is aimed at fixing a number of oss-fuzz segfaults that
don't reproduce reliably with their current infrastructure, the
problem being that one invocation of readelf is effectively being run
on multiple object files.  I believe that these segfaults could be
reliably reproduced with just two fuzzed objects being presented to
readelf, but those inputs are currently not identified by oss-fuzz.
So there is some guesswork involved in this patch.  The idea here is
to clear stashed data such as symtab_shndx_list that is processed
using section header info, at the same time that header info is
cleared.

* readelf.c (process_section_headers): Free dynamic symbols etc.
earlier.

4 years agoAutomatic date update in version.in
GDB Administrator [Mon, 20 Apr 2020 00:00:07 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 years agoreadelf memory leaks
Alan Modra [Sun, 19 Apr 2020 07:35:02 +0000 (17:05 +0930)] 
readelf memory leaks

This fixes two leaks found in the new code supporting display of
dynamic symbols retrieved via dynamic tags.

* readelf.c (get_num_dynamic_syms): Formatting.  Don't return
on error without freeing.
(process_dynamic_section): Don't recreate dynamic symbols from
dynamic tag info when the dynamic symbols have already been
read via section headers.

4 years agoPowerPC64: remove empty .rela.dyn (.rela.branch_lt)
Alan Modra [Sat, 18 Apr 2020 06:27:07 +0000 (15:57 +0930)] 
PowerPC64: remove empty .rela.dyn (.rela.branch_lt)

Stripping .rela.branch_lt is easy enough but messes with the
testsuite due to stub symbols (that use section id) changing.  Tests
that run on more than one target variant can be tricky to fix, this
renaming happened to work.

bfd/
* elf64-ppc.c (ppc64_elf_size_stubs): Strip relbrlt too.
ld/
* testsuite/ld-powerpc/tlsopt5.s: Rename foo to aaaaa.
* testsuite/ld-powerpc/tlsopt5.d: Adjust to suit.
* testsuite/ld-powerpc/tlsopt6.d: Likewise.

4 years agoRestore some windows-tdep.c code
Tom Tromey [Sun, 19 Apr 2020 01:28:13 +0000 (19:28 -0600)] 
Restore some windows-tdep.c code

When I removed init_w32_command_list, I weirdly neglected to see if it
was called anywhere else.  This patch restores the function, which is
called from windows-nat.c.  Sorry about the breakage.

Is it possible to have a windows-native gdb that isn't also using
windows-tdep?

Anyway, I'm checking this in.

gdb/ChangeLog
2020-04-18  Tom Tromey  <tom@tromey.com>

* windows-tdep.c (init_w32_command_list)
(w32_prefix_command_valid): Restore.
(_initialize_windows_tdep): Call init_w32_command_list.

4 years agoAutomatic date update in version.in
GDB Administrator [Sun, 19 Apr 2020 00:00:06 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 years agold: Don't xfail ld-elf/warn[12] on 64-bit Solaris/SPARC
Rainer Orth [Sat, 18 Apr 2020 20:17:24 +0000 (22:17 +0200)] 
ld: Don't xfail ld-elf/warn[12] on 64-bit Solaris/SPARC

Two ld tests currently XPASS on 64-bit Solaris/SPARC:

XPASS: ld-elf/warn1
XPASS: ld-elf/warn2

They were xfail'ed on Solaris/SPARCv9 back in 2005

https://sourceware.org/pipermail/binutils/2005-February/039268.html

but obviously this no longer appplies.

Fixed by removing the xfail's.

Tested on sparcv9-sun-solaris2.11 and sparc-sun-solaris2.11.

* testsuite/ld-elf/warn1.d: Don't xfail on 64-bit Solaris/SPARC.
* testsuite/ld-elf/warn2.d: Likewise.

4 years agoelf: Don't use .set for alpha target
H.J. Lu [Sat, 18 Apr 2020 18:23:09 +0000 (11:23 -0700)] 
elf: Don't use .set for alpha target

Since the .set directive of ELF/alpha target is different, define NO_SET
to 1 to use "=" for ELF/alpha target.

* testsuite/ld-elf/elf.exp (ASFLAGS): Add "--defsym NO_SET=1" for
alpha target.
* testsuite/ld-elf/pr19789.s: Use "=" if NO_SET is defined.

4 years agoChange get_objfile_arch to a method on objfile
Tom Tromey [Sat, 18 Apr 2020 14:35:04 +0000 (08:35 -0600)] 
Change get_objfile_arch to a method on objfile

This changes get_objfile_arch to be a new inline method,
objfile::arch.

To my surprise, this function came up while profiling DWARF psymbol
reading.  Making this change improved performance from 1.986 seconds
to 1.869 seconds.  Both measurements were done by taking the mean of
10 runs on a fixed copy of the gdb executable.

gdb/ChangeLog
2020-04-18  Tom Tromey  <tom@tromey.com>

* xcoffread.c (enter_line_range, scan_xcoff_symtab): Update.
* value.c (value_fn_field): Update.
* valops.c (find_function_in_inferior)
(value_allocate_space_in_inferior): Update.
* tui/tui-winsource.c (tui_update_source_windows_with_line):
Update.
* tui/tui-source.c (tui_source_window::set_contents): Update.
* symtab.c (lookup_global_or_static_symbol)
(find_function_start_sal_1, skip_prologue_sal)
(print_msymbol_info, find_gnu_ifunc, symbol_arch): Update.
* symmisc.c (dump_msymbols, dump_symtab_1)
(maintenance_print_one_line_table): Update.
* symfile.c (init_entry_point_info, section_is_mapped)
(list_overlays_command, simple_read_overlay_table)
(simple_overlay_update_1): Update.
* stap-probe.c (handle_stap_probe): Update.
* stabsread.c (dbx_init_float_type, define_symbol)
(read_one_struct_field, read_enum_type, read_range_type): Update.
* source.c (info_line_command): Update.
* python/python.c (gdbpy_source_objfile_script)
(gdbpy_execute_objfile_script): Update.
* python/py-type.c (save_objfile_types): Update.
* python/py-objfile.c (py_free_objfile): Update.
* python/py-inferior.c (python_new_objfile): Update.
* psymtab.c (psym_find_pc_sect_compunit_symtab, dump_psymtab)
(dump_psymtab_addrmap_1, maintenance_info_psymtabs)
(maintenance_check_psymtabs): Update.
* printcmd.c (info_address_command): Update.
* objfiles.h (struct objfile) <arch>: New method, from
get_objfile_arch.
(get_objfile_arch): Don't declare.
* objfiles.c (get_objfile_arch): Remove.
(filter_overlapping_sections): Update.
* minsyms.c (msymbol_is_function): Update.
* mi/mi-symbol-cmds.c (mi_cmd_symbol_list_lines)
(output_nondebug_symbol): Update.
* mdebugread.c (parse_symbol, basic_type, parse_partial_symbols)
(mdebug_expand_psymtab): Update.
* machoread.c (macho_add_oso_symfile): Update.
* linux-tdep.c (linux_infcall_mmap, linux_infcall_munmap):
Update.
* linux-fork.c (checkpoint_command): Update.
* linespec.c (convert_linespec_to_sals): Update.
* jit.c (finalize_symtab): Update.
* infrun.c (insert_exception_resume_from_probe): Update.
* ia64-tdep.c (ia64_find_unwind_table): Update.
* hppa-tdep.c (internalize_unwinds): Update.
* gdbtypes.c (get_type_arch, init_float_type, objfile_type):
Update.
* gcore.c (call_target_sbrk): Update.
* elfread.c (record_minimal_symbol, elf_symtab_read)
(elf_rel_plt_read, elf_gnu_ifunc_record_cache)
(elf_gnu_ifunc_resolve_by_got): Update.
* dwarf2/read.c (create_addrmap_from_index)
(create_addrmap_from_aranges, dw2_find_pc_sect_compunit_symtab)
(read_debug_names_from_section)
(process_psymtab_comp_unit_reader, add_partial_symbol)
(add_partial_subprogram, process_full_comp_unit)
(read_file_scope, read_func_scope, read_lexical_block_scope)
(read_call_site_scope, dwarf2_ranges_read)
(dwarf2_record_block_ranges, dwarf2_add_field)
(mark_common_block_symbol_computed, read_tag_pointer_type)
(read_tag_string_type, dwarf2_init_float_type)
(dwarf2_init_complex_target_type, read_base_type)
(partial_die_info::read, partial_die_info::read)
(read_attribute_value, dwarf_decode_lines_1, new_symbol)
(dwarf2_fetch_die_loc_sect_off): Update.
* dwarf2/loc.c (dwarf2_find_location_expression)
(class dwarf_evaluate_loc_desc, rw_pieced_value)
(dwarf2_evaluate_loc_desc_full, dwarf2_locexpr_baton_eval)
(dwarf2_loc_desc_get_symbol_read_needs)
(locexpr_describe_location_piece, locexpr_describe_location_1)
(loclist_describe_location): Update.
* dwarf2/index-write.c (write_debug_names): Update.
* dwarf2/frame.c (dwarf2_build_frame_info): Update.
* dtrace-probe.c (dtrace_process_dof): Update.
* dbxread.c (read_dbx_symtab, dbx_end_psymtab)
(process_one_symbol): Update.
* ctfread.c (ctf_init_float_type, read_base_type): Update.
* coffread.c (coff_symtab_read, enter_linenos, decode_base_type)
(coff_read_enum_type): Update.
* cli/cli-cmds.c (edit_command, list_command): Update.
* buildsym.c (buildsym_compunit::finish_block_internal): Update.
* breakpoint.c (create_overlay_event_breakpoint)
(create_longjmp_master_breakpoint)
(create_std_terminate_master_breakpoint)
(create_exception_master_breakpoint, get_sal_arch): Update.
* block.c (block_gdbarch): Update.
* annotate.c (annotate_source_line): Update.

4 years agobfd_is_const_section thinko
Alan Modra [Sat, 18 Apr 2020 00:45:35 +0000 (10:15 +0930)] 
bfd_is_const_section thinko

* section.c (bfd_is_const_section): Correct test for special
sections.
* bfd-in2.h: Regenerate.

4 years agoAutomatic date update in version.in
GDB Administrator [Sat, 18 Apr 2020 00:00:10 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 years agoFix gdb.base/attach-twice.c build on NetBSD
Kamil Rytarowski [Fri, 17 Apr 2020 16:39:42 +0000 (18:39 +0200)] 
Fix gdb.base/attach-twice.c build on NetBSD

Add a fallback definition of PTRACE_ATTACH that is an alias of
PT_ATTACH. Change the 4th argument of ptrace(2) to 0 as it is
compatible with void * (Linux) and int (NetBSD) arguments.

Include <sys/types.h> for <sys/ptrace.h>.

gdb/testsuite/ChangeLog:

* gdb.base/attach-twice.c: Include "sys/types.h".
(PTRACE_ATTACH): Add fallback definition.
(main): Pass `0' to the 4th argument of `ptrace'.

4 years agoFix the build of fork-running-state.c on NetBSD
Kamil Rytarowski [Fri, 17 Apr 2020 16:51:34 +0000 (18:51 +0200)] 
Fix the build of fork-running-state.c on NetBSD

Include <signal.h> for kill(2).

gdb/testsuite/ChangeLog:

        * gdb.base/fork-running-state.c: Include "signal.h".

4 years agoReplace most calls to help_list and cmd_show_list
Tom Tromey [Fri, 17 Apr 2020 13:27:14 +0000 (07:27 -0600)] 
Replace most calls to help_list and cmd_show_list

Currently there are many prefix commands that do nothing but call
either help_list or cmd_show_list.  I happened to notice that one such
call, for "set print type", used the wrong command list parameter,
causing incorrect output.

Rather than fix this bug in isolation, I decided to eliminate this
possibility by adding two new ways to add prefix commands, which
simply route the call to help_list or cmd_show_list, as appropriate.
This makes it impossible for a mismatch to occur.

In some cases, a bit of output was removed; however, I don't think
this output in general was very useful.  It seemed redundant with
what's already printed by help_list.  A representative example is this
hunk, removed from ada-lang.c:

-  printf_unfiltered (_(\
-"\"set ada\" must be followed by the name of a setting.\n"));

This simplified the CLI style set/show commands quite a bit, and
allowed the deletion of a macro.

This also cleans up some unusual code in windows-tdep.c.

Tested on x86-64 Fedora 30.  Note that I have no way to build the
go32-nat.c change.

gdb/ChangeLog
2020-04-17  Tom Tromey  <tromey@adacore.com>

* auto-load.c (show_auto_load_cmd): Remove.
(auto_load_show_cmdlist_get): Use add_show_prefix_cmd.
* arc-tdep.c (_initialize_arc_tdep): Use add_show_prefix_cmd.
(maintenance_print_arc_command): Remove.
* tui/tui-win.c (tui_command): Remove.
(tui_get_cmd_list): Use add_basic_prefix_cmd.
* tui/tui-layout.c (tui_layout_command): Remove.
(_initialize_tui_layout): Use add_basic_prefix_cmd.
* python/python.c (user_set_python, user_show_python): Remove.
(_initialize_python): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* guile/guile.c (set_guile_command, show_guile_command): Remove.
(install_gdb_commands): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
(info_guile_command): Remove.
* dwarf2/read.c (set_dwarf_cmd, show_dwarf_cmd): Remove.
(_initialize_dwarf2_read): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* cli/cli-style.h (class cli_style_option) <add_setshow_commands>:
Remove do_set and do_show parameters.
* cli/cli-style.c (set_style, show_style): Remove.
(_initialize_cli_style): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
(cli_style_option::add_setshow_commands): Remove do_set and
do_show parameters.
(cli_style_option::add_setshow_commands): Use
add_basic_prefix_cmd, add_show_prefix_cmd.
(STYLE_ADD_SETSHOW_COMMANDS): Remove macro.
(set_style_name): Remove.
* cli/cli-dump.c (dump_command, append_command): Remove.
(srec_dump_command, ihex_dump_command, verilog_dump_command)
(tekhex_dump_command, binary_dump_command)
(binary_append_command): Remove.
(_initialize_cli_dump): Use add_basic_prefix_cmd.
* windows-tdep.c (w32_prefix_command_valid): Remove global.
(init_w32_command_list): Remove; move into ...
(_initialize_windows_tdep): ... here.  Use add_basic_prefix_cmd.
* valprint.c (set_print, show_print, set_print_raw)
(show_print_raw): Remove.
(_initialize_valprint): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* typeprint.c (set_print_type, show_print_type): Remove.
(_initialize_typeprint): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* record.c (set_record_command, show_record_command): Remove.
(_initialize_record): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* cli/cli-cmds.c (_initialize_cli_cmds): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
(info_command, show_command, set_debug, show_debug): Remove.
* top.h (set_history, show_history): Don't declare.
* top.c (set_history, show_history): Remove.
* target-descriptions.c (set_tdesc_cmd, show_tdesc_cmd)
(unset_tdesc_cmd): Remove.
(_initialize_target_descriptions): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* symtab.c (info_module_command): Remove.
(_initialize_symtab): Use add_basic_prefix_cmd.
* symfile.c (overlay_command): Remove.
(_initialize_symfile): Use add_basic_prefix_cmd.
* sparc64-tdep.c (info_adi_command): Remove.
(_initialize_sparc64_adi_tdep): Use add_basic_prefix_cmd.
* sh-tdep.c (show_sh_command, set_sh_command): Remove.
(_initialize_sh_tdep): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* serial.c (serial_set_cmd, serial_show_cmd): Remove.
(_initialize_serial): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* ser-tcp.c (set_tcp_cmd, show_tcp_cmd): Remove.
(_initialize_ser_tcp): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* rs6000-tdep.c (set_powerpc_command, show_powerpc_command)
(_initialize_rs6000_tdep): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* riscv-tdep.c (show_riscv_command, set_riscv_command)
(show_debug_riscv_command, set_debug_riscv_command): Remove.
(_initialize_riscv_tdep): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* remote.c (remote_command, set_remote_cmd): Remove.
(_initialize_remote): Use add_basic_prefix_cmd.
* record-full.c (set_record_full_command)
(show_record_full_command): Remove.
(_initialize_record_full): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* record-btrace.c (cmd_set_record_btrace)
(cmd_show_record_btrace, cmd_set_record_btrace_bts)
(cmd_show_record_btrace_bts, cmd_set_record_btrace_pt)
(cmd_show_record_btrace_pt): Remove.
(_initialize_record_btrace): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* ravenscar-thread.c (set_ravenscar_command)
(show_ravenscar_command): Remove.
(_initialize_ravenscar): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* mips-tdep.c (show_mips_command, set_mips_command)
(_initialize_mips_tdep): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* maint.c (maintenance_command, maintenance_info_command)
(maintenance_check_command, maintenance_print_command)
(maintenance_set_cmd, maintenance_show_cmd): Remove.
(_initialize_maint_cmds): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
(show_per_command_cmd): Remove.
* maint-test-settings.c (maintenance_set_test_settings_cmd):
Remove.
(maintenance_show_test_settings_cmd): Remove.
(_initialize_maint_test_settings): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* maint-test-options.c (maintenance_test_options_command):
Remove.
(_initialize_maint_test_options): Use add_basic_prefix_cmd.
* macrocmd.c (macro_command): Remove
(_initialize_macrocmd): Use add_basic_prefix_cmd.
* language.c (set_check, show_check): Remove.
(_initialize_language): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* infcmd.c (unset_command): Remove.
(_initialize_infcmd): Use add_basic_prefix_cmd.
* i386-tdep.c (set_mpx_cmd, show_mpx_cmd): Remove.
(_initialize_i386_tdep): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* go32-nat.c (go32_info_dos_command): Remove.
(_initialize_go32_nat): Use add_basic_prefix_cmd.
* cli/cli-decode.c (do_prefix_cmd, add_basic_prefix_cmd)
(do_show_prefix_cmd, add_show_prefix_cmd): New functions.
* frame.c (set_backtrace_cmd, show_backtrace_cmd): Remove.
(_initialize_frame): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* dcache.c (set_dcache_command, show_dcache_command): Remove.
(_initialize_dcache): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* cp-support.c (maint_cplus_command): Remove.
(_initialize_cp_support): Use add_basic_prefix_cmd.
* btrace.c (maint_btrace_cmd, maint_btrace_set_cmd)
(maint_btrace_show_cmd, maint_btrace_pt_set_cmd)
(maint_btrace_pt_show_cmd, _initialize_btrace): Use
add_basic_prefix_cmd, add_show_prefix_cmd.
* breakpoint.c (save_command): Remove.
(_initialize_breakpoint): Use add_basic_prefix_cmd.
* arm-tdep.c (set_arm_command, show_arm_command): Remove.
(_initialize_arm_tdep): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* ada-lang.c (maint_set_ada_cmd, maint_show_ada_cmd)
(set_ada_command, show_ada_command): Remove.
(_initialize_ada_language): Use add_basic_prefix_cmd,
add_show_prefix_cmd.
* command.h (add_basic_prefix_cmd, add_show_prefix_cmd): Declare.

gdb/testsuite/ChangeLog
2020-04-17  Tom Tromey  <tromey@adacore.com>

* gdb.cp/maint.exp (test_help): Simplify multiple_help_body.
Update tests.
* gdb.btrace/cpu.exp: Update tests.
* gdb.base/maint.exp: Update tests.
* gdb.base/default.exp: Update tests.
* gdb.base/completion.exp: Update tests.

4 years ago[PATCH v2] binutils: arm: Fix disassembly of conditional VDUPs.
Fredrik Strupe [Fri, 17 Apr 2020 16:25:19 +0000 (17:25 +0100)] 
[PATCH v2] binutils: arm: Fix disassembly of conditional VDUPs.

VDUP (neon) instructions can be conditional, but this is not taken into
account in the current master. This commit fixes that by i) fixing the
VDUP instruction masks and ii) adding logic for disassembling
conditional neon instructions.

opcodes * arm-dis.c (neon_opcodes): Fix VDUP instruction masks.
(print_insn_neon): Support disassembly of conditional
instructions.

binutils* testsuite/binutils-all/arm/vdup-cond.d: New test for testing that
conditional VDUP instructions are disassembled correctly.
* testsuite/binutils-all/arm/vdup-cond.s: New file used by
vdup-cond.d.
* testsuite/binutils-all/arm/vdup-thumb.d: New test for testing
that VDUP instructions (which are conditional in A32) can be
disassembled in thumb mode.
* testsuite/binutils-all/arm/vdup-cond.s: New file used by
vdup-thumb.d.

4 years agoFix the test for PR 18963 so that it will work on 16-bit targets.
Stephen Casner [Fri, 17 Apr 2020 13:16:27 +0000 (14:16 +0100)] 
Fix the test for PR 18963 so that it will work on 16-bit targets.

PR 18963
* testsuite/ld-scripts/pr18963.t: Reduce section sizes to fit in
16-bit address space.
* testsuite/ld-scripts/pr18963.d: Likewise.

4 years agoRevert "Fix the test for PR 18963 so that it will work on 16-bit targets."
Nick Clifton [Fri, 17 Apr 2020 12:16:56 +0000 (13:16 +0100)] 
Revert "Fix the test for PR 18963 so that it will work on 16-bit targets."

This reverts commit 7a1a12f4d1c6152017142d74c736dc1cc6b0e81c.

4 years ago[PATCH 1/2] coff-go32: update ldscript
Juan Manuel Guerrero [Fri, 17 Apr 2020 12:12:31 +0000 (13:12 +0100)] 
[PATCH 1/2] coff-go32: update ldscript

* scripttempl/i386go32.sc: Provide symbol _environ.  Link in
.ctors and .dtors.  Discard LTO sections.

4 years ago Commit: Running the linker testsuite with clang
Nick Clifton [Fri, 17 Apr 2020 12:03:53 +0000 (13:03 +0100)] 
 Commit: Running the linker testsuite with clang

* testsuite/config/default.exp: If not already set then create the
CCC_OVERRIDE_OPTIONS environment variable to help when running the
testsuite with clang.
* testsuite/ld-elf/pr22269-1.c: Add a missing return statement.
* testsuite/ld-elfvers/vers.exp: Add checks to detect if files
were built before attempting to copy them.

4 years agoRemove obsolete and unused inf_ptrace_target::auxv_parse
Kamil Rytarowski [Wed, 15 Apr 2020 19:32:08 +0000 (21:32 +0200)] 
Remove obsolete and unused inf_ptrace_target::auxv_parse

The only two potential users (NetBSD, OpenBSD) use svr4_auxv_parse.

gdb/ChangeLog:

        * nbsd-nat.c (inf_ptrace_target::auxv_parse): Remove.
        * nbsd-nat.h (inf_ptrace_target::auxv_parse): Likewise.

4 years agobfin: allow ".=.+delta"
Alan Modra [Fri, 17 Apr 2020 03:08:19 +0000 (12:38 +0930)] 
bfin: allow ".=.+delta"

BFIN has lots of instructions that contain "=", so "sym = expression"
is disabled for that target.  This makes an exception for assignment
to dot, fixing the recent regression of ld-scripts/pr18963.

* config/tc-bfin.h (TC_EQUAL_IN_INSN): Allow assignment to dot.

4 years agoPR25842, Null pointer dereference in nm-new
Alan Modra [Thu, 16 Apr 2020 22:59:15 +0000 (08:29 +0930)] 
PR25842, Null pointer dereference in nm-new

PR 25842
* elf.c (_bfd_elf_get_symbol_version_string): Don't segfault on
NULL nodename.

4 years agoPR25840, Null pointer dereference in objdump
Alan Modra [Fri, 17 Apr 2020 01:08:16 +0000 (10:38 +0930)] 
PR25840, Null pointer dereference in objdump

PR 25840
* debug.c (debug_class_type_samep): Don't segfault on NULL type.

4 years agoAutomatic date update in version.in
GDB Administrator [Fri, 17 Apr 2020 00:00:14 +0000 (00:00 +0000)] 
Automatic date update in version.in

4 years agogdb: is_linked_with_cygwin_dll: mention filename in warning messages
Simon Marchi [Thu, 16 Apr 2020 19:46:16 +0000 (15:46 -0400)] 
gdb: is_linked_with_cygwin_dll: mention filename in warning messages

When a warning is displayed, it isn't clear to the user which file is
the cause of the warning.  Add the filename in there.  Remove the
"Failed to parse .idata section" part, since the .idata section is
always mentioned one way or another anyway, so it just contributes to
make the message longer than it needs to be.

gdb/ChangeLog:

* windows-tdep.c (is_linked_with_cygwin_dll): Add filename to
warning messages.

4 years agogdb: is_linked_with_cygwin_dll: handle import table not at beginning of .idata section
Simon Marchi [Thu, 16 Apr 2020 19:46:03 +0000 (15:46 -0400)] 
gdb: is_linked_with_cygwin_dll: handle import table not at beginning of .idata section

When loading the file C:\Windows\SysWOW64\msvcrt.dll, taken from a
Windows 10 system, into GDB, we get the following warning:

    warning: Failed to parse .idata section: name's virtual address (0x0) is outside .idata section's range [0xb82b8, 0xb97f0[.

This uncovers an issue with how we parse the import table, part of the
.idata section.  Right now, we assume that the import table is located
at the beginning of the section.  That was the case in everything I had
tried so far, but this file is an example where that's not true.

We need to compute the offset of the import table within the .idata
section, and start there, instead of at the beginning of the .idata
section.  Using the file mentioned above, this is the values we have to
work with:

  A) bfd_section_vma (idata_section)    101b8000
  B) Import table's virtual address        b82b8
  C) Image base                         10100000

The virtual address that BFD returns us for the section has the image
base applied, so we need to subtract it first.  The offset of the table
in the section is therefore:

    B - (A - C)

This patch implements that.

gdb/ChangeLog:

* windows-tdep.c (is_linked_with_cygwin_dll): Consider case where
import table is not at beginning of .idata section.

4 years agoStop the MIPS assembler from accepting ifunc symbols.
Nick Clifton [Thu, 16 Apr 2020 17:02:10 +0000 (18:02 +0100)] 
Stop the MIPS assembler from accepting ifunc symbols.

PR 25803
gas * config/obj-elf.c (obj_elf_type): Reject ifunc symbols on MIPS
targets.
* testsuite/gas/elf/elf.exp: Add MIPS targets to the list to skip
for the type-2 test.
* testsuite/gas/elf/type-noifunc.e: Update to allow for MIPS
targets running this test.

bfd * elfxx-mips.c (_bfd_mips_elf_adjust_dynamic_symbol): Replace an
abort with a more helpful error message.

4 years agoFix the test for PR 18963 so that it will work on 16-bit targets.
Stephen Casner [Thu, 16 Apr 2020 15:13:31 +0000 (16:13 +0100)] 
Fix the test for PR 18963 so that it will work on 16-bit targets.

PR ld/18963
* testsuite/ld-scripts/pr18963.s: New, replaces empty data.s to
allocate space in text, data, bss here rather than pr18963.t.
* testsuite/ld-scripts/pr18963.t: Remove assignments to dot.
* testsuite/ld-scripts/pr18963.d: Change addresses to fit 16 bits.

4 years agoRefactor delete_program_space as a destructor
Pedro Alves [Thu, 16 Apr 2020 13:50:07 +0000 (14:50 +0100)] 
Refactor delete_program_space as a destructor

Currently, while the program_space's ctor adds the new pspace to the
pspaces list, the destructor doesn't remove the pspace from the pspace
list.  Instead, you're supposed to use delete_program_space, to both
remove the pspace from the list, and deleting the pspace.

This patch eliminates delete_program_space, and makes the pspace dtor
remove the deleted pspace from the pspace list itself, i.e., makes the
dtor do the mirror opposite of the ctor.

I found this helps with a following patch that will allocate a mock
program_space on the stack.  It's easier to just let the regular dtor
remove the mock pspace from the pspace list than arrange to call
delete_program_space instead of the pspace dtor in that situation.

While at it, move the ctor/dtor intro comments to the header file, and
make the ctor explicit.

gdb/ChangeLog:
2020-04-16  Pedro Alves  <palves@redhat.com>

* inferior.c (delete_inferior): Use delete operator directly
instead of delete_program_space.
* progspace.c (add_program_space): New, factored out from
program_space::program_space.
(remove_program_space): New, factored out from
delete_program_space.
(program_space::program_space): Remove intro comment.  Rewrite.
(program_space::~program_space): Remove intro comment.  Call
remove_program_space.
(delete_program_space): Delete.
* progspace.h (program_space::program_space): Make explicit.  Move
intro comment here, adjusted.
(program_space::~program_space): Move intro comment here,
adjusted.
(delete_program_space): Remove.

4 years agoFix Cygwin gdb build
Tom Tromey [Thu, 16 Apr 2020 13:24:57 +0000 (07:24 -0600)] 
Fix Cygwin gdb build

Simon pointed out that the windows-nat sharing series broke the Cygwin
build.  This patch fixes the problem, by moving the Cygwin-specific
code to a new handler function.  This approach is taken because this
code calls find_pc_partial_function, which isn't available in
gdbserver.

gdb/ChangeLog
2020-04-16  Tom Tromey  <tromey@adacore.com>

* windows-nat.c (windows_nat::handle_access_violation): New
function.
* nat/windows-nat.h (handle_access_violation): Declare.
* nat/windows-nat.c (handle_exception): Move Cygwin code to
windows-nat.c.  Call handle_access_violation.

gdbserver/ChangeLog
2020-04-16  Tom Tromey  <tromey@adacore.com>

* win32-low.cc (windows_nat::handle_access_violation): New
function.

4 years ago[gdb/symtab] Handle PU without import in "save gdb-index"
Tom de Vries [Thu, 16 Apr 2020 12:56:32 +0000 (14:56 +0200)] 
[gdb/symtab] Handle PU without import in "save gdb-index"

Consider the test-case added in this patch, with resulting dwarf:
...
  Compilation Unit @ offset 0xc7:
   Length:        0x2c (32-bit)
   Version:       4
   Abbrev Offset: 0x64
   Pointer Size:  8
 <0><d2>: Abbrev Number: 2 (DW_TAG_partial_unit)
    <d3>   DW_AT_language    : 2        (non-ANSI C)
    <d4>   DW_AT_name        : imported_unit.c
 <1><e4>: Abbrev Number: 3 (DW_TAG_base_type)
    <e5>   DW_AT_byte_size   : 4
    <e6>   DW_AT_encoding    : 5        (signed)
    <e7>   DW_AT_name        : int
 <1><eb>: Abbrev Number: 4 (DW_TAG_subprogram)
    <ec>   DW_AT_name        : main
    <f1>   DW_AT_type        : <0xe4>
    <f5>   DW_AT_external    : 1
 <1><f6>: Abbrev Number: 0
  Compilation Unit @ offset 0xf7:
   Length:        0x2c (32-bit)
   Version:       4
   Abbrev Offset: 0x85
   Pointer Size:  8
 <0><102>: Abbrev Number: 2 (DW_TAG_compile_unit)
    <103>   DW_AT_language    : 2       (non-ANSI C)
    <104>   DW_AT_name        : <artificial>
 <1><111>: Abbrev Number: 3 (DW_TAG_subprogram)
    <112>   DW_AT_abstract_origin: <0xeb>
    <116>   DW_AT_low_pc      : 0x4004a7
    <11e>   DW_AT_high_pc     : 0x4004b2
 <1><126>: Abbrev Number: 0
...

When run with target board cc-with-gdb-index, we run into:
...
(gdb) break main
warning: (Internal error: pc 0x4004a7 in read in CU, but not in symtab.)
<repeat>
warning: (Internal error: pc 0x4004ab in read in CU, but not in symtab.)
<repeat>
Breakpoint 1 at 0x4004ab
(gdb) PASS: gdb.dwarf2/imported-unit-runto-main.exp: setting breakpoint at main
run
Starting program: /data/gdb_versions/devel/build/gdb/testsuite/outputs/gdb.dwarf2/imported-unit-runto-main/imported-unit-runto-main
warning: (Internal error: pc 0x4004a7 in read in CU, but not in symtab.)
<repeat>
warning: (Internal error: pc 0x4004ab in read in CU, but not in symtab.)
<repeat>

Breakpoint 1, warning: (Internal error: pc 0x4004ab in read in CU, but not in symtab.)
warning: (Internal error: pc 0x4004ab in read in CU, but not in symtab.)
<repeat>
0x00000000004004ab in main ()
warning: (Internal error: pc 0x4004ab in read in CU, but not in symtab.)
<repeat>
(gdb) FAIL: gdb.dwarf2/imported-unit-runto-main.exp: running to main in runto
...

Looking at the .gdb_index section contents using objdump --dwarf=gdb_index, we
have:
...
CU table:
[  0] 0x0 - 0x2d
[  1] 0x2e - 0xa4
[  2] 0xa5 - 0xc6
[  3] 0xf7 - 0x126
[  4] 0x127 - 0x2de
[  5] 0x2df - 0x300

Address table:
00000000004004a7 00000000004004b2 4

Symbol table:
[489] main: 4 [global, function]
...
We see that both the main symbol, and main address range map to CU 4, which has
offset range 0x127 - 0x2de, while main actually is contained in CU 3 at offset
range 0xf7 - 0x126.

This is caused by this continue in write_gdbindex, which triggers for the PU:
...
      /* CU of a shared file from 'dwz -m' may be unused by this main file.
        It may be referenced from a local scope but in such case it does not
        need to be present in .gdb_index.  */
      if (psymtab == NULL)
       continue;
...
The continue causes the PU to be skipped in the CU table (we can see that the
PU offset range 0xc7-0xf6 is missing) but the references are not taking that
into account.

I've tried fixing this in the optimal way, by updating the references, but ran
into trouble when follow_die_offset tries to find the CU for the inter-CU
ref.  Because the PU is missing from the CU table,
dwarf2_find_containing_comp_unit bisects to the wrong CU.

Fix this by not skipping the PU in the CU table.

Build and reg-tested on x86_64-linux, with native and target boards
cc-with-gdb-index, cc-with-dwz and cc-with-dwz-m.

gdb/ChangeLog:

2020-04-16  Tom de Vries  <tdevries@suse.de>

PR symtab/25791
* dwarf2/index-write.c (write_gdbindex): Generate CU table entries for
CUs without psymtab.

gdb/testsuite/ChangeLog:

2020-04-16  Tom de Vries  <tdevries@suse.de>

PR symtab/25791
* gdb.dwarf2/gdb-add-index.exp (add_gdb_index): Move ...
(ensure_gdb_index): and factor out and move ...
* lib/gdb.exp (add_gdb_index, ensure_gdb_index): ... here.
* gdb.dwarf2/imported-unit-runto-main.exp: New file.

4 years agoFix compilation of python/python.c for Python 3.9
Kevin Buettner [Wed, 15 Apr 2020 17:20:53 +0000 (10:20 -0700)] 
Fix compilation of python/python.c for Python 3.9

This commit fixes a compilation warning/error when building GDB
with Python 3.9:

g++ -x c++  -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection  -DDNF_DEBUGINFO_INSTALL   -I. -I../../gdb -I../../gdb/config -DLOCALEDIR="\"/usr/share/locale\"" -DHAVE_CONFIG_H -I../../gdb/../include/opcode   -I../bfd -I../../gdb/../bfd -I../../gdb/../include -I../libdecnumber -I../../gdb/../libdecnumber  -I../../gdb/../gnulib/import -I../gnulib/import  -DTUI=1    -I/usr/include/guile/2.0 -pthread  -I/usr/include/python3.9 -I/usr/include/python3.9  -I../../gdb/.. -pthread -Wall -Wpointer-arith -Wno-unused -Wunused-value -Wunused-variable -Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body -Wunused-but-set-parameter -Wunused-but-set-variable -Wno-sign-compare -Wno-error=maybe-uninitialized -Wno-mismatched-tags -Wsuggest-override -Wimplicit-fallthrough=3 -Wduplicated-cond -Wshadow=local -Wdeprecated-copy -Wdeprecated-copy-dtor -Wredundant-move -Wformat -Wformat-nonliteral -Wno-unused -Werror -c -o ser-tcp.o -MT ser-tcp.o -MMD -MP -MF ./.deps/ser-tcp.Tpo ../../gdb/ser-tcp.c
../../gdb/python/python.c: In function 'bool do_start_initialization()':
../../gdb/python/python.c:1621:23: error: 'void PyEval_InitThreads()' is deprecated [-Werror=deprecated-declarations]
 1621 |   PyEval_InitThreads ();
      |                       ^
In file included from /usr/include/python3.9/Python.h:141,
                 from ../../gdb/python/python-internal.h:86,
                 from ../../gdb/python/python.c:92:
/usr/include/python3.9/ceval.h:132:37: note: declared here
  132 | Py_DEPRECATED(3.9) PyAPI_FUNC(void) PyEval_InitThreads(void);
      |                                     ^~~~~~~~~~~~~~~~~~

Information about the deprecated function can be found here:

https://docs.python.org/3.9/whatsnew/3.9.html#deprecated

Specifically, with regard to PyEval_InitThreads(), it says:

    The PyEval_InitThreads() and PyEval_ThreadsInitialized() functions
    are now deprecated and will be removed in Python 3.11.  Calling
    PyEval_InitThreads() now does nothing.  The GIL is initialized by
    Py_Initialize() since Python 3.7.  (Contributed by Victor Stinner
    in bpo-39877.)

I chose to disable the call with a #if test using PY_VERSION_HEX.
There is precedent for use of PY_VERSION_HEX; it's used in two places
in python-internal.h.  I noticed that under certain circumstances
python-internal.h defines PyEval_InitThreads to be nothing, which
accomplishes the same thing.  I considered doing something similar for
this case, but decided against it because, at some point in the future,
the presence of PyEval_InitThreads() without some explanation will be
confusing to a reader who won't be able to find PyEval_InitThreads in
the current (future for us) Python API.  IMO, use of the #if along
with an accompanying comment seemed more straightforward.

gdb/ChangeLog:

* python/python.c (do_start_initialization): Don't call
PyEval_InitThreads for Python 3.9 and beyond.

Change-Id: I0679fc10b6b76761a99538568f13188c6d8014e0

4 years agoPR25827, Null pointer dereferencing in scan_unit_for_symbols
Alan Modra [Thu, 16 Apr 2020 08:19:38 +0000 (17:49 +0930)] 
PR25827, Null pointer dereferencing in scan_unit_for_symbols

PR 25827
* dwarf2.c (scan_unit_for_symbols): Wrap overlong lines.  Don't
strdup(0).

4 years agocpu,gas,opcodes: support for eBPF JMP32 instruction class
David Faust [Thu, 16 Apr 2020 07:52:57 +0000 (09:52 +0200)] 
cpu,gas,opcodes: support for eBPF JMP32 instruction class

Add support for the JMP32 class of eBPF instructions.

cpu/ChangeLog

* bpf.cpu (define-cond-jump-insn): Renamed from djci.
(dcji) New version with support for JMP32

gas/ChangeLog

* testsuite/gas/bpf/bpf.exp: Run jump32 tests.
* testsuite/gas/bpf/jump32.s: New file.
* testsuite/gas/bpf/jump32.d: Likewise.

opcodes/ChangeLog

* bpf-desc.c: Regenerate.
* bpf-desc.h: Likewise.
* bpf-opc.c: Regenerate.
* bpf-opc.h: Likewise.

4 years ago[gdb/testsuite] Fix maint-expand-symbols-header-file.exp for cc-with-gdb-index
Tom de Vries [Thu, 16 Apr 2020 06:40:19 +0000 (08:40 +0200)] 
[gdb/testsuite] Fix maint-expand-symbols-header-file.exp for cc-with-gdb-index

With test-case gdb.base/maint-expand-symbols-header-file.exp and target board
cc-with-gdb-index, we have:
...
FAIL: gdb.base/maint-expand-symbols-header-file.exp: \
  verify no symtabs are expanded
...

By default, with partial symbols, we find the main function in the partial
symbols, and derive the initial language setting from that, without expanding
any psymtab.

But that doesn't work with the indices, because the indices don't store the
language with the symbols.  So instead, the main psymtab is expanded to get
the language of main, which causes the FAIL.

Fix this by manually setting the language.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-04-16  Tom de Vries  <tdevries@suse.de>

* gdb.base/maint-expand-symbols-header-file.exp: Set language before
loading exec.