From patchwork Thu Mar 13 02:32:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 60 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx22.g.dreamhost.com (caibbdcaabij.dreamhost.com [208.113.200.189]) by wilcox.dreamhost.com (Postfix) with ESMTP id 5FFFE360068 for ; Wed, 12 Mar 2014 19:35:30 -0700 (PDT) Received: by homiemail-mx22.g.dreamhost.com (Postfix, from userid 14314964) id 1D15B4EE9376; Wed, 12 Mar 2014 19:35:25 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx22.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx22.g.dreamhost.com (Postfix) with ESMTPS id EF31E4EE9375 for ; Wed, 12 Mar 2014 19:35:24 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type; q=dns; s=default; b=EV6vl B8l+csvQqFDyKz+5U811Za4jlnzNov9EaC8llI3GIo57kX/kphAWowp8pY2/ry5r 9mVdAXCI7Bth6IBKeVm3qT8CSKNCUEvFra2VI6ByRSUCoB97n08siMvUOs32ptmu x5Y7bmgBLW5RuTgtQXmNh0J4oBApirHYxAA/+g= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type; s=default; bh=EJY0KTI9c/2 rSsticDG29N9+O4A=; b=c4VdbFpSUlpJ+5LBKVLptGk1eM+vuElZ/frx9CDeK7n MeqgiKWgjnDv8Jwzs2/ch7Vu9QfPAJoQGYw6/+Hc8eDJEZhyLcpCJ3kA5GUCcBaz If2tQTj1FGQ1kIqw36zH3MWRLKDZ/Xfm/VEZACk0V6NaVmXyPrsXjFX0Yza9Jiwo = Received: (qmail 5778 invoked by alias); 13 Mar 2014 02:35:12 -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 5668 invoked by uid 89); 13 Mar 2014 02:35:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Mar 2014 02:35:10 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1WNvUC-0001PD-5x from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Wed, 12 Mar 2014 19:35:08 -0700 Received: from SVR-ORW-FEM-03.mgc.mentorg.com ([147.34.97.39]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Wed, 12 Mar 2014 19:35:08 -0700 Received: from qiyao.dyndns.org.com (147.34.91.1) by svr-orw-fem-03.mgc.mentorg.com (147.34.97.39) with Microsoft SMTP Server id 14.2.247.3; Wed, 12 Mar 2014 19:35:07 -0700 From: Yao Qi To: Subject: [PATCH 3/5] Emit wrong value error when parsing range Date: Thu, 13 Mar 2014 10:32:28 +0800 Message-ID: <1394677950-4054-4-git-send-email-yao@codesourcery.com> In-Reply-To: <1394677950-4054-1-git-send-email-yao@codesourcery.com> References: <1394677950-4054-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 X-IsSubscribed: yes X-DH-Original-To: gdb@patchwork.siddhesh.in The current code in get_number_or_range doesn't check the return value of get_number, so current gdb does: (gdb) thread apply 1-1.2 bt inverted range which is a little bit confusing. This patch adds a check to get_number's return value, and emit error "wrong value" if return value is zero. With this patch applied, gdb prints: (gdb) thread apply 1-1.2 bt wrong value gdb: 2014-03-13 Yao Qi * cli/cli-utils.c (get_number_or_range): Error out if get_number returns zero. --- gdb/cli/cli-utils.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/gdb/cli/cli-utils.c b/gdb/cli/cli-utils.c index a0ebc11..d59a231 100644 --- a/gdb/cli/cli-utils.c +++ b/gdb/cli/cli-utils.c @@ -146,7 +146,9 @@ get_number_or_range (struct get_number_or_range_state *state) temp = &state->end_ptr; state->end_ptr = skip_spaces (state->string + 1); state->end_value = get_number (temp); - if (state->end_value < state->last_retval) + if (state->end_value == 0) + error (_("wrong value")); + else if (state->end_value < state->last_retval) { error (_("inverted range")); }