Fix crash when command arg is missing in faas/taas/tfaas commands.
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Thu, 5 Dec 2019 22:41:58 +0000 (23:41 +0100)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Fri, 6 Dec 2019 05:06:02 +0000 (06:06 +0100)
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.

gdb/ChangeLog
gdb/stack.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/frameapply.exp
gdb/testsuite/gdb.threads/pthreads.exp
gdb/thread.c

index 5e4b9f1b176247ef803585811b8075ee8aaa59de..7646214ca8a3dab296b73898fa0bcf816496dd02 100644 (file)
@@ -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.
index fcb9cdae03787ddd5edbbc6a1819494ac4f0d028..cc7b7e5bbe0a855faf84dbc3471ba516a51694a2 100644 (file)
@@ -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);
 }
index 173e82d59644f63b642fcd4c062e1b8431df292f..79b124b8198fed96f0b45b8047db8148028f06a3 100644 (file)
@@ -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
index ccf30f20796c8582eccc28fca7470dbca276288e..30314876d182928f50d81539af4ceea9471553af 100644 (file)
@@ -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"
index 0bb9083f67a256392c297ef309b3c834e181e846..f633b5ec8e495001e4eb917113c8306c91b3d26d 100644 (file)
@@ -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"
 
 }
 
index 7c8426d6257f4da41cc5ad4465bd7216b34455ee..a210d328ed0e9ec148a7ec52aa8fcc7c8cac05cc 100644 (file)
@@ -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);
This page took 0.03884 seconds and 4 git commands to generate.