Commit Graph

118073 Commits

Author SHA1 Message Date
Tom Tromey
7e949f0870 Implement Ada 2022 delta aggregates
Ada 2022 includes a "delta aggregates" feature that can sometimes
simplify aggregate creation.  This patch implements this feature for
GDB.
2024-03-21 12:29:49 -06:00
Tom Tromey
7f032bbedf Require trivial destructor in allocate_on_obstack
This patch makes allocate_on_obstack a little bit safer, by enforcing
the rule that objects allocated on an obstack must have a trivial
destructor.

The static assert is done in a method -- doing it inside the class
itself won't work because the class is incomplete at that point.
2024-03-21 12:21:24 -06:00
Tom Tromey
9069d69398 Don't use virtual destructor in addrmap
The addrmap polymorphism is sort of "phony" in that there isn't really
code in the tree that can be presented with either type.  I haven't
tried to fix this (though perhaps I may); but meanwhile it's handy for
the next patch if addrmap_fixed has a trivial destructor.  This patch
achieves this by making the addrmap destructor non-virtual, and also
making it protected so that objects of any of these types cannot be
destroyed when only the base class is known.
2024-03-21 12:21:23 -06:00
Tom Tromey
3984e52f7f Use addrmap_fixed in a few spots
There are a few spots in the tree that use 'addrmap' where only an
addrmap_fixed will ever really be seen.  This patch changes this code
to use the more specific type.
2024-03-21 12:21:23 -06:00
Orgad Shaneh
acaf48b921 sim/erc32: Rename EVENT_MAX -> MAX_EVENTS
EVENT_MAX is defined as 0x7FFFFFFF (INT_MAX) in winuser.h, so when
building on Windows, the value is overridden and compilation fails
because the array size of evbuf is too large.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28476
Approved-By: Tom Tromey <tom@tromey.com>
2024-03-21 10:46:23 -06:00
Tiezhu Yang
9bec569fda gdb: syscalls: Add some tips for LoongArch xml files
In commit a08dc2aa00 (gdb: syscalls: Add loongarch-linux.xml.in),
it needs special handling when generating xml file. This should at
least be mentioned in the file comment rather than git log to help
the next person who regenerates this file understand what needs to
be done, suggested by Pedro Alves, thank you.

At the beginning, I only added the tips in loongarch-linux.xml.in,
after executing the command "make" to generate loongarch-linux.xml
from loongarch-linux.xml.in, it generates the same tips in the file
loongarch-linux.xml automatically, so update loongarch-linux.xml.in
and loongarch-linux.xml together.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Approved-by: Pedro Alves <pedro@palves.net>
2024-03-21 22:07:44 +08:00
Hui Li
006efc27dc gdb: LoongArch: Silence warning about core file of lsx and lasx
In loongarch_iterate_over_regset_sections(), the second and third arguments
of the iterate_over_regset_sections_cb callback function should be the regset
size which is regsize * regnum. Otherwise when execute:

make check-gdb TESTS="gdb.base/corefile.exp"

there exists the following failed log:

  (gdb) core-file /home/fedora/community/gdb/build/gdb/testsuite/outputs/gdb.base/corefile/corefile.core
  [New LWP 531099]
  warning: Unexpected size of section `.reg-loongarch-lsx/531099' in core file.
  warning: Unexpected size of section `.reg-loongarch-lasx/531099' in core file.
  Core was generated by `/home/fedora/community/gdb/build/gdb/testsuite/outputs/gdb.base/corefile/corefile'.
  Program terminated with signal SIGABRT, Aborted.
  warning: Unexpected size of section `.reg-loongarch-lsx/531099' in core file.
  warning: Unexpected size of section `.reg-loongarch-lasx/531099' in core file.
  #0  0x00007ffff3081600 in __pthread_kill_implementation.constprop.0 () from /lib64/libc.so.6
  (gdb) FAIL: gdb.base/corefile.exp: core-file warning-free

Signed-off-by: Hui Li <lihui@loongson.cn>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2024-03-21 22:07:24 +08:00
Nick Clifton
b7b293fa3b New Romanian translation for gas sub-directory 2024-03-21 08:23:19 +00:00
GDB Administrator
80313193b0 Automatic date update in version.in 2024-03-21 00:01:00 +00:00
Simon Marchi
d5e9331b6b .pre-commit-config.yaml: bump black hook to 24.3.0
Running `pre-commit autoupdate` showed that there is a new version of
the black hook for v24.3.0.  Update it.

ChangeLog:

	* .pre-commit-config.yaml: Bump black hook to 24.3.0

Change-Id: I5ec7d2edf99cd15f6525281a43aed9ff481ee9ee
2024-03-20 14:44:16 -04:00
Tom de Vries
886d73049c [gdb/testsuite] Fix gdb.server/server-connect.exp for missing ipv6
On a system without ipv6 support enabled, when running test-case
gdb.server/server-connect.exp, it takes about 4 minutes, and I get:
...
builtin_spawn gdbserver --once ::1:2347 server-connect^M
Can't open socket: Address family not supported by protocol.^M
Exiting^M
PASS: gdb.server/server-connect.exp: tcp6: start gdbserver
target remote tcp6:::1:2347^M
A program is being debugged already.  Kill it? (y or n) y^M
could not connect: Address family not supported by protocol.^M
(gdb) FAIL: gdb.server/server-connect.exp: tcp6: connect to gdbserver using tcp6:::1
...

Fix this by:
- recognizing the error message in gdbserver_start, and returning an empty list
  to signal unsupported, and
- handling the unsupported response in the test-case.

This brings testing time down to 2 seconds, and gets me:
...
UNSUPPORTED: gdb.server/server-connect.exp: tcp6: start gdbserver
UNSUPPORTED: gdb.server/server-connect.exp: tcp6-with-brackets: start gdbserver
UNSUPPORTED: gdb.server/server-connect.exp: udp6: start gdbserver
UNSUPPORTED: gdb.server/server-connect.exp: udp6-with-brackets: start gdbserver
...

Tested on aarch64-linux.

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

PR testsuite/31502
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31502
2024-03-20 19:31:24 +01:00
Tom de Vries
8d0e6e0831 [gdb/testsuite] Handle core without build-id in gdb.base/corefile-buildid.exp
On aarch64-linux (debian 12), when running test-case gdb.base/corefile-buildid.exp, I get:
...
expecting exec file "debugdir-exec/.build-id/ec/f10ec5d39648774f8c35d3cf757c8db52f5163"
info files^M
Local core dump file:^M
        `build-exec/corefile-buildid.core', file type elf64-littleaarch64.^M
        0x0000aaaac1d70000 - 0x0000aaaac1d71000 is load1^M
	...
        0x0000ffffffa8b000 - 0x0000ffffffaac000 is load16^M
(gdb) FAIL: gdb.base/corefile-buildid.exp: exec: info files
...

The problem is that the test-case expect the build-id to be available in the
core file, while it isn't.

Fix this by detecting that the build-id isn't available in the core file using eu-readelf, as in
gdb.base/coredump-filter-build-id.exp.

Tested on aarch64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2024-03-20 19:29:18 +01:00
Tom de Vries
d51a931152 [gdb/testsuite] Add PR gdb/26967 KFAIL in two more test-cases
On aarch64-linux (debian 12), when running test-case
gdb.base/longjmp-until-in-main.exp, I run into:
...
(gdb) until 33^M
warning: Breakpoint address adjusted from 0x70f727c678928489 to 0xfff727c678928489.^M
Warning:^M
Cannot insert breakpoint 0.^M
Cannot access memory at address 0xfff727c678928489^M
^M
0x0000fffff7e3a580 in siglongjmp () from /lib/aarch64-linux-gnu/libc.so.6^M
(gdb) FAIL: gdb.base/longjmp-until-in-main.exp: until $line, in main
...

This is PR gdb/26967: no longjmp probe is available:
...
(gdb) info probes stap libc ^longjmp$^M
No probes matched.^M
...
and glibc applies pointer mangling which makes it fairly difficult for gdb to
get the longjmp target.

There's a KFAIL for this in test-case gdb.base/longjmp.exp, added in commit
b5e7cd5cd3 ("[gdb/testsuite] Add KFAILs in gdb.base/longjmp.exp").

Factor out new proc have_longjmp_probe, and use it to add similar KFAIL in
this and one more test-case.

Tested on aarch64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2024-03-20 19:23:48 +01:00
Hannes Domani
d391f3721e Fix casting in-memory values of primitive types to const reference
It's currently not possible to cast an in-memory value of a primitive
type to const reference:
```
(gdb) p Q.id
$1 = 42
(gdb) p (int&)Q.id
$2 = (int &) @0x22fd0c: 42
(gdb) p (const int&)Q.id
Attempt to take address of value not located in memory.
```

And if in a function call an argument needs the same kind of casting,
it also doesn't work:
```
(gdb) l f3
39      int f3(const int &i)
40      {
41        return i;
42      }
(gdb) p f3(Q.id)
Attempt to take address of value not located in memory.
```

It's because when the constness of the type changes in a call to
value_cast, a new not_lval value is allocated, which doesn't exist
in the target memory.

Fixed by ignoring const/volatile/restrict qualifications in
value_cast when comparing cast type to original type, so the new
value will point to the same location as the original value:
```
(gdb) p (int&)i
$2 = (int &) @0x39f72c: 1
(gdb) p (const int&)i
$3 = (const int &) @0x39f72c: 1
(gdb) p f3(Q.id)
$4 = 42
```

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=19423
Approved-By: Tom Tromey <tom@tromey.com>
2024-03-20 18:23:50 +01:00
Hannes Domani
23cdd9431a Fix reinterpret_cast for classes with multiple inheritance
Currently a reinterpret_cast may change the pointer value if
multiple inheritance is involved:
```
(gdb) p r
$1 = (Right *) 0x22f75c
(gdb) p reinterpret_cast<LeftRight*>(r)
$2 = (LeftRight *) 0x22f758
```

It's because value_cast is called in this case, which automatically
does up- and downcasting.

Fixed by simply using the target pointer type in a copy of the
original value:
```
(gdb) p r
$1 = (Right *) 0x3bf87c
(gdb) p reinterpret_cast<LeftRight*>(r)
$2 = (LeftRight *) 0x3bf87c
```

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=18861
Approved-By: Tom Tromey <tom@tromey.com>
2024-03-20 18:02:06 +01:00
Simon Marchi
e8f6050cfb Add .pre-commit-config.yaml
Add a pre-commit [1] config file, with a single hook to run black on the
gdb directory whenever a Python file is modified.  We can always add
more hooks if we find some that are useful.

Using pre-commit to run hooks is opt-in, as in it's not mandatory at all
for development, but it can be useful to run some checks that are easy
to forget (like running black).  The hooks run locally on the
developer's machine when doing `git commit` (although they can also be
configured to run at other stages of the git workflow).

Follow these instructions to install the hooks in your local development
git repository:

 - Install pre-commit the way you prefer.  It can be using your OS
   package manager if it has a recent enough version, or using `pip
   install pre-commit`.
 - Go to the binutils-gdb repository and run `pre-commit install`.

This installs a git hook at `.git/hooks/pre-commit`.

Now, whenever you modify and try to commit a Python file, pre-commit
will run black on it.  For instance, if I try to insert something
misformatted, I get this when doing `git commit`:

    $ git commit
    black....................................................................Failed
    - hook id: black
    - files were modified by this hook

    reformatted gdb/python/lib/gdb/dap/breakpoint.py

    All done!  🍰 
    1 file reformatted.

At this point, black has already reformatted the files in place, so the
changes that fix the formatting are ready to add and commit.  black is
only ran on files modified in the commit.

The hook defines a black version, which is downloaded at `pre-commit
install` time.  pre-commit manages its own env at
`$HOME/.cache/pre-commit/<some-hash>`, so it won't use the version of
black you have installed already.  This may help ensure that
contributors use the right black version.

The procedure when there is a new version of black (or a new version of
any hook we might be using in the future) is:

 - Modify .pre-commit-config.yaml to change the version number, push to
   the upstream repo.
 - Have contributors run `pre-commit autoupdate` to make their local
   pre-commit installation update the hooks.

It is possible to have pre-commit skip some hooks if needed [2].

I will add these instructions to the wiki if this patch gets merged, so
they are easy to find.  We could perhaps think of having a
gdb/CONTRIBUTING document of some sort checked in the repo with that
kind of information.

I have not used pre-commit in a real project before, but have heard good
things from it.  If we want to give it a try before pushing it to the
repo, some volunteers can copy the .pre-commit-config.yaml file locally
and try it for some time.  However, pushing the file upstream is not
going to impact anybody who doesn't care about it, so I'd say it's
relatively low-risk to push it right now.

[1] https://pre-commit.com
[2] https://pre-commit.com/#temporarily-disabling-hooks

Change-Id: Id00cda882f5140914a670c87e574fa7f2f972099
Acked-By: Tom Tromey <tromey@adacore.com>
Acked-By: Guinevere Larsen <blarsen@redhat.com>
Acked-By: Andrew Burgess <aburgess@redhat.com>
2024-03-20 11:54:06 -04:00
Hannes Domani
105470cd79 Fix comparison of array types
Currently it's not possible to call functions if an argument is a
pointer to an array:
```
(gdb) l f
1       int f (int (*x)[2])
2       {
3         return x[0][1];
4       }
5
6       int main()
7       {
8         int a[2][2] = {{0, 1}, {2, 3}};
9         return f (a);
10      }
(gdb) p f(a)
Cannot resolve function f to any overloaded instance
```

This happens because types_equal doesn't handle array types, so the
function is never even considered as a possibility.

With array type handling added, by comparing element types and array
bounds, the same works:
```
(gdb) p f(a)
$1 = 1
```

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=15398
Co-Authored-By: Keith Seitz <keiths@redhat.com>
Reviewed-By: Guinevere Larsen <blarsen@redhat.com>
Approved-By: Tom Tromey <tom@tromey.com>
2024-03-20 16:40:30 +01:00
Tiezhu Yang
53ff349e55 gdb: LoongArch: Set the correct XML syscall filename
Now, there exists syscalls/loongarch-linux.xml, let us set the correct
XML syscall filename for LoongArch, otherwise GDB won't be able to find
the correct XML file to open and get the syscalls definitions.

It should install the package expat-devel (a library for XML parsing)
and configure --with-expat (done by default if libexpat is installed
and found at configure time) for compiling gdb in this case.

Without this patch:

(gdb) catch syscall
warning: There is no XML file to open.
warning: GDB will not be able to display syscall names nor to verify if
any provided syscall numbers are valid.
Catchpoint 1 (any syscall)

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Approved-By: John Baldwin <jhb@FreeBSD.org>
2024-03-20 18:50:43 +08:00
Tiezhu Yang
b369b90c0d gdb: syscalls: Add loongarch case in update-linux-from-src.sh
It shows that "Don't know how to generate loongarch-linux.xml.in"
when using the script update-linux-from-src.sh to regenerate the
syscall group info against Linux kernel, just add loongarch case.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Approved-By: John Baldwin <jhb@FreeBSD.org>
2024-03-20 18:50:39 +08:00
Tiezhu Yang
65a550468c gdb: syscalls: Generate loongarch-linux.xml
Make use of the command "make" to generate loongarch-linux.xml
from loongarch-linux.xml.in.

Like this:

  $ git clone https://sourceware.org/git/binutils-gdb.git gdb.git
  $ cd gdb.git/gdb/syscalls/
  $ make

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Approved-By: John Baldwin <jhb@FreeBSD.org>
2024-03-20 18:50:34 +08:00
Tiezhu Yang
a08dc2aa00 gdb: syscalls: Add loongarch-linux.xml.in
There is no syscall.tbl for LoongArch because it uses generic syscalls,
so it can not generate loongarch-linux.xml.in automatically through the
script update-linux-from-src.sh, make use of the script update-linux.sh
to generate loongarch-linux.xml.in.

Like this:

  $ git clone https://sourceware.org/git/binutils-gdb.git gdb.git
  $ cd gdb.git/gdb/syscalls/
  $ touch loongarch-linux.xml.in
  $ ./update-linux.sh loongarch-linux.xml.in

Note that the system header file /usr/include/asm-generic/unistd.h
may be different with the latest upstream Linux kernel uapi header
file include/uapi/asm-generic/unistd.h, it is better to copy the
upstream header file into the system header file when generating
loongarch-linux.xml.in.

There exist some __NR3264_ prefixed syscall numbers, replace them
with digital numbers according to /usr/include/asm-generic/unistd.h
and sort them by syscall number manually, maybe we can modify the
script to do it automatically in the future.

  <syscall name="fcntl" number="__NR3264_fcntl"/>
  <syscall name="statfs" number="__NR3264_statfs"/>
  <syscall name="fstatfs" number="__NR3264_fstatfs"/>
  <syscall name="truncate" number="__NR3264_truncate"/>
  <syscall name="ftruncate" number="__NR3264_ftruncate"/>
  <syscall name="lseek" number="__NR3264_lseek"/>
  <syscall name="sendfile" number="__NR3264_sendfile"/>
  <syscall name="mmap" number="__NR3264_mmap"/>
  <syscall name="fadvise64" number="__NR3264_fadvise64"/>

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Approved-By: John Baldwin <jhb@FreeBSD.org>
2024-03-20 18:50:29 +08:00
Tiezhu Yang
950895a209 gdb: syscalls: Update .xml files for some archs
Make use of the command "make" to regenerate .xml files from .xml.in files.

Like this:

  $ git clone https://sourceware.org/git/binutils-gdb.git gdb.git
  $ cd gdb.git/gdb/syscalls/
  $ make

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Approved-By: John Baldwin <jhb@FreeBSD.org>
2024-03-20 18:50:24 +08:00
Tiezhu Yang
59a83e67de gdb: syscalls: Update .xml.in files for some archs
Make use of the script update-linux-from-src.sh to regenerate the Linux
syscall group info against Linux git commit d206a76d7d27 which will be
released in v6.8.

Like this:

  $ git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git linux.git
  $ git clone https://sourceware.org/git/binutils-gdb.git gdb.git
  $ cd gdb.git/gdb/syscalls/
  $ ./update-linux-from-src.sh ~/linux.git/

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Approved-By: John Baldwin <jhb@FreeBSD.org>
2024-03-20 18:50:10 +08:00
Tiezhu Yang
35716707eb gdb: syscalls: Update linux-defaults.xml.in
Make use of the script update-linux-defaults.sh to regenerate the Linux
syscall group info against strace git commit 8c480270653d which will be
released in v6.8.

Like this:

  $ git clone https://github.com/strace/strace.git strace.git
  $ git clone https://sourceware.org/git/binutils-gdb.git gdb.git
  $ cd gdb.git/gdb/syscalls/
  $ ./update-linux-defaults.sh ~/strace.git/

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Approved-By: John Baldwin <jhb@FreeBSD.org>
2024-03-20 18:49:52 +08:00
Tom de Vries
8a61ee551c [gdb/symtab] Workaround PR gas/31115
On arm-linux, with gas 2.40, I run into:
...
(gdb) x /i main+8^M
   0x4e1 <main+7>:      vrhadd.u16      d14, d14, d31^M
(gdb) FAIL: gdb.arch/pr25124.exp: disassemble thumb instruction (1st try)
...

This is a regression due to PR gas/31115, which makes gas produce a low_pc
with the thumb bit set (0x4d8 & 0x1):
...
 <1><24>: Abbrev Number: 2 (DW_TAG_subprogram)
    <25>   DW_AT_name        : main
    <29>   DW_AT_external    : 1
    <29>   DW_AT_type        : <0x2f>
    <2a>   DW_AT_low_pc      : 0x4d9
    <2e>   DW_AT_high_pc     : 12
...

The regression was introduced in 2.39, and is also present in 2.40 and 2.41,
and hasn't been fixed yet.

Work around this in read_func_scope, by using gdbarch_addr_bits_remove on
low_pc and high_pc.

Tested on arm-linux and x86_64-linux.

PR tdep/31453
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31453
2024-03-20 09:57:49 +01:00
GDB Administrator
8f39d04b97 Automatic date update in version.in 2024-03-20 00:00:44 +00:00
Tom Tromey
1ab9eefe3c Speed up lookup of "type_specific_data"
I noticed that "info locals" on a certain large Ada program was very
slow.  I tracked this down to ada_get_tsd_type expanding nearly every
CU in the program.

This patch fixes the problem by changing this code to use the more
efficient lookup_transparent_type which, unlike the Ada-specific
lookup functions, does not try to find all matching instances.

Note that I first tried fixing this by changing ada_find_any_type, but
this did not work -- I may revisit this approach at some later date.

Also note that the copyright dates on the test files are set that way
because I copied them from another test.

New in v2: the new test failed on the Linaro regression tester.
Looking at the logs, it seems that gdb was picking up a 'value' from
libgnat:

    $1 = {<text variable, no debug info>} 0xf7e227a4 <ada.calendar.formatting.value>

This version renames the local variable in an attempt to work around
this.

v3: In v2, while trying to reproduce the problem locally, I
accidentally forgot to commit one of the changes.
2024-03-19 11:53:21 -06:00
Tom Tromey
12d5d5bfd0 Fix two serious flake8 reports
flake8 points out that some code in frame_filters.py is referring to
undefined variables.

In the first hunk, I've changed the code to match what other
'complete' methods do in this file.

In the second hunk, I've simply removed the try/except -- if
get_filter_priority fails, it will raise GdbError, which is already
handled properly by gdb.
2024-03-19 10:07:59 -06:00
Andrew Burgess
52ca06e807 gdb/python: test exception case for gdb.solib_name
The gdb.solib_name() and Progspace.solib_name() functions can throw an
exception if the address argument is not a valid address, but this is
not currently tested.

This commit adds a couple of tests to check that exceptions are thrown
correctly.

An early version of this commit updated the documentation, but it was
pointed out that lots of functions throw an exception if passed an
argument of the wrong type, and we don't document all of these, it's
kind-of assumed that passing an object of the incorrect type might
result in an exception, so this updated version leaves the docs alone,
but I do think adding the extra tests has value.

There's no changes to GDB itself in this commit.

Approved-By: Tom Tromey <tom@tromey.com>
2024-03-19 16:03:34 +00:00
Saurabh Jha
f3f34f2b26 gas, aarch64: Add faminmax extension 2024-03-19 15:41:41 +00:00
Nick Clifton
696f6b6660 Remove redunant test of ELF size in core note decoder.
PR 31469
2024-03-19 15:17:23 +00:00
Andrew Burgess
8695c3a693 gdbsupport: rename include guard in gdb-checked-static-cast.h
I noticed in passing that the include guard in the file
gdbsupport/gdb-checked-static-cast.h was wrong, it includes the word
DYNAMIC when STATIC would be better, fixed in this commit.

There should be no user visible changes after this commit.
2024-03-19 14:41:51 +00:00
Andrew Burgess
7d18eb9983 gdb: use static_cast in gdb::checked_static_cast
This commit:

  commit 6fe4779ac4
  Date:   Sat Feb 24 11:00:20 2024 +0100

      [gdb/build] Fix static cast of virtual base

addressed an issue where GDB would not compile in production mode due
to a use of gdb::checked_static_cast.  The problem was that we were
asking GDB to cast from a virtual base class to a sub-class, this
works fine when using dynamic_cast, but does not work with
static_cast.

The gdb::checked_static_cast actually uses dynamic_cast under the hood
in development mode in order to ensure that the cast is valid, while
in a production build we use static_cast as this is more efficient.

What this meant however, was that when gdb::checked_static_cast was
used to cast from a virtual base class, the dynamic_cast of a
non-production build worked fine, while the production build's
static_cast caused a build failure.

However, the gdb::checked_static_cast function already contains some
static_assert calls that are intended to catch any issues with invalid
type casting, the goal of these asserts was to prevent issues like
this: the build only failing in production mode.  Clearly the current
asserts are not enough.

I don't think there is a std::is_virtual_base type trait check, so
what I propose instead is that in non-production mode we also make use
of static_cast.  This will ensure that any errors that crop up in
production mode should also be revealed in non-production mode, and
should catch issues like this in the future.

There should be no user visible changes after this commit.

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

Co-Authored-By: Simon Marchi <simon.marchi@polymtl.ca>
2024-03-19 14:41:42 +00:00
Nick Clifton
709b8d140b Fix seg-fault in the DWARF reader code when accessing an abbreviatuin table with a corrupt entry offset.
PR 31456
2024-03-19 14:16:47 +00:00
H.J. Lu
f6080a91c5 ld: Support LD_UNDER_TEST environment variable
Support LD_UNDER_TEST environment variable to test a different linker.
Issue an error if LD_UNDER_TEST isn't an absolute full path.

	* testsuite/config/default.exp: If LD_UNDER_TEST environment
	variable exists, set ld and LD to it and set up tmpdir/ld/ld.
	Issue an error if LD_UNDER_TEST isn't an absolute full path.
2024-03-19 07:07:54 -07:00
Nick Clifton
2c16eb1d83 Fix free of unallocated memory in the BFD library's compression code.
PR 31455
2024-03-19 12:48:04 +00:00
Nick Clifton
dcca32c28b Fix typo in previous patch to ld.texi 2024-03-19 11:44:34 +00:00
Toby Lloyd Davies
c0689161ed gdb/python: Fix segfault when iterating over empty linetable
symtab-> linetable () is set to null in
buildsym_compunit::end_compunit_symtab_with_blockvector () if the symtab
has no linetable. Attempting to iterate over this linetable using the
Python API caused GDB to segfault.

Approved-By: Tom Tromey <tom@tromey.com>
2024-03-19 11:34:16 +00:00
Toby Lloyd Davies
62fd8eb314 Add myself to gdb/MAINTAINERS 2024-03-19 09:59:35 +00:00
Tom de Vries
306361f068 [gdb] Further fix "value is not available" with debug frame
In commit 2aaba74446 ("[gdb] Fix "value is not available" with debug frame")
I fixed a case in frame_unwind_register_value where using "set debug frame on"
caused an "info frame" command to abort, reporting a "value is not available"
error, due to the tpidruro register being unavailable.

Subsequently, commit bbb12eb9c8 ("gdb/arm: Remove tpidruro register from
non-FreeBSD target descriptions") removed the unavailable register, which
caused a progression on test-case gdb.base/inline-frame-cycle-unwind.exp.

While investigating the progression (see PR python/31437), I found that the
"debug frame" output of the test-case (when reverting commit bbb12eb9c8)
showed a smilar problem:
...
Python Exception <class 'gdb.error'>: value is not available^M
...
that was absent without "debug frame".

Fix this likewise in fetch_lazy_register, and update the test-case to check
for the exception.

Furthermore, I realized that there's both value::entirely_available and
value::entirely_unavailable, and that commit 2aaba74446 handled the case
of !entirely_available by printing unavailable.

Instead, print:
- "unavailable" for entirely_unavailable, and
- "partly unavailable" for !entirely_unavailable && !entirely_available.

Tested on x86_64-linux and arm-linux.
2024-03-19 10:30:36 +01:00
mengqinggang
97ce787044 LoongArch: Add relaxation for R_LARCH_CALL36
This relaxation is effective for both macro instructions (call36, tail36)
and explicit relocation instructions (pcaddu18i + jirl).

call36 f	  ->	bl f
  R_LARCH_CALL36  ->	  R_LARCH_B26

tail36 $t0, f	  ->	b f
  R_LARCH_CALL36  ->	  R_LARCH_B26
2024-03-19 14:14:47 +08:00
GDB Administrator
b42aa684f6 Automatic date update in version.in 2024-03-19 00:00:22 +00:00
Nick Clifton
0273b5967e Regenerate AArch64 opcodes files 2024-03-18 18:38:23 +00:00
Yury Khrustalev
07b16fae7b aarch64: Add support for SVE ADDPT, SUBPT, MADPT, MLAPT instructions
The following instructions are added in this patch:

- ADDPT (predicated): Add checked pointer vectors (predicated).
- ADDPT (unpredicated): Add checked pointer vectors (unpredicated).
- SUBPT (predicated): Subtract checked pointer vectors (predicated).
- SUBPT (unpredicated): Subtract checked pointer vectors (unpredicated).
- MADPT: Multiply-add checked pointer vectors, writing multiplicand
- MLAPT: Multiply-add checked pointer vectors, writing addend

These instructions are part of Checked Pointer Arithmetic extension
and are enabled when both CPA and SVE are enabled. To achieve this,
both flag "+sve" and "+cpa" should be active.

This patch adds assembler and disassembler support for these instructions
with relevant checks. Tests are included as well.

Regression tested on the aarch64-none-linux-gnu target and no regressions
have been found.
2024-03-18 16:54:06 +00:00
Yury Khrustalev
4792a423d2 aarch64: Add support for (M)ADDPT and (M)SUBPT instructions
The following instructions are added in this patch:

 - ADDPT and SUBPT - Add/Subtract checked pointer
 - MADDPT and MSUBPT - Multiply Add/Subtract checked pointer

These instructions are part of Checked Pointer Arithmetic extension.
This patch adds assembler and disassembler support for these instructions
with relevant checks. Tests are included as well.

A new flag "+cpa" added to documentation. This flag enables CPA extension.

Regression tested on the aarch64-none-linux-gnu target and no regressions
have been found.
2024-03-18 16:54:06 +00:00
Nick Clifton
ee0fa66270 [PATCH] ld: Improve documentation of -rpath-link search paths 2024-03-18 16:51:49 +00:00
Tom Tromey
38ad466f70 Remove some unnecessary Ada expression code
ada_bitwise_operation differs from the "usual" bitwise operations only
in that it calls value_cast at the end.  However, because gdb is
generally fairly lax about integer types, and because (perhaps oddly)
C-style binary promotion is done here anyway, it seems to me that this
code isn't needed.
2024-03-18 08:32:14 -06:00
Tom Tromey
1dd09e7f70 Fix Ada 'ptype' of access to array
ptype is a bit funny, in that it accepts both expressions and type
names.  It also evaluates the resulting expression using
EVAL_AVOID_SIDE_EFFECTS -- which both seems sensible (as a user would
you expect ptype to possibly cause inferior execution?), but is also a
historical artifact of how expressions are implemented (there's no
EVAL_FOR_TYPE).

In Ada, calling a function with an array will sometimes result in a
"thick pointer" array descriptor being made.  This is essentially a
structure holding a pointer and bounds information.

Currently, in such a callee, printing the type of the array will yield
funny results:

    (gdb) print str.all
    $1 = "Hello World"
    (gdb) ptype str
    type = array (<>) of character
    (gdb) ptype str.all
    type = array (1 .. 0) of character

That "1 .. 0" is the result of an EVAL_AVOID_SIDE_EFFECTS branch
trying to do "something" with an array descriptor, without doing too
much.

I tried briefly to make this code really dereference the array
descriptor and get the correct runtime type.  However, that proved to
be tricky; it certainly can't be done for all access types, because
that will cause dynamic type resolution and end up printing just the
runtime type -- which with variants may be pretty far from what the
user may expect.

Instead, this patch arranges to just leave such types alone in this
situation.  I don't think this should have an extra effects, because
things like array subscripting still work on thick pointers.

This patch also touches arrayptr.exp, because in that case the access
type is a "thin pointer", and this ensures that the output does not
change in that scenario.
2024-03-18 08:22:37 -06:00
Tom Tromey
2b5f0fe323 Use string_view in quirk_rust_enum
quirk_rust_enum makes string copies to store in an unordered_map.
However, the original strings have an appropriate lifetime, and so no
copying is needed.  With C++17, we can rely on string_view having a
std::hash specialization, so this patch changes this code to use
string_view rather than string.
2024-03-18 08:10:06 -06:00
Tom Tromey
a8e1e2aaf8 Set __file__ when source'ing a Python script
This patch arranges to set __file__ when source'ing a Python script.
This fixes a problem that was introduced by the "source" rewrite, and
then pointed out by Lancelot Six.

Reviewed-by: Lancelot Six <lancelot.six@amd.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-03-18 07:20:14 -06:00