aboutsummaryrefslogtreecommitdiff
path: root/gdb/source-cache.c
diff options
context:
space:
mode:
authorPedro Alves <pedro@palves.net>2023-02-08 16:06:23 +0000
committerPedro Alves <pedro@palves.net>2023-02-15 20:58:00 +0000
commit91265a7d7cddc10314335ffcfbfae7159c7cecb1 (patch)
tree3449a623ebe58d5e59ea3c72eb9be336cc0dbc03 /gdb/source-cache.c
parent751495be92b2b319fb66ce4e12b562a0e27c15fe (diff)
downloadbinutils-91265a7d7cddc10314335ffcfbfae7159c7cecb1.zip
binutils-91265a7d7cddc10314335ffcfbfae7159c7cecb1.tar.gz
binutils-91265a7d7cddc10314335ffcfbfae7159c7cecb1.tar.bz2
Add new "$_shell(CMD)" internal function
For testing a following patch, I wanted a way to send a SIGINT to GDB from a breakpoint condition. And I didn't want to do it from a Python breakpoint or Python function, as I wanted to exercise non-Python code paths. So I thought I'd add a new $_shell internal function, that runs a command under the shell, and returns the exit code. With this, I could write: (gdb) b foo if $_shell("kill -SIGINT $gdb_pid") != 0 || <other condition> I think this is generally useful, hence I'm proposing it here. Here's the new function in action: (gdb) p $_shell("true") $1 = 0 (gdb) p $_shell("false") $2 = 1 (gdb) p $_shell("echo hello") hello $3 = 0 (gdb) p $_shell("foobar") bash: line 1: foobar: command not found $4 = 127 (gdb) help function _shell $_shell - execute a shell command and returns the result. Usage: $_shell (command) Returns the command's exit code: zero on success, non-zero otherwise. (gdb) NEWS and manual changes included. Approved-By: Andrew Burgess <aburgess@redhat.com> Approved-By: Tom Tromey <tom@tromey.com> Approved-By: Eli Zaretskii <eliz@gnu.org> Change-Id: I7e36d451ee6b428cbf41fded415ae2d6b4efaa4e
Diffstat (limited to 'gdb/source-cache.c')
0 files changed, 0 insertions, 0 deletions