binutils-gdb.git
3 years agooops - forgot to include the changelog update for the latest binutils/dwarf.c patch
Nick Clifton [Tue, 10 Nov 2020 17:31:14 +0000 (17:31 +0000)]
oops - forgot to include the changelog update for the latest binutils/dwarf.c patch

3 years agoFix bug in gdb.ada/bias.exp
Tom Tromey [Tue, 10 Nov 2020 17:06:08 +0000 (10:06 -0700)]
Fix bug in gdb.ada/bias.exp

While working on a different bug in the Ada support, I found that the
gdb.ada/bias.exp test is slightly incorrect.  In particular, it is
using a range type, which it then overflows during an operation.

This patch changes the test so that the computed values remain in
range.

gdb/testsuite/ChangeLog
2020-11-10  Tom Tromey  <tromey@adacore.com>

* gdb.ada/bias.exp: Update.
* gdb.ada/bias/bias.adb (X): Change value.

3 years agoPrevent false passes in gdb.base/vla-optimized-out.exp
Gary Benson [Tue, 10 Nov 2020 16:40:40 +0000 (16:40 +0000)]
Prevent false passes in gdb.base/vla-optimized-out.exp

The "vla_optimized_out" procedure in gdb.base/vla-optimized-out.exp
accepts a "sizeof_result" argument which is substituted into the
regular expression used to check the result of printing the sizeof
a VLA.  The -O3 test variants, however, pass a regular expression
fragment as that argument, which expands into a regular expression
that matches any result with a "6" in it.  This commit wraps the
substitution with parentheses to prevent these false matches.

gdb/testsuite/ChangeLog:

* gdb.base/vla-optimized-out.exp (p sizeof (a)): Wrap supplied
regexp fragment in parentheses to prevent false matching.

3 years agoPrevent inlining in gdb.base/vla-optimized-out.c
Gary Benson [Tue, 10 Nov 2020 16:40:40 +0000 (16:40 +0000)]
Prevent inlining in gdb.base/vla-optimized-out.c

The function f1 in gdb.base/vla-optimized-out.c sets various
attributes to prevent its being inlined, but Clang inlines it
anyway, causing the test that uses it to fail.  This commit
adds the "weak" attribute to cause Clang to keep the function
fully out of line so the test can operate as it should.

gdb/testsuite/ChangeLog:

* gdb.base/vla-optimized-out.c (f1): Add __attribute__ ((weak)).

3 years agoFix gdb.cp/step-and-next-inline.exp with Clang
Gary Benson [Tue, 10 Nov 2020 16:07:36 +0000 (16:07 +0000)]
Fix gdb.cp/step-and-next-inline.exp with Clang

Clang fails to compile gdb.cp/step-and-next-inline.cc, with the
following error:

  clang-12: error: unknown argument: '-gstatement-frontiers'
  compiler exited with status 1

This commit fixes the testcase by only passing -gstatement-frontiers
when building with GCC.  This commit also alters two checks marked as
known failures, to mark them as known failures only when built using
GCC.

gdb/testsuite/ChangeLog:

* gdb.cp/step-and-next-inline.exp: Only require
-gstatement-frontiers when building with GCC.
Only setup KFAIL's for GCC issues when using
a GCC-built executable.

3 years agoAccept the DW_FORM_ref8 type when parsing DWARF types.
Nick Clifton [Tue, 10 Nov 2020 11:55:18 +0000 (11:55 +0000)]
Accept the DW_FORM_ref8 type when parsing DWARF types.

* dwarf.c (skip_attr_bytes): Correctly handle DW_FORM_ref8.
(get_type_abbrev_from_form): Accept DW_FORM_ref8.

3 years agoAutomatic date update in version.in
GDB Administrator [Tue, 10 Nov 2020 00:00:19 +0000 (00:00 +0000)]
Automatic date update in version.in

3 years agoRevert delta accidentally applied with commit 9372689d72f902c8bae90536acc4747fb0a4b1e1
Nick Clifton [Mon, 9 Nov 2020 16:47:29 +0000 (16:47 +0000)]
Revert delta accidentally applied with commit 9372689d72f902c8bae90536acc4747fb0a4b1e1

3 years agogas: improve reproducibility for stabs debugging data format
Denys Zagorui [Mon, 9 Nov 2020 15:39:10 +0000 (15:39 +0000)]
gas: improve reproducibility for stabs debugging data format

* config/obj-elf (obj_elf_init_stab_section): Improve
reproducibility for stabs debugging data format

3 years agoasan: vms-alpha: stack buffer overflow
Alan Modra [Mon, 9 Nov 2020 12:53:34 +0000 (23:23 +1030)]
asan: vms-alpha: stack buffer overflow

32 bits is too big for the field.

* vms-alpha.c (alpha_vms_write_exec): Write 16 bits to eihd.alias.

3 years agoAdd support for the LMBD (left-most bit detect) instruction to the PRU assembler.
Spencer E. Olson [Mon, 9 Nov 2020 12:41:09 +0000 (12:41 +0000)]
Add support for the LMBD (left-most bit detect) instruction to the PRU assembler.

include * opcode/pru.h: Add LMBD (left-most bit detect) opcode index
opcodes * pru-opc.c: Add opcode description for LMBD (left-most bit detect)
gas  * testsuite/gas/pru/misc.s: Add tests for lmbd (left-most bit detect)
  * testsuite/gas/pru/misc.d: Add tests for lmbd (left-most bit

3 years agoaarch64: Update LS64 feature with system register
Przemyslaw Wirkus [Mon, 9 Nov 2020 11:30:22 +0000 (11:30 +0000)]
aarch64: Update LS64 feature with system register

This patch:
+ Adds new ACCDATA_EL1 (Accelerator Data) system register, see [0].
+ Adds LS64 instruction tests.
+ Update LS64 feature test with new register.
+ Fix comment for AARCH64_OPND_Rt_LS64.

    [0] https://developer.arm.com/docs/ddi0595/i/aarch64-system-registers/accdata_el1

Note: as this is register only extension we do not want to hide these
registers behind -march flag going forward (they should be enabled by
default).

3 years agoaarch64: Limit Rt register number for LS64 load/store instructions
Przemyslaw Wirkus [Mon, 9 Nov 2020 11:09:12 +0000 (11:09 +0000)]
aarch64: Limit Rt register number for LS64 load/store instructions

Atomic 64-byte load/store instructions limit Rt register number to
values matching below condition (register <Xt> number must be even
and <= 22):

    if Rt<4:3> == '11' || Rt<0> == '1' then UNDEFINED;

This patch adds check if Rt fulfills above requirement.

For more details regarding atomic 64-byte load/store instruction for
Armv8.7 please refer to Arm A64 Instruction set documentation for
Armv8-A architecture profile, see document page 157 for load
instruction, and pages 414-418 for store instructions of [0].

    [0]: https://developer.arm.com/docs/ddi0596/i

3 years agoFix regexp for development.exp
Andreas Schwab [Sat, 7 Nov 2020 20:28:47 +0000 (21:28 +0100)]
Fix regexp for development.exp

binutils/:
* Makefile.am (development.exp): Fix regexp.
* Makefile.in: Regenerate.
gas/:
* Makefile.am (development.exp): Fix regexp.
* Makefile.in: Regenerate.
ld/:
* Makefile.am (development.exp): Fix regexp.
* Makefile.in: Regenerate.

3 years agoExtend the DWARF decoder to display FORM names when operating in wide mode.
Nick Clifton [Mon, 9 Nov 2020 10:37:51 +0000 (10:37 +0000)]
Extend the DWARF decoder to display FORM names when operating in wide mode.

PR 26847
* dwarf.c (read_and_display_attr_value): In wide mode, display the
name of the form.

3 years agoelfedit false "may be used uninitialised"
Alan Modra [Sun, 8 Nov 2020 23:09:53 +0000 (09:39 +1030)]
elfedit false "may be used uninitialised"

elfedit.c:904:15: error: 'osabi' may be used uninitialised in this function [-Werror=maybe-uninitialized]
  904 |       osabi = concat (osabi, "|", osabis[i].name, NULL);
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* elfedit (usage): Avoid false positive "may be used uninitialised".
Don't leak memory.

3 years agoxcoff dependency list for static libraries
Alan Modra [Mon, 9 Nov 2020 02:34:04 +0000 (13:04 +1030)]
xcoff dependency list for static libraries

This patch fixes fails adding library dependencies for xcoff, and
improves the error message should stat fail for an archive member.
"tmpdir/artest.a: File not found" is plainly wrong.

Fixes these fails:
powerpc-aix5.1  +FAIL: ar adding library dependencies
powerpc-aix5.2  +FAIL: ar adding library dependencies
rs6000-aix4.3.3  +FAIL: ar adding library dependencies
rs6000-aix5.1  +FAIL: ar adding library dependencies
rs6000-aix5.2  +FAIL: ar adding library dependencies

* archive.c (bfd_ar_hdr_from_filesystem): Use bfd_set_input_error
when stat of archive member fails.
* coff-rs6000.c (xcoff_write_archive_contents_old),
(xcoff_write_archive_contents_big): Likewise, and handle in-memory
bfd.

3 years agoRe: dependency list for static libraries
Howard Chu [Sun, 8 Nov 2020 15:07:28 +0000 (15:07 +0000)]
Re: dependency list for static libraries

This feature doesn't actually require plugin support, that was a
mistake in the previous patch.  Fixes these fails:

hppa-hp-hpux10  +FAIL: ar adding library dependencies
i386-bsd  +FAIL: ar adding library dependencies
i386-msdos  +FAIL: ar adding library dependencies
ns32k-netbsd  +FAIL: ar adding library dependencies
ns32k-pc532-mach  +FAIL: ar adding library dependencies
pdp11-dec-aout  +FAIL: ar adding library dependencies

* ar.c (main): Use plugin_target rather than "target" when
resetting libdeps_bfd target.

3 years agoRISC-V: Update ABI to the elf_flags after parsing elf attributes.
Nelson Chu [Mon, 19 Oct 2020 05:10:42 +0000 (22:10 -0700)]
RISC-V: Update ABI to the elf_flags after parsing elf attributes.

Originally, if the -mabi option isn't set, then assembler will set the
abi according to the architecture string in the riscv_after_parse_args.
But we should also check and reset the abi later since the architecture
string may be reset by the elf attributes.  Therefore, set the abi to
the elf_flags in the riscv_after_parse_args seems too early.  Besides,
we have to set the abi_xlen before assembling any instruction, so it
should be safe to call riscv_set_abi_by_arch at the place that we set
start_assemble to TRUE.  However, one minor case is that we won't call
the md_assemble when we are assembling an file without any instruction.
It seems that we still need to set the abi in riscv_elf_final_processing,
to make sure that abi can be updated according to the elf arch attributes.

For the rv32i and most elf toolchains, this patch can fix the mis-matched
ABI errors for Run pr26391-5 and Run pr26391-6 testcases.  Besides, it
also correct the elf header flags of the output objects.  Consider the
new testcases, mabi-fail-02 and mabi-noabi-attr-[01|02|03], they are
failed before applying this patch.

But I still get the mis-matched ABI errors for the following toolchains
when runnung the riscv-gnu-toolchain regressions,

newlib-rv32imafc-ilp32f-[medlow|medany]
linux-rv32imac-ilp32-[medlow|medany]
linux-rv32imafdc-ilp32-[medlow|medany}
linux-rv64imac-lp64-[medlow|medany]
linux-rv64imafdc-lp64-[medlow|medany}

For the newlib-rv32imafc-ilp32f, although we try to choose the abi
according to the elf attributes, we will use FLOAT_ABI_SOFT rather
than the FLOAT_ABI_SINGLE for the assmebly file wihtout setting the
-mabi, but compiler will set the abi to FLOAT_ABI_SINGLE for the
C files.

As for the linux toolchains, we also get fails for Run pr26391-5 and
Run pr26391-6 testcases.  Since the linux toolchain won't generate elf
attributes to correct the ISA, and the --with-arch configure option
isn't set, assembler will try to set the default arch to rv[32|64]g,
which means the FLOAT_ABI_DOUBLE will be choosed, and may be conflict
with the abi set by the toolchain.

Therefore, I would suggest that it's is more safe to set the --with-arch
when building binutils, but it may break some testcases.  For example,
ld-scripts/fill and ld-scripts/empty-address-2 may be broken when c-ext
is set.  We might insert R_RISCV_ALIGN to make sure the 4-byte alignment,
but the dump result will be a bit different from what the testcase expected.

However, this patch only fix the problem - the abi, elf_flags and the
instruction, which is generated according to the abi_xlen, are all fixed
once the elf attributes are set for most elf toolchains. Other mis-matched
ABI problems should be fixed when we always build the binutils with the
--with-arch= configure option.

gas/
* config/tc-riscv.c (explicit_mabi): New boolean to indicate if
the -mabi= option is explictly set.
(md_parse_option): Set explicit_mabi to TRUE if -mabi is set.
(riscv_set_abi_by_arch): New function.  If the -mabi option isn't
set, then we set the abi according to the architecture string.
Otherwise, check if there are conflicts between architecture
and abi setting.
(riscv_after_parse_args): Move the abi setting to md_assemble nad
riscv_elf_final_processing.
(md_assemble): Call the riscv_set_abi_by_arch when we set the
start_assemble to TRUE.
(riscv_elf_final_processing): Likewise, in case the file without
any instruction.

* testsuite/gas/riscv/mabi-attr-01.s: New testcase.
* testsuite/gas/riscv/mabi-attr-02.s: Likewise.
* testsuite/gas/riscv/mabi-attr-03.s: Likewise.
* testsuite/gas/riscv/mabi-fail-01.d: Likewise.
* testsuite/gas/riscv/mabi-fail-01.l: Likewise.
* testsuite/gas/riscv/mabi-fail-02.d: Likewise.
* testsuite/gas/riscv/mabi-fail-02.l: Likewise.
* testsuite/gas/riscv/mabi-noabi-attr-01a.d: Likewise.
* testsuite/gas/riscv/mabi-noabi-attr-01b.d: Likewise.
* testsuite/gas/riscv/mabi-noabi-attr-02a.d: Likewise.
* testsuite/gas/riscv/mabi-noabi-attr-02b.d: Likewise.
* testsuite/gas/riscv/mabi-noabi-attr-03a.d: Likewise.
* testsuite/gas/riscv/mabi-noabi-attr-03b.d: Likewise.
* testsuite/gas/riscv/mabi-noabi-march-01.d: Likewise.
* testsuite/gas/riscv/mabi-noabi-march-02.d: Likewise.
* testsuite/gas/riscv/mabi-noabi-march-03.d: Likewise.

3 years agoAutomatic date update in version.in
GDB Administrator [Mon, 9 Nov 2020 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in

3 years agogold: Avoid sharing Plugin_list::iterator
H.J. Lu [Sun, 8 Nov 2020 12:10:01 +0000 (04:10 -0800)]
gold: Avoid sharing Plugin_list::iterator

class Plugin_manager has

  // A pointer to the current plugin.  Used while loading plugins.
  Plugin_list::iterator current_;

The same iterator is shared by all threads. It is OK to use it to load
plugins since only one thread loads plugins.  Avoid sharing Plugin_list
iterator in all other cases.

PR gold/26200
* plugin.cc (Plugin_manager::claim_file): Don't share Plugin_list
iterator.
(Plugin_manager::all_symbols_read): Likewise.
(Plugin_manager::cleanup): Likewise.

3 years agoAutomatic date update in version.in
GDB Administrator [Sun, 8 Nov 2020 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in

3 years agoAutomatic date update in version.in
GDB Administrator [Sat, 7 Nov 2020 00:00:17 +0000 (00:00 +0000)]
Automatic date update in version.in

3 years agogdb: fix debug expression dumping of function call expressions
Andrew Burgess [Fri, 6 Nov 2020 13:40:22 +0000 (13:40 +0000)]
gdb: fix debug expression dumping of function call expressions

In commit:

  commit 6d81691950f8c4be4a49a85a672255c140e82468
  CommitDate: Sat Sep 19 09:44:58 2020 +0100

    gdb/fortran: Move Fortran expression handling into f-lang.c

A bug was introduced that broke GDB's ability to perform debug dumps
of expressions containing function calls.  For example this would no
longer work:

  (gdb) set debug expression 1
  (gdb) print call_me (&val)
  Dump of expression @ 0x4eced60, before conversion to prefix form:
   Language c, 12 elements, 16 bytes each.
   Index                Opcode         Hex Value  String Value
       0          OP_VAR_VALUE  40  (...............
       1          OP_M2_STRING  79862864  P...............
       2   unknown opcode: 224  79862240  ................
       3          OP_VAR_VALUE  40  (...............
       4          OP_VAR_VALUE  40  (...............
       5         OP_RUST_ARRAY  79861600  `...............
       6     UNOP_PREDECREMENT  79861312  @...............
       7          OP_VAR_VALUE  40  (...............
       8             UNOP_ADDR  61  =...............
       9            OP_FUNCALL  46  ................
      10             BINOP_ADD  1  ................
      11            OP_FUNCALL  46  ................
  Dump of expression @ 0x4eced60, after conversion to prefix form:
  Expression: `call_me (&main::val, VAL(Aborted (core dumped)

The situation was even worse for Fortran function calls, or array
indexes, which both make use of the same expression opcode.

The problem was that in a couple of places the index into the
expression array was handled incorrectly causing GDB to interpret
elements incorrectly.  These issues are fixed in this commit.

There are already some tests to check GDB when 'set debug expression
1' is set, these can be found in gdb.*/debug-expr.exp.  Unfortunately
the cases above were not covered.

In this commit I have cleaned up all of the debug-expr.exp files a
little, there was a helper function that had clearly been copied into
each file, this is now moved into lib/gdb.exp.

I've added a gdb.fortran/debug-expr.exp test file, and extended
gdb.base/debug-expr.exp to cover the function call case.

gdb/ChangeLog:

* expprint.c (print_subexp_funcall): Increment expression position
after reading argument count.
* f-lang.c (print_subexp_f): Skip over opcode before calling
common function.
(dump_subexp_body_f): Likewise.

gdb/testsuite/ChangeLog:

* gdb.base/debug-expr.c: Add extra function to allow for an
additional test.
* gdb.base/debug-expr.exp (test_debug_expr): Delete, replace calls
to this proc with gdb_test_debug_expr.  Add an extra test.
* gdb.cp/debug-expr.exp (test_debug_expr): Delete, replace calls
to this proc with gdb_test_debug_expr, give the tests names
* gdb.dlang/debug-expr.exp (test_debug_expr): Delete, replace
calls to this proc with gdb_test_debug_expr, give the tests names
* gdb.fortran/debug-expr.exp: New file.
* gdb.fortran/debug-expr.f90: New file.
* lib/gdb.exp (gdb_test_debug_expr): New proc.

3 years agogdb/testsuite: make DWARF assembler's ranges' "base" and "range" procs
Simon Marchi [Fri, 6 Nov 2020 18:09:58 +0000 (13:09 -0500)]
gdb/testsuite: make DWARF assembler's ranges' "base" and "range" procs

When creating a .debug_ranges section using the testsuite's DWARF
assembler, it currently looks like this:

  ranges {
    sequence {
      {base ...}
      {range ...}
      {range ...}
    }
  }

The sub-tree of sequence is manually traversed as a list of lists.  I
think it would be nicer if `base` and `range` where procedure, just like
the other levels:

  ranges {
    sequence {
      base ...
      range ...
      range ...
    }
  }

That makes the implementation more robust, and the usage a bit nicer
(less special characters).  It also allows having comments in between
the range list entries:

  ranges {
    sequence {
      base ...
      range ...

      # Hello world.
      range ...
    }
  }

... which doesn't work with the current approach.

gdb/testsuite/ChangeLog:

* lib/dwarf.exp (ranges): Handle "base" and "range" as
proceduresu.
* gdb.dwarf/dw2-bad-elf.exp: Adjust.
* gdb.dwarf2/dw2-inline-many-frames.exp: Adjust.
* gdb.dwarf2/dw2-inline-stepping.exp: Adjust.
* gdb.dwarf2/dw2-ranges-base.exp: Adjust.
* gdb.dwarf2/dw2-ranges-func.exp: Adjust.
* gdb.dwarf2/dw2-ranges-overlap.exp: Adjust.
* gdb.dwarf2/dw2-ranges-psym.exp: Adjust.
* gdb.dwarf2/enqueued-cu-base-addr.exp: Adjust.

Change-Id: I0b2af480faff54d0fd4214e0cc8d042d9583a865

3 years agogdb: better static python detection in configure machinery
Romain Geissler [Fri, 6 Nov 2020 17:47:21 +0000 (17:47 +0000)]
gdb: better static python detection in configure machinery

In python 3, itertools is a builtin module, so whether or not the
python you link against is a shared or a static one, importing it
works.

Change the import test to use ctypes which is a dynamic module in both
python 2 and 3.

gdb/ChangeLog:

PR python/26832
* configure: Regenerate.
* configure.ac: Check for python modules ctypes instead of
itertools.

3 years agoSplit macro_buffer in two classes, fix Clang build
Pedro Alves [Fri, 6 Nov 2020 17:19:02 +0000 (17:19 +0000)]
Split macro_buffer in two classes, fix Clang build

GDB currently fails to build with (at least) Clang 10 and 11, due to:

 $ make
   CXX    macroexp.o
 ../../src/gdb/macroexp.c:125:3: error: definition of implicit copy constructor for 'macro_buffer' is deprecated because it has a user-declared destructor [-Werror,-Wdeprecated-copy-dtor]
   ~macro_buffer ()
   ^

Now, we could just add the copy constructor, like we already have a
copy assignment operator.  And like that assignment operator, we would
assert that only shared buffers can be copied from.

However, it is hard to see why only shared buffers need to be copied.
I mean, it must be true, otherwise macro support would be broken,
since currently GDB is relying on the default implementation of the
copy constructor, which just copies the fields, which can't work
correctly for the non-shared version.  Still, it's not easy to tell
from the code that that is indeed correct, that there isn't some
corner case that would require copying a non-shared buffer.

Or to put it simply - the tangling of shared and non-shared buffers in
the same macro_buffer struct makes this structure hard to understand.

My reaction was -- try splitting the macro_buffer class into two
classes, one for non-shared buffers, and another for shared buffers.

Comments and asserts like these:

  ...
      SRC must be a shared buffer; DEST must not be one.  */

  static void
  scan (struct macro_buffer *dest,
        struct macro_buffer *src,
        struct macro_name_list *no_loop,
        const macro_scope &scope)
   {
    gdb_assert (src->shared);
    gdb_assert (! dest->shared);

... made me suspect it should be possible.  Then after the split it
should be easier to reimplement either of the classes if we want.

So I decided to try splitting the struct in two distinct types, and
see where that leads.  It turns out that there is really no good
reason for a single struct, no code that wants to work with either
shared or non-shared buffers.  It's always shared for input being
parsed, and non-shared for output.

This commit is the result.  I named the new classes
shared_macro_buffer and growable_macro_buffer.

A future direction could be for example to make shared_macro_buffer
wrap a string_view and growable_macro_buffer a std::string.  With that
in mind, other than text/len, only the 'last_token' field is common to
both classes.  I didn't feel like creating a base class just for that
single field.

I constified shared_macro_buffer's 'text' field, which of course had
some knock-on effects, fixed in the patch.

On the original warning issued by Clang -- now it is clear that only
the shared version needs to be copied.  Since this class doesn't need
a user-declared destructor, the default implementations of the copy
assign/ctor can be used, and Clang no longer warns.

The growable version doesn't need to be copied, so I disabled
copy/assign for it.

gdb/ChangeLog:

* macroexp.c (struct macro_buffer): Split in two classes.  Add
uses adjusted.
(struct shared_macro_buffer): New, factored out from struct
macro_buffer.
(struct growable_macro_buffer): New, factored out from struct
macro_buffer.
(set_token, get_comment, get_identifier, get_pp_number)
(get_character_constant, get_string_literal, get_punctuator)
(get_next_token_for_substitution): Constify parameters.
(substitute_args): Constify locals.

Change-Id: I5712e30e826d949715703b2e9172adf04e63b152

3 years agoExtend ld's -Map=<dir> functionality by allowing '%' to be replaced with the output...
Nick Clifton [Fri, 6 Nov 2020 14:36:45 +0000 (14:36 +0000)]
Extend ld's -Map=<dir> functionality by allowing '%' to be replaced with the output file path.

* lexsup.c (parse_args): Add more checks of the mapfile.  If it is
a directory use the basename of the output file as the file
component.  If the % character is present, replace it with the
full output filepath.
* testsuite/ld-scripts/map-address.exp: Add test of %
functionality.
* ld.texi: Document the new behaviour.

3 years agoelfedit: Update help message
H.J. Lu [Fri, 6 Nov 2020 14:04:32 +0000 (06:04 -0800)]
elfedit: Update help message

Update elfedit message to

$ elfedit --help
Usage: elfedit <option(s)> elffile(s)
 Update the ELF header of ELF files
 The options are:
  --input-mach [none|i386|iamcu|l1om|k1om|x86_64]
                              Set input machine type
  --output-mach [none|i386|iamcu|l1om|k1om|x86_64]
                              Set output machine type
  --input-type [none|rel|exec|dyn]
                              Set input file type
  --output-type [none|rel|exec|dyn]
                              Set output file type
  --input-osabi [none|HPUX|NetBSD|GNU|Linux|Solaris|AIX|Irix|FreeBSD|TRU64|Modesto|OpenBSD|OpenVMS|NSK|AROS|FenixOS]
                              Set input OSABI
  --output-osabi [none|HPUX|NetBSD|GNU|Linux|Solaris|AIX|Irix|FreeBSD|TRU64|Modesto|OpenBSD|OpenVMS|NSK|AROS|FenixOS]
                              Set output OSABI
  --enable-x86-feature [ibt|shstk]
                              Enable x86 feature
  --disable-x86-feature [ibt|shstk]
                              Disable x86 feature
  -h --help                   Display this information
  -v --version                Display the version number of elfedit
Report bugs to <http://www.sourceware.org/bugzilla/>

* elfedit.c: Include "libiberty.h".
(usage): Update help message.

3 years agoaarch64: Extract Pointer Authentication feature from Armv8.3-A
Przemyslaw Wirkus [Fri, 6 Nov 2020 13:09:51 +0000 (13:09 +0000)]
aarch64: Extract Pointer Authentication feature from Armv8.3-A

Extract PAC (Pointer Authentication) feature from Armv8.3-A.
Please note that PAC stays a Armv8.3-A feature but now can be
assigned to other architectures or CPUs.

3 years agoUpdated Serbian translation for the ld subdirectory
Nick Clifton [Fri, 6 Nov 2020 12:41:29 +0000 (12:41 +0000)]
Updated Serbian translation for the ld subdirectory

3 years agoRemove objfile parameter from abbrev_table::read
Tom Tromey [Fri, 6 Nov 2020 01:27:43 +0000 (18:27 -0700)]
Remove objfile parameter from abbrev_table::read

In a longer series that I am working on, I needed to remove the
objfile parameter from abbrev_table::read.  It seemed to me that this
was a simple and relatively harmless patch, so I'm sending it now.

gdb/ChangeLog
2020-11-05  Tom Tromey  <tom@tromey.com>

* dwarf2/read.c (read_cutu_die_from_dwo)
(cutu_reader::cutu_reader, cutu_reader::cutu_reader)
(build_type_psymtabs_1): Update.
* dwarf2/abbrev.h (struct abbrev_table): Remove objfile
parameter.
* dwarf2/abbrev.c (abbrev_table::read): Remove objfile parameter.
Don't read section.  Add assert.

3 years agoAutomatic date update in version.in
GDB Administrator [Fri, 6 Nov 2020 00:00:16 +0000 (00:00 +0000)]
Automatic date update in version.in

3 years agoAutomatic date update in version.in
GDB Administrator [Thu, 5 Nov 2020 00:00:13 +0000 (00:00 +0000)]
Automatic date update in version.in

3 years agoaarch64: Update feature RAS system registers
Przemyslaw Wirkus [Wed, 4 Nov 2020 20:47:06 +0000 (20:47 +0000)]
aarch64: Update feature RAS system registers

This patch:
+ updates RAS feature system registers with new RAS 1.1 regs.
+ extends RAS/RAS 1.1 support for all architecture levels of Armv8-A.

Please note that early Armv8-A architectures do not officially support RAS
extension.

Rationale of the patch:
To ease development so that user-friendly RAS system registers operands can be
used. Certain use cases require developers to enable only more generic
architecture (e.g. -march=armv8-a) during system development. Users must use
RAS extension registers bearing in mind that system they use must support it.

The RAS (Reliability, Availability, Serviceability) extension is a
system-level extension that defines a number of system registers.

RAS 1.1 (FEAT_RASv1p1) introduces five new system registers:
ERXPFGCTL_EL1, ERXPFGCDN_EL1, ERXMISC2_EL1, ERXMISC3_EL1 and
ERXPFGF_EL1.

For details see [0].

[0] https://developer.arm.com/docs/ddi0595/i/

3 years agoHandle __XVL fields in Ada type printing
Tom Tromey [Wed, 4 Nov 2020 16:17:58 +0000 (09:17 -0700)]
Handle __XVL fields in Ada type printing

Sometimes the Ada compiler will emit an "__XVL" name for a field.  The
Ada compiler describes:

--  Second, the variable-length fields themselves are represented by
--  replacing the type by a special access type. The designated type of
--  this access type is the original variable-length type, and the fact
--  that this field has been transformed in this way is signalled by
--  encoding the field name as:

--    field___XVL

Currently gdb describes such fields as having "access" type, but this
is inaccurate.  This patch changes gdb to avoid printing "access" in
this case.

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

* ada-typeprint.c (ada_print_type): Handle __XVL fields.

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

* gdb.ada/funcall_ref.exp: Update.
* gdb.ada/var_rec_arr.exp: Update.

3 years agoPrint Ada type name in more cases
Tom Tromey [Wed, 4 Nov 2020 16:17:58 +0000 (09:17 -0700)]
Print Ada type name in more cases

In some cases the name of an Ada type cannot be decoded by
decoded_type_name.  For example, the name
"p__complex_variable_record_type__T9s" in the included test case is
rejected due to the "T".  This causes ptype to display the full
contents of a record type -- when in fact the name is available and
ought to be printed.

Fixing this in decoded_type_name isn't possible because the "__T" name
is not the real name of the type -- it is just a compiler-assigned
name of convenience.

This patch fixes the problem by using the resolved type's name when
the original type's name isn't suitable.

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

* ada-typeprint.c (ada_print_type): Handle __T types.

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

* gdb.ada/rec_ptype.exp: New file.
* gdb.ada/rec_ptype/main.adb: New file.
* gdb.ada/rec_ptype/p.ads: New file.

3 years agoRecognize names of array types
Tom Tromey [Wed, 4 Nov 2020 15:49:16 +0000 (08:49 -0700)]
Recognize names of array types

With -fgnat-encodings=minimal, Gnat will emit DW_TAG_array_type that
has a name -- and this is the only time the name is emitted for the
type.  (For comparison, in C a typedef would be emitted in this
situation.)

This patch changes gdb to recognize the name of an array type.  This
is limited to Ada, to avoid any potential problems if some rogue DWARF
happens to name an array type in some other language, and to avoid
loading unnecessary partial DIEs.

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

* dwarf2/read.c (add_partial_symbol, process_die):
Handle DW_TAG_array_type.
(is_type_tag_for_partial): Add "lang" parameter.
(load_partial_dies, new_symbol): Handle DW_TAG_array_type.

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

* gdb.ada/tick_length_array_enum_idx.exp: Add ptype test.
* gdb.ada/tick_length_array_enum_idx/foo_n207_004.adb
(PT_Full): New variable.
* gdb.ada/tick_length_array_enum_idx/pck.adb
(Full_PT): New type.

3 years agoUse bit stride when taking slice of array
Tom Tromey [Wed, 4 Nov 2020 15:49:16 +0000 (08:49 -0700)]
Use bit stride when taking slice of array

Testing with -fgnat-encodings=minimal showed that the Ada code failed
to use the bit stride of an array when taking a slice.  This patch
fixes the oversight.

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

* ada-lang.c (ada_value_slice_from_ptr): Use bit size.

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

* gdb.ada/array_of_variant.exp: New file.
* gdb.ada/array_of_variant/p.adb: New file.
* gdb.ada/array_of_variant/pck.ads: New file.
* gdb.ada/array_of_variant/pck.adb: New file.

3 years agoOnly use stride for final element type
Tom Tromey [Wed, 4 Nov 2020 15:49:16 +0000 (08:49 -0700)]
Only use stride for final element type

A DWARF array type may specify a stride.  Currently, the DWARF reader
applies this stride to every dimension of an array.  However, this
seems incorrect to me -- only the innermost array ought to use the
stride, while outer arrays should compute a stride based on the size
of the inner arrays.  This patch arranges to apply the stride only to
the innermost array type.  This fixes a bug noticed when running some
Ada tests with -fgnat-encodings=minimal.

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

* dwarf2/read.c (read_array_type): Only apply stride to innermost
array.

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

* gdb.ada/enum_idx_packed.exp: Add test.
* gdb.ada/enum_idx_packed/foo.adb (Multi_Access):
New variable.
* gdb.ada/enum_idx_packed/pck.ads (Short)
(Multi_Dimension, Multi_Dimension_Access): New types.

3 years agoFix bit strides for -fgnat-encodings=minimal
Tom Tromey [Wed, 4 Nov 2020 15:49:16 +0000 (08:49 -0700)]
Fix bit strides for -fgnat-encodings=minimal

With -fgnat-encodings=minimal, the enum_idx_packed.exp test will fail.
In this test case, we have an array (with dynamic length) of arrays,
and the inner array has a bit stride.  In this situation, the outer
array's bit stride must be updated to account for the entire bit
length of the inner array.

Here, again, some tests must be kfail'd when an older version of GNAT
is in use.

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

* gdbtypes.c (update_static_array_size): Handle bit stride.

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

* gdb.ada/enum_idx_packed.exp: Test two forms of -fgnat-encodings.

3 years agoResolve dynamic type in ada_value_struct_elt
Tom Tromey [Wed, 4 Nov 2020 15:49:16 +0000 (08:49 -0700)]
Resolve dynamic type in ada_value_struct_elt

An internal AdaCore test case showed that gdb mishandled a case of
assigning to an array element in a packed array inside a variant
record.  This problem can only be seen with -fgnat-encodings=minimal,
which isn't yet widely used.  This patch fixes the bug, and also
updates an existing test to check this case.

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

* ada-lang.c (ada_value_struct_elt): Resolve dynamic type.

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

* gdb.ada/set_pckd_arr_elt.exp: Also test
-fgnat-encodings=minimal.  Add tests.
* gdb.ada/set_pckd_arr_elt/foo.adb (Foo): Add VA variable.
Call Update_Small a second time.
* gdb.ada/set_pckd_arr_elt/pck.adb (New_Variant): New function.
* gdb.ada/set_pckd_arr_elt/pck.ads (Buffer, Variant)
(Variant_Access): New types.
(New_Variant): Declare.

3 years agoReject slicing a packed array
Tom Tromey [Wed, 4 Nov 2020 15:49:16 +0000 (08:49 -0700)]
Reject slicing a packed array

In Ada mode, gdb rejects slicing a packed array.  However, with
-fgnat-encodings=minimal, gdb will instead print incorrect results.
This patch changes gdb to also reject slicing a packed array in this
mode.

FWIW I believe that this rejection is a gdb limitation.  Removing it
looked complicated, though, and meanwhile my main goal for the time
being is to bring the DWARF encodings up to par with Gnat encodings.

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

* ada-lang.c (ada_is_any_packed_array_type): New function.
(ada_evaluate_subexp) <case TERNOP_SLICE>: Use it.

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

* gdb.ada/mod_from_name.exp: Test printing slice.

3 years agoSynthesize array descriptors with -fgnat-encodings=minimal
Tom Tromey [Wed, 4 Nov 2020 15:49:16 +0000 (08:49 -0700)]
Synthesize array descriptors with -fgnat-encodings=minimal

When -fgnat-encodings=minimal, the compiler will avoid the special
GNAT-specific "encodings" format, and instead emit ordinary DWARF as
much as possible.

When emitting DWARF for thick pointers to arrays, the compiler emits
something like:

   <1><11db>: Abbrev Number: 7 (DW_TAG_array_type)
      <11dc>   DW_AT_name        : (indirect string, offset: 0x1bb8): string
      <11e0>   DW_AT_data_location: 2 byte block: 97 6
  (DW_OP_push_object_address; DW_OP_deref)
      <11e3>   DW_AT_type        : <0x1173>
      <11e7>   DW_AT_sibling     : <0x1201>
   <2><11eb>: Abbrev Number: 8 (DW_TAG_subrange_type)
      <11ec>   DW_AT_type        : <0x1206>
      <11f0>   DW_AT_lower_bound : 6 byte block: 97 23 8 6 94 4
  (DW_OP_push_object_address; DW_OP_plus_uconst: 8; DW_OP_deref;
   DW_OP_deref_size: 4)
      <11f7>   DW_AT_upper_bound : 8 byte block: 97 23 8 6 23 4 94 4
  (DW_OP_push_object_address; DW_OP_plus_uconst: 8; DW_OP_deref;
   DW_OP_plus_uconst: 4; DW_OP_deref_size: 4)

If you read between the lines, the "array" is actually a structure
with two elements.  One element is a pointer to the array data, and
the other structure describes the bounds of the array.  However, the
compiler doesn't emit this explicitly, but instead hides it behind
these location expressions.

gdb can print such objects, but currently there is no way to construct
one.  So, this patch adds some code to the DWARF reader to recognize
this construct, and then synthesize an array descriptor.  This
descriptor is then handled by the existing Ada code.

Internally, we've modified GCC to emit the structure type explicitly
(we will of course be sending this upstream).  In this case, the array
still has the DW_AT_data_location, though.  This patch also modifies
gdb to ignore the data location in this case -- this is preferred
because the location only serves to confuse the Ada code that already
knows where to find the data.  In the future I hope to move some of
this handling to the gdb core, so that Ada-specific hacks are not
needed; however I have not yet done this.

Because parallel types are not emitted with -fgnat-encodings=minimal,
some changes to the Ada code were also required.

The change ina ada-valprint.c was needed to avoid infinite recursion
when trying to print a constrained packed array.  And, there didn't
seem to be any need for a recursive call here -- the value could
simply be returned instead.

Finally, gdb.ada/frame_arg_lang.exp no longer works in C mode, because
we drop back to the structure approach now.  As mentioned earlier,
future work should probably fix this again; meanwhile, this doesn't
seem to be a big problem, because it is what is currently done (users
as a rule don't use -fgnat-encodings=minimal -- which is what I am
ultimately trying to fix).

Note that a couple of tests have an added KFAIL.  Some
-fgnat-encodings=minimal changes have landed in GNAT, and you need
something very recent to pass all the tests.  I'm using git gcc to
accomplish this.

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

* dwarf2/read.c (recognize_bound_expression)
(quirk_ada_thick_pointer): New functions.
(read_array_type): Call quirk_ada_thick_pointer.
(set_die_type): Add "skip_data_location" parameter.
(quirk_ada_thick_pointer): New function.
(process_structure_scope): Call quirk_ada_thick_pointer.
* ada-lang.c (ada_is_unconstrained_packed_array_type)
(decode_packed_array_bitsize): Handle thick pointers without
parallel types.
(ada_is_gnat_encoded_packed_array_type): Rename from
ada_is_packed_array_type.
(ada_is_constrained_packed_array_type): Update.
* ada-valprint.c (ada_val_print_gnat_array): Remove.
(ada_value_print_1): Use ada_get_decoded_value.

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

* gdb.ada/O2_float_param.exp: Test different -fgnat-encodings
values.
* gdb.ada/access_to_unbounded_array.exp: Test different
-fgnat-encodings values.
* gdb.ada/big_packed_array.exp: Test different -fgnat-encodings
values.
* gdb.ada/arr_enum_idx_w_gap.exp: Test different -fgnat-encodings
values.
* gdb.ada/array_ptr_renaming.exp: Test different -fgnat-encodings
values.
* gdb.ada/array_of_variable_length.exp: Test different
-fgnat-encodings values.
* gdb.ada/arrayparam.exp: Test different -fgnat-encodings values.
* gdb.ada/arrayptr.exp: Test different -fgnat-encodings values.
* gdb.ada/frame_arg_lang.exp: Revert -fgnat-encodings=minimal
change.
* gdb.ada/mi_string_access.exp: Test different -fgnat-encodings
values.
* gdb.ada/mod_from_name.exp: Test different -fgnat-encodings values.
* gdb.ada/out_of_line_in_inlined.exp: Test different
-fgnat-encodings values.
* gdb.ada/packed_array.exp: Test different -fgnat-encodings
values.
* gdb.ada/pckd_arr_ren.exp: Test different -fgnat-encodings
values.
* gdb.ada/unc_arr_ptr_in_var_rec.exp: Test different
-fgnat-encodings values.
* gdb.ada/variant_record_packed_array.exp: Test different
-fgnat-encodings values.

3 years agoFix decoding of multi-dimensional constrained packed arrays
Tom Tromey [Wed, 4 Nov 2020 15:49:16 +0000 (08:49 -0700)]
Fix decoding of multi-dimensional constrained packed arrays

Printing a multi-dimensional constrained packed array in Ada would not
show the correct values.  The bug here is that, when decoding the type
of such an array, only the innermost dimension's element bitsize would
be correct.  For outer dimensions, the bitsize must account for the
size of each sub-array, but this was not done.

This patch fixes the problem by arranging to compute these sizes after
decoding the array type.  I've included a bit more test case than is
strictly necessary -- the current test here was derived from an
internal test, and this patch brings the two into sync.

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

* ada-lang.c (recursively_update_array_bitsize): New function.
(decode_constrained_packed_array_type): Call it.

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

* gdb.ada/enum_idx_packed.exp: Add tests.
* gdb.ada/enum_idx_packed/foo.adb: Add variables.
* gdb.ada/enum_idx_packed/pck.adb: Add functions.
* gdb.ada/enum_idx_packed/pck.ads: Add types, function
declarations.

3 years agoAvoid crash in ada-lang.c:to_fixed_array_type
Tom Tromey [Wed, 4 Nov 2020 15:49:16 +0000 (08:49 -0700)]
Avoid crash in ada-lang.c:to_fixed_array_type

When debugging Ada programs compiled by certain versions of GNAT with
-fgnat-encodings=minimal, gdb can crash.  These crashes occur when
running the gdb test suite, once some of the later patches in this
series have been applied.

This patch works around the bug by throwing an exception in the
failing case.  I did not implement a full fix because GNAT has been
changed to emit better DWARF, and so in the near future this will stop
being a problem.  (Currently, users don't generally use
-fgnat-encodings=minimal, and the GNAT default will only be changed in
a fully-patched compiler.)

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

* ada-lang.c (to_fixed_array_type): Error if
decode_constrained_packed_array_type returns NULL.

3 years agoRewrite leb.h:read_3_bytes
Tom Tromey [Wed, 4 Nov 2020 15:21:36 +0000 (08:21 -0700)]
Rewrite leb.h:read_3_bytes

read_3_bytes assumes little-endian data, but in fact it depends on the
BFD.  This patch rewrites this function to use bfd_get_24 instead.

2020-11-04  Tom Tromey  <tromey@adacore.com>

* dwarf2/leb.h (read_3_bytes): Use bfd_get_24.

3 years agoAutomatic date update in version.in
GDB Administrator [Wed, 4 Nov 2020 00:00:16 +0000 (00:00 +0000)]
Automatic date update in version.in

3 years ago[gdb/testsuite] Fix .debug_abbrev terminators
Tom de Vries [Tue, 3 Nov 2020 16:41:11 +0000 (17:41 +0100)]
[gdb/testsuite] Fix .debug_abbrev terminators

The abbreviations table for a single compilation unit has two types of
terminators:
- a ".byte 0" pair denoting the end of an attribute list
- a single ".byte 0" denoting the end of the table

However, at the end of the .debug_abbrev section in dw2-line-number-zero-dw.S,
we have four ".byte 0" entries:
...
        .uleb128        0x12            /* DW_AT_high_pc */
        .uleb128        0x01            /* DW_FORM_addr */
        .byte        0x0                /* Terminator */
        .byte        0x0                /* Terminator */
        .byte        0x0                /* Terminator */
        .byte        0x0                /* Terminator */
...

The first two are the attribute list terminator, the third is the end-of-table
terminator, and the last is superfluous/incorrect.

Fix this by emitting instead:
...
        .uleb128        0x12            /* DW_AT_high_pc */
        .uleb128        0x01            /* DW_FORM_addr */
        .byte        0x0                /* DW_AT - Terminator */
        .byte        0x0                /* DW_FORM - Terminator */
        .byte        0x0                /* Abbrev end - Terminator */
...
where the last comment resembles the comment for other abbreviation codes:
...
        .section .debug_abbrev
.Labbrev1_begin:
        .uleb128        2               /* Abbrev start */
...

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-11-03  Tom de Vries  <tdevries@suse.de>

* lib/dwarf.exp (Dwarf::_handle_DW_TAG): Improve attribute list
terminator comments.
(Dwarf::cu, Dwarf::tu): Remove superfluous abbreviation table
terminator.

3 years agoAdd an option to the archiver to add a section recording library dependencies.
Howard Chu [Tue, 3 Nov 2020 15:12:47 +0000 (15:12 +0000)]
Add an option to the archiver to add a section recording library dependencies.

* ar.c (long_options): Add --record-libdeps.
(usage): Mention the new option.
(decode_options): Handle the new option.
(replace_members): If necessary, create a bfd to hold the libdeps
description.
* binemul.c (ar_emul_append_bfd): New function.
(ar_emul_replace_bfd): New function.
(ar_emul_default_append): Replace file_name and target arguments
with new_bfd argument.
(ar_emul_default_replace): Likewise.
* binemul.h: Update prototypes.
(struct bin_emulation_xfer_struct): Update fields.
* doc/binutils.texi: Document the new option.
* NEWS: Mention the new feature.
* emul_aix.c (ar_emul_aix_append): Update.
(ar_emul_aix_replace): Likewise.
* testsuite/binutils-all/ar.exp: Add test of new feature.

3 years ago[PATCH][GAS] aarch64: Add atomic 64-byte load/store instructions for Armv8.7
Przemyslaw Wirkus [Tue, 3 Nov 2020 14:21:32 +0000 (14:21 +0000)]
[PATCH][GAS] aarch64: Add atomic 64-byte load/store instructions for Armv8.7

Armv8.7 architecture introduces the "accelerator extension", aka
load/store of 64 bytes. New atomic load/store instructions are: LD64B,
ST64B, ST64BV and ST64BV0.

This patch adds:
+ New feature +ls64 to -march command line.
+ New atomic load/store instructions associated with above feature.

For more details regarding atomic 64-byte load/store instruction for
Armv8.7 please refer to Arm A64 Instruction set documentation for
Armv8-A architecture profile, see document page 157 for load
instruction, and pages 414-418 for store instructions of [0].

    [0]: https://developer.arm.com/docs/ddi0596/i

3 years agoPowerPC problem building gold with clang
Alan Modra [Tue, 3 Nov 2020 10:21:13 +0000 (20:51 +1030)]
PowerPC problem building gold with clang

* powerpc.cc (Target_powerpc::tocsave_loc): Return a pointer.
(Target_powerpc::Relocate::relocate): Avoid -Wdangling-gsl error.

3 years ago[PATCH] aarch64: Update missing ChangeLog for AArch64 commits
Przemyslaw Wirkus [Tue, 3 Nov 2020 11:55:14 +0000 (11:55 +0000)]
[PATCH] aarch64: Update missing ChangeLog for AArch64 commits

Patch with missing ChangeLog entries for GAS AArch64 files.

3 years agoFix compile time warning
Nick Clifton [Tue, 3 Nov 2020 08:56:27 +0000 (08:56 +0000)]
Fix compile time warning

3 years agogas: fix symbol value calculation for versioned symbol aliases
Christian Eggers [Sun, 1 Nov 2020 08:10:14 +0000 (09:10 +0100)]
gas: fix symbol value calculation for versioned symbol aliases

Symbol value is in bytes while fragS::fr_address is in octets. Fixes GAS
symver12 and symver13 tests on ELF targets with with OCTETS_PER_BYTE>1.

* config/obj-elf (elf_frob_symbol): Fix symbol value calculation
for versioned symbol aliases.

Signed-off-by: Christian Eggers <ceggers@gmx.de>
3 years agoasan: leak in bfd_section_from_shdr
Alan Modra [Mon, 2 Nov 2020 23:53:03 +0000 (10:23 +1030)]
asan: leak in bfd_section_from_shdr

* elf.c (bfd_section_from_shdr): Free sections_being_created.
Use bfd_zmalloc.

3 years agogold: ensure file_counts_lock is initialized before using
Nick Gasson [Mon, 2 Nov 2020 04:02:05 +0000 (12:02 +0800)]
gold: ensure file_counts_lock is initialized before using

Since upgrading to binutils 2.35 I've been experiencing random memory
corruption related crashes with ld.gold --threads. It's caused by
multiple threads concurrently pushing elements onto the shared
std::vector in File_read::record_file_read(). This vector is supposed to
be protected by file_counts_lock, but that is initialized lazily and
might be NULL when File_read::open() is called, in which case
Hold_optional_lock silently skips locking it.

Fix by calling the initialize() method before attempting to acquire the
lock, the same as other places that use file_counts_lock.

PR 26827
* fileread.cc (File_read::open): Ensure file_counts_lock is
initialized.
* testsuite/Makefile.am (check_PROGRAMS): Add a test that passes
-Wl,--threads.
* testsuite/Makefile.in: Regenerate.

3 years agoAutomatic date update in version.in
GDB Administrator [Tue, 3 Nov 2020 00:00:12 +0000 (00:00 +0000)]
Automatic date update in version.in

3 years agogdb/testsuite: fix failure in gdb.base/step-over-no-symbols.exp
Simon Marchi [Mon, 2 Nov 2020 21:35:47 +0000 (16:35 -0500)]
gdb/testsuite: fix failure in gdb.base/step-over-no-symbols.exp

This test fails on my machine:

    p /x $pc^M
    $2 = 0x55555555514e^M
    (gdb) PASS: gdb.base/step-over-no-symbols.exp: displaced=off: get after PC
    FAIL: gdb.base/step-over-no-symbols.exp: displaced=off: advanced

This is due to the check added in 5f0e2eb79e6b ("GDB/testsuite: Fix a
catastrophic step-over-no-symbols.exp failure"), that makes sure the PC
values are integer.  As documented in the TCL doc [1], "string is
integer" returns 1 if the string is a valid 32-bit integer format.  The
PC values are greater than 32 bits, so are not recognized as integers by
that test.

    % string is integer -strict 0x55555555
    1
    % string is integer -strict 0x555555555
    0

Replace the "string is integer" test with a regexp one, that verifies
the PC is a hex value.

[1] https://www.tcl.tk/man/tcl/TclCmd/string.htm#M21

gdb/testsuite/ChangeLog:

* gdb.base/step-over-no-symbols.exp (test_step_over): Replace
integer format test with regexp.

Change-Id: I71f8197e7b52e97b4901980544a8d1072aabd362

3 years agoAdd x86_64 ravenscar support
Tom Tromey [Thu, 29 Oct 2020 14:47:16 +0000 (08:47 -0600)]
Add x86_64 ravenscar support

Support for x86_64 ravenscar was recently added to the Ada runtime.
This patch updates gdb to follow.

As this is Ada-specific, and was reviewed internally by Joel, I am
checking it in.

2020-11-02  Tom Tromey  <tromey@adacore.com>

* Makefile.in (ALL_64_TARGET_OBS): Add amd64-ravenscar-thread.o.
(ALLDEPFILES): Add amd64-ravenscar-thread.c.
(HFILES_NO_SRCDIR): Add amd64-ravenscar-thread.h.
* amd64-ravenscar-thread.c: New file.
* amd64-ravenscar-thread.h: New file.
* amd64-tdep.c (amd64_init_abi): Register ravenscar ops.
* configure.tgt (amd64_tobjs): Add ravenscar objects.

3 years agogdb: new function to wrap up executing command line scripts/commands
Andrew Burgess [Wed, 9 Sep 2020 10:26:22 +0000 (11:26 +0100)]
gdb: new function to wrap up executing command line scripts/commands

Small refactor to wrap up executing the scripts and commands passed
using the -x, -ex, -ix, -iex command line flags.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* main.c (execute_cmdargs): New function.
(captured_main_1): Make use of execute_cmdargs.

3 years agogdb: use get_standard_config_dir when looking for .gdbinit
Andrew Burgess [Fri, 25 Sep 2020 13:50:56 +0000 (14:50 +0100)]
gdb: use get_standard_config_dir when looking for .gdbinit

This commit effectively changes the default location of the .gdbinit
file, while maintaining backward compatibility.

For non Apple hosts the .gdbinit file will now be looked for in the
following locations:

  $XDG_CONFIG_HOME/gdb/gdbinit
  $HOME/.config/gdb/gdbinit
  $HOME/.gdbinit

On Apple hosts the search order is instead:

  $HOME/Library/Preferences/gdb/gdbinit
  $HOME/.gdbinit

I've performed an extensive rewrite of the documentation, moving all
information about initialization files and where to find them into a
new @node, text from other areas has been moved into this one
location, and other areas cross-reference to this new @node as much as
possible.

gdb/ChangeLog:

* NEWS: Mention changes to config file search path.
* main.c

gdb/doc/ChangeLog:

* gdb.texinfo (Mode Options): Descriptions of initialization files
has been moved to 'Initialization Files'.
(Startup): Likewise.
(Initialization Files): New node.
(gdb man): Update to mention alternative file paths.
(gdbinit man): Likewise.

3 years agoAdd get_standard_config_dir function
Tom Tromey [Sun, 5 Jul 2020 19:02:40 +0000 (13:02 -0600)]
Add get_standard_config_dir function

This adds a new get_standard_config_dir, which returns the name of the
configuration directory.  In XDG, this is ~/.config/gdb/.  Future
patches will make use of this.

2020-07-05  Tom Tromey  <tom@tromey.com>

* pathstuff.h (get_standard_config_dir): Declare.
* pathstuff.cc (get_standard_config_dir): New function.

3 years agoMinor Python simplifications
Tom Tromey [Mon, 2 Nov 2020 17:17:07 +0000 (10:17 -0700)]
Minor Python simplifications

I noticed that a few "#if"s could be removed from the Python code.
This patch is the result.

gdb/ChangeLog
2020-11-02  Tom Tromey  <tromey@adacore.com>

* python/python.c: Consolidate two HAVE_PYTHON blocks.
(python_GdbModuleDef): Move earlier.  Now static.
(do_start_initialization): Consolidate some IS_PY3K blocks.

3 years agogdb, gdbserver, gdbsupport: fix leading space vs tabs issues
Simon Marchi [Mon, 2 Nov 2020 15:26:14 +0000 (10:26 -0500)]
gdb, gdbserver, gdbsupport: fix leading space vs tabs issues

Many spots incorrectly use only spaces for indentation (for example,
there are a lot of spots in ada-lang.c).  I've always found it awkward
when I needed to edit one of these spots: do I keep the original wrong
indentation, or do I fix it?  What if the lines around it are also
wrong, do I fix them too?  I probably don't want to fix them in the same
patch, to avoid adding noise to my patch.

So I propose to fix as much as possible once and for all (hopefully).

One typical counter argument for this is that it makes code archeology
more difficult, because git-blame will show this commit as the last
change for these lines.  My counter counter argument is: when
git-blaming, you often need to do "blame the file at the parent commit"
anyway, to go past some other refactor that touched the line you are
interested in, but is not the change you are looking for.  So you
already need a somewhat efficient way to do this.

Using some interactive tool, rather than plain git-blame, makes this
trivial.  For example, I use "tig blame <file>", where going back past
the commit that changed the currently selected line is one keystroke.
It looks like Magit in Emacs does it too (though I've never used it).
Web viewers of Github and Gitlab do it too.  My point is that it won't
really make archeology more difficult.

The other typical counter argument is that it will cause conflicts with
existing patches.  That's true... but it's a one time cost, and those
are not conflicts that are difficult to resolve.  I have also tried "git
rebase --ignore-whitespace", it seems to work well.  Although that will
re-introduce the faulty indentation, so one needs to take care of fixing
the indentation in the patch after that (which is easy).

gdb/ChangeLog:

* aarch64-linux-tdep.c: Fix indentation.
* aarch64-ravenscar-thread.c: Fix indentation.
* aarch64-tdep.c: Fix indentation.
* aarch64-tdep.h: Fix indentation.
* ada-lang.c: Fix indentation.
* ada-lang.h: Fix indentation.
* ada-tasks.c: Fix indentation.
* ada-typeprint.c: Fix indentation.
* ada-valprint.c: Fix indentation.
* ada-varobj.c: Fix indentation.
* addrmap.c: Fix indentation.
* addrmap.h: Fix indentation.
* agent.c: Fix indentation.
* aix-thread.c: Fix indentation.
* alpha-bsd-nat.c: Fix indentation.
* alpha-linux-tdep.c: Fix indentation.
* alpha-mdebug-tdep.c: Fix indentation.
* alpha-nbsd-tdep.c: Fix indentation.
* alpha-obsd-tdep.c: Fix indentation.
* alpha-tdep.c: Fix indentation.
* amd64-bsd-nat.c: Fix indentation.
* amd64-darwin-tdep.c: Fix indentation.
* amd64-linux-nat.c: Fix indentation.
* amd64-linux-tdep.c: Fix indentation.
* amd64-nat.c: Fix indentation.
* amd64-obsd-tdep.c: Fix indentation.
* amd64-tdep.c: Fix indentation.
* amd64-windows-tdep.c: Fix indentation.
* annotate.c: Fix indentation.
* arc-tdep.c: Fix indentation.
* arch-utils.c: Fix indentation.
* arch/arm-get-next-pcs.c: Fix indentation.
* arch/arm.c: Fix indentation.
* arm-linux-nat.c: Fix indentation.
* arm-linux-tdep.c: Fix indentation.
* arm-nbsd-tdep.c: Fix indentation.
* arm-pikeos-tdep.c: Fix indentation.
* arm-tdep.c: Fix indentation.
* arm-tdep.h: Fix indentation.
* arm-wince-tdep.c: Fix indentation.
* auto-load.c: Fix indentation.
* auxv.c: Fix indentation.
* avr-tdep.c: Fix indentation.
* ax-gdb.c: Fix indentation.
* ax-general.c: Fix indentation.
* bfin-linux-tdep.c: Fix indentation.
* block.c: Fix indentation.
* block.h: Fix indentation.
* blockframe.c: Fix indentation.
* bpf-tdep.c: Fix indentation.
* break-catch-sig.c: Fix indentation.
* break-catch-syscall.c: Fix indentation.
* break-catch-throw.c: Fix indentation.
* breakpoint.c: Fix indentation.
* breakpoint.h: Fix indentation.
* bsd-uthread.c: Fix indentation.
* btrace.c: Fix indentation.
* build-id.c: Fix indentation.
* buildsym-legacy.h: Fix indentation.
* buildsym.c: Fix indentation.
* c-typeprint.c: Fix indentation.
* c-valprint.c: Fix indentation.
* c-varobj.c: Fix indentation.
* charset.c: Fix indentation.
* cli/cli-cmds.c: Fix indentation.
* cli/cli-decode.c: Fix indentation.
* cli/cli-decode.h: Fix indentation.
* cli/cli-script.c: Fix indentation.
* cli/cli-setshow.c: Fix indentation.
* coff-pe-read.c: Fix indentation.
* coffread.c: Fix indentation.
* compile/compile-cplus-types.c: Fix indentation.
* compile/compile-object-load.c: Fix indentation.
* compile/compile-object-run.c: Fix indentation.
* completer.c: Fix indentation.
* corefile.c: Fix indentation.
* corelow.c: Fix indentation.
* cp-abi.h: Fix indentation.
* cp-namespace.c: Fix indentation.
* cp-support.c: Fix indentation.
* cp-valprint.c: Fix indentation.
* cris-linux-tdep.c: Fix indentation.
* cris-tdep.c: Fix indentation.
* darwin-nat-info.c: Fix indentation.
* darwin-nat.c: Fix indentation.
* darwin-nat.h: Fix indentation.
* dbxread.c: Fix indentation.
* dcache.c: Fix indentation.
* disasm.c: Fix indentation.
* dtrace-probe.c: Fix indentation.
* dwarf2/abbrev.c: Fix indentation.
* dwarf2/attribute.c: Fix indentation.
* dwarf2/expr.c: Fix indentation.
* dwarf2/frame.c: Fix indentation.
* dwarf2/index-cache.c: Fix indentation.
* dwarf2/index-write.c: Fix indentation.
* dwarf2/line-header.c: Fix indentation.
* dwarf2/loc.c: Fix indentation.
* dwarf2/macro.c: Fix indentation.
* dwarf2/read.c: Fix indentation.
* dwarf2/read.h: Fix indentation.
* elfread.c: Fix indentation.
* eval.c: Fix indentation.
* event-top.c: Fix indentation.
* exec.c: Fix indentation.
* exec.h: Fix indentation.
* expprint.c: Fix indentation.
* f-lang.c: Fix indentation.
* f-typeprint.c: Fix indentation.
* f-valprint.c: Fix indentation.
* fbsd-nat.c: Fix indentation.
* fbsd-tdep.c: Fix indentation.
* findvar.c: Fix indentation.
* fork-child.c: Fix indentation.
* frame-unwind.c: Fix indentation.
* frame-unwind.h: Fix indentation.
* frame.c: Fix indentation.
* frv-linux-tdep.c: Fix indentation.
* frv-tdep.c: Fix indentation.
* frv-tdep.h: Fix indentation.
* ft32-tdep.c: Fix indentation.
* gcore.c: Fix indentation.
* gdb_bfd.c: Fix indentation.
* gdbarch.sh: Fix indentation.
* gdbarch.c: Re-generate
* gdbarch.h: Re-generate.
* gdbcore.h: Fix indentation.
* gdbthread.h: Fix indentation.
* gdbtypes.c: Fix indentation.
* gdbtypes.h: Fix indentation.
* glibc-tdep.c: Fix indentation.
* gnu-nat.c: Fix indentation.
* gnu-nat.h: Fix indentation.
* gnu-v2-abi.c: Fix indentation.
* gnu-v3-abi.c: Fix indentation.
* go32-nat.c: Fix indentation.
* guile/guile-internal.h: Fix indentation.
* guile/scm-cmd.c: Fix indentation.
* guile/scm-frame.c: Fix indentation.
* guile/scm-iterator.c: Fix indentation.
* guile/scm-math.c: Fix indentation.
* guile/scm-ports.c: Fix indentation.
* guile/scm-pretty-print.c: Fix indentation.
* guile/scm-value.c: Fix indentation.
* h8300-tdep.c: Fix indentation.
* hppa-linux-nat.c: Fix indentation.
* hppa-linux-tdep.c: Fix indentation.
* hppa-nbsd-nat.c: Fix indentation.
* hppa-nbsd-tdep.c: Fix indentation.
* hppa-obsd-nat.c: Fix indentation.
* hppa-tdep.c: Fix indentation.
* hppa-tdep.h: Fix indentation.
* i386-bsd-nat.c: Fix indentation.
* i386-darwin-nat.c: Fix indentation.
* i386-darwin-tdep.c: Fix indentation.
* i386-dicos-tdep.c: Fix indentation.
* i386-gnu-nat.c: Fix indentation.
* i386-linux-nat.c: Fix indentation.
* i386-linux-tdep.c: Fix indentation.
* i386-nto-tdep.c: Fix indentation.
* i386-obsd-tdep.c: Fix indentation.
* i386-sol2-nat.c: Fix indentation.
* i386-tdep.c: Fix indentation.
* i386-tdep.h: Fix indentation.
* i386-windows-tdep.c: Fix indentation.
* i387-tdep.c: Fix indentation.
* i387-tdep.h: Fix indentation.
* ia64-libunwind-tdep.c: Fix indentation.
* ia64-libunwind-tdep.h: Fix indentation.
* ia64-linux-nat.c: Fix indentation.
* ia64-linux-tdep.c: Fix indentation.
* ia64-tdep.c: Fix indentation.
* ia64-tdep.h: Fix indentation.
* ia64-vms-tdep.c: Fix indentation.
* infcall.c: Fix indentation.
* infcmd.c: Fix indentation.
* inferior.c: Fix indentation.
* infrun.c: Fix indentation.
* iq2000-tdep.c: Fix indentation.
* language.c: Fix indentation.
* linespec.c: Fix indentation.
* linux-fork.c: Fix indentation.
* linux-nat.c: Fix indentation.
* linux-tdep.c: Fix indentation.
* linux-thread-db.c: Fix indentation.
* lm32-tdep.c: Fix indentation.
* m2-lang.c: Fix indentation.
* m2-typeprint.c: Fix indentation.
* m2-valprint.c: Fix indentation.
* m32c-tdep.c: Fix indentation.
* m32r-linux-tdep.c: Fix indentation.
* m32r-tdep.c: Fix indentation.
* m68hc11-tdep.c: Fix indentation.
* m68k-bsd-nat.c: Fix indentation.
* m68k-linux-nat.c: Fix indentation.
* m68k-linux-tdep.c: Fix indentation.
* m68k-tdep.c: Fix indentation.
* machoread.c: Fix indentation.
* macrocmd.c: Fix indentation.
* macroexp.c: Fix indentation.
* macroscope.c: Fix indentation.
* macrotab.c: Fix indentation.
* macrotab.h: Fix indentation.
* main.c: Fix indentation.
* mdebugread.c: Fix indentation.
* mep-tdep.c: Fix indentation.
* mi/mi-cmd-catch.c: Fix indentation.
* mi/mi-cmd-disas.c: Fix indentation.
* mi/mi-cmd-env.c: Fix indentation.
* mi/mi-cmd-stack.c: Fix indentation.
* mi/mi-cmd-var.c: Fix indentation.
* mi/mi-cmds.c: Fix indentation.
* mi/mi-main.c: Fix indentation.
* mi/mi-parse.c: Fix indentation.
* microblaze-tdep.c: Fix indentation.
* minidebug.c: Fix indentation.
* minsyms.c: Fix indentation.
* mips-linux-nat.c: Fix indentation.
* mips-linux-tdep.c: Fix indentation.
* mips-nbsd-tdep.c: Fix indentation.
* mips-tdep.c: Fix indentation.
* mn10300-linux-tdep.c: Fix indentation.
* mn10300-tdep.c: Fix indentation.
* moxie-tdep.c: Fix indentation.
* msp430-tdep.c: Fix indentation.
* namespace.h: Fix indentation.
* nat/fork-inferior.c: Fix indentation.
* nat/gdb_ptrace.h: Fix indentation.
* nat/linux-namespaces.c: Fix indentation.
* nat/linux-osdata.c: Fix indentation.
* nat/netbsd-nat.c: Fix indentation.
* nat/x86-dregs.c: Fix indentation.
* nbsd-nat.c: Fix indentation.
* nbsd-tdep.c: Fix indentation.
* nios2-linux-tdep.c: Fix indentation.
* nios2-tdep.c: Fix indentation.
* nto-procfs.c: Fix indentation.
* nto-tdep.c: Fix indentation.
* objfiles.c: Fix indentation.
* objfiles.h: Fix indentation.
* opencl-lang.c: Fix indentation.
* or1k-tdep.c: Fix indentation.
* osabi.c: Fix indentation.
* osabi.h: Fix indentation.
* osdata.c: Fix indentation.
* p-lang.c: Fix indentation.
* p-typeprint.c: Fix indentation.
* p-valprint.c: Fix indentation.
* parse.c: Fix indentation.
* ppc-linux-nat.c: Fix indentation.
* ppc-linux-tdep.c: Fix indentation.
* ppc-nbsd-nat.c: Fix indentation.
* ppc-nbsd-tdep.c: Fix indentation.
* ppc-obsd-nat.c: Fix indentation.
* ppc-ravenscar-thread.c: Fix indentation.
* ppc-sysv-tdep.c: Fix indentation.
* ppc64-tdep.c: Fix indentation.
* printcmd.c: Fix indentation.
* proc-api.c: Fix indentation.
* producer.c: Fix indentation.
* producer.h: Fix indentation.
* prologue-value.c: Fix indentation.
* prologue-value.h: Fix indentation.
* psymtab.c: Fix indentation.
* python/py-arch.c: Fix indentation.
* python/py-bpevent.c: Fix indentation.
* python/py-event.c: Fix indentation.
* python/py-event.h: Fix indentation.
* python/py-finishbreakpoint.c: Fix indentation.
* python/py-frame.c: Fix indentation.
* python/py-framefilter.c: Fix indentation.
* python/py-inferior.c: Fix indentation.
* python/py-infthread.c: Fix indentation.
* python/py-objfile.c: Fix indentation.
* python/py-prettyprint.c: Fix indentation.
* python/py-registers.c: Fix indentation.
* python/py-signalevent.c: Fix indentation.
* python/py-stopevent.c: Fix indentation.
* python/py-stopevent.h: Fix indentation.
* python/py-threadevent.c: Fix indentation.
* python/py-tui.c: Fix indentation.
* python/py-unwind.c: Fix indentation.
* python/py-value.c: Fix indentation.
* python/py-xmethods.c: Fix indentation.
* python/python-internal.h: Fix indentation.
* python/python.c: Fix indentation.
* ravenscar-thread.c: Fix indentation.
* record-btrace.c: Fix indentation.
* record-full.c: Fix indentation.
* record.c: Fix indentation.
* reggroups.c: Fix indentation.
* regset.h: Fix indentation.
* remote-fileio.c: Fix indentation.
* remote.c: Fix indentation.
* reverse.c: Fix indentation.
* riscv-linux-tdep.c: Fix indentation.
* riscv-ravenscar-thread.c: Fix indentation.
* riscv-tdep.c: Fix indentation.
* rl78-tdep.c: Fix indentation.
* rs6000-aix-tdep.c: Fix indentation.
* rs6000-lynx178-tdep.c: Fix indentation.
* rs6000-nat.c: Fix indentation.
* rs6000-tdep.c: Fix indentation.
* rust-lang.c: Fix indentation.
* rx-tdep.c: Fix indentation.
* s12z-tdep.c: Fix indentation.
* s390-linux-tdep.c: Fix indentation.
* score-tdep.c: Fix indentation.
* ser-base.c: Fix indentation.
* ser-mingw.c: Fix indentation.
* ser-uds.c: Fix indentation.
* ser-unix.c: Fix indentation.
* serial.c: Fix indentation.
* sh-linux-tdep.c: Fix indentation.
* sh-nbsd-tdep.c: Fix indentation.
* sh-tdep.c: Fix indentation.
* skip.c: Fix indentation.
* sol-thread.c: Fix indentation.
* solib-aix.c: Fix indentation.
* solib-darwin.c: Fix indentation.
* solib-frv.c: Fix indentation.
* solib-svr4.c: Fix indentation.
* solib.c: Fix indentation.
* source.c: Fix indentation.
* sparc-linux-tdep.c: Fix indentation.
* sparc-nbsd-tdep.c: Fix indentation.
* sparc-obsd-tdep.c: Fix indentation.
* sparc-ravenscar-thread.c: Fix indentation.
* sparc-tdep.c: Fix indentation.
* sparc64-linux-tdep.c: Fix indentation.
* sparc64-nbsd-tdep.c: Fix indentation.
* sparc64-obsd-tdep.c: Fix indentation.
* sparc64-tdep.c: Fix indentation.
* stabsread.c: Fix indentation.
* stack.c: Fix indentation.
* stap-probe.c: Fix indentation.
* stubs/ia64vms-stub.c: Fix indentation.
* stubs/m32r-stub.c: Fix indentation.
* stubs/m68k-stub.c: Fix indentation.
* stubs/sh-stub.c: Fix indentation.
* stubs/sparc-stub.c: Fix indentation.
* symfile-mem.c: Fix indentation.
* symfile.c: Fix indentation.
* symfile.h: Fix indentation.
* symmisc.c: Fix indentation.
* symtab.c: Fix indentation.
* symtab.h: Fix indentation.
* target-float.c: Fix indentation.
* target.c: Fix indentation.
* target.h: Fix indentation.
* tic6x-tdep.c: Fix indentation.
* tilegx-linux-tdep.c: Fix indentation.
* tilegx-tdep.c: Fix indentation.
* top.c: Fix indentation.
* tracefile-tfile.c: Fix indentation.
* tracepoint.c: Fix indentation.
* tui/tui-disasm.c: Fix indentation.
* tui/tui-io.c: Fix indentation.
* tui/tui-regs.c: Fix indentation.
* tui/tui-stack.c: Fix indentation.
* tui/tui-win.c: Fix indentation.
* tui/tui-winsource.c: Fix indentation.
* tui/tui.c: Fix indentation.
* typeprint.c: Fix indentation.
* ui-out.h: Fix indentation.
* unittests/copy_bitwise-selftests.c: Fix indentation.
* unittests/memory-map-selftests.c: Fix indentation.
* utils.c: Fix indentation.
* v850-tdep.c: Fix indentation.
* valarith.c: Fix indentation.
* valops.c: Fix indentation.
* valprint.c: Fix indentation.
* valprint.h: Fix indentation.
* value.c: Fix indentation.
* value.h: Fix indentation.
* varobj.c: Fix indentation.
* vax-tdep.c: Fix indentation.
* windows-nat.c: Fix indentation.
* windows-tdep.c: Fix indentation.
* xcoffread.c: Fix indentation.
* xml-syscall.c: Fix indentation.
* xml-tdesc.c: Fix indentation.
* xstormy16-tdep.c: Fix indentation.
* xtensa-config.c: Fix indentation.
* xtensa-linux-nat.c: Fix indentation.
* xtensa-linux-tdep.c: Fix indentation.
* xtensa-tdep.c: Fix indentation.

gdbserver/ChangeLog:

* ax.cc: Fix indentation.
* dll.cc: Fix indentation.
* inferiors.h: Fix indentation.
* linux-low.cc: Fix indentation.
* linux-nios2-low.cc: Fix indentation.
* linux-ppc-ipa.cc: Fix indentation.
* linux-ppc-low.cc: Fix indentation.
* linux-x86-low.cc: Fix indentation.
* linux-xtensa-low.cc: Fix indentation.
* regcache.cc: Fix indentation.
* server.cc: Fix indentation.
* tracepoint.cc: Fix indentation.

gdbsupport/ChangeLog:

* common-exceptions.h: Fix indentation.
* event-loop.cc: Fix indentation.
* fileio.cc: Fix indentation.
* filestuff.cc: Fix indentation.
* gdb-dlfcn.cc: Fix indentation.
* gdb_string_view.h: Fix indentation.
* job-control.cc: Fix indentation.
* signals.cc: Fix indentation.

Change-Id: I4bad7ae6be0fbe14168b8ebafb98ffe14964a695

3 years agoFix gdb.base/print-file-var.exp with Clang
Gary Benson [Mon, 2 Nov 2020 14:19:29 +0000 (14:19 +0000)]
Fix gdb.base/print-file-var.exp with Clang

The C++ parts of gdb.base/print-file-var.exp failed to build with
Clang because the "-x c++" option added by gdb_compile caused the
compiler to attempt to parse .so files as C++.  This commit splits
the compiler and linker options into separate lists, and switches
to building via build_executable_from_specs which can accommodate
this separation.

gdb/testsuite/ChangeLog:

* gdb.base/print-file-var.exp (test): Separate compiler and
linker options, and build using build_executable_from_specs
to accommodate this.

3 years agoDetect and report incompatible gdb_compile options
Gary Benson [Mon, 2 Nov 2020 14:19:29 +0000 (14:19 +0000)]
Detect and report incompatible gdb_compile options

In commits 221db974e653659edb280787af1b3efdd1615083 and
68d654afdfcff840ebb3ae432ed72dca0521d670, these patches:

    2020-06-24  Pedro Alves  <palves@redhat.com>

* lib/gdb.exp (gdb_compile): Pass "-x c++" explicitly when
compiling C++ programs.

    2020-09-25  Gary Benson <gbenson@redhat.com>

* lib/gdb.exp (gdb_compile): Pass "-x c++" earlier, and only
for .c files.

attempted to fix problems with testcases that compile .c files
using the C++ compiler.  These patches cause gdb_compile to add
"-x c++" to the compiler options when using Clang.  This fix does
not work for gdb.base/print-file-var.exp, however, which attempts
to compile a .c input file to an executable linked with shared
libraries: the resulting command caused the compiler to attempt
to parse the .so files as C++.  This commit causes gdb_compile
to reject this combination of options.

gdb/testsuite/ChangeLog:

* lib/gdb.exp (gdb_compile): Inhibit passing "-x c++"
for .c files compiled as C++ with Clang if any shared
libraries are specified.

3 years agoFix testcases using __attribute__((noclone)) with Clang
Gary Benson [Mon, 2 Nov 2020 11:52:41 +0000 (11:52 +0000)]
Fix testcases using __attribute__((noclone)) with Clang

Clang fails to compile a number of files with the following warning:
unknown attribute 'noclone' ignored [-Wunknown-attributes].  This
commit adds a new header, lib/noclone.h, which defines the macro
ATTRIBUTE_NOCLONE accordingly, and updates the relevant testcases
to use it.

gdb/testsuite/ChangeLog:

* lib/attributes.h: New header.
* gdb.base/backtrace.c: Include the above. Replace
__attribute__(noclone)) with ATTRIBUTE_NOCLONE.
* gdb.base/infcall-nested-structs.c: Likewise.
* gdb.base/vla-optimized-out.c: Likewise.

3 years ago[gdb/testsuite] Remove .debug_line.dwo from gdb.dwarf2/fission-multi-cu.S
Tom de Vries [Mon, 2 Nov 2020 10:25:38 +0000 (11:25 +0100)]
[gdb/testsuite] Remove .debug_line.dwo from gdb.dwarf2/fission-multi-cu.S

Consider test-case gdb.dwarf2/fission-multi-cu.exp.  It produces an executable
fission-multi-cu and a dwo file fission-multi-cu.dwo.

The file fission-multi-cu.dwo contains a .debug_line.dwo section, which
according to the DWARF v5 standard is a "specialized line number table" for
type units in the .debug_info.dwo section, and contains only the directory and
filename lists.

When reading the actual .debug_line.dwo section using readelf -w, we get:
...
 The Directory Table is empty.

 The File Name Table is empty.

 No Line Number Statements.
...
So, the section does not contain any actual information.  Furthermore, no
information is required because the .debug_line.dwo section does not contain
any type units.

This is confirmed by:
- re-doing the commands listed at the start of fission-multi-cu.S, which were
  used as starting point for fission-multi-cu.S, and
- compiling the fission-multi-cu{1,2}.c files with clang -flto -g -gsplit-dwarf
In both cases, no .debug_line.dwo section is generated.

Remove the .debug_line.dwo section, to make it fit how split dwarf is actually
generated by clang.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-11-02  Tom de Vries  <tdevries@suse.de>

* gdb.dwarf2/fission-multi-cu.S: Remove .debug_line.dwo section.

3 years agogdb/riscv: read frame base register as unsigned in the unwinder
Andrew Burgess [Tue, 27 Oct 2020 15:31:53 +0000 (15:31 +0000)]
gdb/riscv: read frame base register as unsigned in the unwinder

I noticed an issue with the RISC-V prologue scanning stack unwinder.
We currently read the frame base register (either $sp or $fp) as a
signed value.  This means that the frame_id's stack_addr field will be
a signed value.

In other contexts though these registers are data pointers, and so are
unsigned.

There's not many places where this mismatch actually shows though, but
I did find one place.  Consider this GDB session:

  (gdb) maintenance set dwarf unwinders off
  (gdb) set backtrace past-main on
  ...
  (gdb) b main
  Breakpoint 1 at 0x20400344: file main.c, line 86.
  (gdb) run
  ...
  (gdb) bt
  #0  main () at main.c:86
  #1  0x2040005c in _start () at start.S:59
  Backtrace stopped: frame did not save the PC
  (gdb) info frame 1
  Stack frame at 0x80000a1c:
   pc = 0x2040005c in _start (start.S:59); saved pc = <not saved>
   Outermost frame: frame did not save the PC
   caller of frame at 0x80000a1c
   source language asm.
   Arglist at 0x80000a1c, args:
   Locals at 0x80000a1c, Previous frame's sp is 0x80000a1c
  (gdb) frame address 0x80000a1c
  No frame at address 0x80000a1c.
  (gdb) frame address 0xffffffff80000a1c
  #1  0x2040005c in _start () at start.S:59
  59              call main

Notice that the 'info frame 1' reports that the frame is at
'0x80000a1c', this is the unsigned frame base value, but when I try
to select a frame using this address I can't.

The reason is that the frame_id for frame #1 actually has the
unsigned (and hence sign-extended) stack_addr value.  When I use the
sign extended address I can correctly select the frame.

I propose changing the prologue scanning unwinder to read the frame
base as unsigned.  After this in the above case I can now do this:

  (gdb) frame address 0x80000a1c
  #1  0x2040005c in _start () at start.S:59
  59              call main
  (gdb) frame address 0xffffffff80000a1c
  No frame at address 0xffffffff80000a1c.

Which I think makes more sense.

This issue causes failures in gdb.base/frame-selection.exp if you
compile for RV32 with a linker script that places the stack in the
correct location, which are resolved by this patch.

gdb/ChangeLog:

* riscv-tdep.c (riscv_frame_cache): Read the frame base register
as an unsigned value.

3 years agosim/bpf: re-generate configure
Simon Marchi [Mon, 2 Nov 2020 00:39:11 +0000 (19:39 -0500)]
sim/bpf: re-generate configure

I noticed a little diff when re-generating the configure file in this
directory.

sim/ChangeLog:

* bpf/configure: Re-generate.

Change-Id: Ieb26be2cc1be8108d4b08387255f45b57f288171

3 years agoAutomatic date update in version.in
GDB Administrator [Mon, 2 Nov 2020 00:00:14 +0000 (00:00 +0000)]
Automatic date update in version.in

3 years agoPR26806, Suspected linker bug with LTO
Alan Modra [Fri, 30 Oct 2020 04:26:35 +0000 (14:56 +1030)]
PR26806, Suspected linker bug with LTO

This patch reverts most of git commit 1e3b96fd6cf, so IR symbols are
again not marked def_regular or ref_regular.  That should be enough to
stop IR symbols from becoming dynamic.  To mark as-needed shared
libraries referenced by IR symbols, use the referencing BFD rather
than the ref flags.

bfd/
PR 15146
PR 26314
PR 26530
PR 26806
* elflink.c (elf_link_add_object_symbols): Don't set def/ref flags
for plugin syms.  Do allow plugin syms to mark as-needed libs.
ld/
PR 26806
* testsuite/ld-plugin/lto-19.h,
* testsuite/ld-plugin/lto-19a.c,
* testsuite/ld-plugin/lto-19b.c,
* testsuite/ld-plugin/lto-19c.c: New test.
* testsuite/ld-plugin/pr26806.c,
* testsuite/ld-plugin/pr26806.d: New test.
* testsuite/ld-plugin/lto.exp: Run them.

3 years agoChange end_psymtab_common to a method
Tom Tromey [Sun, 1 Nov 2020 16:51:13 +0000 (09:51 -0700)]
Change end_psymtab_common to a method

This changes end_psymtab_common to be a method on partial_symtab.
This seems a little cleaner to me.

gdb/ChangeLog
2020-11-01  Tom Tromey  <tom@tromey.com>

* dbxread.c (dbx_end_psymtab): Update.
* dwarf2/read.c (process_psymtab_comp_unit_reader)
(build_type_psymtabs_reader): Update.
* xcoffread.c (xcoff_end_psymtab): Update.
* ctfread.c (scan_partial_symbols): Update.
* psymtab.c (sort_pst_symbols): Remove.
(partial_symtab::end): Rename from end_psymtab_common.  Inline
sort_pst_symbols.
* psympriv.h (struct partial_symtab) <end>: New method.
(end_psymtab_common): Don't declare.

3 years agoRemove partial symbol statistics
Tom Tromey [Sun, 1 Nov 2020 16:51:13 +0000 (09:51 -0700)]
Remove partial symbol statistics

The "n_psyms" statistic in the per-objfile stats is not really needed,
but its use requires passing the objfile to add_psymbol.  This patch
removes the field in favor of counting the psyms when needed.

Note that this is not exactly equivalent -- in the old approach, a
psymbol can in theory be created and then the psymtab discarded, which
would increment the counter.  This does not seem very important to me.

I rewrote the code to count partial symbols; though TBH I think that
this information is not really very useful.

gdb/ChangeLog
2020-11-01  Tom Tromey  <tom@tromey.com>

* symmisc.c (count_psyms): New function.
(print_objfile_statistics): Use it.
* psymtab.c (append_psymbol_to_list): Remove.
(partial_symtab::add_psymbol): Inline append_psymbol_to_list.
* objfiles.h (struct objstats) <n_psyms>: Remove.

3 years agoRemove parameter from end_psymtab_common
Tom Tromey [Sun, 1 Nov 2020 16:51:13 +0000 (09:51 -0700)]
Remove parameter from end_psymtab_common

The objfile parameter to end_psymtab_common is no longer needed, so
this removes it.

gdb/ChangeLog
2020-11-01  Tom Tromey  <tom@tromey.com>

* dbxread.c (dbx_end_psymtab): Update.
* dwarf2/read.c (process_psymtab_comp_unit_reader): Update.
(build_type_psymtabs_reader): Update.
* xcoffread.c (xcoff_end_psymtab): Update.
* ctfread.c (scan_partial_symbols): Update.
* psympriv.h (end_psymtab_common): Update.
* psymtab.c (end_psymtab_common): Remove objfile parameter.
(sort_pst_symbols): Likewise.

3 years agoRemove init_psymbol_list
Tom Tromey [Sun, 1 Nov 2020 16:51:13 +0000 (09:51 -0700)]
Remove init_psymbol_list

init_psymbol_list is now empty, and so this removes it.

gdb/ChangeLog
2020-11-01  Tom Tromey  <tom@tromey.com>

* dbxread.c (dbx_symfile_read): Update.
* dwarf2/read.c (dwarf2_build_psymtabs): Update.
* xcoffread.c (xcoff_initial_scan): Update.
* psympriv.h (init_psymbol_list): Don't declare.
* psymtab.c (init_psymbol_list): Remove.

3 years agoavoid unwarranted assumption in gdb.ada/fixed_points/fixed_points.adb
Joel Brobecker [Sun, 1 Nov 2020 11:37:41 +0000 (15:37 +0400)]
avoid unwarranted assumption in gdb.ada/fixed_points/fixed_points.adb

The test program being used declares a fixed-point type
(Base_Fixed_Point_Type) Base_Fixed_Point_Type whose (scaled) range
is System.Min_Int .. System.Max_Int. is an unwarranted assumption because
the range is implementation-defined. It means the compiler is therefore
free to reject that declaration.

We noticed this while one of my coworkers was working on enhancing
GNAT to support 128bit integers. The bulk of the work has been done,
but one side-effect is that there is a small gap in this particular
area where the compiler is now rejecting this code. We will eventually
plug that gap, but in meantime, since the testcase itself doesn't really
need such a large range, this commit simply adjusts the test program
to use hard-coded bounds for the range whose value are more reasonable.

gdb/testsuite/ChangeLog:

        * gdb.ada/fixed_points/fixed_points.adb: Replace use of
        System.Min_Int and System.Max_Int with smaller hardcoded
        constants.

3 years agoada-lang.c: Rename gnat_encoded_fixed_type_info
Joel Brobecker [Sun, 1 Nov 2020 07:41:06 +0000 (02:41 -0500)]
ada-lang.c: Rename gnat_encoded_fixed_type_info

This commit renames gnat_encoded_fixed_type_info into
gnat_encoded_fixed_point_type_info, so as to be more consistent
with the naming used for the other associated routines (i.e.
use "fixed_point" rather than just "fixed").

gdb/ChangeLog:

        * ada-lang.c (gnat_encoded_fixed_point_type_info): Renames
        gnat_encoded_fixed_type_info.  Update all callers.

3 years agoada-lang.c: fix line too long in cast_from_gnat_encoded_fixed_point_type
Joel Brobecker [Sun, 1 Nov 2020 07:38:45 +0000 (02:38 -0500)]
ada-lang.c: fix line too long in cast_from_gnat_encoded_fixed_point_type

One of the lines got too long after a renaming done in a previous
commit. This fixes that.

gdb/ChangeLog:

        * ada-lang.c (cast_from_gnat_encoded_fixed_point_type): Split
        line too long.

3 years agoada-lang.c: Renaming some fixed-point-related routines
Joel Brobecker [Sun, 1 Nov 2020 07:29:27 +0000 (02:29 -0500)]
ada-lang.c: Renaming some fixed-point-related routines

This patch renames some of the fixed-point-related subprograms in ada-lang.c
so as to make it obvious that those routines only handle the case where
the types are encoded using the GNAT encoding.

No function change; this patch is preparation work for adding support
for fixed-point types purely based on standard DWARF debug info.

gdb/ChangeLog:

        * ada-lang.c (cast_from_gnat_encoded_fixed_point_type): Renames
        cast_from_fixed.  Update all callers.
        (cast_to_gnat_encoded_fixed_point_type): Renames cast_to_fixed.
        Update all callers.
        (gnat_encoded_fixed_point_scaling_factor): Renames ada_scaling_factor.
        Update all callers.
        * ada-lang.h (gnat_encoded_fixed_point_scaling_factor): Renames
        ada_scaling_factor.
        * ada-typeprint.c: Replace call to ada_scaling_factor by call
        to print_gnat_encoded_fixed_point_type.
        * ada-valprint.c: Likewise.

3 years agoAutomatic date update in version.in
GDB Administrator [Sun, 1 Nov 2020 00:00:12 +0000 (00:00 +0000)]
Automatic date update in version.in

3 years agogdb: restore some checks of debug flags
Andrew Burgess [Sat, 31 Oct 2020 21:50:44 +0000 (21:50 +0000)]
gdb: restore some checks of debug flags

This partially reverts some parts of the commit:

  commit 17417fb0ec9842de1774e1e76f1f11c00cdafc47
  Date:   Sat Oct 31 09:01:25 2020 -0400

      gdb, gdbsupport: add debug_prefixed_printf, remove boilerplate functions

This commit removed 3 places where some debug flags were being
checked.  The result was that debug tracing was being printed
unconditionally.

This commit adds back the 3 flag checks.

gdb/ChangeLog:

* infrun.h (infrun_debug_printf): Add check of debug_infrun flag.
(debug_prefixed_printf): Add check of debug_displaced flag.
* linux-nat.c (linux_nat_debug_printf): Add check of
debug_linux_nat flag.

3 years agogdb, gdbsupport: add debug_prefixed_printf, remove boilerplate functions
Simon Marchi [Sat, 31 Oct 2020 13:01:25 +0000 (09:01 -0400)]
gdb, gdbsupport: add debug_prefixed_printf, remove boilerplate functions

The *_debug_print_1 functions are all very similar, the only difference
being the subsystem name.  Remove them all and make the logging macros
use a new debug_prefixed_printf function directly.

gdb/ChangeLog:

* infrun.c (infrun_debug_printf_1): Remove.
(displaced_debug_printf_1): Remove.
(stop_all_threads): Use debug_prefixed_printf.
* infrun.h (infrun_debug_printf_1): Remove.
(infrun_debug_printf): Use debug_prefixed_printf.
(displaced_debug_printf_1): Remove.
(displaced_debug_printf): Use debug_prefixed_printf.
* linux-nat.c (linux_nat_debug_printf_1): Remove.
(linux_nat_debug_printf): Use debug_prefixed_printf.

gdbsupport/ChangeLog:

* common-debug.cc (debug_prefixed_printf): New.
* common-debug.h (debug_prefixed_printf): New declaration.
* event-loop.cc (event_loop_debug_printf_1): Remove.
* event-loop.h (event_loop_debug_printf_1): Remove.
(event_loop_debug_printf): Use debug_prefixed_printf.
(event_loop_ui_debug_printf): Use debug_prefixed_printf.

Change-Id: Ib323087c7257f0060121d302055c41eb64aa60c6

3 years agogdbserver: replace AC_TRY_COMPILE in acinclude.m4
Simon Marchi [Sat, 31 Oct 2020 12:31:00 +0000 (08:31 -0400)]
gdbserver: replace AC_TRY_COMPILE in acinclude.m4

... with AC_COMPILE_IFELSE and AC_LANG_PROGRAM.

All changes in the generated configure file are insignificant
whitespace changes.

gdbserver/ChangeLog:

* acinclude.m4: Replace AC_TRY_COMPILE with AC_COMPILE_IFELSE +
AC_LANG_PROGRAM.
* configure: Re-generate.

Change-Id: Idab8b5e1a984046b5283940c02e5a22da2291d58

3 years agogdb: replace AC_TRY_LINK in sanitize.m4
Simon Marchi [Sat, 31 Oct 2020 12:31:00 +0000 (08:31 -0400)]
gdb: replace AC_TRY_LINK in sanitize.m4

... with AC_LINK_IFELSE + AC_LANG_PROGRAM.

All changes in the generated configure file are insignificant whitespace
changes.

gdb/ChangeLog:

* configure: Re-generate.
* sanitize.m4: Replace AC_TRY_LINK with AC_LINK_IFELSE +
AC_LANG_PROGRAM.

Change-Id: I6fc4c39e10b28d2ade964e0d59a7f8ec0d3a272a

3 years agogdbsupport: replace AC_TRY_COMPILE in common.m4
Simon Marchi [Sat, 31 Oct 2020 12:31:00 +0000 (08:31 -0400)]
gdbsupport: replace AC_TRY_COMPILE in common.m4

... with AC_COMPILE_IFELSE + AC_LANG_PROGRAM.  All the changes in the
generated configure files are insignificant whitespace changes.

gdb/ChangeLog:

* configure: Re-generate.

gdbserver/ChangeLog:

* configure: Re-generate.

gdbsupport/ChangeLog:

* common.m4: Replace AC_TRY_COMPILE with AC_COMPILE_IFELSE +
AC_LANG_PROGRAM.
* configure: Re-generate.

Change-Id: Id58e6e887f6be817d52b189921845838031dbd2a

3 years agogdbsupport: use AC_FUNC_FORK instead of AC_FUNC_VFORK
Simon Marchi [Sat, 31 Oct 2020 12:31:00 +0000 (08:31 -0400)]
gdbsupport: use AC_FUNC_FORK instead of AC_FUNC_VFORK

autoupdate does this change, it fixes this warning:

    configure.ac:50: warning: The macro `AC_FUNC_VFORK' is obsolete.
    configure.ac:50: You should run autoupdate.
    ../../lib/autoconf/functions.m4:1944: AC_FUNC_VFORK is expanded from...
    common.m4:20: GDB_AC_COMMON is expanded from...
    configure.ac:50: the top level

There are not changes in the generated configure files.

gdbsupport/ChangeLog:

* common.m4: Replace AC_FUNC_VFORK with AC_FUNC_FORK.

Change-Id: I9de9f718c57e6d51c9734161f36c36ce39170325

3 years agogdbsupport: replace AC_TRY_COMPILE in warning.m4
Simon Marchi [Sat, 31 Oct 2020 12:30:59 +0000 (08:30 -0400)]
gdbsupport: replace AC_TRY_COMPILE in warning.m4

Replace AC_TRY_COMPILE with AC_COMPILE_IFELSE + AC_LANG_PROGRAM.

All changes in generated configure files are insignificant whitespace
changes.

gdb/ChangeLog:

* configure: Re-generate.

gdbserver/ChangeLog:

* configure: Re-generate.

gdbsupport/ChangeLog:

* configure: Re-generate.
* warning.m4: Replace AC_TRY_COMPILE with AC_COMPILE_IFELSE +
AC_LANG_PROGRAM.

Change-Id: I517bd20ec3af960ad999a586761df0ac8959a3fc

3 years agogdbsupport: replace AC_TRY_COMPILE in ptrace.m4
Simon Marchi [Sat, 31 Oct 2020 12:30:59 +0000 (08:30 -0400)]
gdbsupport: replace AC_TRY_COMPILE in ptrace.m4

Replace AC_TRY_COMPILE with AC_COMPILE_IFELSE + AC_LANG_PROGRAM.

All the changes in the generated configure files are insignificant
whitespace changes.

gdb/ChangeLog:

* configure: Re-generate.

gdbserver/ChangeLog:

* configure: Re-generate.

gdbsupport/ChangeLog:

* configure: Re-generate.
* ptrace.m4: Replace AC_TRY_COMPILE with AC_COMPILE_IFELSE +
AC_LANG_PROGRAM.

Change-Id: Ia782b5477fe49dad04e68c0f41c6d8ab3fde5bf0

3 years agogdbsupport: re-indent ptrace.m4
Simon Marchi [Sat, 31 Oct 2020 12:30:59 +0000 (08:30 -0400)]
gdbsupport: re-indent ptrace.m4

For some reason, autoupdate isn't able to grok ptrace.m4:

    $ autoupdate ptrace.m4
    /usr/bin/m4:/tmp/auYjuodw/input.m4:171: ERROR: end of file in string
    autoupdate: /usr/bin/m4 failed with exit status: 1

Honestly, I'm unable to grok it either.  This patch re-indents it in a
way that I think is easier to read.  With this patch applied, autoupdate
becomes able to parse ptrace.m4, but I chose to keep this re-indent in a
patch of its own.

All the changes in generated configure files consist of insignificant
whitespace changes.

gdb/ChangeLog:

* configure: Re-generate.

gdbserver/ChangeLog:

* configure: Re-generate.

gdbsupport/ChangeLog:

* configure: Re-generate.
* ptrace.m4: Re-indent.

Change-Id: Ie2afab09fecc8b6d0cccccb47ac9756f3843881e

3 years agogdb: modernize acinclude.m4
Simon Marchi [Sat, 31 Oct 2020 12:30:58 +0000 (08:30 -0400)]
gdb: modernize acinclude.m4

Run autoupdate, fix indentation for readability.

gdb/ChangeLog:

* acinclude.m4: Modernize.
* configure: Re-generate.

Change-Id: I8949f885326a3206f414776b63a1fdba197bb19a

3 years agogdb/testsuite: modernize configure.ac
Simon Marchi [Sat, 31 Oct 2020 12:30:58 +0000 (08:30 -0400)]
gdb/testsuite: modernize configure.ac

Run autoupdate, the only change is to split AC_INIT into AC_INIT and
AC_CONFIG_SRCDIR.

gdb/testsuite/ChangeLog:

* configure.ac: Split AC_INIT into AC_INIT and AC_CONFIG_SRCDIR.
* configure: Re-generate.

Change-Id: I6e40c0261bda4fe9144b896799ef460d23e22e09

3 years agogdb: modernize configure.ac
Simon Marchi [Sat, 31 Oct 2020 12:30:58 +0000 (08:30 -0400)]
gdb: modernize configure.ac

Run autoupdate on configure.ac and adjust the indentation of the result
for better readability.  This removes a bunch of warnings when running
`autoreconf -vf -Wall`.  The changes are:

    * Replace AC_INIT with AC_INIT and no arguments plus
      AC_CONFIG_SRCDIR.
    * Replace AC_ERROR with AC_MSG_ERROR.
    * Replace AC_TRY_LINK with AC_LINK_IFELSE.
    * Replace AC_TRY_COMPILE with AC_COMPILE_IFELSE.
    * Replace AC_HELP_STRING with AS_HELP_STRING.

autoupdate erroneously tries to replace AC_C_LONG_DOUBLE in a comment,
which I reverted manually.

All the changes in the generated configure file are insignificant
whitespaces changes.

gdb/ChangeLog:

* configure.ac: Modernize.
* configure: Re-generate.

Change-Id: Ie3a1409c8032a36a6383da964286a46ece9b546e

3 years agogdbserver: modernize configure.ac
Simon Marchi [Sat, 31 Oct 2020 12:30:58 +0000 (08:30 -0400)]
gdbserver: modernize configure.ac

Run autoupdate on gdbserver/configure.ac and then tweak it to use easier
to read indentation.  This removes a few warnings when running
`autoreconf -vf -Wall`.

  * Replace AC_INIT with AC_INIT and no arguments plus AC_CONFIG_SRCDIR.
  * Replace AC_GNU_SOURCE with AC_USE_SYSTEM_EXTENSIONS.
  * Replace AC_TRY_COMPILE with AC_COMPILE_IFELSE.
  * Replace AC_TRY_LINK with AC_LINK_IFELSE.

autoupdate gets it right, except this one here:

    --- a/gdbserver/configure.ac
    +++ b/gdbserver/configure.ac
    @@ -304,7 +304,7 @@ if test "$srv_linux_thread_db" = "yes"; then
         AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[found="-Wl,--dynamic-list"
                     RDYNAMIC='-Wl,--dynamic-list=$(srcdir)/proc-service.list'],[RDYNAMIC="-rdynamic"
                     LDFLAGS="$old_LDFLAGS $RDYNAMIC"
    -                AC_TRY_LINK([], [],
    +                _au_m4_changequote([,])AC_TRY_LINK([], [],
                                 [found="-rdynamic"],
                                 [found="no"
                                  RDYNAMIC=""])])

... which I had to convert manually.

The changes in the generated configure file only contain insignificant
whitespace changes, so that gives confidence that the conversion is
correct.

gdbserver/ChangeLog:

* configure.ac: Modernize.
* configure: Re-generate.

Change-Id: Ia769aaec2aafac595504f477da955e91dffa4d8f

3 years agogdb: use AC_PROG_CC_STDC instead of AM_PROG_CC_STDC
Simon Marchi [Sat, 31 Oct 2020 12:30:57 +0000 (08:30 -0400)]
gdb: use AC_PROG_CC_STDC instead of AM_PROG_CC_STDC

`autoconf -Wall` notes that AM_PROG_CC_STDC is obsolete:
Fixes this autoconf warning:

    configure.ac:40: warning: 'AM_PROG_CC_STDC': this macro is obsolete.
    configure.ac:40: You should simply use the 'AC_PROG_CC' macro instead.
    configure.ac:40: Also, your code should no longer depend upon 'am_cv_prog_cc_stdc',
    configure.ac:40: but upon 'ac_cv_prog_cc_stdc'.
    aclocal.m4:770: AM_PROG_CC_STDC is expanded from...
    configure.ac:40: the top level

Since we build with a C++ compiler now, I don't think this is relevant.
If you look at the messages removed from gdbsupport/aclocal.m4, it says
that this functionality is now integrated in AC_PROG_CC, which we
already call.  So it might not even make a difference.

We had a local version of AM_PROG_CC_STDC, in gdb/acinclude.m4 (only
used by gdb/configure.ac), remove it.

gdb/ChangeLog:

* acinclude.m4 (AM_PROG_CC_STDC): Remove.
* configure: Re-generate.
* configure.ac: Remove AM_PROG_CC_STDC.

gdbsupport/ChangeLog:

* aclocal.m4: Re-generate.
* configure: Re-generate.
* configure.ac: Remove AM_PROG_CC_STDC.

Change-Id: Ic824393598805d4f78cda9d119f8af46096e9c73

3 years agogdb, gdbserver, gdbsupport: use AC_CANONICAL_{BUILD,HOST,TARGET} instead of AC_CANONI...
Simon Marchi [Sat, 31 Oct 2020 12:30:57 +0000 (08:30 -0400)]
gdb, gdbserver, gdbsupport: use AC_CANONICAL_{BUILD,HOST,TARGET} instead of AC_CANONICAL_SYSTEM

`autoreconf -Wall` notes that AC_CANONICAL_SYSTEM is obsolete:

    configure.ac:36: warning: The macro `AC_CANONICAL_SYSTEM' is obsolete.

Replace it by AC_CANONICAL_BUILD, AC_CANONICAL_HOST and
AC_CANONICAL_TARGET in configure.ac files in gdb, gdbserver and
gdbsupport.  All three macros may not be needed everywhere, but it is
hard to completely audit the configure files to see which are required,
so I think it's better (and that there's no downside) to just call all
three.

gdb/ChangeLog:

* configure.ac: Use AC_CANONICAL_{BUILD,HOST,TARGET} instead of
AC_CANONICAL_SYSTEM.
* configure: Re-generate.

gdbserver/ChangeLog:

* configure.ac: Use AC_CANONICAL_{BUILD,HOST,TARGET} instead of
AC_CANONICAL_SYSTEM.
* configure: Re-generate.

gdbsupport/ChangeLog:

* configure.ac: Use AC_CANONICAL_{BUILD,HOST,TARGET} instead of
AC_CANONICAL_SYSTEM.
* configure: Re-generate.

Change-Id: Ifd0e21f1e478634e768b5de1b8ee06a7f690d863

3 years agoAutomatic date update in version.in
GDB Administrator [Sat, 31 Oct 2020 00:00:15 +0000 (00:00 +0000)]
Automatic date update in version.in

3 years agogdb: introduce displaced_debug_printf
Simon Marchi [Fri, 30 Oct 2020 19:10:08 +0000 (15:10 -0400)]
gdb: introduce displaced_debug_printf

Move all debug prints of the "displaced" category to use a new
displaced_debug_printf macro, like what was done for infrun and others
earlier.

The debug output for one displaced step one amd64 looks like:

    [displaced] displaced_step_prepare_throw: stepping process 3367044 now
    [displaced] displaced_step_prepare_throw: saved 0x555555555042: 1e fa 31 ed 49 89 d1 5e 48 89 e2 48 83 e4 f0 50
    [displaced] amd64_displaced_step_copy_insn: copy 0x555555555131->0x555555555042: b8 00 00 00 00 5d c3 0f 1f 84 00 00 00 00 00 f3
    [displaced] displaced_step_prepare_throw: displaced pc to 0x555555555042
    [displaced] resume_1: run 0x555555555042: b8 00 00 00
    [displaced] displaced_step_restore: restored process 3367044 0x555555555042
    [displaced] amd64_displaced_step_fixup: fixup (0x555555555131, 0x555555555042), insn = 0xb8 0x00 ...
    [displaced] amd64_displaced_step_fixup: relocated %rip from 0x555555555047 to 0x555555555136

On test case needed to be updated because it relied on the specific
formatting of the message.

gdb/ChangeLog:

* infrun.h (displaced_debug_printf): New macro.  Replace
displaced debug prints throughout to use it.
(displaced_debug_printf_1): New declaration.
(displaced_step_dump_bytes): Return string, remove ui_file
parameter, update all callers.
* infrun.c (displaced_debug_printf_1): New function.
(displaced_step_dump_bytes): Return string, remove ui_file
parameter

gdb/testsuite/ChangeLog:

* gdb.arch/amd64-disp-step-avx.exp: Update displaced step debug
expected output.

Change-Id: Ie78837f56431f6f98378790ba1e6051337bf6533

3 years agogdb: rs6000_dwarf2_reg_to_regnum return -1 for unknown register number
Simon Marchi [Fri, 30 Oct 2020 19:01:13 +0000 (15:01 -0400)]
gdb: rs6000_dwarf2_reg_to_regnum return -1 for unknown register number

With the current implementation of rs6000_dwarf2_reg_to_regnum, if an
unknown DWARF register number is passed, the same number is returned as
the internal GDB number.  This assumes that the internal GDB register
numbers match the DWARF register numbers, which is not the case.

Change it to return -1, as documented in gdbarch.sh for the
dwarf2_reg_to_regnum method.

This fixes a failure in gdb.dwarf2/bad-regnum.exp:

     (gdb) info addr foo1
    -Symbol "foo1" is a variable in $.
    -(gdb) FAIL: gdb.dwarf2/bad-regnum.exp: info addr foo1
    +Symbol "foo1" is a variable in $bad_register_number.
    +(gdb) PASS: gdb.dwarf2/bad-regnum.exp: info addr foo1

I ran the entire testsuite on powerpc64 (gcc203 on the compile farm) and
didn't see any regression.

gdb/ChangeLog:

* rs6000-tdep.c (rs6000_dwarf2_reg_to_regnum): Return -1 for
  unknown register numbers.

Change-Id: I585aa07a08f845a46c36bfdb6d3118ea94f8f54d