binutils-gdb.git
13 months agox86: correct cpu_arch_isa_flags maintenance
Jan Beulich [Wed, 27 Sep 2023 14:51:46 +0000 (16:51 +0200)]
x86: correct cpu_arch_isa_flags maintenance

These may not be set from a value derived from cpu_arch_flags: That
starts with (almost) all functionality enabled, while cpu_arch_isa_flags
is supposed to track features that were explicitly enabled (and perhaps
later disabled) by the user.

To avoid needing to do any such adjustment in two places (each),
introduce helper functions used by both command line handling and
directive processing.

13 months agoAdjust gdb.thread/pthreads.exp for Cygwin
Pedro Alves [Tue, 19 Sep 2023 11:26:26 +0000 (12:26 +0100)]
Adjust gdb.thread/pthreads.exp for Cygwin

The Cygwin runtime spawns a few extra threads, so using hardcoded
thread numbers in tests rarely works correctly.  Thankfully, this
testcase already records the ids of the important threads in globals.
It just so happens that they are not used in a few tests.  This commit
fixes that.

With this, the test passes cleanly on Cygwin [1].  Still passes cleanly on
x86-64 GNU/Linux.

[1] - with system GDB.  Upstream GDB is missing a couple patches
Cygwin carries downstream.

Approved-By: Tom Tromey <tom@tromey.com>
Change-Id: I01bf71fcb44ceddea8bd16b933b10b964749a6af

13 months agoIn gdb.threads/pthreads.c, handle pthread_attr_setscope ENOTSUP
Pedro Alves [Fri, 15 Sep 2023 19:06:37 +0000 (20:06 +0100)]
In gdb.threads/pthreads.c, handle pthread_attr_setscope ENOTSUP

On Cygwin, I see:

 (gdb) PASS: gdb.threads/pthreads.exp: break thread1
 continue
 Continuing.
 pthread_attr_setscope 1: Not supported (134)
 [Thread 3732.0x265c exited with code 1]
 [Thread 3732.0x2834 exited with code 1]
 [Thread 3732.0x2690 exited with code 1]

 Program terminated with signal SIGHUP, Hangup.
 The program no longer exists.
 (gdb) FAIL: gdb.threads/pthreads.exp: Continue to creation of first thread

 ... and then a set of cascading failures.

Fix this by treating ENOTSUP the same way as if PTHREAD_SCOPE_SYSTEM
were not defined.  I.e., ignore ENOTSUP errors, and proceed with
testing.

Approved-By: Tom Tromey <tom@tromey.com>
Change-Id: Iea68ff8b9937570726154f36610c48ef96101871

13 months agoFix gdb.threads/pthreads.exp error handling/printing
Pedro Alves [Fri, 15 Sep 2023 18:43:55 +0000 (19:43 +0100)]
Fix gdb.threads/pthreads.exp error handling/printing

On Cygwin, I noticed:

 (gdb) PASS: gdb.threads/pthreads.exp: break thread1
 continue
 Continuing.
 pthread_attr_setscope 1: No error
 [Thread 8732.0x28f8 exited with code 1]
 [Thread 8732.0xb50 exited with code 1]
 [Thread 8732.0x17f8 exited with code 1]

 Program terminated with signal SIGHUP, Hangup.
 The program no longer exists.
 (gdb) FAIL: gdb.threads/pthreads.exp: Continue to creation of first thread

Note "No error" in "pthread_attr_setscope 1: No error".  That is a bug
in the test.  It is using perror, but that prints errno, while the
pthread functions return the error directly.  Fix all cases of the
same problem, by adding a new print_error function and using it.

We now get:

  ...
  pthread_attr_setscope 1: Not supported (134)
  ...

Approved-By: Tom Tromey <tom@tromey.com>
Change-Id: I972ebc931b157bc0f9084e6ecd8916a5e39238f5

13 months agoFix gdb.threads/pthreads.c formatting
Pedro Alves [Fri, 15 Sep 2023 18:55:54 +0000 (19:55 +0100)]
Fix gdb.threads/pthreads.c formatting

Just some GNU formatting fixes throughout.

Approved-By: Tom Tromey <tom@tromey.com>
Change-Id: Ie851e3815b839e57898263896db0ba8ddfefe09e

13 months agogdb.threads/pthreads.c, K&R -> ANSI function style
Pedro Alves [Fri, 15 Sep 2023 18:54:40 +0000 (19:54 +0100)]
gdb.threads/pthreads.c, K&R -> ANSI function style

gdb.threads/pthreads.c is declaring functions with old K&R style.
This commit converts them to ANSI style.

Approved-By: Tom Tromey <tom@tromey.com>
Change-Id: I1ce007c67bb4ab1e49248c014c7881e46634f8f8

13 months agoopcodes: microblaze: Add wdc.ext.clear and wdc.ext.flush insns
Neal Frager [Wed, 27 Sep 2023 13:47:01 +0000 (14:47 +0100)]
opcodes: microblaze: Add wdc.ext.clear and wdc.ext.flush insns

13 months agoFix: Output section type does not been applied to section forced output by `. = ...
Hsinyuan Xavier [Wed, 27 Sep 2023 12:21:43 +0000 (13:21 +0100)]
Fix: Output section type does not been applied to section forced output by `. = .` assignment

  PR 30875
  * ldlang.c (get_os_init_flag): New function. (exp_init_os, map_input_to_output_sections): Use it.

13 months agox86: fold FMA VEX and EVEX templates
Jan Beulich [Wed, 27 Sep 2023 12:16:09 +0000 (14:16 +0200)]
x86: fold FMA VEX and EVEX templates

Following the folding of some generic AVX/AVX2 templates with their
AVX512F counterpart ones, do this for FMA ones as well, requiring one
further adjustment to cpu_flags_match().

13 months agox86: fold VAES/VPCLMULQDQ VEX and EVEX templates
Jan Beulich [Wed, 27 Sep 2023 12:15:44 +0000 (14:15 +0200)]
x86: fold VAES/VPCLMULQDQ VEX and EVEX templates

Following the folding of some generic AVX/AVX2 templates with their
AVX512F counterpart ones, do this for VAES and VPCLMULQDQ ones as well.

13 months agox86: fold certain VEX and EVEX templates
Jan Beulich [Wed, 27 Sep 2023 12:15:19 +0000 (14:15 +0200)]
x86: fold certain VEX and EVEX templates

In anticipation of APX introduce logic to reduce the number of templates
we have now, allowing to limit some the number of ones we then need to
gain.

The fundamental requirements are that
- attributes be compatible, which specifically means VexW needs to be
  the same in the templates (which often isn't the case, for VEX
  encodings having far more WIG tha, EVEX ones),
- the EVEX form being AVX512F (with or without AVX512VL), not any of its
  extensions (the same will then be required for APX - it'll need to be
  APX_F).

Note that in check_register() there's now a redundant zmm check. Since
this logic will need revisiting for APX anyway, I'd like to keep it that
way for now. (Similarly a couple of if()-s which could be folded are
kept separate, to reduce code churn when adding APX support.)

13 months agox86: tighten .insn SAE and broadcast checking
Jan Beulich [Wed, 27 Sep 2023 08:54:23 +0000 (10:54 +0200)]
x86: tighten .insn SAE and broadcast checking

SAE / embedded rounding are invalid when there's the memory operand, as
the bit encoding this specifies broadcast in that case.

Broadcast needs to be specified on the memory operand.

13 months agox86-64: REX.W overrides DATA_PREFIX
Jan Beulich [Wed, 27 Sep 2023 08:53:59 +0000 (10:53 +0200)]
x86-64: REX.W overrides DATA_PREFIX

REX.W needs to be respected when immediate size and relocation type are
determined.

13 months agox86-64: fix suffix-less PUSH of symbol address
Jan Beulich [Wed, 27 Sep 2023 08:53:38 +0000 (10:53 +0200)]
x86-64: fix suffix-less PUSH of symbol address

PR gas/30856

In 5cc007751cdb ("x86: further adjust extend-to-32bit-address
conditions") I neglected the case of PUSH, which is the only insn
allowing (proper) symbol addresses to be used as immediates (not
displacements, like CALL/JMP) in the absence of any register operands.
Since it defaults to 64-bit operand size, guessing an L suffix is wrong
there.

13 months agogdb: Fix an ODR warning with byacc with GDB_YY_REMAP
Sam James [Tue, 12 Sep 2023 00:46:51 +0000 (01:46 +0100)]
gdb: Fix an ODR warning with byacc with GDB_YY_REMAP

With byacc, we get an ODR warning with YYSTACKDATA between ada-exp.c.tmp
and c-exp.c.tmp. Just include it in the list of symbols we rename.

PR gdb/30839

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30839
Approved-By: Tom de Vries <tdevries@suse.de>
Copyright-paperwork-exempt: yes

13 months agoAdd support for "pcaddi rd, symbol"
mengqinggang [Mon, 18 Sep 2023 10:00:21 +0000 (18:00 +0800)]
Add support for "pcaddi rd, symbol"

Add a macro pcaddi instruction to support "pcaddi rd, symbol".

pcaddi has a 20-bit signed immediate, it can address a +/- 2MB pc relative
address, and the address should be 4-byte aligned.

13 months agoAutomatic date update in version.in
GDB Administrator [Wed, 27 Sep 2023 00:00:32 +0000 (00:00 +0000)]
Automatic date update in version.in

13 months agogdb/testsuite: add xfail for gdb/29965 in gdb.threads/process-exit-status-is-leader...
Simon Marchi [Fri, 8 Sep 2023 01:53:55 +0000 (21:53 -0400)]
gdb/testsuite: add xfail for gdb/29965 in gdb.threads/process-exit-status-is-leader-exit-status.exp

Bug 29965 shows on a Linux kernel >= 6.1, that test fails consistently
with:

    FAIL: gdb.threads/process-exit-status-is-leader-exit-status.exp: iteration=0: continue (the program exited)
    ...
    FAIL: gdb.threads/process-exit-status-is-leader-exit-status.exp: iteration=9: continue (the program exited)

This is due to a change in Linux kernel behavior [1] that affects
exactly what this test tests.  That is, if multiple threads (including
the leader) call SYS_exit, the exit status of the process should be the
exit status of the leader.  After that change in the kernel, it is no
longer the case.

Add an xfail in the test, based on the Linux kernel version.  The goal
is that if a regression is introduced in GDB regarding this feature, it
should be caught if running on an older kernel where the behavior was
consistent.

[1] https://bugzilla.suse.com/show_bug.cgi?id=1206926

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29965
Change-Id: If6ab7171c92bfc1a3b961c7179e26611773969eb
Approved-By: Tom de Vries <tdevries@suse.de>
13 months ago[gdb/testsuite] Fix gdb.ada/mi_task_arg.exp with newer gcc
Tom de Vries [Tue, 26 Sep 2023 16:57:49 +0000 (18:57 +0200)]
[gdb/testsuite] Fix gdb.ada/mi_task_arg.exp with newer gcc

When running test-case gdb.ada/mi_task_arg.exp on openSUSE Tumbleweed using
gcc 13.2.1, I run into (layout adapted for readability):
...
-stack-list-arguments 1^M
^done,stack-args=[
  frame={level="0",args=[]},
  frame={level="1",args=[{name="<_task>",value="0x464820"},
                         {name="<_taskL>",value="129"}]},
  frame={level="2",args=[{name="self_id",value="0x464840"}]},
  frame={level="3",args=[]},
  frame={level="4",args=[]}
]^M
(gdb) ^M
FAIL: gdb.ada/mi_task_arg.exp: -stack-list-arguments 1 (unexpected output)
...

On openSUSE Leap 15.4 with gcc 7.5.0 I get instead:
...
-stack-list-arguments 1^M
^done,stack-args=[
  frame={level="0",args=[]},
  frame={level="1",args=[{name="<_task>",value="0x444830"}]},
  frame={level="2",args=[{name="self_id",value="0x444850"}]},
  frame={level="3",args=[]},
  frame={level="4",args=[]}]^M
(gdb) ^M
PASS: gdb.ada/mi_task_arg.exp: -stack-list-arguments 1
...

The difference in gdb output is due to difference in the dwarf generated by
the compiler, so I don't see a problem with gdb here.

Fix this by updating the test-case to accept this output.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
13 months agoRemove some unnecessary qualification from printing.py
Tom Tromey [Tue, 26 Sep 2023 15:51:56 +0000 (09:51 -0600)]
Remove some unnecessary qualification from printing.py

printing.py references "gdb.printing" in a few spots, but there's no
need for this.  I think this is leftover from when this code was
(briefly) in some other module.  This patch removes the unnecessary
qualifications.  Tested on x86-64 Fedora 36.

13 months agoAdd two new pretty-printer methods
Tom Tromey [Fri, 8 Sep 2023 19:18:17 +0000 (13:18 -0600)]
Add two new pretty-printer methods

This adds two new pretty-printer methods, to support random access to
children.  The methods are implemented for the no-op array printer,
and DAP is updated to use this.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
13 months agoIntroduce gdb.ValuePrinter
Tom Tromey [Thu, 7 Sep 2023 19:40:29 +0000 (13:40 -0600)]
Introduce gdb.ValuePrinter

There was an earlier thread about adding new methods to
pretty-printers:

https://sourceware.org/pipermail/gdb-patches/2023-June/200503.html

We've known about the need for printer extensibility for a while, but
have been hampered by backward-compatibilty concerns: gdb never
documented that printers might acquire new methods, and so existing
printers may have attribute name clashes.

To solve this problem, this patch adds a new pretty-printer tag class
that signals to gdb that the printer follows new extensibility rules.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30816
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
13 months agoFix a snafu in the new tests for reproducible archives that assumed a umask of 22.
Nick Clifton [Tue, 26 Sep 2023 15:27:28 +0000 (16:27 +0100)]
Fix a snafu in the new tests for reproducible archives that assumed a umask of 22.

13 months ago[gdb/testsuite] Fix gdb.server/ext-run.exp in container
Tom de Vries [Tue, 26 Sep 2023 14:28:48 +0000 (16:28 +0200)]
[gdb/testsuite] Fix gdb.server/ext-run.exp in container

When running the gdb testsuite inside a container, I run into:
...
(gdb) gdb_expect_list pattern: /1 +root +[/a-z]*(init|systemd)/
FAIL: gdb.server/ext-run.exp: get process list (pattern 2)
...
because there's no process with pid 1 and cmd init or systemd.

In the host system (where the test passes), I have:
...
$ ps -f 1
UID        PID  PPID  C STIME TTY      STAT   TIME CMD
root         1     0  0 Sep25 ?        Ss     0:03 /usr/lib/systemd/systemd ...
...
but in the container instead:
...
UID        PID  PPID  C STIME TTY      STAT   TIME CMD
root         1     0  0 11:45 pts/0    Ss     0:00 /bin/bash
...

Fix this by also accepting bash as a valid cmd.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
13 months agoaarch64: Allow feature flags to occupy >64 bits
Richard Sandiford [Tue, 26 Sep 2023 14:01:21 +0000 (15:01 +0100)]
aarch64: Allow feature flags to occupy >64 bits

Following on from the previous patch to make the feature macros take
a word number, this one increases the number of flag words from 1 to 2.

The patch uses some dummy features to push the number of features
over 64.  The intention is that these should be reused by real
features rather than kept as-is.

13 months agoaarch64: Restructure feature flag handling
Richard Sandiford [Tue, 26 Sep 2023 14:01:21 +0000 (15:01 +0100)]
aarch64: Restructure feature flag handling

The AArch64 feature-flag code is currently limited to a maximum
of 64 features.  This patch reworks it so that the limit can be
increased more easily.  The basic idea is:

(1) Turn the ARM_FEATURE_FOO macros into an enum, with the enum
    counting bit positions.

(2) Make the feature-list macros take an array index argument
    (currently always 0).  The macros then return the
    aarch64_feature_set contents for that array index.

    An N-element array would then be initialised as:

      { MACRO (0), ..., MACRO (N - 1) }

(3) Provide convenience macros for initialising an
    aarch64_feature_set for:

    - a single feature
    - a list of individual features
    - an architecture version
    - an architecture version + a list of additional features

(2) and (3) use the preprocessor to generate static initialisers.
The main restriction was that uses of the same preprocessor macro
cannot be nested.  So if a macro wants to do something for N individual
arguments, it needs to use a chain of N macros to do it.  There then
needs to be a way of deriving N, as a preprocessor token suitable for
pasting.

The easiest way of doing that was to precede each list of features
by the number of features in the list.  So an aarch64_feature_set
initialiser for three features A, B and C would be written:

  AARCH64_FEATURES (3, A, B, C)

This scheme makes it difficult to keep AARCH64_FEATURE_CRYPTO as a
synonym for SHA2+AES, so the patch expands the former to the latter.

13 months ago[gdb/dap] Fix dap for python < 3.8
Tom de Vries [Tue, 26 Sep 2023 13:51:27 +0000 (15:51 +0200)]
[gdb/dap] Fix dap for python < 3.8

With any gdb.dap test and python 3.6 I run into:
...
Error occurred in Python: 'code' object has no attribute 'co_posonlyargcount'
ERROR: eof reading json header
...

The attribute is not supported before python 3.8, which introduced the
"Positional−only Parameters" concept.

Fix this by using try/except AttributeError.

Tested on x86_64-linux:
- openSUSE Leap 15.4 with python 3.6, and
- openSUSE Tumbleweed with python 3.11.5.

Approved-By: Tom Tromey <tom@tromey.com>
13 months agofbsd-nat: Fix build failure with GCC 12
Enze Li [Tue, 26 Sep 2023 12:55:36 +0000 (20:55 +0800)]
fbsd-nat: Fix build failure with GCC 12

A user pointed out that the build failed on FreeBSD/amd64 with my last
commit.  The problem is that I'm not using the proper way to tell the
compiler that the variable has been "used".  This patch fixes this issue
as suggested by John.  Pushed as obvious.

Tested both on FreeBSD/amd64 and FreeBSD/aarch64 by rebuilding.

Suggested-By: John Baldwin <jhb@FreeBSD.org>
13 months agoFix to step instruction due to P10 prefix instruction.
Aditya Vidyadhar Kamath [Tue, 26 Sep 2023 05:48:57 +0000 (00:48 -0500)]
Fix to step instruction due to P10 prefix instruction.

In AIX, power 10 instructions like paddi occupy 8 bytes, while the other instructions
4 bytes of space. Due to this when we do a stepi on paddi instruction we get a SIGILL interrupt. Hence, we
need to check during stepi if we are able to step 8 bytes during this instruction execution and is the
breakpoint to this instruction set correctly in both 32- and 64-bit mode.

This patch is a fix to the same.

13 months agoAllow the use of SOURCE_DATE_EPOCH in the timestamps for members of static archives.
Nick Clifton [Tue, 26 Sep 2023 13:07:23 +0000 (14:07 +0100)]
Allow the use of SOURCE_DATE_EPOCH in the timestamps for members of static archives.

(For some reason this commit was not applied at the time that the patch was approved).

13 months agoUse string_file::release in some places
Tom Tromey [Thu, 21 Sep 2023 19:31:14 +0000 (13:31 -0600)]
Use string_file::release in some places

I found a few spots like:

    string_file f;
    std::string x = f.string ();

However, string_file::string returns a 'const std::string &'...  so it
seems to me that this must be copying the string (? I find it hard to
reason about this in C++).

This patch changes these spots to use release() instead, which moves
the string.

Reviewed-by: Keith Seitz <keiths@redhat.com>
Reviewed-by: Lancelot Six <lancelot.six@amd.com>
13 months agoAutomatic date update in version.in
GDB Administrator [Tue, 26 Sep 2023 00:00:42 +0000 (00:00 +0000)]
Automatic date update in version.in

13 months agoFix readelf's display of dwarf v5 range lists
Vsevolod Alekseyev [Mon, 25 Sep 2023 17:01:31 +0000 (18:01 +0100)]
Fix readelf's display of dwarf v5 range lists

  PR 30792
  * dwarf.h (struct debug_info): Remove range_versions field.
  * dwarf.c (fetch_indexed_offset): New function. (read_and_display_attr_value): Use it for DW_FORM_rnglistx. Remove code to initialise range_versions. (skip_attribute): New function. (read_bases): Read and reccord all range and address bases in a CU. (process_debug_info): Call read_bases. (display_debug_rnglists): Rename to display_debug_rnglists_unit_header and only display the range list header information. (display_debug_ranges): Adjust.

13 months agoRevert "arc: Add new GAS tests for ARCv3."
Claudiu Zissulescu [Mon, 25 Sep 2023 14:03:35 +0000 (17:03 +0300)]
Revert "arc: Add new GAS tests for ARCv3."

This reverts commit 462693a455f04fc52c1c91ffc52ea2446a086444.

13 months agoRevert "arc: Add new LD tests for ARCv3."
Claudiu Zissulescu [Mon, 25 Sep 2023 14:03:20 +0000 (17:03 +0300)]
Revert "arc: Add new LD tests for ARCv3."

This reverts commit 6e467e9a94c1135bd11d985e9263d43204a9258b.

13 months agoRevert "arc: Add new ARCv3 ISA to BFD."
Claudiu Zissulescu [Mon, 25 Sep 2023 14:03:06 +0000 (17:03 +0300)]
Revert "arc: Add new ARCv3 ISA to BFD."

This reverts commit 06e8d9861d16c5b7e6920ad0e89889ccf45c575a.

13 months agoRevert "arc: Add new linker emulation and scripts for ARCv3 ISA."
Claudiu Zissulescu [Mon, 25 Sep 2023 14:02:55 +0000 (17:02 +0300)]
Revert "arc: Add new linker emulation and scripts for ARCv3 ISA."

This reverts commit 4deb1ee57fdb711cac6f36fed75b3c8cb5112d99.

13 months agoRevert "arc: Update opcode related include files for ARCv3."
Claudiu Zissulescu [Mon, 25 Sep 2023 14:02:41 +0000 (17:02 +0300)]
Revert "arc: Update opcode related include files for ARCv3."

This reverts commit 04414221df53bb5129e34bec354dae3121db436a.

13 months agoRevert "arc: Update ARC's Gnu Assembler backend with ARCv3 ISA."
Claudiu Zissulescu [Mon, 25 Sep 2023 14:02:29 +0000 (17:02 +0300)]
Revert "arc: Update ARC's Gnu Assembler backend with ARCv3 ISA."

This reverts commit f3d38d7d0b7346515ba603454feeddc58a3fc451.

13 months agoRevert "arc: Add new opcode functions for ARCv3 ISA."
Claudiu Zissulescu [Mon, 25 Sep 2023 14:02:19 +0000 (17:02 +0300)]
Revert "arc: Add new opcode functions for ARCv3 ISA."

This reverts commit c99dc76089a2de97ea0ee755aa8e87037a17b6d6.

13 months agoRevert "arc: New ARCv3 ISA instruction table"
Claudiu Zissulescu [Mon, 25 Sep 2023 14:02:08 +0000 (17:02 +0300)]
Revert "arc: New ARCv3 ISA instruction table"

This reverts commit 67036dfacf87e79317984f51892bfc0eda0e597f.

13 months agoRevert "arc: Update arc's gas tests"
Claudiu Zissulescu [Mon, 25 Sep 2023 14:01:58 +0000 (17:01 +0300)]
Revert "arc: Update arc's gas tests"

This reverts commit ef90c0991e78c28bebdd3ed31a77c05be0444191.

13 months agoRevert "arc: Update NEWS files"
Claudiu Zissulescu [Mon, 25 Sep 2023 14:01:47 +0000 (17:01 +0300)]
Revert "arc: Update NEWS files"

This reverts commit a47d304b1229ecf8912fac17ee9c48d1bf3c729a.

13 months agoRevert "arc: Update bfd arc pattern file to allow enable-targets=all"
Claudiu Zissulescu [Mon, 25 Sep 2023 14:01:34 +0000 (17:01 +0300)]
Revert "arc: Update bfd arc pattern file to allow enable-targets=all"

This reverts commit 5e5116071b09e187ee3c6b7e86e86114f6a65ef3.

13 months agoarc: Update bfd arc pattern file to allow enable-targets=all
Claudiu Zissulescu [Mon, 25 Sep 2023 12:00:49 +0000 (15:00 +0300)]
arc: Update bfd arc pattern file to allow enable-targets=all

The ARC backend uses a BFD pattern file to generate three ARC targets:
- an BFD ARC target for ARCv1 and ARCv2 CPU families. It also works
for big-endian variants.
- an BFD ARC64 target for ARCv3 64bit machines. It also allows working
with ARCv3 32bit machines.
- an BFD ARC32 target for ARCv4 32bit machines. It also allows working
with ARCv3 64bit machines.

When configuring with `--enable-targets=all` some patterns are defined
multiple times. Fix this issue.

Signed-off-by: Claudiu Zissulescu <claziss@gmail.com>
13 months agoRISC-V: Protect .got with relro
Andreas Schwab [Thu, 21 Sep 2023 14:49:41 +0000 (16:49 +0200)]
RISC-V: Protect .got with relro

Move .got before .data so that it can be protected with -zrelro.  Also
separate .got.plt from .got if -znow is not in effect; the first two words
of .got.plt are placed within the relro region.

ld:
PR ld/30877
* emulparams/elf32lriscv-defs.sh (DATA_GOT, SEPARATE_GOTPLT):
Define.
* emulparams/elf64lriscv-defs.sh (SEPARATE_GOTPLT): Define.
* testsuite/ld-elf/binutils.exp (binutils_test): Remove riscv*-*-*
from relro_got expression.

13 months agoarc: Update NEWS files
Claudiu Zissulescu [Mon, 25 Sep 2023 08:33:12 +0000 (11:33 +0300)]
arc: Update NEWS files

Add ARCv3 support in NEWS files.

Signed-off-by: Claudiu Zissulescu <claziss@gmail.com>
13 months agoarc: Update arc's gas tests
Claudiu Zissulescu [Mon, 25 Sep 2023 07:55:51 +0000 (10:55 +0300)]
arc: Update arc's gas tests

The disassembler can recognize the alternative register names ILINK1
and ILINK2.  Update tests.

gas/testsuite/gas/arc
xxxx-xx-xx  Claudiu Zissulescu <claziss@synopsys.com>

* gas/testsuite/gas/arc/adc.d: Update ILINK1/INLINK2 reg names.
* gas/testsuite/gas/arc/add.d: Likewise.
* gas/testsuite/gas/arc/and.d: Likewise.
* gas/testsuite/gas/arc/asl.d: Likewise.
* gas/testsuite/gas/arc/asr.d: Likewise.
* gas/testsuite/gas/arc/bic.d: Likewise.
* gas/testsuite/gas/arc/lsr.d: Likewise.
* gas/testsuite/gas/arc/nps400-1.d: Likewise.
* gas/testsuite/gas/arc/or.d: Likewise.
* gas/testsuite/gas/arc/ror.d: Likewise.
* gas/testsuite/gas/arc/sbc.d: Likewise.
* gas/testsuite/gas/arc/sub.d: Likewise.
* gas/testsuite/gas/arc/textinsn3op.d: Likewise.
* gas/testsuite/gas/arc/warn.exp: Update predicate.
* gas/testsuite/gas/arc/arc.exp: Likewise.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
13 months agoarc: New ARCv3 ISA instruction table
Claudiu Zissulescu [Mon, 25 Sep 2023 07:55:51 +0000 (10:55 +0300)]
arc: New ARCv3 ISA instruction table

opcodes/
xxxx-xx-xx  Claudiu Zissulescu <claziss@synopsys.com>

* opcodes/arc64-tbl.h: New file.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
13 months agoarc: Add new opcode functions for ARCv3 ISA.
Claudiu Zissulescu [Mon, 25 Sep 2023 07:55:51 +0000 (10:55 +0300)]
arc: Add new opcode functions for ARCv3 ISA.

opcodes/
xxxx-xx-xx  Claudiu Zissulescu <claziss@synopsys.com>
            Cupertino Miranda <cmiranda@synopsys.com>

        * opcodes/Makefile.am: Add ARC64 opcode file.
        * opcodes/Makefile.in: Regenerate.
        * opcodes/arc-opc.c: Move the common functionality to
        arcxx-opc.inc. Keep only ARCv2 ARCv1 specifics.
        * opcodes/arc-ext-tbl.h: Deleted file.
        * opcodes/arcxx-opc.inc: New file.
        * opcodes/arc64-opc.c: Likewise.
        * opcodes/arc-fxi.h (insert_uimm9_a32_11_s): New function.
        (extract_uimm9_a32_11_s): Likewise.
        (insert_uimm10_13_s): Likewise.
        (extract_uimm10_13_s): Likewise.
        * opcodes/configure: Regenerate.
        * opcodes/configure.ac: Add ARC64 target.
        * opcodes/disassemble.c: Likewise.
        * opcodes/arc-dis.c (regmod_t): New type.
        (regmods): New structure.
        (fpnames): New strings with fp-regs name.
        (REG_PCL, REG_LIMM, REG_LIMM_S, REG_U32, REG_S32): New defines.
        (getregname): New function.
        (find_format_from_table): Discriminate between signed and unsigned
        32bit immediates.
        (find_format): Handle extract function for flags.
        (arc_insn_length): Update insn lengths to various architectures.
        (print_insn_arc): Update printing for various ARC architectures.
* opcodes/arc-flag-classes.def: New file.
* opcodes/arc-flag.def: New file.
* opcodes/arc-operands.def: New file.
* opcodes/arc-regs.h: Changed.

Signed-off-by: Claudiu Zissulescu <claziss@gmail.com>
13 months agoarc: Update ARC's Gnu Assembler backend with ARCv3 ISA.
Claudiu Zissulescu [Mon, 25 Sep 2023 07:55:51 +0000 (10:55 +0300)]
arc: Update ARC's Gnu Assembler backend with ARCv3 ISA.

The new Synopsys ARCv3 ISA has a similar instruction format like
the old ARCv1 and ARCv2 ISA.  Thus, the ARCv3 addition is using
whatever we have for old ARC processors plus some ARCv3 spcific mods.

To distinguish between various ARC variants, we introduced two new
configure defines named TARGET_ARCv3_32 and TARGET_ARCv3_64 which are
set when we choose either an ARC32 (ARCv3/32) ISA toolchain or an
ARC64 (ARCv3/64) ISA toolchain.

gas/
xxxx-xx-xx  Claudiu Zissulescu <claziss@synopsys.com>

* gas/config/tc-arc.h: Selectively define default target macros.
* gas/configure.ac: Add ARC64 target.
* gas/configure.tgt: Likewise.
* gas/configure: Regenerate
* gas/config.in: Regenerate.
* gas/config/tc-arc.c (DEFAULT_ARCH): New macro.
(default_arch): New variable.
(md_pseudo_table): Add xword.
(md_shortopts): Only a few options are recognized by the new ARC64
assembler.
(md_longopts): Likewise.
(ARC_CPU_TYPE_A64x): New define.
(ARC_CPU_TYPE_A32x): Likewise.
(cpu_type): New arch field.
(selected_cpu): Update fields.
(arc_opcode_hash_entry_iterator_init): Formating.
(arc_opcode_hash_entry_iterator_next): Likewise.
(arc_select_cpu): Likewise.
(arc_option): Likewise.
(check_cpu_feature): Likewise.
(debug_exp): Recognize new expression operands.
(parse_reloc_symbol): Parse new signed/unsigend cases.
(parse_opcode_flags): Update for the case when the flags needs
insert/extract functions.
(find_opcode_match): Match new signed/unsigned 32-bit immediates.
(autodetect_attributes): PLT34 only available for ARC64.
(md_assemble): Extend match characters.
(declare_fp_set): New function.
(init_default_arch): Likewise.
(md_begin): Detect and initialize the correct CPU and coresponding
registers.
(md_pcrel_from_section): Add new relocs.
(arc_target_format): New function.
(md_apply_fix): Add new relocs.
(md_parse_option): Update options.
(arc_show_cpu_list): Update with ARC64 cpus.
(md_show_usage): Update messages.
(may_relax_expr): Add PLT34 case.
(assemble_insn): Update for ARC64.
(arc_make_nops): New function.
(arc_handle_align): Refurbish this function, use arc_make_nops.
(tc_arc_fix_adjustable): Update messages.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
13 months agoarc: Update opcode related include files for ARCv3.
Claudiu Zissulescu [Mon, 25 Sep 2023 07:55:51 +0000 (10:55 +0300)]
arc: Update opcode related include files for ARCv3.

Add new ARCv3 CPUs and required bits to decode/encode ARCv3 ISA
opcodes. Fix 32 bit relocations which were set as signed but should be
bitfield: ARC_32_ME, ARC_GLOB_DAT, ARC_JMP_SLOT, ARC_RELATIVE. Remove
non-ABI relocation ARC_32_ME_S.

include/
xxxx-xx-xx  Claudiu Zissulescu  <claziss@synopsys.com>
    Cupertino Miranda  <cupertinomiranda@gmail.com>
    Bruno Mauricio <brunoasmauricio@gmail.com>

* include/elf/arc-cpu.def: Add new HS5x and HS6x CPUs.
* include/elf/arc-reloc.def: Add new ARC64 relocations.
* include/elf/arc.h (EF_ARC_CPU_ARC64): New define.
* include/opcode/arc-attrs.h (FEATURE_LIST_NAME): Update predicate.
* include/opcode/arc-func.h: Update formating.
(replace_disp8ls): New function.
(replace_disp9s): Likewise.
(replace_disp6s): Likewise.
(replace_disp7s): Likewise.
(replace_disp12s): Likewise.
* include/opcode/arc.h (ARC_OPCODE_ARC64): New define.
(ARC_OPCODE_ARC32): Likewise.
(ARC_OPERAND_FP): Likewise.
(HARD_FIELDF): Likewise.
(ARC_OPCODE_ARCVx): New macro.
(arc_flag_class): Update structure to hold new extract/insert
functions for flags.
(INSN3OP): Update macro.
(FP_SIZE, TPOF, DPOF, SOPF, COPF, CONVOPS): New enums.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
13 months agoarc: Add new linker emulation and scripts for ARCv3 ISA.
Claudiu Zissulescu [Mon, 25 Sep 2023 07:55:51 +0000 (10:55 +0300)]
arc: Add new linker emulation and scripts for ARCv3 ISA.

Add ARCv3's linker bits. Remove obsolete tests.

ld/
xxxx-xx-xx  Claudiu Zissulescu  <claziss@synopsys.com>

* ld/Makefile.am: Add ARC64 targets.
* ld/configure.tgt: Likewise.
* ld/Makefile.in: Regenerate.
* ld/emulparams/arc64elf32.sh: New file.
* ld/emulparams/arc64elf64.sh: Likewise.
* ld/emulparams/arc64linux32.sh: Likewise.
* ld/emulparams/arc64linux64.sh: Likewise.
* ld/scripttempl/elfarc.sc: Update stack and heap definitions.
* ld/testsuite/ld-arc/got-weak.d: Deleted file.
* ld/testsuite/ld-arc/got-weak.s: Likewise.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
13 months agoarc: Add new ARCv3 ISA to BFD.
Claudiu Zissulescu [Mon, 25 Sep 2023 07:55:51 +0000 (10:55 +0300)]
arc: Add new ARCv3 ISA to BFD.

The new Synopsys's ARCv3 ISA is capable to run either 64-bit or
32-bit ISA.  The new 32-bit ISA is not compatible with the old
Synopsys ARCv1/ARCv2 ISA, however, it retains a lot of common
concepts.  Thus, this patch is reusing the old ARC BFD backend and
adds the necessary bits for the new architecture in a similar way as
it is done for RISCV backend.

bfd/
xxxx-xx-xx  Claudiu Zissulescu  <claziss@synopsys.com>
    Cupertino Miranda  <cupertinomiranda@gmail.com>

* bfd/Makefile.am: Add ARC64 files.
* bfd/Makefile.in: Regerate.
* bfd/arc-got.h (TCB_SIZE): Depends on the target architecture.
(GOT_ENTRY_SIZE): New define.
(write_in_got): Likewise.
(read_from_got): Likewise.
(align_power): Likewise.
(arc_got_entry_type_for_reloc): Use RELA_SIZE and GOT_ENTRY_SIZE.
(arc_fill_got_info_for_reloc): Update formating.
(relocate_fix_got_relocs_for_got_info): Likewise.
(arc_static_sym_data): Deleted structure.
(get_static_sym_data): Deleted function.
(relocate_fix_got_relocs_for_got_info): Use symbol static data.
(create_got_dynrelocs_for_single_entry): Update formating.
(create_got_dynrelocs_for_got_info): Likewise.
* bfd/arc-plt.c: New file.
* bfd/arc-plt.def: Add ARC64 PLT entry.
* bfd/arc-plt.h: Clean it up, move functionality to arc-plt.c file.
* bfd/archures.c: Add ARC64 target.
* bfd/config.bfd: Likewise.
* bfd/configure.ac: Likewise.
* bfd/bfd-in2.h: Regenerate.
* bfd/configure: Likewise.
* bfd/libbfd.h: Likewise.
* bfd/cpu-arc.c: Clean it up.
* bfd/cpu-arc64.c: New file.
* bfd/elf32-arc.c: Renamed to elfnn-arc.c.
* bfd/elfnn-arc.c: New file.
* bfd/reloc.c: Add new ARC64 relocs.
* bfd/targets.c: Add ARC64 target.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
13 months agoarc: Add new LD tests for ARCv3.
Claudiu Zissulescu [Mon, 25 Sep 2023 07:55:51 +0000 (10:55 +0300)]
arc: Add new LD tests for ARCv3.

Add new linker tests for ARCv3 ISA. All the new tests are added in a
distinct new folder named arc64.

ld/
xxxx-xx-xx  Claudiu Zissulescu  <claziss@synopsys.com>

* ld/testsuite/ld-arc64/arcv3_64-reloc-near-exe.dd: New file.
* ld/testsuite/ld-arc64/arcv3_64-reloc-near-so.dd: Likewise.
* ld/testsuite/ld-arc64/arcv3_64-reloc-near.s: Likewise.
* ld/testsuite/ld-arc64/arcv3_64.exp: Likewise.
* ld/testsuite/ld-arc64/bl34.dd: Likewise.
* ld/testsuite/ld-arc64/bl34.s: Likewise.
* ld/testsuite/ld-arc64/linkscript.ld: Likewise.
* ld/testsuite/ld-arc64/plt34-got.dd: Likewise.
* ld/testsuite/ld-arc64/plt34-got.s: Likewise.
* ld/testsuite/ld-arc64/plt34-reloc.dd: Likewise.
* ld/testsuite/ld-arc64/plt34-reloc.s: Likewise.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
13 months agoarc: Add new GAS tests for ARCv3.
Claudiu Zissulescu [Mon, 25 Sep 2023 07:55:51 +0000 (10:55 +0300)]
arc: Add new GAS tests for ARCv3.

Add new assembler tests for ARCv3 ISA. All the new tests are added in
a distinct folder named arc64.

gas/
xxxx-xx-xx  Claudiu Zissulescu <claziss@synopsys.com>

* gas/testsuite/gas/arc64/arc64.exp: New file.
* gas/testsuite/gas/arc64/float01.d: Likewise.
* gas/testsuite/gas/arc64/float01.s: Likewise.
* gas/testsuite/gas/arc64/ldd.d: Likewise.
* gas/testsuite/gas/arc64/ldd.s: Likewise.
* gas/testsuite/gas/arc64/lddl.d: Likewise.
* gas/testsuite/gas/arc64/lddl.s: Likewise.
* gas/testsuite/gas/arc64/load.d: Likewise.
* gas/testsuite/gas/arc64/load.s: Likewise.
* gas/testsuite/gas/arc64/st.d: Likewise.
* gas/testsuite/gas/arc64/st.s: Likewise.
* gas/testsuite/gas/arc64/std.d: Likewise.
* gas/testsuite/gas/arc64/std.s: Likewise.
* gas/testsuite/gas/arc64/stdl.d: Likewise.
* gas/testsuite/gas/arc64/stdl.s: Likewise.
* gas/testsuite/gas/arc64/stl.d: Likewise.
* gas/testsuite/gas/arc64/stl.s: Likewise.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
13 months agoarc: Update binutils arc predicate for tests.
Claudiu Zissulescu [Mon, 25 Sep 2023 07:32:52 +0000 (10:32 +0300)]
arc: Update binutils arc predicate for tests.

binutils/testsuite/binutils-all
xxxx-xx-xx  Claudiu Zissulescu  <claziss@synopsys.com>

* binutils/testsuite/binutils-all/arc/objdump.exp: Update predicate.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
13 months agoAutomatic date update in version.in
GDB Administrator [Mon, 25 Sep 2023 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in

13 months agoAutomatic date update in version.in
GDB Administrator [Sun, 24 Sep 2023 00:00:24 +0000 (00:00 +0000)]
Automatic date update in version.in

13 months agoAutomatic date update in version.in
GDB Administrator [Sat, 23 Sep 2023 00:00:32 +0000 (00:00 +0000)]
Automatic date update in version.in

14 months agoUpdate the NetBSD system call table to add memfd_create(2) and epoll(2).
Frederic Cambus [Thu, 21 Sep 2023 14:12:03 +0000 (16:12 +0200)]
Update the NetBSD system call table to add memfd_create(2) and epoll(2).

Generated from sys/sys/syscall.h revision 1.324.

14 months agofbsd-nat: Pacify gcc with no functional changes
Enze Li [Mon, 11 Sep 2023 14:40:43 +0000 (22:40 +0800)]
fbsd-nat: Pacify gcc with no functional changes

I see these errors on FreeBSD/aarch64 when using gcc 12 without passing
--disable-werror.

=====================================================================
  CXX    fbsd-nat.o
fbsd-nat.c: In member function 'void fbsd_nat_target::resume_one_process(ptid_t, int, gdb_signal)':
fbsd-nat.c:1208:11: error: unused variable 'request' [-Werror=unused-variable]
 1208 |       int request;
      |           ^~~~~~~
fbsd-nat.c: In member function 'virtual ptid_t fbsd_nat_target::wait(ptid_t, target_waitstatus*, target_wait_flags)':
fbsd-nat.c:1726:22: error: declaration of 'inf' shadows a previous local [-Werror=shadow=compatible-local]
 1726 |       for (inferior *inf : all_non_exited_inferiors (this))
      |                      ^~~
fbsd-nat.c:1697:17: note: shadowed declaration is here
 1697 |       inferior *inf = find_inferior_ptid (this, wptid);
      |                 ^~~
fbsd-nat.c: In member function 'virtual void fbsd_nat_target::detach(inferior*, int)':
fbsd-nat.c:2044:18: error: variable 'wptid' set but not used [-Werror=unused-but-set-variable]
 2044 |           ptid_t wptid = wait_1 (ptid, &ws, 0);
      |                  ^~~~~
cc1plus: all warnings being treated as errors
=====================================================================

This patch includes the following non-functional changes,

1. Remove unused variable "request".
2. Rename inf to inf_p to avoid shadowed declaration warnings.
3. Mark wptid as used when USE_SIGTRAP_SIGINFO is defined.

Tested on FreeBSD/aarch64 by rebuilding.

Approved-By: John Baldwin <jhb@FreeBSD.org>
14 months agoRemove keywords from target debug printer names
Tom Tromey [Tue, 19 Sep 2023 17:02:27 +0000 (11:02 -0600)]
Remove keywords from target debug printer names

I recently checked in a patch that removed the use of the "struct"
keyword in some spots.  Doing this pointed out that the target
delegate code preserves this keyword -- but, with C++, it does not
really need to.  This patch changes make-target-delegates.py to remove
these keywords, and updates target-debug.h to follow.  This pointed
out that there was already one redudancy: both
target_debug_print_struct_inferior_p and target_debug_print_inferior_p
existed.

Tested by rebuilding.

Reviewed-by: Kevin Buettner <kevinb@redhat.com>
14 months agogprofng: 30834 improve disassembly output for call and branch instructions
Vladimir Mezentsev [Wed, 20 Sep 2023 20:22:12 +0000 (13:22 -0700)]
gprofng: 30834 improve disassembly output for call and branch instructions

This patch makes the gprofng disassembler to emit, e.g.
    call   fprintf@plt [ 0x401060, .-0x49c]
instead of
    call   0xfffffffffffffb64

I use bfd_get_synthetic_symtab() to get function names in the .plt section.
I have not yet modified Elf-reader in gprofng to remove parsing of .symtab or
.dynsym sections. But we plan to do it.

gprofng/ChangeLog
2023-09-20  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>

PR gprofng/30834
* src/Disasm.cc: Show the function name in the call instruction
and the relative address in the branch instruction. Remove unused code.
* src/Disasm.h (map_PC_to_func, get_funcname_in_plt): New functions.
* src/Elf.cc: Get function names for the .plt section.
* src/Elf.h (get_funcname_in_plt, get_bfd_symbols): New functions.
* src/Stabs.cc: Add pltSym to SymLst. Remove the conversion to uint32_t.

14 months agoAutomatic date update in version.in
GDB Administrator [Fri, 22 Sep 2023 00:00:27 +0000 (00:00 +0000)]
Automatic date update in version.in

14 months agold: write resolved path to included file to dependency-file
Thomas Weißschuh [Thu, 21 Sep 2023 06:03:09 +0000 (08:03 +0200)]
ld: write resolved path to included file to dependency-file

In ldfile_open_command_file_1() name written to the dependency files is
the name as specified passed to the "INCLUDE" directive.
This is before include-path processing so the tracked dependency
location is most likely wrong.

Instead track the opened file at the point where the resolved path is
actually available, in try_open().

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
14 months agoAutomatic date update in version.in
GDB Administrator [Thu, 21 Sep 2023 00:01:00 +0000 (00:01 +0000)]
Automatic date update in version.in

14 months agoRemove stray trailing "," from DAP breakpoint.py
Tom Tromey [Wed, 20 Sep 2023 23:08:28 +0000 (17:08 -0600)]
Remove stray trailing "," from DAP breakpoint.py

The buildbot pointed out that the last DAP series I checked in had an
issue.  Looking into it, it seems there is a stray trailing "," in
breakpoint.py.  This patch removes it.

This seems to point out a test suite deficiency.  I will look into
fixing that.

14 months agoRemove explanatory comments from includes
Tom Tromey [Wed, 20 Sep 2023 02:34:23 +0000 (20:34 -0600)]
Remove explanatory comments from includes

I noticed a comment by an include and remembered that I think these
don't really provide much value -- sometimes they are just editorial,
and sometimes they are obsolete.  I think it's better to just remove
them.  Tested by rebuilding.

Approved-By: Andrew Burgess <aburgess@redhat.com>
14 months agogdb/dap: only include sourceReference if file path does not exist
Gregory Anders [Fri, 1 Sep 2023 21:02:20 +0000 (16:02 -0500)]
gdb/dap: only include sourceReference if file path does not exist

According to the DAP specification if the "sourceReference" field is
included in a Source object, then the DAP client _must_ make a "source"
request to the debugger to retrieve file contents, even if the Source
object also includes path information.

If the Source's path field is a valid path that the DAP client is able
to read from the filesystem, having to make another request to the
debugger to get the file contents is wasteful and leads to incorrect
results (DAP clients will try to get the contents from the server and
display those contents as a file with the name in "source.path", but
this will conflict with the _acutal_ existing file at "source.path").

Instead, only set "sourceReference" if the source file path does not
exist.

Approved-By: Tom Tromey <tom@tromey.com>
14 months agogdb/dap: use breakpoint fullname to resolve source
Gregory Anders [Fri, 1 Sep 2023 21:02:19 +0000 (16:02 -0500)]
gdb/dap: use breakpoint fullname to resolve source

If the breakpoint has a fullname, use that as the source path when
resolving the breakpoint source information. This is consistent with
other callers of make_source which also use "fullname" if it exists (see
e.g. DAPFrameDecorator which returns the symtab's fullname).

Approved-By: Tom Tromey <tom@tromey.com>
14 months agogdb/dap: ignore unused keyword args in step_out
Gregory Anders [Fri, 1 Sep 2023 21:02:18 +0000 (16:02 -0500)]
gdb/dap: ignore unused keyword args in step_out

Some DAP clients may send additional parameters in the stepOut command
(e.g. "granularity") which are not used by GDB, but should nonetheless
be accepted without error.

Approved-By: Tom Tromey <tom@tromey.com>
14 months agogdb/dap: check for breakpoint source before unpacking
Gregory Anders [Fri, 1 Sep 2023 21:02:17 +0000 (16:02 -0500)]
gdb/dap: check for breakpoint source before unpacking

Not all breakpoints have a source location. For example, a breakpoint
set on a raw address will have only the "address" field populated, but
"source" will be None, which leads to a RuntimeError when attempting to
unpack the filename and line number.

Before attempting to unpack the filename and line number from the
breakpoint, ensure that the source information is not None. Also
populate the source and line information separately from the
"instructionReference" field, so that breakpoints that include only an
address are still included.

Approved-By: Tom Tromey <tom@tromey.com>
14 months agoRun 'black' on printing.py
Tom Tromey [Wed, 20 Sep 2023 16:43:04 +0000 (10:43 -0600)]
Run 'black' on printing.py

The buildbot pointed out that I neglected to re-run 'black' after
making some changes.  This patch fixes the oversight.

14 months agogdb/tui: add 'set tui mouse-events off' to restore mouse selection
Matthew "strager" Glazar [Sat, 28 Jan 2023 00:19:45 +0000 (16:19 -0800)]
gdb/tui: add 'set tui mouse-events off' to restore mouse selection

Rationale:
I use the mouse with my terminal to select and copy text. In gdb, I use
the mouse to select a function name to set a breakpoint, or a variable
name to print, for example.

When gdb is compiled with ncurses mouse support, gdb's TUI mode
intercepts mouse events. Left-clicking and dragging, which would
normally select text, seems to do nothing. This means I cannot select
text using my mouse anymore. This makes it harder to set breakpoints,
print variables, etc.

Solution:
I tried to fix this issue by editing the 'mousemask' call to only enable
buttons 4 and 5. However, this still caused my terminal (gnome-terminal)
to not allow text to be selected. The only way I could make it work is
by calling 'mousemask (0, NULL);'. But doing so disables the mouse code
entirely, which other people might want.

I therefore decided to make a setting in gdb called 'tui mouse-events'.
If enabled (the default), the behavior is as it is now: terminal mouse
events are given to gdb, disabling the terminal's default behavior.
If disabled (opt-in), the behavior is as it was before the year 2020:
terminal mouse events are not given to gdb, therefore the mouse can be
used to select and copy text.

Notes:
I am not attached to the setting name or its description. Feel free to
suggest better wording.

Testing:
I tested this change in gnome-terminal by performing the following steps
manually:

1. Run: gdb --args ./myprogram
2. Enable TUI: press ctrl-x ctrl-a
3. Click and drag text with the mouse. Observe no selection.
4. Input: set tui mouse-events off
5. Click and drag text with the mouse. Observe that selection works now.
6. Input: set tui mouse-events on.
7. Click and drag text with the mouse. Observe no selection.

14 months ago[gdb/symtab] Error out for .debug_types section in dwz file
Tom de Vries [Wed, 20 Sep 2023 14:05:55 +0000 (16:05 +0200)]
[gdb/symtab] Error out for .debug_types section in dwz file

There are two methods to factor out type information in a dwarf4 executable:
- use -fdebug-info-types to generate type units in a .debug_types section, and
- use dwz to create partial units.

The dwz method has an extra benefit: it also allows to factor out information
between executables into a newly created .dwz file, pointed to by a
.gnu_debugaltlink section.

There is nothing prohibiting a .gnu_debugaltlink file to contain a
.debug_types section.

It's just not generated by dwz or any other tool atm, and consequently gdb has
no support for it.  Enhancement PR symtab/30838 is open about the lack of
support.

Make the current situation explicit by emitting a dwarf error:
...
(gdb) file struct-with-sig-2^M
Reading symbols from struct-with-sig-2...^M
Dwarf Error: .debug_types section not supported in dwz file^M
...
and add an assert in write_gdbindex:
...
+      /* See enhancement PR symtab/30838.  */
+      gdb_assert (!(per_cu->is_dwz && per_cu->is_debug_types));
...
to clarify why we can use:
...
      data_buf &cu_list = (per_cu->is_debug_types
                           ? types_cu_list
                           : per_cu->is_dwz ? dwz_cu_list : objfile_cu_list);
...

The test-case is a modified copy from gdb.dwarf2/struct-with-sig.exp, so it
keeps the copyright years range.

Tested on x86_64-linux.

Tested-By: Guinevere Larsen <blarsen@redhat.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30838

14 months agoPR30870, VMS_DEBUG compilation error
Song Mengzhi [Tue, 19 Sep 2023 07:13:46 +0000 (07:13 +0000)]
PR30870, VMS_DEBUG compilation error

Introduced by 8169954446.

PR 30870
* vms-alpha.c (image_write): Remove extraneous parenthesis.

14 months agoAutomatic date update in version.in
GDB Administrator [Wed, 20 Sep 2023 00:00:48 +0000 (00:00 +0000)]
Automatic date update in version.in

14 months agoreadelf.c 'ext' may be used uninitialized
Alan Modra [Tue, 19 Sep 2023 00:20:57 +0000 (09:50 +0930)]
readelf.c 'ext' may be used uninitialized

* readelf.c (display_lto_symtab): Init ext.

14 months agoelf-attrs.c memory allocation fail
Alan Modra [Tue, 19 Sep 2023 00:09:31 +0000 (09:39 +0930)]
elf-attrs.c memory allocation fail

Report errors rather than segfaulting.

bfd/
* elf-attrs.c (elf_new_obj_attr): Return NULL on bfd_alloc fail.
(bfd_elf_add_obj_attr_int): Handle NULL return from the above,
and propagate return to callers.
(elf_add_obj_attr_string, elf_add_obj_attr_int_string): Likewise.
(bfd_elf_add_obj_attr_string): Similarly.
(_bfd_elf_copy_obj_attributes): Report error on alloc fails.
(_bfd_elf_parse_attributes): Likewise.
* elf-bfd.h (bfd_elf_add_obj_attr_int): Update prototype.
(bfd_elf_add_obj_attr_string): Likewise.
(bfd_elf_add_obj_attr_int_string): Likewise.
gas/
* config/obj-elf.c (obj_elf_vendor_attribute): Report fatal
error on out of memory from bfd attribute functions.
* config/tc-arc.c (arc_set_attribute_int): Likewise.
(arc_set_attribute_string, arc_set_public_attributes): Likewise.
* config/tc-arm.c (aeabi_set_attribute_int): Likewise.
(aeabi_set_attribute_string): Likewise.
* config/tc-mips.c (mips_md_finish): Likewise.
* config/tc-msp430.c (msp430_md_finish): Likewise.
* config/tc-riscv.c (riscv_write_out_attrs): Likewise.
* config/tc-sparc.c (sparc_md_finish): Likewise.
* config/tc-tic6x.c (tic6x_set_attribute_int): Likewise.
* config/tc-csky.c (md_begin): Likewise.
(set_csky_attribute): Return ok status.

14 months agoHandle pointers and references correctly in DAP
Tom Tromey [Tue, 5 Sep 2023 15:13:14 +0000 (09:13 -0600)]
Handle pointers and references correctly in DAP

A user pointed out that the current DAP variable code does not let the
client deference a pointer.  Oops!

Fixing this oversight is simple enough -- adding a new no-op
pretty-printer for pointers and references is quite simple.

However, doing this naive caused a regession in scopes.exp, which
expected there to be no children of a 'const char *' variable.  This
problem was fixed by the preceding patches in the series, which ensure
that a C type of this kind is recognized as a string.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30821

14 months agoGive a language to a type
Tom Tromey [Tue, 5 Sep 2023 18:29:23 +0000 (12:29 -0600)]
Give a language to a type

This changes main_type to hold a language, and updates the debug
readers to set this field.  This is done by adding the language to the
type-allocator object.

Note that the non-DWARF readers are changed on a "best effort" basis.

This patch also reimplements type::is_array_like to use the type's
language, and it adds a new type::is_string_like as well.  This in
turn lets us change the Python implementation of these methods to
simply defer to the type.

14 months agoAdd is_array_like and to_array to language_defn
Tom Tromey [Tue, 5 Sep 2023 19:08:29 +0000 (13:08 -0600)]
Add is_array_like and to_array to language_defn

This adds new is_array_like and to_array methods to language_defn.
This will be used in a subsequent patch that generalizes the new
Python array- and string-handling code.

14 months agoRegularize some DWARF type initialization
Tom Tromey [Tue, 5 Sep 2023 18:54:40 +0000 (12:54 -0600)]
Regularize some DWARF type initialization

In one spot, it will be convenient for a subsequent patch if the CU is
passed to a type-creation helper function.  In another spot, remove
the redundant 'objfile' parameter to another such function.

14 months agoPass a type allocator to init_fixed_point_type
Tom Tromey [Tue, 5 Sep 2023 18:43:50 +0000 (12:43 -0600)]
Pass a type allocator to init_fixed_point_type

init_fixed_point_type currently takes an objfile and creates its own
type allocator.  However, for a later patch it is more convenient if
this function accepts a type allocator.  This patch makes this change.

14 months agoUse gdb::checked_static_cast for catchpoints
Tom Tromey [Fri, 15 Sep 2023 18:22:47 +0000 (12:22 -0600)]
Use gdb::checked_static_cast for catchpoints

This replaces some casts to various kinds of catchpoint with
checked_static_cast.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
14 months agoUse gdb::checked_static_cast for code_breakpoint
Tom Tromey [Fri, 15 Sep 2023 18:19:57 +0000 (12:19 -0600)]
Use gdb::checked_static_cast for code_breakpoint

This replaces some casts to 'code_breakpoint *' with
checked_static_cast.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
14 months agoUse gdb::checked_static_cast for tracepoints
Tom Tromey [Fri, 15 Sep 2023 18:05:57 +0000 (12:05 -0600)]
Use gdb::checked_static_cast for tracepoints

This replaces some casts to 'tracepoint *' with checked_static_cast.
Some functions are changed to accept a 'tracepoint *' now, for better
type safety.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
14 months agoUse gdb::checked_static_cast for watchpoints
Tom Tromey [Fri, 15 Sep 2023 17:56:35 +0000 (11:56 -0600)]
Use gdb::checked_static_cast for watchpoints

This replaces some casts to 'watchpoint *' with checked_static_cast.
In one spot, an unnecessary block is also removed.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
14 months agogdb, breakpoint: add a destructor to the watchpoint struct
Mohamed Bouhaouel [Fri, 30 Jun 2023 08:10:15 +0000 (10:10 +0200)]
gdb, breakpoint: add a destructor to the watchpoint struct

Make sure to unlink the related breakpoint when the watchpoint instance
is deleted.  This prevents having a wp-related breakpoint that is
linked to a NULL watchpoint (e.g.  the watchpoint instance is being
deleted when the 'watch' command fails).  With the below scenario,
having such a left out breakpoint will lead to a GDB hang, and this
is due to an infinite loop when deleting all inferior breakpoints.

Scenario:
(gdb) set can-use-hw-watchpoints 0
(gdb) awatch <SCOPE VAR>
Can't set read/access watchpoint when hardware watchpoints are disabled.
(gdb) rwatch <SCOPE VAR>
Can't set read/access watchpoint when hardware watchpoints are disabled.
(gdb) <continue the program until the end>
>> HANG <<

Signed-off-by: Mohamed Bouhaouel <mohamed.bouhaouel@intel.com>
Reviewed-by: Bruno Larsen <blarsen@redhat.com>
14 months agogdb/cli: fixes to newly added "list ." command
Guinevere Larsen [Tue, 19 Sep 2023 12:06:49 +0000 (14:06 +0200)]
gdb/cli: fixes to newly added "list ." command

After the series that added this command was pushed, Pedro mentioned
that the news description could easily be misinterpreted, as well as
some code and test improvements that should be made.

While fixing the test, I realized that code repetition wasn't
happening as it should, so I took care of that too.

Approved-By: Andrew Burgess <aburgess@redhat.com>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
14 months agoAutomatic date update in version.in
GDB Administrator [Tue, 19 Sep 2023 00:00:41 +0000 (00:00 +0000)]
Automatic date update in version.in

14 months agoMore type safety for symbol_search
Tom Tromey [Sat, 16 Sep 2023 21:00:13 +0000 (15:00 -0600)]
More type safety for symbol_search

This patch changes class symbol_search to store a block_enum rather
than an int.

Regression tested on x86-64 Fedora 38.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
14 months agoMove val_prettyformat to valprint.h
Tom Tromey [Tue, 5 Sep 2023 18:30:08 +0000 (12:30 -0600)]
Move val_prettyformat to valprint.h

I stumbled across an ancient FIXME comment that was easy to fix --
val_prettyformat does not need to be in defs.h, and is easily moved to
valprint.h, where (despite what the comment says) it belongs.

Tested by rebuilding.

14 months agoFix: Use of uninitialized memory
Jacob Navia [Mon, 18 Sep 2023 11:03:58 +0000 (12:03 +0100)]
Fix: Use of uninitialized memory

  * config/tc-riscv.c (riscv_ip_hardcode): Fully initialise the allocated riscv_opcode structure.

14 months agogdb: remove unused free_actions declaration
Simon Marchi [Mon, 18 Sep 2023 00:42:05 +0000 (20:42 -0400)]
gdb: remove unused free_actions declaration

This appears to be a leftover from a past change.

Change-Id: I8e747edbf291400e4f417f5c6875049479a1669a

14 months agoAutomatic date update in version.in
GDB Administrator [Mon, 18 Sep 2023 00:00:37 +0000 (00:00 +0000)]
Automatic date update in version.in

14 months agoAutomatic date update in version.in
GDB Administrator [Sun, 17 Sep 2023 00:00:26 +0000 (00:00 +0000)]
Automatic date update in version.in

14 months ago[gdb/symtab] Fix overly large gdb-index file check for 32-bit
Tom de Vries [Sat, 16 Sep 2023 02:10:53 +0000 (04:10 +0200)]
[gdb/symtab] Fix overly large gdb-index file check for 32-bit

Add a unit test which checks that write_gdb_index_1 will throw
an error when the size of the file would exceed the maximum value
capable of being represented by 'offset_type'.

The unit test fails on 32-bit systems due to wrapping overflow.  Fix this by
changing the type of total_len in write_gdbindex_1 from size_t to uint64_t.

Tested on x86_64-linux.

Co-Authored-By: Kevin Buettner <kevinb@redhat.com>
Approved-by: Kevin Buettner <kevinb@redhat.com>
14 months agoAutomatic date update in version.in
GDB Administrator [Sat, 16 Sep 2023 00:00:27 +0000 (00:00 +0000)]
Automatic date update in version.in