Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: Tom Tromey <tromey@redhat.com>
Cc: Joel Brobecker <brobecker@adacore.com>, <gdb-patches@sourceware.org>
Subject: Re: [PATCH 1/3] Test of breakpoint output for dprintf
Date: Thu, 10 Jan 2013 14:53:00 -0000	[thread overview]
Message-ID: <50EED5CD.9020802@codesourcery.com> (raw)
In-Reply-To: <20130110054342.GI6143@adacore.com>

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  <yao@codesourcery.com>

	* 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


  reply	other threads:[~2013-01-10 14:53 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-12  4:13 [PATCH 0/3] dprintf tweaks Yao Qi
2012-12-12  4:13 ` [PATCH 1/3] Test of breakpoint output for dprintf Yao Qi
2013-01-09 20:35   ` Tom Tromey
2013-01-10  5:43     ` Joel Brobecker
2013-01-10 14:53       ` Yao Qi [this message]
2013-01-10 14:55         ` Tom Tromey
2013-01-11 15:22         ` [obv] Fix new FAIL on 64-bit targets [Re: [PATCH 1/3] Test of breakpoint output for dprintf] Jan Kratochvil
2012-12-12  4:13 ` [PATCH 3/3] Assert 'printf_line' is non-null Yao Qi
2013-01-09 21:43   ` Tom Tromey
2012-12-12  4:13 ` [PATCH 2/3] Remove dead code for dprintf Yao Qi
2013-01-09 20:45   ` Tom Tromey
2013-01-07 14:16 ` [ping]: [PATCH 0/3] dprintf tweaks Yao Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50EED5CD.9020802@codesourcery.com \
    --to=yao@codesourcery.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox