Commit Graph

118027 Commits

Author SHA1 Message Date
Tom de Vries
623840fc07 gdb/testsuite: Simplify gdb.threads/threadcrash.exp
I noticed in gdb.threads/threadcrash.exp that the usage of test_list is
somewhat convoluted.

Simplify the test-case by storing a classification instead of a pattern in
test_list.

Tested on arm-linux and x86_64-linux.
2024-03-11 10:57:32 +01:00
Guinevere Larsen
b95b92ec09 gdb/testsuite: Use _inferior_thread_count in gdb.threads/threadcrash.exp
A linaro PR [1] reports that the gdb.threads/threadcrash.exp test-case fails
to cout the number of threads in the inferior:
...
FAIL: gdb.threads/threadcrash.exp: test_gcore: $thread_count == 7
FAIL: gdb.threads/threadcrash.exp: test_gcore: $thread_count == [llength $test_list]
...

Fix this by getting the convenience variable _inferior_thread_count as opposed
to calculating it based on the output of "info threads".

Tested on arm-linux and x86_64-linux.

Reviewed-By: Lancelot Six <lancelot.six@amd.com>
Approved-By: Tom de Vries <tdevries@suse.de>

[1] https://linaro.atlassian.net/browse/GNU-1120
2024-03-11 10:57:31 +01:00
Tom de Vries
72ab7ac8be gdb/testsuite: Fix gdb.threads/threadcrash.exp with check-readmore
With check-readmore, I run into:
...
FAIL: gdb.threads/threadcrash.exp: test_corefile: \
  $thread_count == [llength $test_list]
...

The problem is that the clauses in the gdb_test_multiple for
"thread apply all backtrace" intent to match one line, but actually can
match more than one line, and consequently a match for one type of thread can
consume a line that was supposed to match another thread.

For instance, there's this regexp:
...
	    -re "\[^\n\]*syscall_task .location=SIGNAL_ALT_STACK\[^\n\]*" {
...

It's limited at the end by \[^\n\]*, meaning the match stops at the end of the
line.

But it doesn't start with a ^, and consequently can match more than one line.
The "\[^\n\]*" at the start doesn't prevent this, there's an implicit .* at
the start of each pattern, unless it's anchored using a ^.

Fix this by rewriting the regexps in a "^\r\n$hs$regexp$hs$eol" style, where:
- hs is: \[^\n\]* (horizontal space), and
- eol is (?=\r\n) (look-ahead end-of-line).

It also turned out to be necessary to drop the -lbl switch, and introduce a
corresponding explicit clause.  The -lbl clause is placed ALAP, and
consequently allowed the default fail clause to trigger.

Tested on arm-linux and x86_64-linux.
2024-03-11 10:57:31 +01:00
Tom de Vries
85041a8d51 gdb/testsuite: Reduce indentation in gdb.threads/threadcrash.exp
In test-case gdb.threads/threadcrash.exp we have an unnecessarily indented
gdb_test_multiple:
...
    gdb_test_multiple "thread apply all backtrace" \
	"Get thread information" -lbl {
	    -re "#\[0-9\]+\\\?\\\?\[^\n\]*" {
...

Fix this by moving the command into a variable, allowing the
"gdb_test_multiple ... {" to fit on a single 80 chars line.

Tested on arm-linux and x86_64-linux.
2024-03-11 10:57:31 +01:00
Jan Beulich
06360a5cbd x86: KeyLocker insn interaction with -msse-check / .sse_check
Some of these have no explicit %xmm operand(s), yet they still act SSE-
like (in leaveing bits 128 and up untouched). Hence they want similarly
diagnosing, if that was asked for.
2024-03-11 08:23:45 +01:00
Jan Beulich
ec6b11e7ec x86/APX: permit wider than 4-bit immediates with V{EXTRACT,INSERT}{F,I}128
These aren't useful, but can be encoded for their AVX forms and hence
should also be permitted for the APX surrogates. Extend the respective
conditional by a base opcode check, to restrict it to VROUND{P,S}{S,D}.
2024-03-11 08:23:11 +01:00
Jan Beulich
788b11d9c6 x86: don't open-code REG_{SP,FP}
Since we have the #define-s, we should also use them.
2024-03-11 08:22:35 +01:00
Stephen Kitt
64e215c15b tests: force non-deterministic mode in non-deterministic tests
Since ar can be built defaulting to deterministic mode, tests which
expect non-deterministic behaviour need to explicitly set the U flag.

The non-deterministic member test expects SOURCE_DATE_EPOCH to not be
set; this documents that. Unconditionally unsetting the variable
causes issues in test infrastructure (which expects unsetenv to only
be called on variables which are already set).

Signed-off-by: Stephen Kitt <steve@sk2.org>
2024-03-11 08:21:47 +01:00
GDB Administrator
5790996072 Automatic date update in version.in 2024-03-11 00:00:31 +00:00
GDB Administrator
a23cc3f389 Automatic date update in version.in 2024-03-10 00:00:26 +00:00
Tom de Vries
2cf3c79c80 [gdb/python] Handle deprecation of PyErr_{Fetch,Restore} in 3.12
Starting python version 3.12, PyErr_Fetch and PyErr_Restore are deprecated.

Use PyErr_GetRaisedException and PyErr_SetRaisedException instead, for
python >= 3.12.

Tested on aarch64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2024-03-09 16:13:10 +01:00
Tom de Vries
50ede76876 [gdb/python] Normalize exceptions in gdbpy_err_fetch
With python 3.12, I run into:
...
(gdb) PASS: gdb.python/py-block.exp: check variable access
python print (block['nonexistent'])^M
Python Exception <class 'KeyError'>: 'nonexistent'^M
Error occurred in Python: 'nonexistent'^M
(gdb) FAIL: gdb.python/py-block.exp: check nonexistent variable
...

The problem is that that PyErr_Fetch returns a normalized exception, while the
test-case matches the output for an unnormalized exception.

With python 3.6, PyErr_Fetch returns an unnormalized exception, and the
test passes.

Fix this by:
- updating the test-case to match the output for a normalized exception, and
- lazily forcing normalized exceptions using PyErr_NormalizeException.

Tested on aarch64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2024-03-09 16:13:10 +01:00
Tom de Vries
b1abf8b1b9 [gdb/python] Use gdbpy_err_fetch::{type,value} as getters
Similar to gdbpy_err_fetch::value, add a getter gdbpy_err_fetch::type, and use
both consistently to get gdbpy_err_fetch members m_error_value and
m_error_type.

Tested on aarch64-linux.
2024-03-09 16:13:10 +01:00
Alan Modra
5cd5266180 Reinstate bfd_print_error as an extern function
* bfd.c (_bfd_print): Renamed from bfd_print_error.
	(bfd_print_error): Reinstate previous code but using the above.
	(error_handler_fprintf, error_handler_sprintf): Adjust.
	* bfd-in2.h: Regenerate.
2024-03-09 21:00:02 +10:30
Alan Modra
0c947d990a Re: Move bfd_init to bfd.c
Commit b1c95bc4dd cleared some bfd static variables, with bad
results since bfd_set_error_program_name is often called before
bfd_init.

	* bfd.c (bfd_init): Don't clear _bfd_error_program_name.
2024-03-09 19:52:16 +10:30
Alan Modra
bd8d76258f print cached error messages using _bfd_error_handler
* bfd.c (bfd_print_error): Make static.  Don't print program name.
	(error_handler_fprintf): Print program name here.
	* format.c (print_warnmsg): Use _bfd_error_handler to print
	cached messages.
	* bfd-in2.h: Regenerate.
2024-03-09 14:35:09 +10:30
Tom Tromey
ed29a346be Avoid race when writing to index cache
The background DWARF reader changes introduced a race when writing to
the index cache.  The problem here is that constructing the
index_cache_store_context object should only happen on the main
thread, to ensure that the various value captures do not race.

This patch adds an assert to the construct to that effect, and then
arranges for this object to be constructed by the cooked_index_worker
constructor -- which is only invoked on the main thread.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31262
2024-03-08 17:25:50 -07:00
Tom Tromey
ba9583c7d5 Move the 'store' method to index_cache_store_context
I think it is cleaner for 'store' to be a method on
index_cache_store_context rather than on the global index cache
itself.  This patch makes this change.
2024-03-08 17:25:50 -07:00
Tom Tromey
b183313dfa Capture the per-BFD object in index_cache_store_context
This changes index_cache_store_context to also capture the per-BFD
object when it is constructed.  This is used when storing to the
cache, and this approach makes the code a little simpler.
2024-03-08 17:25:49 -07:00
Tom Tromey
2509ae7fb0 Capture directory in index_cache_store_context
I noticed that index_cache_store_context captures the 'enabled'
setting, but not the index cache directory.  This patch makes this
change, which avoids a possible race -- with background reading, the
user could possibly change this directory at the exact moment the
writer examines the variable.
2024-03-08 17:25:49 -07:00
Tom Tromey
71d67416e7 Rename members of index_cache_store_context
This renames the private members of index_cache_store_context to start
with "m_".
2024-03-08 17:25:49 -07:00
GDB Administrator
0d3e7c8b72 Automatic date update in version.in 2024-03-09 00:00:29 +00:00
Tom Tromey
2755241d02 Add return value to DAP scope
A bug report in the DAP specification repository pointed out that it
is typical for DAP implementations to put a function's return value
into the outermost scope.

This patch changes gdb to follow this convention.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31341
Reviewed-By: Kévin Le Gouguec <legouguec@adacore.com>
2024-03-08 10:50:13 -07:00
Tom Tromey
99761c5ab5 Export "finish" return value to Python
This patch changes the Python "stop" event emission code to also add
the function return value, if it is known.  This happens when the stop
comes from a "finish" command and when the value can be fetched.

The test is in the next patch.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2024-03-08 10:50:12 -07:00
H.J. Lu
03fa0c63d3 gas: Fix x86 build with GCC 6.4
Add "()" to silence GCC 6.4:

.../gas/config/tc-i386.c: In function ‘x86_ginsn_lea’:
.../gas/config/tc-i386.c:5738:19: error: logical not is only applied to the left hand side of comparison [-Werror=logical-not-parentheses]
   if (!i.base_reg != (!i.index_reg || i.index_reg->reg_num == RegIZ))
                   ^~
cc1: all warnings being treated as errors

	PR gas/31464
	* config/tc-i386.c (x86_ginsn_lea): Add "()" to silence GCC 6.4.
2024-03-08 08:08:02 -08:00
Tom Tromey
e9b738dfbd Avoid race when reading dwz file
PR gdb/31260 points out a race introduced by the background reading
changes.  If a given objfile is re-opened when it is already being
read, dwarf2_initialize_objfile will call dwarf2_read_dwz_file again,
causing the 'dwz_file' to be reset.

This patch fixes the problem by arranging to open the dwz just once:
when the dwarf2_per_bfd object is created.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31260
2024-03-08 07:15:08 -07:00
H.J. Lu
cdabd12b18 bfd: Change the --with-mmap default to true
Change the configure default to using mmap.

	* configure.ac: Change the --with-mmap default to true.
	* configure: Regenerated.
2024-03-08 05:44:12 -08:00
H.J. Lu
433b4f8ab7 bfd: Don't hard-code BFD_JUMP_TABLE_COPY
In BFD_JUMP_TABLE_COPY, replace _bfd_generic_init_private_section_data
with NAME##_init_private_section_data so that ELF targets can properly
replace it with _bfd_elf_init_private_section_data.

	* aout-target.h (MY_init_private_section_data): New.
	* coff-rs6000.c (_bfd_xcoff_init_private_section_data): New.
	* coffcode.h (coff_init_private_section_data): New.
	* elfxx-target.h (bfd_elfNN_init_private_section_data): New.
	* libecoff.h (_bfd_ecoff_init_private_section_data): New.
	* mach-o-target.c (bfd_mach_o_init_private_section_data): New.
	* mmo.c (mmo_init_private_section_data): New.
	* plugin.c (bfd_plugin_init_private_section_data): New.
	* ppcboot.c (ppcboot_init_private_section_data): New.
	* som.c (som_init_private_section_data): New.
	* targets.c (BFD_JUMP_TABLE_COPY): Replace
	_bfd_generic_init_private_section_data with
	NAME##_init_private_section_data.
	* vms-alpha.c (vms_init_private_section_data): New.
	* elf-bfd.h (_bfd_generic_init_private_section_data): Removed.
	* bfd-in2.h: Regenerated.
2024-03-08 05:43:51 -08:00
Jiawei
dac0b8a4af RISC-V: Support Zabha extension.
The Zabha extension[1] supports for byte and halfword
atomic memory operations. This patch add all instructions
include in Zabha. Further work is waiting Zacas[2] merge.

[1] https://github.com/riscv/riscv-zabha/tags
[2] https://sourceware.org/pipermail/binutils/2023-May/127700.html

Version log:
Add new imply relation that Zabha extension implies A extension.

bfd/ChangeLog:

        * elfxx-riscv.c (riscv_implicit_subsets): New imply.
        (riscv_multi_subset_supports): New extension.
        (riscv_multi_subset_supports_ext): Ditto.

gas/ChangeLog:

        * testsuite/gas/riscv/zabha-32.d: New test.
        * testsuite/gas/riscv/zabha.d: New test.
        * testsuite/gas/riscv/zabha.s: New test.

include/ChangeLog:

        * opcode/riscv-opc.h (MATCH_AMOADD_B): New opcodes.
        (MASK_AMOADD_B): Ditto.
        (MATCH_AMOXOR_B): Ditto.
        (MASK_AMOXOR_B): Ditto.
        (MATCH_AMOOR_B): Ditto.
        (MASK_AMOOR_B): Ditto.
        (MATCH_AMOAND_B): Ditto.
        (MASK_AMOAND_B): Ditto.
        (MATCH_AMOMIN_B): Ditto.
        (MASK_AMOMIN_B): Ditto.
        (MATCH_AMOMAX_B): Ditto.
        (MASK_AMOMAX_B): Ditto.
        (MATCH_AMOMINU_B): Ditto.
        (MASK_AMOMINU_B): Ditto.
        (MATCH_AMOMAXU_B): Ditto.
        (MASK_AMOMAXU_B): Ditto.
        (MATCH_AMOSWAP_B): Ditto.
        (MASK_AMOSWAP_B): Ditto.
        (MATCH_AMOADD_H): Ditto.
        (MASK_AMOADD_H): Ditto.
        (MATCH_AMOXOR_H): Ditto.
        (MASK_AMOXOR_H): Ditto.
        (MATCH_AMOOR_H): Ditto.
        (MASK_AMOOR_H): Ditto.
        (MATCH_AMOAND_H): Ditto.
        (MASK_AMOAND_H): Ditto.
        (MATCH_AMOMIN_H): Ditto.
        (MASK_AMOMIN_H): Ditto.
        (MATCH_AMOMAX_H): Ditto.
        (MASK_AMOMAX_H): Ditto.
        (MATCH_AMOMINU_H): Ditto.
        (MASK_AMOMINU_H): Ditto.
        (MATCH_AMOMAXU_H): Ditto.
        (MASK_AMOMAXU_H): Ditto.
        (MATCH_AMOSWAP_H): Ditto.
        (MASK_AMOSWAP_H): Ditto.
        (DECLARE_INSN): New declare.
        * opcode/riscv.h (enum riscv_insn_class): New class.

opcodes/ChangeLog:

        * riscv-opc.c: New instructions.
2024-03-08 10:04:25 +08:00
GDB Administrator
acab5b12b9 Automatic date update in version.in 2024-03-08 00:00:21 +00:00
GDB Administrator
5b95198e2e Automatic date update in version.in 2024-03-07 00:00:53 +00:00
Nick Clifton
164cc86b81 Add "-j1" to make command lines in the create-a-release README. 2024-03-06 10:57:39 +00:00
Lulu Cai
a9859f5ad0 LoongArch: Fix some test cases for TLS transition and relax 2024-03-06 14:47:03 +08:00
Lulu Cai
d5de762be7 LoongArch: Add dtpoff calculation function
When tls_sec is NULL, we should not access the virtual address
of tls_sec.
2024-03-06 14:47:03 +08:00
Lulu Cai
0e45942b2c LoongArch: Delete extra instructions when TLS type transition
This modification mainly changes the timing of type transition,
adds relaxation to the old LE instruction sequence, and fixes
bugs in extreme code models.

We strictly distinguish between type transition and relaxation.
Type transition is from one type to another, while relaxation
is the removal of instructions under the same TLS type. Detailed
instructions are as follows:

1. For type transition, only the normal code model of DESC/IE
does type transition, and each relocation is accompanied by a
RELAX relocation. Neither abs nor extreme will do type transition,
and no RELAX relocation will be generated.
The extra instructions when DESC transitions to other TLS types
will be deleted during the type transition.

2. Implemented relaxation for the old LE instruction sequence.
The first two instructions of LE's 32-bit and 64-bit models
use the same relocations and cannot be distinguished based on
relocations. Therefore, for LE's instruction sequence, any code
model will try to relax.

3. Some function names have been adjusted to facilitate understanding,
parameters have been adjusted, and unused macros have been deleted.
2024-03-06 14:47:03 +08:00
Alan Modra
55e01dbd76 Don't use bfd_error_handler in bfd_abort
We don't want to lose an abort message when bfd_set_error_handler has
been called to ignore or cache errors.

	PR ld/31444
	* bfd.c (_bfd_abort): Don't use _bfd_error_handler.
2024-03-06 11:22:29 +10:30
GDB Administrator
ea1b1dc0b5 Automatic date update in version.in 2024-03-06 00:00:59 +00:00
Andrew Burgess
f08311ceb1 gdb/testsuite: fix duplicate test names in gdb.trace/circ.exp
This fixes some duplicate test names in gdb.trace/circ.exp when using
native-gdbserver and native-extended-gdbserver boards.

In this test we set the trace buffer size twice.  The same test name
was used each time the size was adjusted.

I've fixed this issue by:

  1. Creating a new proc, set_trace_buffer_size, which factors out the
  code to change the buffer size, and uses test names based on the
  size we're setting the buffer too,

  2. Calling the new proc each time we want to adjust the buffer size.

After this the duplicate test names are resolved.  There should be no
change in what is tested after this commit.
2024-03-05 16:35:23 +00:00
Andrew Burgess
b208792b31 gdb/testsuite: fix some more duplicate test names in gdb.trace/
This commit fixes some duplicate test names in the gdb.trace/
directory when run with the native-gdbserver and
native-extended-gdbserver boards.  In this case the duplicates relate
to the calls to gdb_compile_pthreads which emits a fixed PASS message,
as there are two calls to gdb_compile_pthreads we get a duplicate PASS
message.

In both cases the problem is fixed by adding a with_test_prefix around
one of the compilations, however, I've made additional changes to
clean up the tests a little while I was working on them:

  1. Switch to use prepare_for_testing instead of
  gdb_compile_pthreads.  By passing the 'pthreads' option this does
  call gdb_compile_pthreads under the hood, but using the standard
  compile function is cleaner,

  2. Using prepare_for_testing removes the need to call clean_restart
  immediately afterwards, so those calls are removed,

  3. I removed the unneeded $executable and $expfile globals, where
  the $executable global was used I've replaced this with $binfile,

  4. When we compile two executables I've now given these different
  names so that both exist at the end of the test run,

  5. Removed a gdb_reinitialize_dir call, this is covered by
  clean_restart,

  6. Use gdb_test_no_output where it makes sense.

I now see no duplicate test names when running these test scripts.
There should be no change in what is being tested after this commit.
2024-03-05 16:35:23 +00:00
Lulu Cai
533c24e167 LoongArch: Add gas testsuit for LA32 relocations
Test the relocation of the LA32 instruction set.
2024-03-05 19:55:33 +08:00
Lulu Cai
4cde4ce70a LoongArch: Add gas testsuit for LA64 relocations
Test the relocation of the LA64 instruction set.
2024-03-05 19:55:33 +08:00
Lulu Cai
0c7cde4d9a LoongArch: Add gas testsuit for LA32 int/float instructions
Test the int/float instructions of LA32.
2024-03-05 19:55:32 +08:00
Lulu Cai
95616510b6 LoongArch: Add gas testsuit for LA64 int/float instructions
Test the int/float instructions of LA64.
2024-03-05 19:55:31 +08:00
Lulu Cai
f35f0ceddf LoongArch: Add gas testsuit for lsx/lasx instructions
Test the LSX/LASX instructions. Only LA64 supports
these instructions.
2024-03-05 19:55:31 +08:00
Lulu Cai
10b6919c1f LoongArch: Add gas testsuit for lbt/lvz instructions
Test the LBT/LVZ instructions. Only LA64 supports
these instructions.
2024-03-05 19:55:31 +08:00
Lulu Cai
30dbbdc55a LoongArch: Add gas testsuit for alias instructions
Test the alias instructions.
2024-03-05 19:55:31 +08:00
GDB Administrator
a7ea089b0b Automatic date update in version.in 2024-03-05 00:00:23 +00:00
GDB Administrator
1485a3fb63 Automatic date update in version.in 2024-03-04 00:00:24 +00:00
GDB Administrator
90f8d97c8e Automatic date update in version.in 2024-03-03 00:00:24 +00:00
Hui Li
1304f47d02 gdb: LoongArch: Change LOONGARCH_FIRST_FP_REGNUM to 35
There is an assertion error "gdb_assert (n < tdesc->reg_defs.size ())"
in find_register_by_number() when gdb connects to gdbserver, this
is because the value of LOONGARCH_LINUX_NUM_GREGSET (45, which contains
10 reserved regs) is different with the number of regs (35, which not
contains 10 reserved regs) in file gdb/features/loongarch/base64.xml.
Add a new macro LOONGARCH_USED_NUM_GREGSET which is defined as 35 to
keep consistent with the gdb/features/loongarch/base64.xml, and then
define LOONGARCH_FIRST_FP_REGNUM as LOONGARCH_USED_NUM_GREGSET so that
all the reg numbers in regcache are consistent with tdesc reg numbers.

without this patch:

Execute on the target machine:

  $ gdbserver 192.168.1.123:5678 ./test

Execute on the host machine:

  $ gdb ./test
  (gdb) target remote 192.168.1.123:5678

Output on the target machine:

  Process ./test created; pid = 67683
  Listening on port 5678
  Remote debugging from host 192.168.1.136, port 6789
  gdbserver/regcache.cc:205: A problem internal to GDBserver has been detected.
  find_register_by_number: Assertion 'n < tdesc->reg_defs.size ()' failed.

Output on the host machine:

  Remote debugging using 192.168.1.123:5678
  Remote connection closed

Signed-off-by: Hui Li <lihui@loongson.cn>
Approved-By: John Baldwin <jhb@FreeBSD.org>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2024-03-02 19:07:04 +08:00