This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 1/3] Test of breakpoint output for dprintf
- From: Yao Qi <yao at codesourcery dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: Joel Brobecker <brobecker at adacore dot com>, <gdb-patches at sourceware dot org>
- Date: Thu, 10 Jan 2013 22:53:01 +0800
- 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>
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