Commit Graph

118290 Commits

Author SHA1 Message Date
GDB Administrator
121a4d3d80 Automatic date update in version.in 2024-03-25 00:00:23 +00:00
GDB Administrator
ec6f962151 Automatic date update in version.in 2024-03-24 00:00:33 +00:00
John Baldwin
467a34bb9e gdb tests: Allow for "LWP" or "process" in thread IDs from info threads
Several tests assume that the first word after a thread ID in 'info
threads' output is "Thread".  However, several targets use "LWP"
instead such as the FreeBSD and NetBSD native targets.  The Linux
native target also uses "LWP" if libthread_db is not being used.
Targets that do not support threads use "process" as the first word
via normal_pid_to_str.

Add a tdlabel_re global variable as a regular-expression for a thread
label in `info threads' that matches either "process", "Thread", or
"LWP".

Some other tests in the tree don't require a specific word, and
some targets may use other first words (e.g. OpenBSD uses "thread"
and Ravenscar threads use "Ravenscar Thread").
2024-03-22 17:29:47 -07:00
GDB Administrator
efd58a4379 Automatic date update in version.in 2024-03-23 00:00:33 +00:00
Pedro Alves
e9315f148d windows-nat: Use gdb_realpath
Use gdb_realpath instead of realpath in windows-nat.c:windows_make_so,
so that we don't have to manually call free.

Approved-By: John Baldwin <jhb@FreeBSD.org>
Change-Id: Id3cda7e177ac984c9a5f7c23f354e72bd561edff
2024-03-22 19:46:59 +00:00
Pedro Alves
30512efab1 windows-nat: Remove SO_NAME_MAX_PATH_SIZE limit
There is no need to limit shared library path sizes to
SO_NAME_MAX_PATH_SIZE nowadays.  windows_solib::name and
windows_solib::original_name are std::strings nowadays, and so are
solib::so_name and solib::so_original_name in the core solib code.

This commit reworks the code to remove that limit.  This also fixes a
leak where we were not releasing 'rname' in the realpath branch if the
'rname' string was larger than SO_NAME_MAX_PATH_SIZE.

Note: I tested the cygwin_conv_path with a manual hack to force that
path, and then stepping through the code.  You only get to that path
if Windows doesn't report an absolute path for ntdll.dll, and on my
machine (running Windows 10), it always does.

Approved-By: John Baldwin <jhb@FreeBSD.org>
Change-Id: I79e9862d5a7646eebfef7ab5b05b96318a7ca0c5
2024-03-22 19:46:59 +00:00
Pedro Alves
092ff48583 Simplify windows-nat.c:windows_make_so #ifdefery
There are two separate #ifndef __CYGWIN__/#else/#endif sections in the
windows_make_so function with 3 lines of shared code separating them.
I find this makes the code harder to understand than necessary.
AFAICS, there is no reason those three shared lines need to be after
the first #ifdef block.  There is no early return, nor are 'load_addr'
nor 'name' modified.

This commit moves that shared code to the top of the function, and
then combines the two #ifndef sections.

Approved-By: John Baldwin <jhb@FreeBSD.org>
Change-Id: If2678b52836b1c3134a5e9f9fdaee74448d8b7bc
2024-03-22 19:46:59 +00:00
Pedro Alves
9f88262921 Remove SO_NAME_MAX_PATH_SIZE limit from core solib code
solib_map_sections errors out if the library file name is longer than
SO_NAME_MAX_PATH_SIZE.

solib::so_name and solib::so_original_name used to be arrays of
SO_NAME_MAX_PATH_SIZE size, so that check made sense then.

However, since commit 98107b0b17 ("gdb: make
so_list::{so_original_name,so_name} std::strings") those fields are of
std::string type, so there's really no need for the limit.

This commit simply removes the length limit check.

Approved-By: John Baldwin <jhb@FreeBSD.org>
Change-Id: I2ec676b231cd18ae900c61c5caea461f47e989e6
2024-03-22 19:46:58 +00:00
Tom Tromey
c05dd51122 Use std::string for disassembler options
I noticed that the disassembler_options code uses manual memory
management.  It seemed simpler to replace this with std::string.

Approved-By: John Baldwin <jhb@FreeBSD.org>
2024-03-22 13:17:43 -06:00
Tom Tromey
af25053d5f Remove some unnecessary casts
I found a few unnecessary casts when calling
set_gdbarch_disassembler_options_implicit.

Approved-By: John Baldwin <jhb@FreeBSD.org>
2024-03-22 13:17:43 -06:00
Tom Tromey
9f1c94481f Constify get_disassembler_options
This changes get_disassembler_options to return a const char *.

Approved-By: John Baldwin <jhb@FreeBSD.org>
2024-03-22 13:17:43 -06:00
Tom Tromey
319719bb29 Revert "Pass GUILE down to subdirectories"
This reverts commit b7e5a29602143b53267efcd9c8d5ecc78cd5a62f.

This patch caused problems for some users when building gdb, because
it would cause 'guild' to be invoked with the wrong versin of guile.
On the whole it seems simpler to just back this out.

I'm checking this in to the binutils-gdb repository in the interest of
fixing the build for Andrew.  No one has responded to the identical
patch sent to gcc-patches, but I will ping it there.

	* Makefile.in: Rebuild.
	* Makefile.tpl (BASE_EXPORTS): Remove GUILE.
	(GUILE): Remove.
	* Makefile.def (flags_to_pass): Remove GUILE.
2024-03-22 11:07:28 -06:00
Tiezhu Yang
7845a24a6d gdb: LoongArch: Clean up loongarch_iterate_over_regset_sections()
Define a new variable gpsize as gprsize * LOONGARCH_LINUX_NUM_GREGSET
to replace the related code in the first cb(), and also make use of
tabs and spaces in indentation to force the proper alignment of code,
then remove the empty line at the end of the function.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2024-03-22 20:36:39 +08:00
Pedro Alves
431a6b091d Teach GDB to generate sparse core files (PR corefiles/31494)
This commit teaches GDB's gcore command to generate sparse core files
(if supported by the filesystem).

To create a sparse file, all you have to do is skip writing zeros to
the file, instead lseek'ing-ahead over them.

The sparse logic is applied when writing the memory sections, as
that's where the bulk of the data and the zeros are.

The commit also tweaks gdb.base/bigcore.exp to make it exercise
gdb-generated cores in addition to kernel-generated cores.  We
couldn't do that before, because GDB's gcore on that test's program
would generate a multi-GB non-sparse core (16GB on my system).

After this commit, gdb.base/bigcore.exp generates, when testing with
GDB's gcore, a much smaller core file, roughly in line with what the
kernel produces:

 real sizes:

 $ du --hu testsuite/outputs/gdb.base/bigcore/bigcore.corefile.*
 2.2M    testsuite/outputs/gdb.base/bigcore/bigcore.corefile.gdb
 2.0M    testsuite/outputs/gdb.base/bigcore/bigcore.corefile.kernel

 apparent sizes:

 $ du --hu --apparent-size testsuite/outputs/gdb.base/bigcore/bigcore.corefile.*
 16G     testsuite/outputs/gdb.base/bigcore/bigcore.corefile.gdb
 16G     testsuite/outputs/gdb.base/bigcore/bigcore.corefile.kernel

Time to generate the core also goes down significantly.  On my machine, I get:

  when writing to an SSD, from 21.0s, down to 8.0s
  when writing to an HDD, from 31.0s, down to 8.5s

The changes to gdb.base/bigcore.exp are smaller than they look at
first sight.  It's basically mostly refactoring -- moving most of the
code to a new procedure which takes as argument who should dump the
core, and then calling the procedure twice.  I purposely did not
modernize any of the refactored code in this patch.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31494
Reviewed-By: Lancelot Six <lancelot.six@amd.com>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Reviewed-By: John Baldwin <jhb@FreeBSD.org>
Change-Id: I2554a6a4a72d8c199ce31f176e0ead0c0c76cff1
2024-03-22 12:31:29 +00:00
Jan Beulich
820a77554e x86: fix Solaris testsuite failures
For one 0afc614c99 ("x86: Warn .insn instruction with length > 15
bytes") introduced a .insn use involving a slash; such tests need to
have --divide passed to gas.

And then 5bc71c2a6b ("x86-64: Add R_X86_64_CODE_6_GOTTPOFF") broke
BFD_RELOC_X86_64_GOTTPOFF conversion to R_X86_64_CODE_4_GOTTPOFF, by
adding respective code in a section guarded by
generate_relax_relocations (the case of that not being required there
was limited to 32-bit object files). Re-arrange that block of code to
check generate_relax_relocations later.
2024-03-22 09:08:51 +01:00
GDB Administrator
40dcb60aff Automatic date update in version.in 2024-03-22 00:00:33 +00:00
H.J. Lu
4bb20a6244 gdbserver: Clear X86_XSTATE_MPX bits in xcr0 on x32
Since MPX isn't available for x32, we should clear X86_XSTATE_MPX bits
on x32.

	PR server/31511
	* linux-x86-low.cc (x86_linux_read_description): Clear
	X86_XSTATE_MPX bits in xcr0 on x32.
Reviewed-by: Felix Willgerodt <felix.willgerodt@intel.com>
2024-03-21 12:44:40 -07:00
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