as does not accept instructions like brasl %r0,.-0x100000000, because
of two problems with the generic overflow check:
1. PCRel32 operands are signed, but are treated as unsigned.
2. The allowed range for these operands is [-(1 << 32), (1 << 32) - 1],
and not [-(1 << 31), (1 << 31) - 1].
Fix both by disabling the generic overflow check - it's not needed,
because s390_insert_operand () performs its own.
gas/
* config/tc-s390.c (md_gather_operands): Set fx_no_overflow.
* testsuite/gas/s390/s390.exp: Add zarch-z900-err.
* testsuite/gas/s390/esa-z900.d: New test.
* testsuite/gas/s390/esa-z900.s: New test.
* testsuite/gas/s390/zarch-z900-err.l: New test.
* testsuite/gas/s390/zarch-z900-err.s: New test.
In bug PR gdb/29036, another failure was reported for the test
gdb.mi/mi-multi-commands.exp. This test sends two commands to GDB as
a single write, and then checks that both commands are executed.
The problem that was encountered here is that the output of the first
command, which looks like this:
^done,value="\"FIRST COMMAND\""
Is actually produced in parts, first the '^done' is printed, then the
',value="\"FIRST COMMAND\"" is printed.
What was happening is that some characters from the second command
were being echoed after the '^done' had been printed, but before the
value part had been printed. To avoid this issue I've relaxed the
pattern that checks for the first command a little. With this fix in
place the occasional failure in this test is no longer showing up.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29036
- Add a script syscalls/gen-header.py, based on syscalls/arm-linux.py.
- Add a script syscalls/update-linux.sh (alongside update-freebsd.sh and
update-netbsd.sh).
- Use syscalls/update-linux.sh to update syscalls/{amd64,i386}-linux.xml.in.
- Regenerate syscalls/{amd64,i386}-linux.xml using syscalls/Makefile.
In gdb/syscalls/i386-linux.xml.in, updating has the following notable effect:
...
- <syscall name="madvise1" number="220"/>
- <syscall name="getdents64" number="221"/>
- <syscall name="fcntl64" number="222"/>
+ <syscall name="getdents64" number="220"/>
+ <syscall name="fcntl64" number="221"/>
...
I've verified in ./arch/x86/entry/syscalls/syscall_32.tbl that the numbers are
correct.
Tested on x86_64-linux.
Add a Makefile in gdb/syscalls that can be used to translate
gdb/syscalls/*.xml.in into gdb/syscalls/*.xml.
Calling make reveals that bfin-linux.xml is missing, so add it.
Tested on x86_64-linux.
When execute the following command on LoongArch:
make check-gdb TESTS="gdb.base/async.exp"
there exist the following failed testcases:
FAIL: gdb.base/async.exp: finish& (timeout)
FAIL: gdb.base/async.exp: jump& (timeout)
FAIL: gdb.base/async.exp: until& (timeout)
FAIL: gdb.base/async.exp: set exec-done-display off (GDB internal error)
we can see the following messages in gdb/testsuite/gdb.log:
finish&
Run till exit from #0 foo () at /home/loongson/gdb.git/gdb/testsuite/gdb.base/async.c:9
(gdb) /home/loongson/gdb.git/gdb/gdbarch.c:2646: internal-error: gdbarch_return_value: Assertion `gdbarch->return_value != NULL' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
In order to fix the above failed testcases, implement the return_value
gdbarch method on LoongArch.
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
This fix relates to PR gdb/29032, this makes the test more stable by
ensuring that the Ctrl-D is only sent once the prompt has been
displayed. This issue was also discussed on the mailing list here:
https://sourceware.org/pipermail/gdb-patches/2022-April/187670.html
The problem identified in the bug report is that sometimes the Ctrl-D
(that the test sends to GDB) arrives while GDB is processing a
command. When this happens the Ctrl-D is handled differently than if
the Ctrl-D is sent while GDB is waiting for input at a prompt.
The original intent of the test was that the Ctrl-D be sent while GDB
was waiting at a prompt, and that is the case the occurs most often,
but, when the Ctrl-D arrives during command processing, then GDB will
ignore the Ctrl-D, and the test will fail.
This commit ensures the Ctrl-D is always sent while GDB is waiting at
a prompt, which makes this test stable.
But, that still leaves an open question, what should happen when the
Ctrl-D arrives while GDB is processing a command? This commit doesn't
attempt to answer that question, which is while bug PR gdb/29032 will
not be closed once this commit is merged.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29032
Do:
...
-record btrace <name> <email>
+record
+ btrace <name> <email>
...
to clarify that the listed maintainer is only maintainer of the btrace part of
record.
With test-case gdb.base/catch-syscall.exp and target board unix/-m32, we run
into:
...
(gdb) catch syscall pipe2^M
Unknown syscall name 'pipe2'.^M
(gdb) FAIL: gdb.base/catch-syscall.exp: determine pipe syscall: catch syscall pipe2
...
Fix this by:
- adding a pipe2 entry in gdb/syscalls/i386-linux.xml.in, and
- regenerating gdb/syscalls/i386-linux.xml using
"xsltproc --output i386-linux.xml apply-defaults.xsl i386-linux.xml.in".
Tested on x86_64-linux with native and unix/-m32.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29056
When running test-case gdb.reverse/pipe-reverse.exp on openSUSE Tumbleweed,
I run into:
...
(gdb) continue^M
Continuing.^M
^M
Catchpoint 2 (returned from syscall pipe2), in pipe () from /lib64/libc.so.6^M
(gdb) FAIL: gdb.base/catch-syscall.exp: without arguments: \
syscall pipe has returned
...
The current glibc on Tumbleweed is 2.35, which contains commit
"linux: Implement pipe in terms of __NR_pipe2", and consequently syscall pipe2
is used instead of syscall pipe.
Fix this by detecting whether syscall pipe or pipe2 is used before running the
tests.
Tested on x86_64-linux, specifically on:
- openSUSE Tumbleweed (with glibc 2.35), and
- openSUSE Leap 15.3 (with glibc 2.31).
On openSUSE Tumbleweed + target board unix/-m32, this exposes:
...
(gdb) catch syscall pipe2^M
Unknown syscall name 'pipe2'.^M
...
which will be fixed in a folllow-up patch.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29056
When running test-case gdb.reverse/pipe-reverse.exp on openSUSE Tumbleweed,
I run into:
...
(gdb) continue^M
Continuing.^M
Process record and replay target doesn't support syscall number 293^M
Process record: failed to record execution log.^M
^M
Program stopped.^M
0x00007ffff7daabdb in pipe () from /lib64/libc.so.6^M
(gdb) FAIL: gdb.reverse/pipe-reverse.exp: continue to breakpoint: marker2
...
The current glibc on Tumbleweed is 2.35, which contains commit
"linux: Implement pipe in terms of __NR_pipe2", and consequently syscall pipe2
is used in stead of syscall pipe.
There is already support added for syscall pipe2 for aarch64 (which only has
syscall pipe2, not syscall pipe), so enable the same for amd64, by:
- adding amd64_sys_pipe2 in enum amd64_syscall
- translating amd64_sys_pipe2 to gdb_sys_pipe2 in amd64_canonicalize_syscall
Tested on x86_64-linux, specifically on:
- openSUSE Tumbleweed (with glibc 2.35), and
- openSUSE Leap 15.3 (with glibc 2.31).
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29056
When running test-case gdb.tui/scroll.exp, I get:
...
Box Dump (80 x 8) @ (0, 0):
0 $17 = 16
1 (gdb) p 17
2 $18 = 17
3 (gdb) p 18
4 $19 = 18
5 (gdb) p 19
6 $20 = 19
7 (gdb)
PASS: gdb.tui/scroll.exp: check cmd window in flip layout
...
but with check-read1 I get instead:
...
Box Dump (80 x 8) @ (0, 0):
0 (gdb) 15
1 (gdb) p 16
2 $17 = 16
3 (gdb) p 17
4 $18 = 17
5 (gdb) p 18
6 $19 = 18
7 (gdb) p 19
FAIL: gdb.tui/scroll.exp: check cmd window in flip layout
...
The "p 19" command is handled by Term::command, which sends the command and then
does Term::wait_for "^$gdb_prompt [string_to_regexp $cmd]", which:
- matches the line with "(gdb) p 19", and
- tries to match the following prompt "(gdb) "
The problem is that scrolling results in reissuing output before the "(gdb) p
19", and the second matching triggers on that. Consequently, wait_for no
longer translates gdb output into screen actions, and the screen does not
reflect the result of "p 19".
Fix this by using a new proc wait_for_region_contents, which in contrast to
wait_for can handle a multi-line regexp.
Tested on x86_64-linux with make targets check and check-read1.
When running test-case gdb.cp/casts.exp with target board unix/-m32, I run
into:
...
(gdb) print (unsigned long long) &gd == gd_value^M
$31 = false^M
(gdb) FAIL: gdb.cp/casts.exp: print (unsigned long long) &gd == gd_value
...
With some additional printing, we can see in more detail why the comparison
fails:
...
(gdb) print /x &gd^M
$31 = 0xffffc5c8^M
(gdb) PASS: gdb.cp/casts.exp: print /x &gd
print /x (unsigned long long)&gd^M
$32 = 0xffffc5c8^M
(gdb) PASS: gdb.cp/casts.exp: print /x (unsigned long long)&gd
print /x gd_value^M
$33 = 0xffffffffffffc5c8^M
(gdb) PASS: gdb.cp/casts.exp: print /x gd_value
print (unsigned long long) &gd == gd_value^M
$34 = false^M
(gdb) FAIL: gdb.cp/casts.exp: print (unsigned long long) &gd == gd_value
...
The gd_value is set by this assignment:
...
unsigned long long gd_value = (unsigned long long) &gd;
...
The problem here is directly casting from a pointer to a non-pointer-sized
integer.
Fix this by adding an intermediate cast to std::uintptr_t.
Tested on x86_64-linux with native and target board unix/-m32.
In OBS, on aarch64-linux, with a gdb 11.1 based package, I run into:
...
(gdb) builtin_spawn -pty^M
new-ui mi /dev/pts/5^M
New UI allocated^M
(gdb) =thread-group-added,id="i1"^M
(gdb) ERROR: MI channel failed
warning: Error detected on fd 11^M
thread 1.1^M
Unknown thread 1.1.^M
(gdb) UNRESOLVED: gdb.mi/user-selected-context-sync.exp: mode=non-stop: \
test_cli_inferior: reset selection to thread 1.1
...
with many more UNRESOLVED following.
The ERROR is a common problem, filed as
https://sourceware.org/bugzilla/show_bug.cgi?id=28561 .
But the many UNRESOLVEDs are due to not checking whether the setup as done in
the test_setup function succeeds or not.
Fix this by:
- making test_setup return an error upon failure
- handling test_setup error at the call site
- adding a "setup done" pass/fail to be turned into an unresolved
in case of error during setup.
Tested on x86_64-linux, by manually triggering the error in
mi_gdb_start_separate_mi_tty.
When running test-case gdb.ada/catch_ex_std.exp on target board
remote-gdbserver-on-localhost, I run into:
...
(gdb) continue^M
Continuing.^M
[Inferior 1 (process 15656) exited with code 0177]^M
(gdb) FAIL: gdb.ada/catch_ex_std.exp: runto: run to main
Remote debugging from host ::1, port 49780^M
/home/vries/foo: error while loading shared libraries: libsome_package.so: \
cannot open shared object file: No such file or directory^M
...
Fix this by adding the usual shared-library + remote-target helper
"gdb_load_shlib $sofile".
Tested on x86_64-linux with native and target board
remote-gdbserver-on-localhost.
When running test-case gdb.threads/fork-plus-threads.exp with check-readmore,
I run into:
...
[Inferior 11 (process 7029) exited normally]^M
[Inferior 1 (process 6956) exited normally]^M
FAIL: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: \
inferior 1 exited (timeout)
...
The problem is that the regexp consuming the "Inferior exited normally"
messages:
- consumes more than one of those messages at a time, but
- counts only one of those messages.
Fix this by adopting a line-by-line approach, which deals with those messages
one at a time.
Tested on x86_64-linux with native, check-read1 and check-readmore.
Simon pointed out that some recent patches of mine broke "catch
syscall". Apparently I forgot to finish the conversion of this code
when removing init_catchpoint. This patch completes the conversion
and fixes the bug.
After these two commits:
commit 4fb7bc4b14
Date: Mon Mar 7 13:49:21 2022 +0000
readline: back-port changes needed to properly detect EOF
commit 91395d97d9
Date: Tue Feb 15 17:28:03 2022 +0000
gdb: handle bracketed-paste-mode and EOF correctly
It was observed that, if a previous command is selected at the
readline prompt using the up arrow key, then when the command is
accepted (by pressing return) an unexpected 'quit' message will be
printed by GDB. Here's an example session:
(gdb) p 123
$1 = 123
(gdb) p 123
quit
$2 = 123
(gdb)
In this session the second 'p 123' was entered not by typing 'p 123',
but by pressing the up arrow key to select the previous command. It
is important that the up arrow key is used, typing Ctrl-p will not
trigger the bug.
The problem here appears to be readline's EOF detection when handling
multi-character input sequences. I have raised this issue on the
readline mailing list here:
https://lists.gnu.org/archive/html/bug-readline/2022-04/msg00012.html
a solution has been proposed here:
https://lists.gnu.org/archive/html/bug-readline/2022-04/msg00016.html
This patch includes a test for this issue as well as a back-port of
(the important bits of) readline commit:
commit 2ef9cec8c48ab1ae3a16b1874a49bd1f58eaaca1
Date: Wed May 4 11:18:04 2022 -0400
fix for setting RL_STATE_EOF in callback mode
That commit also includes some updates to the readline documentation
and tests that I have not included in this commit.
With this commit in place the unexpected 'quit' messages are resolved.
Commit 39fb369834 "opcodes: Make i386-dis.c thread-safe" introduced
a number of casts to bfd_signed_vma that cause undefined behaviour
with a 32-bit libbfd. Revert those changes.
* i386-dis.c (OP_E_memory): Do not cast disp to bfd_signed_vma
for negation.
(get32, get32s): Don't use bfd_signed_vma here.
Fix it some more.
bfd/
* elfnn-loongarch.c: Remove commented out elf_backend_* defines.
ld/
* testsuite/ld-elf/elf.exp (target_defaults_to_execstack): Match
arm*. Delete loongarch.
On PowerPC, the stop in the printf function is of the form:
Breakpoint 2, 0x00007ffff7c6ab08 in printf@@GLIBC_2.17 () from /lib64/libc.so.6
On other architectures the output looks like:
Breakpoint 2, 0x0000007fb7ea29ac in printf () from /lib/aarch64-linux-gnu/libc.so.6
The following patch modifies the printf test by matchine any character
starting immediately after the printf. The test now works for PowerPC
output as well as the output from other architectures.
The test has been run on a Power 10 system and and Intel x86_64 system.
This introduces a catchpoint class that is used as the base class for
all catchpoints. init_catchpoint is rewritten to be a constructor
instead.
This changes the hierarchy a little -- some catchpoints now inherit
from base_breakpoint whereas previously they did not. This isn't a
problem, as long as re_set is redefined in catchpoint.
This adds some initializers to tracepoint. I think right now these
may not be needed, due to obscure rules about zero initialization.
However, this will change in the next patch, and anyway it is clearer
to be explicit.
This changes print_recreate_thread to be a method on breakpoint. This
function is only used as a helper by print_recreate methods, so I
thought this transformation made sense.
The break point after the stepi on Intel is the entry point of the user
signal handler function test_signal_handler. The code at the break point
looks like:
0x<hex address> <test_signal_handler>: endbr64
On PowerPC with a Linux 5.9 kernel or latter, the address where gdb stops
after the stepi is in the vdso code inserted by the kernel. The code at the
breakpoint looks like:
0x<hex address> <__kernel_start_sigtramp_rt64>: bctrl
This is different from other architectures. As discussed below, recent
kernel changes involving the vdso for PowerPC have been made changes to the
signal handler code flow. PowerPC is now stopping in function
__kernel_start_sigtramp_rt64. PowerPC now requires an additional stepi to
reach the user signal handler unlike other architectures.
The bp-permanent.exp and kill-after-signal tests run fine on PowerPC with an
kernel that is older than Linux 5.9.
The PowerPC 64 signal handler was updated by the Linux kernel 5.9-rc1:
commit id: 0138ba5783ae0dcc799ad401a1e8ac8333790df9
powerpc/64/signal: Balance return predictor stack in signal trampoline
An additional change to the PowerPC 64 signal handler was made in Linux
kernel version 5.11-rc7 :
commit id: 24321ac668e452a4942598533d267805f291fdc9
powerpc/64/signal: Fix regression in __kernel_sigtramp_rt64() semantics
The first kernel change, puts code into the user space signal handler (in
the vdso) as a performance optimization to prevent the call/return stack
from getting out of balance. The patch ensures that the entire
user/kernel/vdso cycle is balanced with the addition of the "brctl"
instruction.
The second patch, fixes the semantics of __kernel_sigtramp_rt64(). A new
symbol is introduced to serve as the jump target from the kernel to the
trampoline which now consists of two parts.
The above changes for PowerPC signal handler, causes gdb to stop in the
kernel code not the user signal handler as expected. The kernel dispatches
to the vdso code which in turn calls into the signal handler. PowerPC is
special in that the kernel is using a vdso instruction (bctrl) to enter the
signal handler.
I do not have access to a system with the first patch but not the second. I did
test on Power 9 with the Linux 5.15.0-27-generic kernel. Both tests fail on
this Power 9 system. The two tests also fail on Power 10 with the Linux
5.14.0-70.9.1.el9_0.ppc64le kernel.
The following patch fixes the issue by checking if gdb stopped at "signal
handler called". If gdb stopped there, the tests verifies gdb is in the kernel
function __kernel_start_sigtramp_rt64 then does an additional stepi to reach the
user signal handler. With the patch below, the tests run without errors on both
the Power 9 and Power 10 systems with out any failures.
I hit this just now with a make -j build after touching config.bfd.
mv: cannot stat 'targmatch.new': No such file or directory
make[2]: *** [Makefile:2336: targmatch.h] Error 1
make[2]: *** Waiting for unfinished jobs....
Fix that by not removing the target of the rule, a practice that seems
likely to cause parallel running of the rule recipe. The bug goes
back to 1997, the initial c073470881 commit.
* Makefile.am (targmatch.h): rm the temp file, not targmatch.h.
* Makefile.in: Regenerate.