From patchwork Fri Apr 25 17:46:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Seitz X-Patchwork-Id: 686 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx20.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id B92F9360060 for ; Fri, 25 Apr 2014 10:47:01 -0700 (PDT) Received: by homiemail-mx20.g.dreamhost.com (Postfix, from userid 14314964) id 52F76414CB62A; Fri, 25 Apr 2014 10:47:01 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx20.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-mx20.g.dreamhost.com (Postfix) with ESMTPS id 2F85D417F07C3 for ; Fri, 25 Apr 2014 10:47:01 -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:message-id:date:from:mime-version:to:subject :content-type; q=dns; s=default; b=I0mwPakbo+UbP2yYBCMI6jIF00lBK /QFnNzesVusWZkqeZHfHVWk9XQBmY95oAUECtlczN6VWir62q7RVA9vpkrB/SUmL rPBd7XE7utZMw3eQ3ZT+lboQjN5ttmhel1hnKLgXuuBfYiVzRC3gwtuxaXGYOklV LV273M32AKCaHk= 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:message-id:date:from:mime-version:to:subject :content-type; s=default; bh=zzoUfA8I2iups5qCj+NF1I3PeAE=; b=WoD Uv/4ju0K3LR56FlPpgCUMTc6gIqp+7c5EjT3D+NJluYqrYPDhVxyIvWjbMQ81r9p mgkEpQeMq+WhM/+Shr8kBaSvO2UT6lnkT2x3oGdyjBSPle5MfK+VhzMJYmA3CbKU h7ZiBAbcmopRRqvdpn3luLLkmTKeAKC3xdqa9o4g= Received: (qmail 26941 invoked by alias); 25 Apr 2014 17:46:59 -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 26930 invoked by uid 89); 25 Apr 2014 17:46:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 25 Apr 2014 17:46:58 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s3PHkuH7002065 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 25 Apr 2014 13:46:56 -0400 Received: from valrhona.uglyboxes.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s3PHktpk026488 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Fri, 25 Apr 2014 13:46:56 -0400 Message-ID: <535A9F8F.1080809@redhat.com> Date: Fri, 25 Apr 2014 10:46:55 -0700 From: Keith Seitz User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: "gdb-patches@sourceware.org ml" Subject: [RFA] Fix dangling cleanup in linespec_parse_basic X-IsSubscribed: yes X-DH-Original-To: gdb@patchwork.siddhesh.in Hi, For a linespec such as "filename:$convenience_variable", the local variable holding the name of the convenience variable ('name' in the code) is not freed if no parsing error occurred, i.e., the convenience variable is defined. This leaves a dangling cleanup. The error case was already properly handling the cleanup. This patch adds the appropriate cleanup handling when there is no error. I've also added a test for this to ls-dollar.exp. Ok? Keith ChangeLog 2014-04-25 Keith Seitz * linespec.c (linespec_parse_basic): Run cleanups if a convenience variable or history value is successfully parsed. testsuite/ChangeLog 2014-04-25 Keith Seitz * gdb.linespec/ls-dollar.exp: Add test for linespec file:convenience_variable. diff --git a/gdb/linespec.c b/gdb/linespec.c index 610809d..cb76b9c 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -1665,6 +1665,10 @@ linespec_parse_basic (linespec_parser *parser) discard_cleanups (cleanup); return; } + + /* The convenience variable/history value parsed correctly. + NAME is no longer needed. */ + do_cleanups (cleanup); } else { diff --git a/gdb/testsuite/gdb.linespec/ls-dollar.exp b/gdb/testsuite/gdb.linespec/ls-dollar.exp index 2e35804..bccc40a 100644 --- a/gdb/testsuite/gdb.linespec/ls-dollar.exp +++ b/gdb/testsuite/gdb.linespec/ls-dollar.exp @@ -30,7 +30,16 @@ if {[prepare_for_testing $testfile $exefile $srcfile \ gdb_test_no_output "set listsize 1" +set line [gdb_get_line_number {dollar_func}] + gdb_test "list \$dollar_var" \ ".*static int [string_to_regexp {$dollar_var}] = 0;" gdb_test "break \$dollar_func" \ - "Breakpoint $decimal at $hex: file .*$srcfile, line [gdb_get_line_number {dollar_func}]\\\." + "Breakpoint $decimal at $hex: file .*$srcfile, line $line\\\." + +gdb_test_no_output "set var \$theline = $line" +gdb_test "list $srcfile:\$theline" \ + ".*[string_to_regexp {/* dollar_func */}]" + +gdb_test "break $srcfile:\$theline" \ + "Breakpoint $decimal at $hex: file .*$srcfile, line $line\\\."