This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 2/4] Test case of conditional dprintf


This is to test that dprintf works well with condition.  Since print
stuff in dprintf is implemented as commands, so there should be no
FAIL without patch 1/5 applied.

Note that this case is similar to

  PR 15179 - Dprintf interrupts execution when condition is false

but I am still unable to reproduce this PR.  dprintf-cond.exp can easily
extended to reproduce PR 15180 in next step.

gdb/testsuite:

2013-02-28  Yao Qi  <yao@codesourcery.com>

     * gdb.base/dprintf-cond.exp: New.
---
 gdb/testsuite/gdb.base/dprintf-cond.exp |   75 +++++++++++++++++++++++++++++++
 1 files changed, 75 insertions(+), 0 deletions(-)
 create mode 100644 gdb/testsuite/gdb.base/dprintf-cond.exp

diff --git a/gdb/testsuite/gdb.base/dprintf-cond.exp b/gdb/testsuite/gdb.base/dprintf-cond.exp
new file mode 100644
index 0000000..b692124
--- /dev/null
+++ b/gdb/testsuite/gdb.base/dprintf-cond.exp
@@ -0,0 +1,75 @@
+# Copyright 2013 Free Software Foundation, Inc.
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+standard_testfile pr15075.c
+
+set executable $testfile
+set expfile $testfile.exp
+
+set dp_location [gdb_get_line_number "set dprintf here"]
+set bp_location [expr $dp_location + 1]
+
+if [prepare_for_testing $expfile $executable $srcfile {debug}] {
+    untested "failed to prepare for trace tests"
+    return -1
+}
+
+proc test_dprintf { style } { with_test_prefix "$style" {
+
+    global executable
+    global dp_location bp_location
+
+    # Start with a fresh gdb.
+    clean_restart ${executable}
+    if ![runto_main] {
+	fail "Can't run to main"
+	return -1
+    }
+
+    gdb_test_no_output "set dprintf-style ${style}" \
+	"Set dprintf style"
+    gdb_test "dprintf $dp_location, \"false, %d\\n\", x" \
+	"Dprintf 2 at .*" "dprintf 1"
+    gdb_test "cond 2 x == 5"
+
+    gdb_test "dprintf $dp_location, \"true, %d\\n\", x" \
+	"Dprintf 3 at .*" "dprintf 2"
+    gdb_test "cond 3 x > 5"
+
+    gdb_test "break $bp_location" "Breakpoint .*"
+
+    gdb_test "continue" "true, 6\\r\\n\\r\\n.*" "continue"
+
+    # Test program stops on the right breakpoint.
+    gdb_test "p x" ".* = 7"
+
+    # Test the hit count of dprintf breakpoints.
+    gdb_test_sequence "info breakpoints" "dprintf info" {
+	"\[\r\n\]Num     Type           Disp Enb Address +What"
+	"\[\r\n\]1       breakpoint"
+	"\[\r\n\]2       dprintf"
+	"\[\r\n\]\tstop only if x == 5"
+	"\[\r\n\]"
+	"\[\r\n\]3       dprintf"
+	"\[\r\n\]\tstop only if x > 5"
+	"\[\r\n\]\tbreakpoint already hit 1 time"
+	"\[\r\n\]"
+    }
+}}
+
+test_dprintf "gdb"
+
+if ![target_info exists gdb,noinferiorio] {
+    test_dprintf "call"
+}
-- 
1.7.7.6


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]