diff options
author | Tom de Vries <tdevries@suse.de> | 2023-11-21 11:44:07 +0100 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2023-11-21 11:44:07 +0100 |
commit | eb42bb148956c283d485bbd182606a851280149d (patch) | |
tree | 8ce16155fd9466d9328a163dc865e3ca7152be56 /gdb/testsuite/lib/cl_util.c | |
parent | 1c320501655ec8d5077d0a3231652c7d661249bc (diff) | |
download | gdb-eb42bb148956c283d485bbd182606a851280149d.zip gdb-eb42bb148956c283d485bbd182606a851280149d.tar.gz gdb-eb42bb148956c283d485bbd182606a851280149d.tar.bz2 |
[gdb/tdep] Fix catching syscall execve exit for arm
When running test-case gdb.base/catch-syscall.exp on a pinebook (64-bit
aarch64 kernel, 32-bit userland) I run into:
...
(gdb) PASS: $exp: execve: syscall(s) execve appears in 'info breakpoints'
continue^M
Continuing.^M
^M
Catchpoint 18 (call to syscall execve), 0xf7726318 in execve () from \
/lib/arm-linux-gnueabihf/libc.so.6^M
(gdb) PASS: gdb.base/catch-syscall.exp: execve: program has called execve
continue^M
Continuing.^M
process 32392 is executing new program: catch-syscall^M
Cannot access memory at address 0xf77c6a7c^M
(gdb) FAIL: $exp: execve: syscall execve has returned
...
The memory error is thrown by arm_linux_get_syscall_number, when doing:
...
/* PC gets incremented before the syscall-stop, so read the
previous instruction. */
unsigned long this_instr =
read_memory_unsigned_integer (pc - 4, 4, byte_order_for_code);
...
The reason for the error is that we're stopped at the syscall exit of syscall
execve, and the pc is at the first insn of the new exec, which also happens to
be the first insn in the code segment, so consequently we cannot read the
previous insn.
Fix this by detecting the situation by looking at the register state, similar
to what is done in aarch64_linux_get_syscall_number.
Furthermore, catch the memory error by using safe_read_memory_unsigned_integer
and return -1 instead, matching the documented behaviour of
arm_linux_get_syscall_number.
Finally, rather than using a hardcoded constant 11, introduce an ad-hoc
arm_sys_execve.
Tested on pinebook.
PR tdep/31071
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31071
Diffstat (limited to 'gdb/testsuite/lib/cl_util.c')
0 files changed, 0 insertions, 0 deletions