From patchwork Thu Dec 5 23:05:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Waroquiers X-Patchwork-Id: 36548 Received: (qmail 107242 invoked by alias); 5 Dec 2019 23:05:35 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 107229 invoked by uid 89); 5 Dec 2019 23:05:35 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=crashing, HContent-Transfer-Encoding:8bit X-HELO: mailsec106.isp.belgacom.be Received: from mailsec106.isp.belgacom.be (HELO mailsec106.isp.belgacom.be) (195.238.20.102) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 05 Dec 2019 23:05:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=skynet.be; i=@skynet.be; q=dns/txt; s=securemail; t=1575587134; x=1607123134; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=yXx1Xeqh+2bE8Tra+ALWSE4GNSYrHwtN9NC4PYa0UoA=; b=j/WdwsVcK3EEYsXLgMTHAZZQ1NLdhv+ZJBZXuKs4KId0zb3v7L0U3ppA WRymUvPyOYfGepITKTltz21h1dji+A==; IronPort-SDR: Kh80gEORLYuerJDcNSiS/K4z1YdsEDPkgpMznayhNr/mOQAkukbsB5os7Uk+SVXfpVLhVK5RDX dk6g1iJU7GhoFm62TyIdBYe66jRJw4fIUFy+C7JhD+/A2R6v8dgtwwYlxZks2I6I0lvyTbjaGx pJfm+zVAtWlWwDoul6kfD61YJLM4B7yOu+8w73cNYKRN0zpobskKB2nJOQdEarlgUsczntccCe LBWvhwTb5IL1bMWi+ceSpkVQNT4QWfyP3q2igvFvRsActbqXdBOEBaFT8e822nSUB4vpQ9i0so i+s= Received: from 136.173-134-109.adsl-dyn.isp.belgacom.be (HELO md.home) ([109.134.173.136]) by relay.skynet.be with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 06 Dec 2019 00:05:32 +0100 From: Philippe Waroquiers To: gdb-patches@sourceware.org Cc: Philippe Waroquiers Subject: [RFA] Fix crash when command arg is missing in faas/taas/tfaas commands. Date: Fri, 6 Dec 2019 00:05:25 +0100 Message-Id: <20191205230525.19171-1-philippe.waroquiers@skynet.be> MIME-Version: 1.0 X-IsSubscribed: yes GDB crashes when doing: (gdb) faas Aborted Do the needed check to avoid crashing. gdb/ChangeLog 2019-12-05 Philippe Waroquiers * stack.c (faas_command): Check a command is provided. * thread.c (taas_command, tfaas_command): Likewise. gdb/testsuite/ChangeLog 2019-12-05 Philippe Waroquiers * gdb.threads/pthreads.exp: Test taas and tfaas without command. * gdb.base/frameapply.exp: Test faas without command. --- gdb/stack.c | 2 ++ gdb/testsuite/gdb.base/frameapply.exp | 2 ++ gdb/testsuite/gdb.threads/pthreads.exp | 6 +++++- gdb/thread.c | 4 ++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/gdb/stack.c b/gdb/stack.c index fcb9cdae03..cc7b7e5bbe 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/gdb.base/frameapply.exp b/gdb/testsuite/gdb.base/frameapply.exp index ccf30f2079..30314876d1 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 0bb9083f67..f633b5ec8e 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 7c8426d625..a210d328ed 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);