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>
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);