[gdb/breakpoints] Fix segfault for catch syscall -1
authorTom de Vries <tdevries@suse.de>
Fri, 5 Feb 2021 16:47:07 +0000 (17:47 +0100)
committerTom de Vries <tdevries@suse.de>
Fri, 5 Feb 2021 16:47:07 +0000 (17:47 +0100)
commit0e857c82883cff04ccc8868762c78b0e94ccde91
tree2da77697ed1016db5c8fadd40e36327f88d57085
parentbdfea17ea9bbd9f92ad19a70d770af42473d9c07
[gdb/breakpoints] Fix segfault for catch syscall -1

Using a hello world a.out, I run into a segfault:
...
$ gcc hello.c
$ gdb -batch a.out -ex "catch syscall -1" -ex r
Catchpoint 1 (syscall -1)
Aborted (core dumped)
...

Fix this by erroring out if a negative syscall number is used in the
catch syscall command.

Tested on x86_64-linux.

gdb/ChangeLog:

2021-02-05  Tom de Vries  <tdevries@suse.de>

PR breakpoints/27313
* break-catch-syscall.c (catch_syscall_split_args): Reject negative
syscall numbers.

gdb/testsuite/ChangeLog:

2021-02-05  Tom de Vries  <tdevries@suse.de>

PR breakpoints/27313
* gdb.base/catch-syscall.exp: Check that "catch syscall -1" is
rejected.
gdb/ChangeLog
gdb/break-catch-syscall.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/catch-syscall.exp