From patchwork Wed Apr 16 18:52:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Seitz X-Patchwork-Id: 580 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx21.g.dreamhost.com (peon2454.g.dreamhost.com [208.113.200.127]) by wilcox.dreamhost.com (Postfix) with ESMTP id 66B3A36007A for ; Wed, 16 Apr 2014 11:52:14 -0700 (PDT) Received: by homiemail-mx21.g.dreamhost.com (Postfix, from userid 14314964) id 263A2128A82A; Wed, 16 Apr 2014 11:52:14 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx21.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-mx21.g.dreamhost.com (Postfix) with ESMTPS id E407C131BD97 for ; Wed, 16 Apr 2014 11:52:13 -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=TWQ2c6B9688cbyrcNFqDybj1vztq+ waw06KxfglOnaGYc0O8bxQvlimAQnU9MqAoLY0ZA8JbjLBlEimAKuFmaO8Ds0GO1 RPr9XdQVElat+A+SItotMByx+OSRwltrK4TQeyoQy9vKn8SPHRQpFxHBl24qYpi9 AtM302PDeaPx7k= 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=cGL9UI3FdGctm+rJKZEBZsVclI0=; b=oNZ 8LmEjWaL4l4h9u136VhwsZSqdkkRycipJwASP+xjAHEwdX0bffNND0NcVEs+FrDa btmuK67l8bmZCrasdnzYeAEFpGyJBS4sm70YQiQbszppHWiJf1vJOAXjEVM0/7Vh CxR8NshhnNWrMp0xW1YEWRaSh8h5NaAv71sNLwTM= Received: (qmail 455 invoked by alias); 16 Apr 2014 18:52: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 442 invoked by uid 89); 16 Apr 2014 18:52:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 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; Wed, 16 Apr 2014 18:52:11 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s3GIqAxN006631 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 16 Apr 2014 14:52:10 -0400 Received: from valrhona.uglyboxes.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s3GIq9tS015365 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Wed, 16 Apr 2014 14:52:09 -0400 Message-ID: <534ED159.8050304@redhat.com> Date: Wed, 16 Apr 2014 11:52:09 -0700 From: Keith Seitz User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: "gdb-patches@sourceware.org ml" Subject: [RFA testsuite 3/5] Introduce mi_make_breakpoint X-IsSubscribed: yes X-DH-Original-To: gdb@patchwork.siddhesh.in This next patch introduces mi_make_breakpoint. This function builds breakpoint regexps, such as "bkpt={number=\".*\", [snip]}". I've also taken this time to change mi_create_breakpoint to use the same interface as this function and return the result. Note that ONLY the options given to mi_make_breakpoint/mi_create_breakpoint will actually be tested. So if -number is omitted, the regexp will allow anything [number=\".*\"] It gets a little tricky with optional arguments, like -script and -ignore, but as far as I know, I've handled all those cases. Examples: # Create a breakpoint regexp which only looks for "number=\"3\"" mi_make_breakpoint -number 3 # Create a breakpoint in myfile.c:21 mi_create_breakpoint "myfile.c:21" -file myfile.c -line 21 testsuite/ChangeLog 2014-04-15 Keith Seitz * lib/mi-support.exp (mi_create_breakpoint): Use mi_make_breakpoint and return the result. (mi_make_breakpoint): New procedure. diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp index abbcd8d..fa778eb 100644 --- a/gdb/testsuite/lib/mi-support.exp +++ b/gdb/testsuite/lib/mi-support.exp @@ -1232,12 +1232,14 @@ proc mi0_continue_to { bkptno func args file line test } { "$func" "$args" "$file" "$line" "" "$test" } -# Creates a breakpoint and checks the reported fields are as expected -proc mi_create_breakpoint { location number disp func file line address test } { - verbose -log "Expecting: 222\\^done,bkpt=\{number=\"$number\",type=\"breakpoint\",disp=\"$disp\",enabled=\"y\",addr=\"$address\",func=\"$func\",file=\"$file\",fullname=\".*\",line=\"$line\",thread-groups=\\\[\".*\"\\\],times=\"0\",original-location=\".*\"\}" - mi_gdb_test "222-break-insert $location" \ - "222\\^done,bkpt=\{number=\"$number\",type=\"breakpoint\",disp=\"$disp\",enabled=\"y\",addr=\"$address\",func=\"$func\",file=\"$file\",fullname=\".*\",line=\"$line\",thread-groups=\\\[\".*\"\\\],times=\"0\",original-location=\".*\"\}" \ - $test +# Creates a breakpoint and checks the reported fields are as expected. +# This procedure takes the same options as mi_make_breakpoint and +# returns the breakpoint regexp from that procedure. + +proc mi_create_breakpoint {location test args} { + set bp [eval mi_make_breakpoint $args] + mi_gdb_test "222-break-insert $location" "222\\^done,$bp" $test + return $bp } proc mi_list_breakpoints { expected test } { @@ -2376,3 +2378,56 @@ proc mi_build_kv_pairs {attr_list {joiner ,}} { } return "[join $l $joiner]" } + +# Construct a breakpoint regexp. This may be used to test the output of +# -break-insert, -dprintf-insert, or -break-info. +# +# All arguments for the breakpoint may be specified using the options +# number, type, disp, enabled, addr, func, file, fullanme, line, +# thread-groups, times, ignore, script, and original-location. +# +# Only if -script and -ignore are given will they appear in the output. +# Otherwise, this procedure will skip them using ".*". +# +# Example: mi_make_breakpoint -number 2 -file ".*/myfile.c" -line 3 +# will return the breakpoint: +# bkpt={number="2",type=".*",disp=".*",enabled=".*",addr=".*",func=".*", +# file=".*/myfile.c",fullname=".*",line="3",thread-groups=\[.*\], +# times="0".*original-location=".*"} + +proc mi_make_breakpoint {args} { + parse_args {{number .*} {type .*} {disp .*} {enabled .*} {addr .*} \ + {func .*} {file .*} {fullname .*} {line .*} \ + {thread-groups \\\[.*\\\]} {times .*} {ignore 0} \ + {script ""} {original-location .*}} + + set attr_list {} + foreach attr [list number type disp enabled addr func file \ + fullname line thread-groups times] { + lappend attr_list $attr [set $attr] + } + + set result "bkpt={[mi_build_kv_pairs $attr_list]" + + # There are always exceptions. + # If SCRIPT and IGNORE are not present, do not output them. + if {$ignore != 0} { + append result "," + append result [mi_build_kv_pairs [list "ignore" $ignore]] + append result "," + } + if {[string length $script] > 0} { + append result "," + append result [mi_build_kv_pairs [list "script" $script]] + append result "," + } else { + # Allow anything up until the next "official"/required attribute. + # This pattern skips over script/ignore if matches on those + # were not specifically required by the caller. + append result ".*" + } + append result [mi_build_kv_pairs \ + [list "original-location" ${original-location}]] + append result "}" + return $result +}