2012-05-14 Stan Shebs <stan@codesourcery.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / dprintf.exp
1 # Copyright (C) 2012 Free Software Foundation, Inc.
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16
17 if { [prepare_for_testing dprintf.exp "dprintf" {} {debug}] } {
18 return -1
19 }
20
21 set srcfile dprintf.c
22
23 set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
24 set dp_location1 [gdb_get_line_number "set dprintf 1 here"]
25
26 gdb_breakpoint "main"
27 gdb_run_cmd
28
29 gdb_test "dprintf" "Format string required"
30
31 gdb_test "dprintf foo" "Format string required"
32
33 gdb_test "dprintf 29" "Format string required"
34
35 delete_breakpoints
36
37 gdb_breakpoint "main"
38
39 gdb_test "dprintf foo,\"At foo entry\\n\"" \
40 "Dprintf .*"
41
42 gdb_test "dprintf $dp_location1,\"arg=%d, g=%d\\n\", arg, g" \
43 "Dprintf .*"
44
45 gdb_test "break $bp_location1" \
46 "Breakpoint .*"
47
48 gdb_run_cmd
49
50 gdb_test "" "Breakpoint"
51
52 gdb_test "continue" "At foo entry.*arg=1234, g=1234.*" "1st dprintf, gdb"
53
54 gdb_test "continue" "At foo entry.*arg=1235, g=2222.*" "2nd dprintf, gdb"
55
56 # The "call" style depends on having I/O functions available, so test.
57
58 if ![target_info exists gdb,noinferiorio] {
59
60 # Now switch styles and rerun; in the absence of redirection the
61 # output should be the same.
62
63 gdb_test_no_output "set dprintf-style call" "Set dprintf style to call"
64
65 gdb_run_cmd
66
67 gdb_test "" "Breakpoint"
68
69 gdb_test "continue" "At foo entry.*arg=1234, g=1234.*" "1st dprintf, call"
70
71 gdb_test "continue" "At foo entry.*arg=1235, g=2222.*" "2nd dprintf, call"
72
73 gdb_test_no_output "set dprintf-function fprintf" "Set dprintf function"
74 gdb_test_no_output "set dprintf-channel stderr" "Set dprintf channel"
75
76 gdb_run_cmd
77
78 gdb_test "" "Breakpoint"
79
80 gdb_test "continue" "At foo entry.*arg=1234, g=1234.*" \
81 "1st dprintf, fprintf"
82
83 gdb_test "continue" "At foo entry.*arg=1235, g=2222.*" \
84 "2nd dprintf, fprintf"
85 }
86
87 gdb_test "set dprintf-style foobar" "Undefined item: \"foobar\"." \
88 "Set dprintf style to an unrecognized type"
89
This page took 0.033451 seconds and 4 git commands to generate.