diff options
author | Philippe Waroquiers <philippe.waroquiers@skynet.be> | 2019-12-05 23:41:58 +0100 |
---|---|---|
committer | Philippe Waroquiers <philippe.waroquiers@skynet.be> | 2019-12-06 06:06:02 +0100 |
commit | e0fad1eadfcb68d543cdd96f44dca86364778fa2 (patch) | |
tree | 68b36fc2f7ffd19d3bc886bac5e9ef0bea5bc1c1 | |
parent | 8fc52a054bb7954813ff62adc6187c1072f09e8b (diff) | |
download | binutils-e0fad1eadfcb68d543cdd96f44dca86364778fa2.zip binutils-e0fad1eadfcb68d543cdd96f44dca86364778fa2.tar.gz binutils-e0fad1eadfcb68d543cdd96f44dca86364778fa2.tar.bz2 |
Fix crash when command arg is missing in faas/taas/tfaas commands.
GDB crashes when doing:
(gdb) faas
Aborted
Do the needed check to avoid crashing.
gdb/ChangeLog
2019-12-06 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* stack.c (faas_command): Check a command is provided.
* thread.c (taas_command, tfaas_command): Likewise.
gdb/testsuite/ChangeLog
2019-12-06 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* gdb.threads/pthreads.exp: Test taas and tfaas without command.
* gdb.base/frameapply.exp: Test faas without command.
-rw-r--r-- | gdb/ChangeLog | 4 | ||||
-rw-r--r-- | gdb/stack.c | 2 | ||||
-rw-r--r-- | gdb/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/frameapply.exp | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.threads/pthreads.exp | 6 | ||||
-rw-r--r-- | gdb/thread.c | 4 |
6 files changed, 22 insertions, 1 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 5e4b9f1..7646214 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2019-12-06 Philippe Waroquiers <philippe.waroquiers@skynet.be> + * stack.c (faas_command): Check a command is provided. + * thread.c (taas_command, tfaas_command): Likewise. + 2019-12-05 Philippe Waroquiers <philippe.waroquiers@skynet.be> * inferior.c (prune_inferiors): Only call delete_inferior, Do not modify the inferior list. diff --git a/gdb/stack.c b/gdb/stack.c index fcb9cda..cc7b7e5 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -3281,6 +3281,8 @@ frame_apply_command (const char* cmd, int from_tty) static void faas_command (const char *cmd, int from_tty) { + if (cmd == NULL || *cmd == '\0') + error (_("Please specify a command to apply on all frames")); std::string expanded = std::string ("frame apply all -s ") + cmd; execute_command (expanded.c_str (), from_tty); } diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 173e82d..79b124b 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-12-06 Philippe Waroquiers <philippe.waroquiers@skynet.be> + + * gdb.threads/pthreads.exp: Test taas and tfaas without command. + * gdb.base/frameapply.exp: Test faas without command. + 2019-12-04 Andrew Burgess <andrew.burgess@embecosm.com> * lib/gdb.exp (gdb_compile): Add -J compiler option when building diff --git a/gdb/testsuite/gdb.base/frameapply.exp b/gdb/testsuite/gdb.base/frameapply.exp index ccf30f2..3031487 100644 --- a/gdb/testsuite/gdb.base/frameapply.exp +++ b/gdb/testsuite/gdb.base/frameapply.exp @@ -215,3 +215,5 @@ gdb_test "frame apply level 4-2 p 1" "inverted range" "inverted range" gdb_test "frame apply level 0-3" \ "Please specify a command to apply on the selected frames" \ "missing command" +gdb_test "faas" "Please specify a command to apply on all frames" \ + "missing command for faas" diff --git a/gdb/testsuite/gdb.threads/pthreads.exp b/gdb/testsuite/gdb.threads/pthreads.exp index 0bb9083..f633b5e 100644 --- a/gdb/testsuite/gdb.threads/pthreads.exp +++ b/gdb/testsuite/gdb.threads/pthreads.exp @@ -334,10 +334,14 @@ proc check_qcs {} { ] \ "run a failing command except in one frame of thread 2,3, -s to silently continue. Do not show thread and frame info" - # Check invalid flag combinations. + # Check invalid flag combinations and errors. gdb_test "thread apply all -c -s p 1" \ "thread apply all: -c and -s are mutually exclusive" \ "check -c and -s cannot be used simultaneously" + gdb_test "taas" "Please specify a command to apply on all threads" \ + "missing command for taas" + gdb_test "tfaas" "Please specify a command to apply on all frames of all threads" \ + "missing command for tfaas" } diff --git a/gdb/thread.c b/gdb/thread.c index 7c8426d..a210d32 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -1818,6 +1818,8 @@ thread_apply_command (const char *tidlist, int from_tty) static void taas_command (const char *cmd, int from_tty) { + if (cmd == NULL || *cmd == '\0') + error (_("Please specify a command to apply on all threads")); std::string expanded = std::string ("thread apply all -s ") + cmd; execute_command (expanded.c_str (), from_tty); } @@ -1827,6 +1829,8 @@ taas_command (const char *cmd, int from_tty) static void tfaas_command (const char *cmd, int from_tty) { + if (cmd == NULL || *cmd == '\0') + error (_("Please specify a command to apply on all frames of all threads")); std::string expanded = std::string ("thread apply all -s -- frame apply all -s ") + cmd; execute_command (expanded.c_str (), from_tty); |