]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright (C) 2008-2024 Free Software Foundation, Inc. |
ed3ef339 DE |
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 | # This file is part of the GDB testsuite. | |
17 | # It tests Guile-based pretty-printing for the CLI. | |
18 | ||
19 | load_lib gdb-guile.exp | |
20 | ||
e71b6502 TT |
21 | require allow_guile_tests |
22 | ||
ed3ef339 DE |
23 | standard_testfile |
24 | ||
ed3ef339 | 25 | proc run_lang_tests {exefile lang} { |
4a0a0bd2 AB |
26 | with_test_prefix "lang=$lang" { |
27 | global srcdir subdir srcfile testfile hex | |
28 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${exefile}" executable "debug $lang"] != "" } { | |
29 | untested "failed to compile in $lang mode" | |
30 | return | |
31 | } | |
32 | ||
33 | set nl "\[\r\n\]+" | |
34 | ||
35 | # Start with a fresh gdb. | |
888438e2 | 36 | clean_restart $exefile |
4a0a0bd2 AB |
37 | |
38 | if ![gdb_guile_runto_main] { | |
39 | return | |
40 | } | |
41 | ||
42 | gdb_test_no_output "set print pretty on" | |
43 | ||
44 | gdb_test "b [gdb_get_line_number {break to inspect} ${testfile}.c ]" \ | |
45 | ".*Breakpoint.*" | |
46 | gdb_test "continue" ".*Breakpoint.*" | |
47 | ||
48 | set remote_scheme_file [gdb_remote_download host \ | |
49 | ${srcdir}/${subdir}/${testfile}.scm] | |
50 | ||
51 | gdb_scm_load_file ${remote_scheme_file} | |
52 | ||
53 | gdb_test "print ss" " = a=<a=<1> b=<$hex>> b=<a=<2> b=<$hex>>" | |
54 | gdb_test "print ssa\[1\]" " = a=<a=<5> b=<$hex>> b=<a=<6> b=<$hex>>" | |
55 | gdb_test "print ssa" " = {a=<a=<3> b=<$hex>> b=<a=<4> b=<$hex>>, a=<a=<5> b=<$hex>> b=<a=<6> b=<$hex>>}" | |
56 | ||
57 | gdb_test "print arraystruct" " = {$nl *y = 7, *$nl *x = {a=<23> b=<$hex>, a=<24> b=<$hex>} *$nl *}" | |
58 | ||
59 | if {$lang == "c++"} { | |
60 | gdb_test "print cps" "= a=<8> b=<$hex>" | |
61 | gdb_test "print cpss" " = {$nl *zss = 9, *$nl *s = a=<10> b=<$hex>$nl}" | |
62 | gdb_test "print cpssa\[0\]" " = {$nl *zss = 11, *$nl *s = a=<12> b=<$hex>$nl}" | |
63 | gdb_test "print cpssa\[1\]" " = {$nl *zss = 13, *$nl *s = a=<14> b=<$hex>$nl}" | |
64 | gdb_test "print cpssa" " = {{$nl *zss = 11, *$nl *s = a=<12> b=<$hex>$nl *}, {$nl *zss = 13, *$nl *s = a=<14> b=<$hex>$nl *}}" | |
65 | gdb_test "print sss" "= a=<15> b=<a=<8> b=<$hex>>" | |
66 | gdb_test "print ref" "= a=<15> b=<a=<8> b=<$hex>>" | |
67 | gdb_test "print derived" \ | |
68 | " = \{.*<Vbase1> = pp class name: Vbase1.*<Vbase2> = \{.*<VirtualTest> = pp value variable is: 1,.*members of Vbase2:.*_vptr.Vbase2 = $hex.*<Vbase3> = \{.*members of Vbase3.*members of Derived:.*value = 2.*" | |
69 | gdb_test "print ns " "\"embedded\\\\000null\\\\000string\"" \ | |
70 | "print ns with 200 elements" | |
71 | gdb_test_no_output "set print elements 3" "" | |
72 | gdb_test "print ns" "emb\.\.\.." \ | |
73 | "print ns with 3 elements" | |
74 | gdb_test_no_output "set print elements 10" "" | |
75 | gdb_test "print ns" "embedded\\\\000n\.\.\.." \ | |
76 | "print ns with 10 elements" | |
77 | gdb_test_no_output "set print elements 200" "" | |
78 | } | |
79 | ||
80 | if { ![is_address_zero_readable] } { | |
81 | gdb_test "print ns2" "<error reading variable: ERROR: Cannot access memory at address 0x0>" | |
82 | } | |
83 | ||
84 | gdb_test "print x" " = \"this is x\"" | |
d9211df2 AB |
85 | gdb_test "print cstring" " = \"const string\"" \ |
86 | "print cstring with max-depth unlimited" | |
ecf25064 | 87 | gdb_test_no_output "set print max-depth 0" |
d9211df2 AB |
88 | gdb_test "print cstring" " = \"const string\"" \ |
89 | "print cstring with max-depth 0" | |
ecf25064 KC |
90 | gdb_test_no_output "set print max-depth unlimited" |
91 | ||
4a0a0bd2 AB |
92 | gdb_test "print estring" " = \"embedded x\\\\201\\\\202\\\\203\\\\204\"" |
93 | ||
94 | gdb_test_no_output "guile (set! *pp-ls-encoding* \"UTF-8\")" | |
95 | gdb_test "print estring2" "\"embedded \", <incomplete sequence \\\\302>" | |
96 | ||
97 | gdb_test_no_output "set guile print-stack full" | |
98 | gdb_test "print hint_error" "ERROR: Invalid display hint: 42\r\nhint_error_val" | |
99 | ||
100 | gdb_test "print c" " = container \"container\" with 2 elements = {$nl *.0. = 23,$nl *.1. = 72$nl}" | |
101 | ||
102 | gdb_test "print nstype" " = {$nl *.0. = 7,$nl *.1. = 42$nl}" | |
103 | ||
104 | gdb_test_no_output "set print pretty off" | |
105 | gdb_test "print nstype" " = {.0. = 7, .1. = 42}" \ | |
106 | "print nstype on one line" | |
107 | ||
108 | gdb_continue_to_end | |
ed3ef339 | 109 | } |
ed3ef339 DE |
110 | } |
111 | ||
112 | run_lang_tests "${binfile}" "c" | |
113 | run_lang_tests "${binfile}-cxx" "c++" | |
114 | ||
115 | # Run various other tests. | |
116 | ||
888438e2 | 117 | clean_restart $binfile |
ed3ef339 DE |
118 | |
119 | if ![gdb_guile_runto_main] { | |
120 | return | |
121 | } | |
122 | ||
123 | set remote_scheme_file [gdb_remote_download host \ | |
124 | ${srcdir}/${subdir}/${testfile}.scm] | |
125 | ||
126 | gdb_scm_load_file ${remote_scheme_file} | |
127 | ||
128 | gdb_breakpoint [gdb_get_line_number "eval-break"] | |
129 | gdb_continue_to_breakpoint "eval-break" ".* eval-break .*" | |
130 | ||
131 | gdb_test "info locals" "eval9 = eval=<123456789>" | |
132 | ||
133 | gdb_test "b [gdb_get_line_number {break to inspect} ${testfile}.c ]" \ | |
134 | ".*Breakpoint.*" | |
135 | gdb_test "continue" ".*Breakpoint.*" | |
136 | ||
137 | gdb_test "print ss" " = a=<a=<1> b=<$hex>> b=<a=<2> b=<$hex>>" \ | |
138 | "print ss enabled #1" | |
139 | ||
140 | gdb_test_no_output "guile (disable-matcher!)" | |
ed3ef339 DE |
141 | gdb_test "print ss" " = {a = {a = 1, b = $hex}, b = {a = 2, b = $hex}}" \ |
142 | "print ss disabled" | |
143 | ||
144 | gdb_test_no_output "guile (enable-matcher!)" | |
ed3ef339 DE |
145 | gdb_test "print ss" " = a=<a=<1> b=<$hex>> b=<a=<2> b=<$hex>>" \ |
146 | "print ss enabled #2" | |
ded03782 DE |
147 | |
148 | gdb_test_no_output "guile (install-progspace-pretty-printers! (current-progspace))" | |
149 | gdb_test "print ss" \ | |
150 | " = a=<progspace a=<1> b=<$hex>> b=<progspace a=<2> b=<$hex>>" \ | |
151 | "print ss via progspace" | |
152 | ||
153 | gdb_test_no_output "guile (install-objfile-pretty-printers! (current-progspace) \"scm-pretty-print\")" | |
154 | gdb_test "print ss" \ | |
155 | " = a=<objfile a=<1> b=<$hex>> b=<objfile a=<2> b=<$hex>>" \ | |
156 | "print ss via objfile" |