Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Unified Diff: gdb/testsuite/gdb.base/dprintf.exp

Issue 11969036: Merge GDB 7.5.1 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@master
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gdb/testsuite/gdb.base/dprintf.c ('k') | gdb/testsuite/gdb.base/dump.exp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gdb/testsuite/gdb.base/dprintf.exp
diff --git a/gdb/testsuite/gdb.base/dprintf.exp b/gdb/testsuite/gdb.base/dprintf.exp
new file mode 100644
index 0000000000000000000000000000000000000000..bd0615b783b55ad512f23131ef52116f01998beb
--- /dev/null
+++ b/gdb/testsuite/gdb.base/dprintf.exp
@@ -0,0 +1,114 @@
+# Copyright (C) 2012 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/>.
+
+
+if { [prepare_for_testing dprintf.exp "dprintf" {} {debug}] } {
+ return -1
+}
+
+set srcfile dprintf.c
+
+set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
+set dp_location1 [gdb_get_line_number "set dprintf 1 here"]
+
+if ![runto main] {
+ return -1
+}
+
+gdb_test "dprintf" "Format string required"
+
+gdb_test "dprintf foo" "Format string required"
+
+gdb_test "dprintf 29" "Format string required"
+
+delete_breakpoints
+
+gdb_breakpoint "main"
+
+gdb_test "dprintf foo,\"At foo entry\\n\"" \
+ "Dprintf .*"
+
+gdb_test "dprintf $dp_location1,\"arg=%d, g=%d\\n\", arg, g" \
+ "Dprintf .*"
+
+gdb_test "break $bp_location1" \
+ "Breakpoint .*"
+
+gdb_run_cmd
+
+gdb_test "" "Breakpoint"
+
+gdb_test "continue" "At foo entry.*arg=1234, g=1234.*" "1st dprintf, gdb"
+
+gdb_test "continue" "At foo entry.*arg=1235, g=2222.*" "2nd dprintf, gdb"
+
+# The "call" style depends on having I/O functions available, so test.
+
+if ![target_info exists gdb,noinferiorio] {
+
+ # Now switch styles and rerun; in the absence of redirection the
+ # output should be the same.
+
+ gdb_test_no_output "set dprintf-style call" "Set dprintf style to call"
+
+ gdb_run_cmd
+
+ gdb_test "" "Breakpoint"
+
+ gdb_test "continue" "At foo entry.*arg=1234, g=1234.*" "1st dprintf, call"
+
+ gdb_test "continue" "At foo entry.*arg=1235, g=2222.*" "2nd dprintf, call"
+
+ gdb_test_no_output "set dprintf-function fprintf" "Set dprintf function"
+ gdb_test_no_output "set dprintf-channel stderr" "Set dprintf channel"
+
+ gdb_run_cmd
+
+ gdb_test "" "Breakpoint"
+
+ gdb_test "continue" "At foo entry.*arg=1234, g=1234.*" \
+ "1st dprintf, fprintf"
+
+ gdb_test "continue" "At foo entry.*arg=1235, g=2222.*" \
+ "2nd dprintf, fprintf"
+}
+
+set target_can_dprintf 1
+set msg "Set dprintf style to agent"
+gdb_test_multiple "set dprintf-style agent" $msg {
+ -re "warning: Target cannot run dprintf commands.*\r\n$gdb_prompt $" {
+ set target_can_dprintf 0
+ pass "$msg - cannot do"
+ }
+ -re ".*$gdb_prompt $" {
+ pass "$msg - can do"
+ }
+}
+
+if $target_can_dprintf {
+
+ gdb_run_cmd
+
+ gdb_test "" "Breakpoint"
+
+ gdb_test "continue" "Breakpoint \[0-9\]+, foo .*" "1st dprintf, agent"
+
+ gdb_test "continue" "Breakpoint \[0-9\]+, foo .*" "2nd dprintf, agent"
+
+}
+
+gdb_test "set dprintf-style foobar" "Undefined item: \"foobar\"." \
+ "Set dprintf style to an unrecognized type"
+
« no previous file with comments | « gdb/testsuite/gdb.base/dprintf.c ('k') | gdb/testsuite/gdb.base/dump.exp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698