diff options
author | Tom de Vries <tdevries@suse.de> | 2023-11-21 13:57:19 +0100 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2023-11-21 13:57:19 +0100 |
commit | d80aef339f6c7c30da28f79056725eedd64f84d7 (patch) | |
tree | 07af9834a72ff597a205158f1b6995cb8aa46bad /gdb | |
parent | 42ffc15774fc791f2ac9a719e81589c8e91bdb98 (diff) | |
download | gdb-d80aef339f6c7c30da28f79056725eedd64f84d7.zip gdb-d80aef339f6c7c30da28f79056725eedd64f84d7.tar.gz gdb-d80aef339f6c7c30da28f79056725eedd64f84d7.tar.bz2 |
[gdb/tdep] Handle memory error in s390_linux_get_syscall_number
In s390_linux_get_syscall_number, we use read_memory_unsigned_integer, which
can throw a memory error.
According to the function comment though, it should return -1 on error:
...
/* Retrieve the syscall number at a ptrace syscall-stop. Return -1
upon error. */
...
Catch the memory error by using safe_read_memory_unsigned_integer instead,
similar to how that was fixed for arm in commit eb42bb14895 ("[gdb/tdep] Fix
catching syscall execve exit for arm").
Approved-By: Ulrich Weigand <uweigand@de.ibm.com>
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/s390-linux-tdep.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/gdb/s390-linux-tdep.c b/gdb/s390-linux-tdep.c index ae45ec6..1eaeff3 100644 --- a/gdb/s390-linux-tdep.c +++ b/gdb/s390-linux-tdep.c @@ -572,12 +572,21 @@ s390_linux_get_syscall_number (struct gdbarch *gdbarch, don't currently support SVC via EXECUTE. */ regcache_cooked_read_unsigned (regs, tdep->pc_regnum, &pc); pc -= 2; - opcode = read_memory_unsigned_integer ((CORE_ADDR) pc, 1, byte_order); + + ULONGEST val; + if (!safe_read_memory_unsigned_integer ((CORE_ADDR) pc, 1, byte_order, + &val)) + return -1; + opcode = val; + if (opcode != op_svc) return -1; - svc_number = read_memory_unsigned_integer ((CORE_ADDR) pc + 1, 1, - byte_order); + if (!safe_read_memory_unsigned_integer ((CORE_ADDR) pc + 1, 1, byte_order, + &val)) + return -1; + svc_number = val; + if (svc_number == 0) regcache_cooked_read_unsigned (regs, S390_R1_REGNUM, &svc_number); |