Commit Graph

103928 Commits

Author SHA1 Message Date
Simon Marchi
acb994fab6 gdb/testsuite: add "breakpoint always-inserted" axis in gdb.base/continue-after-aborted-step-over.exp
The test gdb.base/continue-after-aborted-step-over.exp fails on ROCm GDB
[1] when using the unix board (when debugging a standard x86-64/Linux
program), with:

    (gdb) b *0^M
    Breakpoint 2 at 0x0^M
    Warning:^M
    Cannot insert breakpoint 2.^M
    Cannot access memory at address 0x0^M
    ^M
    (gdb) FAIL: gdb.base/continue-after-aborted-step-over.exp: displaced-stepping=off: b *0

This happens because that build of GDB defaults to "set breakpoint
always-inserted on", for reasons that are unrelevant to explain here.
As soon as the breakpoint is created, GDB tries to insert it and
(expectedly) fails.  This causes more text to be output than what the
pattern expects.

It is actually be relevant to run the test with both "set breakpoint
always-inserted" on and off.  With it on, it mimics what happens when
running in non-stop mode, with other threads running.  This is relevant
for upstream even outside of the ROCm port, so here's a patch for it.

Add this other axis and adjust the "b *0" test to handle the extra
output when it is on.

[1] https://github.com/ROCm-Developer-Tools/ROCgdb

gdb/testsuite/ChangeLog:

	* gdb.base/continue-after-aborted-step-over.exp: Add "breakpoint
	always-inserted" axis.
	(do_test): Add breakpoint_always_inserted parameter.

Change-Id: I95126cae563a0b9a72f4a99627809fc34340cd5e
2020-11-11 11:18:11 -05:00
Przemyslaw Wirkus
f27c0b449f aarch64: Allow LS64 feature with Armv8.6
Allow users to use LS64 extension with Armv8.6 architecture.
2020-11-11 15:30:21 +00:00
Bernd Edlinger
4d93271533 readelf: Fix output of rnglists section
* dwarf.c (display_debug_rnglists_list): Only bias the
	DW_RLS_offset_pair with the base address.
2020-11-11 14:31:46 +00:00
Tom Tromey
0dd7428d89 Fix Windows-x-PPC build
A recent BFD change caused a build failure for a Windows->PPC cross:

ld.exe: ../bfd/libbfd.a(coff-rs6000.o):coff-rs6000.c:(.text+0x4571): undefined reference to `getuid'
ld.exe: ../bfd/libbfd.a(coff-rs6000.o):coff-rs6000.c:(.text+0x457e): undefined reference to `getgid'

This patch fixes the problem by moving the replacement definitions of
getuid and getgid to system.h.

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

	* archive.c (getuid, getgid): Move...
	* sysdep.h (getuid, getgid): ...here.
2020-11-11 06:38:43 -07:00
Andrew Burgess
550820e16d gdb/riscv: add ability to decode dwarf CSR numbers
Extends riscv_dwarf_reg_to_regnum to add the ability to convert the
DWARF register numbers for CSRs into GDB's internal numbers.

gdb/ChangeLog:

	* riscv-tdep.c (riscv_dwarf_reg_to_regnum): Decode DWARF CSR
	numbers.
	* riscv-tdep.h (RISCV_DWARF_FIRST_CSR, RISCV_DWARF_LAST_CSR): New
	enum values.
2020-11-11 11:55:08 +00:00
Andrew Burgess
81fdd7acec gdbserver: add missing --disable-packet options to help text
The help text for the --disable-packet option was missing one of the
possible values.

As this option is for maintainers only it is explicitly not documented
in gdb/doc/gdb.texinfo, so no update is needed there.

gdbserver/ChangeLog:

	* server.cc (gdbserver_usage): Add missing option to usage text.
	(gdbserver_show_disableable): Likewise.
2020-11-11 09:08:31 +00:00
GDB Administrator
424171c6f1 Automatic date update in version.in 2020-11-11 00:00:11 +00:00
Tom Tromey
baf20f7627 Make internalvar_name return a const char *
This changes internalvar_name to return a const char *.

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

	* value.h (internalvar_name): Update.
	* value.c (internalvar_name): Make return type const.
2020-11-10 15:46:19 -07:00
Tom Tromey
caaece0e2f Use "const" more in ax-gdb.c
This changes a few spots in ax-gdb.c to use a "const char *" rather
than a non-const one.

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

	* ax-gdb.c (gen_struct_elt_for_reference, gen_namespace_elt)
	(gen_maybe_namespace_elt, gen_aggregate_elt_ref, gen_expr): Use
	const.
2020-11-10 15:46:18 -07:00
Tom Tromey
8e20b4be65 Constify value_nsstring
This changes the "ptr" parameter to value_nsstring to be const.

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

	* objc-lang.h (value_nsstring): Update.
	* objc-lang.c (value_nsstring): Make "ptr" const.
2020-11-10 15:46:18 -07:00
Tom Tromey
6c51cf513d Move include block to pathstuff.h
A recent commit caused pathstuff.cc to fail to compile on mingw, like:

../../binutils-gdb/gdbsupport/pathstuff.cc:324:1: error: no previous declaration for 'std::string find_gdb_home_config_file(const char*, _stati64*)' [-Werror=missing-declarations]

Some newly-added #includes were changing which "stat" was being seen
by the compiler.  This patch moves the includes to the header, so that
the declaration and definition now agree.

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

	PR build/26848:
	* pathstuff.h: Move include block here...
	* pathstuff.cc: ... from here.
2020-11-10 13:12:59 -07:00
Nick Clifton
ed1afd8666 oops - forgot to include the changelog update for the latest binutils/dwarf.c patch 2020-11-10 17:31:14 +00:00
Tom Tromey
95016fd211 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.
2020-11-10 10:06:08 -07:00
Gary Benson
83100a74a5 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.
2020-11-10 16:40:40 +00:00
Gary Benson
6ff174a727 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)).
2020-11-10 16:40:40 +00:00
Gary Benson
eb24648c45 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.
2020-11-10 16:07:36 +00:00
Nick Clifton
1f57314183 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.
2020-11-10 11:55:18 +00:00
GDB Administrator
07bbadc83d Automatic date update in version.in 2020-11-10 00:00:19 +00:00
Nick Clifton
3e50c9d9c9 Revert delta accidentally applied with commit 9372689d72 2020-11-09 16:47:29 +00:00
Denys Zagorui
0541201782 gas: improve reproducibility for stabs debugging data format
* config/obj-elf (obj_elf_init_stab_section): Improve
	reproducibility for stabs debugging data format
2020-11-09 15:39:10 +00:00
Alan Modra
5cbc0eb01a 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.
2020-11-09 23:27:46 +10:30
Spencer E. Olson
9372689d72 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
2020-11-09 12:41:09 +00:00
Przemyslaw Wirkus
4a3e3e2282 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).
2020-11-09 11:37:32 +00:00
Przemyslaw Wirkus
8edca81ece 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
2020-11-09 11:19:44 +00:00
Andreas Schwab
a76bf0e55d 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.
2020-11-09 12:05:39 +01:00
Nick Clifton
521d4b194f 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.
2020-11-09 10:37:51 +00:00
Alan Modra
a4e91c4630 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.
2020-11-09 14:20:10 +10:30
Alan Modra
904790e24f 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.
2020-11-09 14:09:01 +10:30
Howard Chu
c9af384513 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.
2020-11-09 14:07:19 +10:30
Nelson Chu
6e1605e430 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.
2020-11-09 09:48:56 +08:00
GDB Administrator
4985fbc120 Automatic date update in version.in 2020-11-09 00:00:09 +00:00
H.J. Lu
d4820dac5e 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.
2020-11-08 04:10:15 -08:00
GDB Administrator
a907d563de Automatic date update in version.in 2020-11-08 00:00:09 +00:00
GDB Administrator
f07952eb0b Automatic date update in version.in 2020-11-07 00:00:17 +00:00
Andrew Burgess
86775fab42 gdb: fix debug expression dumping of function call expressions
In commit:

  commit 6d81691950
  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.
2020-11-06 20:58:06 +00:00
Simon Marchi
a1945bd452 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
2020-11-06 13:10:29 -05:00
Romain Geissler
3fed4c0b7a 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.
2020-11-06 18:01:47 +00:00
Pedro Alves
ac3d406409 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
2020-11-06 17:19:02 +00:00
Nick Clifton
2c72361c81 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.
2020-11-06 14:36:45 +00:00
H.J. Lu
9c905051aa 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.
2020-11-06 06:04:41 -08:00
Przemyslaw Wirkus
af1bd771fc 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.
2020-11-06 13:14:14 +00:00
Nick Clifton
fa63ba779d Updated Serbian translation for the ld subdirectory 2020-11-06 12:41:29 +00:00
Tom Tromey
606decb27e 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.
2020-11-05 18:27:43 -07:00
GDB Administrator
7ef63c9507 Automatic date update in version.in 2020-11-06 00:00:16 +00:00
GDB Administrator
712b8a0f68 Automatic date update in version.in 2020-11-05 00:00:13 +00:00
Przemyslaw Wirkus
55cc012834 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/
2020-11-04 20:54:13 +00:00
Tom Tromey
9c91c72591 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.
2020-11-04 09:17:58 -07:00
Tom Tromey
8d9fd3a107 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.
2020-11-04 09:17:58 -07:00
Tom Tromey
d8f62e8447 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.
2020-11-04 08:49:19 -07:00
Tom Tromey
7ff5b9370f 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.
2020-11-04 08:49:19 -07:00