From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4995 invoked by alias); 10 Jan 2013 14:53:39 -0000 Received: (qmail 4986 invoked by uid 22791); 10 Jan 2013 14:53:38 -0000 X-SWARE-Spam-Status: No, hits=-4.6 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 10 Jan 2013 14:53:31 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1TtJVZ-0000O6-Um from Yao_Qi@mentor.com ; Thu, 10 Jan 2013 06:53:29 -0800 Received: from SVR-ORW-FEM-05.mgc.mentorg.com ([147.34.97.43]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Thu, 10 Jan 2013 06:53:29 -0800 Received: from qiyao.dyndns.org (147.34.91.1) by svr-orw-fem-05.mgc.mentorg.com (147.34.97.43) with Microsoft SMTP Server id 14.1.289.1; Thu, 10 Jan 2013 06:53:28 -0800 Message-ID: <50EED5CD.9020802@codesourcery.com> Date: Thu, 10 Jan 2013 14:53:00 -0000 From: Yao Qi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Tom Tromey CC: Joel Brobecker , Subject: Re: [PATCH 1/3] Test of breakpoint output for dprintf References: <1355285581-28889-1-git-send-email-yao@codesourcery.com> <1355285581-28889-2-git-send-email-yao@codesourcery.com> <87vcb6w0v7.fsf@fleche.redhat.com> <20130110054342.GI6143@adacore.com> In-Reply-To: <20130110054342.GI6143@adacore.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2013-01/txt/msg00197.txt.bz2 On 01/10/2013 01:43 PM, Joel Brobecker wrote: >> Yao> +gdb_test "info breakpoints" "3\[\t \]+dprintf .* >> Yao> +\[\t \]+printf \"At foo entry\\\\n\". >> Yao> +\[\t \]+continue. >> Yao> +4\[\t \]+dprintf .* >> Yao> +\[\t \]+printf \"arg=%d, g=%d\\\\n\", arg, g. >> Yao> +\[\t \]+continue." "dprintf info 1" >> >> I find this style of test pretty hard to read. >> How about using "\n" instead of a newline? >> Or writing the string some other way to make it more readable? > > FWIW, I sometimes do the following when writing tests: > > gdb_test "info tasks" \ > [join {" +ID +TID P-ID Pri State +Name" \ > " +1 .* main_task" \ > " +2 .* task_list\\(1\\)" \ > "\\* +3 .* task_list\\(2\\)" \ > " +4 .* task_list\\(3\\)"} \ > "\r\n"] \ > "info tasks after hitting breakpoint" > > I find that having a multi-line expected output shown as multiple > lines is easier to understand than one ginormous string... > I agree, and that is why I break pattern into several lines. I use gdb_test_sequence in the new version of patch, which looks better. gdb_test_sequence "info breakpoints" "dprintf info 2" { "\[\r\n\]Num Type Disp Enb Address What" "\[\r\n\]2 breakpoint" "\[\r\n\]\tbreakpoint already hit 2 times" "\[\r\n\]3 dprintf" "\[\r\n\]\tbreakpoint already hit 2 times" "\[\r\n\] agent-printf \"At foo entry\\\\n\"" "\[\r\n\]4 dprintf" "\[\r\n\]\tbreakpoint already hit 2 times" "\[\r\n\] agent-printf \"arg=%d, g=%d\\\\n\", arg, g" } How about the new version? -- Yao (齐尧) gdb/testsuite: 2013-01-10 Yao Qi * gdb.base/dprintf.exp: Check the output of 'info breakpoints' for dprintf. * gdb.mi/mi-breakpoint-changed.exp (test_insert_delete_modify): Check the fields in "=breakpoint-created" for dprintf. --- gdb/testsuite/gdb.base/dprintf.exp | 22 ++++++++++++++++++++++ gdb/testsuite/gdb.mi/mi-breakpoint-changed.exp | 2 +- 2 files changed, 23 insertions(+), 1 deletions(-) diff --git a/gdb/testsuite/gdb.base/dprintf.exp b/gdb/testsuite/gdb.base/dprintf.exp index f99d75e..fb626fa 100644 --- a/gdb/testsuite/gdb.base/dprintf.exp +++ b/gdb/testsuite/gdb.base/dprintf.exp @@ -43,6 +43,17 @@ gdb_test "dprintf foo,\"At foo entry\\n\"" \ gdb_test "dprintf $dp_location1,\"arg=%d, g=%d\\n\", arg, g" \ "Dprintf .*" +gdb_test_sequence "info breakpoints" "dprintf info 1" { + "\[\r\n\]Num Type Disp Enb Address What" + "\[\r\n\]2 breakpoint" + "\[\r\n\]3 dprintf" + "\[\r\n\] printf \"At foo entry\\\\n\"" + "\[\r\n\] continue" + "\[\r\n\]4 dprintf" + "\[\r\n\] printf \"arg=%d, g=%d\\\\n\", arg, g" + "\[\r\n\] continue" +} + gdb_test "break $bp_location1" \ "Breakpoint .*" @@ -107,6 +118,17 @@ if $target_can_dprintf { gdb_test "continue" "Breakpoint \[0-9\]+, foo .*" "2nd dprintf, agent" + gdb_test_sequence "info breakpoints" "dprintf info 2" { + "\[\r\n\]Num Type Disp Enb Address What" + "\[\r\n\]2 breakpoint" + "\[\r\n\]\tbreakpoint already hit 2 times" + "\[\r\n\]3 dprintf" + "\[\r\n\]\tbreakpoint already hit 2 times" + "\[\r\n\] agent-printf \"At foo entry\\\\n\"" + "\[\r\n\]4 dprintf" + "\[\r\n\]\tbreakpoint already hit 2 times" + "\[\r\n\] agent-printf \"arg=%d, g=%d\\\\n\", arg, g" + } } gdb_test "set dprintf-style foobar" "Undefined item: \"foobar\"." \ diff --git a/gdb/testsuite/gdb.mi/mi-breakpoint-changed.exp b/gdb/testsuite/gdb.mi/mi-breakpoint-changed.exp index 7ce314d..fd32698 100644 --- a/gdb/testsuite/gdb.mi/mi-breakpoint-changed.exp +++ b/gdb/testsuite/gdb.mi/mi-breakpoint-changed.exp @@ -96,7 +96,7 @@ proc test_insert_delete_modify { } { $test set test "dprintf marker, \"arg\" \"" mi_gdb_test $test \ - {.*=breakpoint-created,bkpt=\{number="6",type="dprintf".*\}.*\n\^done} \ + {.*=breakpoint-created,bkpt=\{number="6",type="dprintf".*,script=\{\"printf \\\\\"arg\\\\\" \\\\\"\",\"continue\"\}.*\}\r\n\^done} \ $test # 2. when modifying condition -- 1.7.7.6