deliverable/binutils-gdb.git
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.

4 years agoPowerPC64 GOT reloc reserving PLT entry for ifunc
Alan Modra [Thu, 16 Apr 2020 03:15:30 +0000 (12:45 +0930)] 
PowerPC64 GOT reloc reserving PLT entry for ifunc

I can't see any reason why ELFv2 should create a PLT entry for ifuncs
referenced by GOT relocs as long as the GOT entry remains.  The GOT
entry ought to be resolved by ld.so to the value returned by the ifunc
resolver, or if there is global entry stub created for some other
reason, by the linker to the stub address.

* elf64-ppc.c (ppc64_elf_check_relocs): Don't create plt entries
for GOT relocs against ifuncs.

4 years agoPowerPC64 GOT reloc optimisation
Alan Modra [Thu, 16 Apr 2020 01:13:25 +0000 (10:43 +0930)] 
PowerPC64 GOT reloc optimisation

When the symbol referenced by a GOT reloc is an ifunc, we can't
optimise away the GOT indirection.  Well, we can, but only if a global
entry stub is created with the ifunc symbol redefined to the stub.
But that results in slower code and an indirection via the PLT so
there isn't much to like about that solution.

* elf64-ppc.c (ppc64_elf_edit_toc): Exclude ifunc from GOT
optimisation.
(ppc64_elf_relocate_section): Likewise.

4 years agoExtend objdump --no-addresses info
Alan Modra [Thu, 16 Apr 2020 01:48:05 +0000 (11:18 +0930)] 
Extend objdump --no-addresses info

* doc/binutils.texi: Mention --no-show-raw-insn in objdump
--no-addresses description.

4 years agogdbserver: fix format string warning in win32-low.cc
Simon Marchi [Thu, 16 Apr 2020 01:09:17 +0000 (21:09 -0400)] 
gdbserver: fix format string warning in win32-low.cc

When compiling on Cygwin, we get:

      CXX    win32-low.o
    /home/smarchi/src/binutils-gdb/gdbserver/win32-low.cc: In function â€˜int get_child_debug_event(DWORD*, target_waitstatus*)’:
    /home/smarchi/src/binutils-gdb/gdbserver/win32-low.cc:1459:17: error: format â€˜%x’ expects argument of type â€˜unsigned int’, but argument 2 has type â€˜long int’ [-Werror=format=]
     1459 |       OUTMSG2 (("get_windows_debug_event - "
          |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
     1460 |   "unexpected stop in 0x%x (expecting 0x%x)\n",
          |   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     1461 |   ptid.lwp (), desired_stop_thread_id));
          |   ~~~~~~~~~~~
          |            |
          |            long int
    /home/smarchi/src/binutils-gdb/gdbserver/win32-low.cc:52:11: note: in definition of macro â€˜OUTMSG2’
       52 |    printf X;    \
          |           ^
    /home/smarchi/src/binutils-gdb/gdbserver/win32-low.cc:1460:26: note: format string is defined here
     1460 |   "unexpected stop in 0x%x (expecting 0x%x)\n",
          |                         ~^
          |                          |
          |                          unsigned int
          |                         %lx

`ptid.lwp ()` is a `long` value, so it indeed needs the `l` size modifier.

gdbserver/ChangeLog:

* win32-low.cc (get_child_debug_event): Fix format string warning.

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

4 years agoFix OpenBSD build error.
Kamil Rytarowski [Wed, 15 Apr 2020 19:23:30 +0000 (14:23 -0500)] 
Fix OpenBSD build error.

This was likely introduced by 5b6d1e4fa4fc6827c7b3f0e99ff120dfa14d65d2

gdb/ChangeLog:

2020-04-15  Kamil Rytarowski  <n54@gmx.com>

* obsd-nat.c (obsd_nat_target::update_thread_list): Pass "this" to
thread functions.
(obsd_nat_target::wait): Likewise.

Change-Id: Ib8d11238c55e0ebdbcf127d1f28c9693c785527a

4 years agoUse debug_printf in windows-nat.c
Tom Tromey [Wed, 15 Apr 2020 18:37:29 +0000 (12:37 -0600)] 
Use debug_printf in windows-nat.c

While debugging a bug on Windows, I noticed that windows-nat.c is not
sending its debugging output to gdb_stdlog.  This is unfortunate
because it means that "set logging debugredirect" doesn't work
properly.

This patch fixes the problem by changing windows-nat.c to use
debug_printf.

Note that get_windows_debug_event also writes one debugging message
unconditionally.  It isn't clear to me if this really ought to use
DEBUG_EVENTS or not, since it seems like perhaps it is intended to
note an unexpected event occurring.  So, I didn't change this.

I'm checking this in.

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

* windows-nat.c (DEBUG_EXEC, DEBUG_EVENTS, DEBUG_MEM)
(DEBUG_EXCEPT): Use debug_printf.

4 years agogdb: Don't corrupt completions hash when expanding the hash table
Andrew Burgess [Sat, 4 Apr 2020 13:54:15 +0000 (14:54 +0100)] 
gdb: Don't corrupt completions hash when expanding the hash table

Commit:

  commit 724fd9ba432a20ef2e3f2c0d6060bff131226816
  Date:   Mon Jan 27 17:37:20 2020 +0000

      gdb: Restructure the completion_tracker class

caused the completion hash table to become corrupted if the table ever
needed to grow beyond its original size of 200 elements.

The hash table stores completion_tracker::completion_hash_entry
objects, but hashes them based on their name, which is only one field
of the object.

When possibly inserting a new element we compute the hash with
htab_hash_string of the new elements name, and then lookup matching
elements using htab_find_slot_with_hash.  If there's not matching
element we create a completion_hash_entry object within the hash
table.

However, when we allocate the hash we pass htab_hash_string to
htab_create_alloc as the hash function, and this is not OK.  This
means that when the hash table needs to grow, existing elements within
the hash are re-hashed by passing the completion_hash_entry pointer to
htab_hash_string, which obviously does not do what we expect.

The solution is to create a new hash function that takes a pointer to
a completion_hash_entry, and then calls htab_hash_string on the name
of the entry only.

This regression was spotted when running the gdb.base/completion.exp
test on the aarch64 target.

gdb/ChangeLog:

* completer.c (class completion_tracker::completion_hash_entry)
<hash_name>: New member function.
(completion_tracker::discard_completions): New callback to hash a
completion_hash_entry, pass this to htab_create_alloc.

gdb/testsuite/ChangeLog:

* gdb.base/many-completions.exp: New file.

4 years agoBetter handling of realpath() failure in windows_make_so() on Cygwin
Jon Turney [Wed, 13 Jan 2016 18:27:48 +0000 (18:27 +0000)] 
Better handling of realpath() failure in windows_make_so() on Cygwin

It seems Cygwin's realpath() can fail on certain DLLs (apparently some
AV software prevent it working on it's DLLs; See [1], [2]).  Warn rather
than stopping with an error if that occurs.

Based on an original patch from Tim Chick.

[1] https://cygwin.com/ml/cygwin/2014-08/msg00401.html
[2] https://cygwin.com/ml/cygwin/2015-11/msg00353.html

gdb/ChangeLog:

2016-01-20  Jon Turney  <jon.turney@dronecode.org.uk>

* windows-nat.c (windows_make_so): Warn rather than stopping with
an error if realpath() fails.

4 years agoUnify the behaviour of ld.bfd and ld.gold with respect to warning about unresolved...
Fangrui Song [Wed, 15 Apr 2020 13:25:08 +0000 (14:25 +0100)] 
Unify the behaviour of ld.bfd and ld.gold with respect to warning about unresolved symbol references.  (PR 24613)

PR binutils/24613
include * bfdlink.h (enum report_method): Delete RM_GENERATE_WARNING and
RM_GENERATE_ERROR. Add RM_DIAGNOSE.
(struct bfd_link_info): Add warn_unresolved_syms.

ld * lexsup.c (parse_args): Change RM_GENERATE_WARNING and
RM_GENERATE_ERROR to RM_DIAGNOSE.
* emultempl/aix.em (ld_${EMULATION_NAME}_emulation): Change
RM_GENERATE_ERROR to RM_DIAGNOSE.
* emultempl/elf.em (ld_${EMULATION_NAME}_emulation): Likewise.

bfd * coff-rs6000.c (xcoff_ppc_relocate_section): Change RM_GENERATE_ERROR
to RM_DIAGNOSE plus a check of warn_unresolved_syms.
* coff64-rs6000.c (xcoff_ppc_relocate_section): Likewise.
* elf-bfd.h (_bfd_elf_large_com_section): Likewise.
* elf32-m32r.c (m32r_elf_relocate_section): Likewise.
* elf32-score.c (s3_bfd_score_elf_relocate_section): Likewise.
* elf32-score7.c (s7_bfd_score_elf_relocate_section): Likewise.
* elf32-sh.c (sh_elf_relocate_section): Likewise.
* elf32-spu.c (spu_elf_relocate_section): Likewise.
* elf64-hppa.c (elf64_hppa_relocate_section): Likewise.
* elflink.c (elf_link_output_extsym): Likewise.
* elfxx-mips.c (mips_elf_calculate_relocation): Likewise.

4 years agoobjdump --no-addresses
Alan Modra [Wed, 15 Apr 2020 09:56:55 +0000 (19:26 +0930)] 
objdump --no-addresses

I find this useful when needing to compare compiler output, where the
address of the instruction and the value of symbols results in
unwanted differences.

* objdump.c (no_addresses): New static var.
(usage): Print help for --no-addresses.
(long_options): Add --no-addresses entry.
(objdump_print_addr_with_sym, objdump_print_addr): Omit symbol address.
(disassemble_bytes): Don't print current line address, or reloc
address.
* doc/binutils.texi: Document objdump --no-addresses.

4 years agoPR25823, Use after free in bfd_hash_lookup
Alan Modra [Wed, 15 Apr 2020 09:28:11 +0000 (18:58 +0930)] 
PR25823, Use after free in bfd_hash_lookup

PR 25823
* peXXigen.c (_bfd_XXi_swap_sym_in <C_SECTION>): Don't use a
pointer into strings that may be freed for section name, always
allocate a new string.

4 years agoFix makeinfo warnings in gdb.texinfo and python.texi docs
Artur Shepilko [Wed, 15 Apr 2020 07:44:12 +0000 (09:44 +0200)] 
Fix makeinfo warnings in gdb.texinfo and python.texi docs

Building gdb-9.1 on a system that has an older version of makeinfo
(4.8) shows the following warnings:

-----------------
make[4]: Entering directory '/home/tester/gdb-9.1/build/gdb/doc'
makeinfo --split-size=5000000 --split-size=5000000   -I
../../../gdb/doc/../../readline/readline/doc -I ../../../gdb/doc/../mi
-I ../../../gdb/doc \
    -o gdb.info ../../../gdb/doc/gdb.texinfo
../../../gdb/doc/gdb.texinfo:21867: warning: unlikely character [ in @var.
../../../gdb/doc/gdb.texinfo:21867: warning: unlikely character ] in @var.
../../../gdb/doc/gdb.texinfo:21868: warning: unlikely character [ in @var.
../../../gdb/doc/gdb.texinfo:21868: warning: unlikely character ] in @var.
../../../gdb/doc/gdb.texinfo:21869: warning: unlikely character [ in @var.
../../../gdb/doc/gdb.texinfo:21869: warning: unlikely character ] in @var.
../../../gdb/doc/gdb.texinfo:21872: warning: unlikely character [ in @var.
../../../gdb/doc/gdb.texinfo:21872: warning: unlikely character ] in @var.
../../../gdb/doc/gdb.texinfo:21874: warning: unlikely character [ in @var.
../../../gdb/doc/gdb.texinfo:21874: warning: unlikely character ] in @var.
../../../gdb/doc/gdb.texinfo:21876: warning: unlikely character [ in @var.
../../../gdb/doc/gdb.texinfo:21876: warning: unlikely character ] in @var.
../../../gdb/doc/gdb.texinfo:21879: warning: unlikely character [ in @var.
../../../gdb/doc/gdb.texinfo:21879: warning: unlikely character ] in @var.
../../../gdb/doc/gdb.texinfo:21931: warning: unlikely character [ in @var.
../../../gdb/doc/gdb.texinfo:21931: warning: unlikely character ] in @var.
../../../gdb/doc/gdb.texinfo:21933: warning: unlikely character [ in @var.
../../../gdb/doc/gdb.texinfo:21933: warning: unlikely character ] in @var.
../../../gdb/doc/gdb.texinfo:21936: warning: unlikely character [ in @var.
../../../gdb/doc/gdb.texinfo:21936: warning: unlikely character ] in @var.
../../../gdb/doc/gdb.texinfo:21939: warning: unlikely character [ in @var.
../../../gdb/doc/gdb.texinfo:21939: warning: unlikely character ] in @var.
../../../gdb/doc//python.texi:3297: warning: `.' or `,' must follow
@xref, not `A'.
make[4]: Leaving directory '/home/tester/gdb-9.1/build/gdb/doc'
-----------------

These are thrown by expressions like `@var{[host]}`, intended to
produce `[HOST]`.

In that context this should instead be changed to `[@var{host}]`, which
has the same effect but without the warnings.

As for the warning in `python.texi`, there's period missing at the end
of one `@xref{}` clause.  Added.

gdb/doc/ChangeLog:

2020-04-15  Artur Shepilko  <nomadbyte@gmail.com>

* gdb.texinfo: Transform @var{[host]} to [@var{host}]; this
clears makeinfo warnings.
* python.texi: Add a missing period trailing an @xref{} clause;
this clears a makeinfo warning.

4 years agoPR25822, Invalid read in process_symbol_table
Alan Modra [Wed, 15 Apr 2020 07:08:01 +0000 (16:38 +0930)] 
PR25822, Invalid read in process_symbol_table

PR 25822
* readelf.c (get_num_dynamic_syms): Don't set num_of_syms when
reading buckets or chains fails.

4 years agoreadelf: zero static vars after freeing
Alan Modra [Wed, 15 Apr 2020 07:10:54 +0000 (16:40 +0930)] 
readelf: zero static vars after freeing

When readelf is processing more than one file, static bss vars won't
start out as zero for the second file unless they are cleared.

* readelf.c (process_symbol_table): Zero gnubuckets, gnuchains
etc. after freeing.

4 years agoreadelf: increase size of static buffers
Alan Modra [Wed, 15 Apr 2020 05:23:32 +0000 (14:53 +0930)] 
readelf: increase size of static buffers

Translated strings might be larger than the original.

* readelf.c (get_group_flags): Translate text.
(get_file_type, get_symbol_binding, get_symbol_type),
(get_ppc64_symbol_other, get_symbol_other): Increase size of buffer.

4 years agoRe: readelf: Consolidate --syms --use-dynamic with --dyn-syms
Alan Modra [Wed, 15 Apr 2020 03:09:54 +0000 (12:39 +0930)] 
Re: readelf: Consolidate --syms --use-dynamic with --dyn-syms

PR 25821
* readelf.c (get_num_dynamic_syms): Typo fix.

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

4 years ago[PATCH v2 2/2] coff-go32: support extended relocations
Juan Manuel Guerrero [Tue, 14 Apr 2020 16:30:01 +0000 (17:30 +0100)] 
[PATCH v2 2/2] coff-go32: support extended relocations

This patch extends the relocation and line number counters for
coff-go32 and coff-go32-exe to 32 bits.  As I understand it works the
same as for PE-COFF:

If the number of relocations in an object file exceeds 65534, the
NRELOC field is set to 65535 and the actual number of relocations is
stored in the VADDR field of the first relocation entry.

Executable files have no relocations, and thus the NRELOC field is
repurposed to extend NLNNO to 32-bits.

bfd * coff-go32.c (COFF_GO32, IMAGE_SCN_LNK_NRELOC_OVFL)
(coff_SWAP_scnhdr_in, coff_SWAP_scnhdr_out): Define.
(_bfd_go32_swap_scnhdr_in, _bfd_go32_swap_scnhdr_out)
(_bfd_go32_mkobject): New functions.
* coff-stgo32.c (IMAGE_SCN_LNK_NRELOC_OVFL)
(coff_SWAP_scnhdr_in, coff_SWAP_scnhdr_out): Define.
(go32exe_mkobject): Call _bfd_go32_mkobject.
* coffcode.h (COFF_WITH_EXTENDED_RELOC_COUNTER): Define.
(coff_set_alignment_hook): Define function for COFF_GO32_EXE
and COFF_GO32.
(coff_write_relocs): Enable extended reloc counter code if
COFF_WITH_EXTENDED_RELOC_COUNTER is defined.  Test for obj_go32.
(coff_write_object_contents): Likewise.  Pad section headers
for COFF_GO32 and COFF_GO32EXE.  Use bfd_coff_swap_scnhdr_out
instead of coff_swap_scnhdr_out.
* cofflink.c (_bfd_coff_final_link): Test also for obj_go32 to
enable extended reloc counter.
* coffswap.h: (coff_swap_scnhdr_in, coff_swap_scnhdr_out):
Declare with ATTRIBUTE_UNUSED.
* libcoff-in.h: (struct coff_tdata): New field go32.
(obj_go32): Define.
* libcoff.h: Regenerate.

4 years agoImplement IP_STAT+IP_STATUS (aliases of the same format) on NetBSD
Kamil Rytarowski [Mon, 13 Apr 2020 11:05:59 +0000 (13:05 +0200)] 
Implement IP_STAT+IP_STATUS (aliases of the same format) on NetBSD

Output based on FreeBSD with the following changes:
 - "utime+stime, children" merged from "utime, children" and
   "stime, children".
 - "Minor faults, children", "Major faults, children",
   "Virtual memory size" removed as not available in a direct
   equivalent.

No new values missing or skipped in FreeBSD are printed, although
there is a long list of potential candiates.

gdb/ChangeLog:

        * nbsd-nat.c (nbsd_pid_to_kinfo_proc2): New.
        (nbsd_nat_target::info_proc): Add do_status.

4 years agoThe assembler only supports 32-bit stabs. So set sh_entsize unconditionally to 12.
Fangrui Song [Tue, 14 Apr 2020 14:21:50 +0000 (15:21 +0100)] 
The assembler only supports 32-bit stabs. So set sh_entsize unconditionally to 12.

PR gas/25768
* elf.c (assign_section_numbers): Always set .stab sh_entsize to
12.

4 years agoreadelf memory leaks processing mips
Alan Modra [Tue, 14 Apr 2020 00:21:44 +0000 (09:51 +0930)] 
readelf memory leaks processing mips

* readelf.c (process_mips_specific): Free eopt and iopt.  Avoid
possibility of overflow when checking number of conflicts.

4 years agoFixes for the magic number used in PDP11 AOUT binaries.
Stephen Casner [Tue, 14 Apr 2020 13:41:27 +0000 (14:41 +0100)] 
Fixes for the magic number used in PDP11 AOUT binaries.

PR ld/25677
include * aout/aout64.h (N_DATADDR): Add IMAGIC case.

bfd * pdp11.c: Add implementation of --imagic option.
(adjust_o_magic): Fix objcopy --extract-symbol test.
* libaout.h (enum aout_magic): Add i_magic.

ld * emulparams/pdp11.sh (SCRIPT_NAME): Change to pdp11.
(EXTRA_EM_FILE): New, add emulation file pdp11.
* scripttempl/pdp11.sc: New, derived from aout.sc without
irrelevant input sections.
* emultempl/pdp11.em (_add_options, _handle_option)
(_list_options): New. Add options -z, --imagic for pdp11-aout.
(_before_parse): Make --omagic be default instead of --nmagic.
(_get_script): Modify special-case linker script for --imagic.
* lexsup.c (parse_args): Explictly set config.text_read_only for -n.
* ld.texi (Options): Add documentation of PDP11-specific options.
(Options): Fix unrelated typo to --no-compact-branches.
* gen-doc.texi: @set PDP11.
* testsuite/ld-pdp11/pdp11.exp: New, start pdp11 testing.
* testsuite/ld-pdp11/sections.s: New, source for options tests.
* testsuite/ld-pdp11/imagic.d: New, test --imagic format.
* testsuite/ld-pdp11/imagicz.d: New, test -z (imagic) format.
* testsuite/ld-pdp11/nmagic.d: New, test --nmagic format.
* testsuite/ld-pdp11/omagic.d: New, test --omagic format.

4 years ago[gdb] Fix missing symtab includes
Tom de Vries [Tue, 14 Apr 2020 13:30:50 +0000 (15:30 +0200)] 
[gdb] Fix missing symtab includes

[ The test-case requires commit c1a66c0629 "[gdb] Expand symbolless symtabs
using maint expand-symtabs". ]

Consider the debug info for the test-case included in this patch.  It consists
of a PU:
...
 <0><d2>: Abbrev Number: 2 (DW_TAG_partial_unit)
 <1><d3>: Abbrev Number: 0
...
imported by a CU:
...
 <0><df>: Abbrev Number: 2 (DW_TAG_compile_unit)
    <e0>   DW_AT_language    : 2        (non-ANSI C)
    <e1>   DW_AT_stmt_list   : 0xe9
 <1><e5>: Abbrev Number: 3 (DW_TAG_imported_unit)
    <e6>   DW_AT_import      : <0xd2>   [Abbrev Number: 2]
 <1><ea>: Abbrev Number: 0
...
and the CU has a dw2-symtab-includes.h file in the .debug_line file name
table:
...
 The Directory Table (offset 0x101):
  1     /data/gdb_versions/devel/src/gdb/testsuite/gdb.dwarf2

 The File Name Table (offset 0x138):
  Entry Dir     Time    Size    Name
  1     1       0       0       dw2-symtab-includes.h
...

After expanding all symtabs, we can see the CU listed in the user field of the
PU, and vice-versa the PU listed in the includes of the CU:
...
$ gdb.sh -batch \
  -iex "set language c" \
  outputs/gdb.dwarf2/dw2-symtab-includes/dw2-symtab-includes \
  -ex "maint expand-symtabs" \
  -ex "maint info symtabs"
  ...
  { ((struct compunit_symtab *) 0x394dd60)
    debugformat DWARF 2
    producer (null)
    dirname (null)
    blockvector ((struct blockvector *) 0x394dea0)
    user ((struct compunit_symtab *) 0x394dba0)
  }
  { ((struct compunit_symtab *) 0x394dba0)
    debugformat DWARF 2
    producer (null)
    dirname (null)
    blockvector ((struct blockvector *) 0x394dd10)
    user ((struct compunit_symtab *) (null))
    ( includes
      ((struct compunit_symtab *) 0x394dd60)
    )
  }
...

But if we instead only expand the symtab for the dw2-symtab-includes.h file,
the includes and user links are gone:
...
$ gdb -batch \
  -iex "set language c" \
  outputs/gdb.dwarf2/dw2-symtab-includes/dw2-symtab-includes \
  -ex "maint expand-symtabs dw2-symtab-includes.h" \
  -ex "maint info symtabs"
  ...
  { ((struct compunit_symtab *) 0x2728210)
    debugformat DWARF 2
    producer (null)
    dirname (null)
    blockvector ((struct blockvector *) 0x2728350)
    user ((struct compunit_symtab *) (null))
  }
  { ((struct compunit_symtab *) 0x2728050)
    debugformat DWARF 2
    producer (null)
    dirname (null)
    blockvector ((struct blockvector *) 0x27281c0)
    user ((struct compunit_symtab *) (null))
  }
...

The includes are calculated by process_cu_includes in gdb/dwarf2/read.c.

In the case of expanding all symtabs:
- the CU partial symtab is expanded using psymtab_to_symtab
- psymtab_to_symtab calls dwarf2_psymtab::read_symtab
- dwarf2_psymtab::read_symtab calls dwarf2_psymtab::expand_psymtab
- dwarf2_psymtab::read_symtab calls process_cu_includes, and we have the
  includes

In the case of expanding the symtab for dw2-symtab-includes.h:
- the dw2-symtab-includes.h partial symtab is expanded using psymtab_to_symtab
- psymtab_to_symtab calls dwarf2_include_psymtab::read_symtab
- dwarf2_include_psymtab::read_symtab calls
  dwarf2_include_psymtab::expand_psymtab
- dwarf2_include_psymtab::expand_psymtab calls
  partial_symtab::expand_dependencies
- partial_symtab::expand_dependencies calls dwarf2_psymtab::expand_psymtab
  for the CU partial symtab
- the CU partial symtab is expanded using dwarf2_psymtab::expand_psymtab
- process_cu_includes is never called

Fix this by making sure in dwarf2_include_psymtab::read_symtab that
read_symtab is called for the CU partial symtab.

Tested on x86_64-linux, with native, and target board cc-with-dwz and
cc-with-dwz-m.

In addition, tested test-case with target boards cc-with-gdb-index.exp,
cc-with-debug-names.exp and readnow.exp.

gdb/ChangeLog:

2020-04-14  Simon Marchi  <simon.marchi@polymtl.ca>
    Tom de Vries  <tdevries@suse.de>

PR symtab/25718
* psympriv.h (struct partial_symtab::read_symtab)
(struct partial_symtab::expand_psymtab)
(struct partial_symtab::read_dependencies): Update comments.
* dwarf2/read.c (struct dwarf2_include_psymtab::read_symtab): Call
read_symtab for includer.
(struct dwarf2_include_psymtab::expand_psymtab): Assert false.
(struct dwarf2_include_psymtab::readin_p): Call readin_p () for includer.
(struct dwarf2_include_psymtab::m_readin): Remove.
(struct dwarf2_include_psymtab::includer): New member function.
(dwarf2_psymtab::expand_psymtab): Assert !readin.

gdb/testsuite/ChangeLog:

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

PR symtab/25718
* gdb.dwarf2/dw2-symtab-includes.exp: New file.

4 years ago[gdb] Expand symbolless symtabs using maint expand-symtabs
Tom de Vries [Tue, 14 Apr 2020 13:08:42 +0000 (15:08 +0200)] 
[gdb] Expand symbolless symtabs using maint expand-symtabs

Consider this test-case, consisting of header file hello.h:
...
inline static const char*
foo (void)
{
  return "foo";
}
...
and source file hello.c:
...
int
main (void)
{
  printf ("hello: %s\n", foo ());
  return 0;
}
...
compiled with -g:
...
$ gcc hello.c -g
...

When trying to expand the partial symtab for hello.h:
...
$ gdb -batch \
  -iex "set language c" \
  a.out \
  -ex "maint expand-symtabs hello.h" \
  -ex "maint info psymtabs"
...
we in fact find that the partial symtab for hello.h (and corresponding
includer partial symtab hello.c) have not been expanded:
...
  { psymtab hello.h ((struct partial_symtab *) 0x27cf070)
    readin no
  ...
  { psymtab hello.c ((struct partial_symtab *) 0x2cf09e0)
    readin no
...

This is due to the recursively_search_psymtabs call in
psym_expand_symtabs_matching:
...
      if (recursively_search_psymtabs (ps, objfile, domain,
                                      lookup_name, symbol_matcher))
...
which always returns false for symbolless partial symtabs.

The same problem occurs with CUs where the dwarf is generated by gas
--gdwarf-2 for a foo.S: if we read such a test-case with -readnow, we'll have
a symbolless symtab for foo.S.  But if we read the test-case with partial
symtabs, and expand those using "maint expand-symtabs", the foo.S psymtab
remains unexpanded.

Fix this by passing a NULL symbol_matcher and lookup_name to
expand_symtabs_matching in maintenance_expand_symtabs, and skipping the call
to recursively_search_psymtabs if symbol_matcher == NULL and
lookup_name == NULL.

Build and tested on x86_64-linux, with native.

In addition, tested test-case with target boards cc-with-gdb-index.exp,
cc-with-debug-names.exp and readnow.exp.

gdb/ChangeLog:

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

PR symtab/25720
* symmisc.c (maintenance_expand_symtabs): Call expand_symtabs_matching
with NULL symbol_matcher and lookup_name.
* psymtab.c (psym_expand_symtabs_matching): Handle NULL symbol_matcher
and lookup_name.
* dwarf2/read.c (dw2_expand_symtabs_matching)
(dw2_debug_names_expand_symtabs_matching): Same.
* symfile.h (struct quick_symbol_functions::expand_symtabs_matching):
Make lookup_name a pointer.  Update comment.
* symtab.c (global_symbol_searcher::expand_symtabs): Handle
lookup_name being a pointer.
* symfile.c (expand_symtabs_matching): Same.
* symfile-debug.c (debug_qf_expand_symtabs_matching): Same.
* linespec.c (iterate_over_all_matching_symtabs): Same.

gdb/testsuite/ChangeLog:

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

PR symtab/25720
* gdb.base/maint-expand-symbols-header-file.c: New test.
* gdb.base/maint-expand-symbols-header-file.exp: New file.
* gdb.base/maint-expand-symbols-header-file.h: New test.

4 years agoreadelf: Consolidate --syms --use-dynamic with --dyn-syms
H.J. Lu [Tue, 14 Apr 2020 12:00:22 +0000 (05:00 -0700)] 
readelf: Consolidate --syms --use-dynamic with --dyn-syms

When reconstructing dynamic symbol table from the PT_DYNAMIC segment,
compute dynamic symbol table size from hash table.  For DT_HASH, the
number of dynamic symbol table entries equals the number of chains.
For DT_GNU_HASH/DT_MIPS_XHASH, only defined symbols with non-STB_LOCAL
indings are in hash table.  Since DT_GNU_HASH/DT_MIPS_XHASH place all
symbols with STB_LOCAL binding before symbols with other bindings and
all undefined symbols defined ones in dynamic symbol table, the highest
symbol index in DT_GNU_HASH/DT_MIPS_XHASH is the highest dynamic symbol
table index.

Rewrite print_dynamic_symbol to dump dynamic symbol table for --dyn-syms
and --syms --use-dynamic.

binutils/

PR binutils/25707
* readelf.c (nbuckets): New.
(nchains): Likewise.
(buckets): Likewise.
(chains): Likewise.
(ngnubuckets): Likewise.
(gnubuckets): Likewise.
(gnuchains): Likewise.
(mipsxlat): Likewise.
(ngnuchains): Likewise.
(gnusymidx): Likewise.
(VALID_SYMBOL_NAME): Likewise.
(VALID_DYNAMIC_NAME): Use it.
(get_dynamic_data): Moved before process_dynamic_section.
(get_num_dynamic_syms): New function.
(process_dynamic_section): Use DT_SYMTAB, DT_SYMENT, DT_HASH,
DT_GNU_HASH and DT_MIPS_XHASH to reconstruct dynamic symbol
table.  Use DT_STRTAB and DT_STRSZ to reconstruct dynamic string
table.
(get_symbol_index_type): Don't print "bad section index" when
there is no section header.
(print_dynamic_symbol): Rewrite.
(process_symbol_table): Call print_dynamic_symbol to dump dynamic
symbol table.

ld/

PR binutils/25707
* testsuite/ld-arm/armthumb-lib.sym: Updated.
* testsuite/ld-arm/farcall-mixed-app.sym: Likewise.
* testsuite/ld-arm/farcall-mixed-app2.sym: Likewise.
* testsuite/ld-arm/fdpic-main-m.sym: Likewise.
* testsuite/ld-arm/fdpic-main.sym: Likewise.
* testsuite/ld-arm/fdpic-shared-m.sym: Likewise.
* testsuite/ld-arm/fdpic-shared.sym: Likewise.
* testsuite/ld-arm/mixed-app.sym: Likewise.
* testsuite/ld-arm/mixed-lib.sym: Likewise.
* testsuite/ld-arm/preempt-app.sym: Likewise.
* testsuite/ld-elf/hash.d: Likewise.
* testsuite/ld-elf/pr13195.d: Likewise.
* testsuite/ld-elfvsb/hidden2.d: Likewise.
* testsuite/ld-mips-elf/hash2.d: Likewise.

4 years agogdb/testsuite: Move helper function into lib/dwarf.exp
Andrew Burgess [Fri, 3 Apr 2020 19:41:00 +0000 (20:41 +0100)] 
gdb/testsuite: Move helper function into lib/dwarf.exp

Every time I write a test making use of the DWARF assembler I end up
copying in the function get_func_info.  Duplicating code is bad, so
lets put this function into lib/dwarf.exp and remove all of the
duplicates.

There should be no changes in the testsuite behaviour after this
commit.

gdb/testsuite/ChangeLog:

* gdb.dwarf2/dw2-inline-many-frames.exp (get_func_info): Delete.
* gdb.dwarf2/dw2-inline-small-func.exp: Pass options to
get_func_info.
(get_func_info): Delete.
* gdb.dwarf2/dw2-is-stmt-2.exp (get_func_info): Delete.
* gdb.dwarf2/dw2-is-stmt.exp (get_func_info): Delete.
* lib/dwarf.exp (get_func_info): New function.

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

This page took 0.055539 seconds and 4 git commands to generate.