a080ce1e5a453c6a5b11fd9e2d649b6282a303c2
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / print-symbol-loading.exp
1 # Copyright 2012-2014 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 # Test the "print symbol-loading" option.
17
18 if {[skip_shlib_tests]} {
19 return 0
20 }
21
22 standard_testfile print-symbol-loading-main.c
23 set libfile print-symbol-loading-lib
24 set srcfile_lib ${libfile}.c
25 set binfile_lib [standard_output_file ${libfile}.so]
26 set gcorefile ${binfile}.gcore
27 set objfile [standard_output_file ${testfile}.o]
28
29 if { [gdb_compile_shlib ${srcdir}/${subdir}/${srcfile_lib} ${binfile_lib} {debug}] != ""
30 || [gdb_compile ${srcdir}/${subdir}/${srcfile} ${objfile} object {debug}] != "" } {
31 untested ${testfile}.exp
32 return -1
33 }
34 set opts [list debug shlib=${binfile_lib}]
35 if { [gdb_compile ${objfile} ${binfile} executable $opts] != "" } {
36 untested ${testfile}.exp
37 return -1
38 }
39
40 clean_restart ${binfile}
41 gdb_load_shlibs ${binfile_lib}
42
43 # Does this gdb support gcore?
44 set test "help gcore"
45 gdb_test_multiple $test $test {
46 -re "Undefined command: .gcore.*\r\n$gdb_prompt $" {
47 # gcore command not supported -- nothing to test here.
48 unsupported "gdb does not support gcore on this target"
49 return -1
50 }
51 -re "Save a core file .*\r\n$gdb_prompt $" {
52 pass $test
53 }
54 }
55
56 if ![runto lib] {
57 return -1
58 }
59
60 if {![gdb_gcore_cmd $gcorefile "save a corefile"]} {
61 return -1
62 }
63
64 proc test_load_core { print_symbol_loading } {
65 global binfile binfile_lib gcorefile srcdir subdir
66 with_test_prefix "core ${print_symbol_loading}" {
67 gdb_exit
68 gdb_start
69 gdb_reinitialize_dir $srcdir/$subdir
70 gdb_test_no_output "set print symbol-loading $print_symbol_loading"
71 if { ${print_symbol_loading} != "off" } {
72 gdb_test "file $binfile" "Reading symbols from.*done\\." "file"
73 } else {
74 gdb_test_no_output "file $binfile" "file"
75 }
76 # Rename the shared lib so gdb can't find it.
77 remote_exec host "mv -f ${binfile_lib} ${binfile_lib}.save"
78 gdb_test "core ${gcorefile}" "Core was generated by .*" \
79 "re-load generated corefile"
80 # Now put it back and use "set solib-search-path" to trigger
81 # loading of symbols.
82 remote_exec host "mv -f ${binfile_lib}.save ${binfile_lib}"
83 set test_name "load shared-lib"
84 switch "${print_symbol_loading}" {
85 "off" {
86 gdb_test_no_output "set solib-search-path [file dirname ${binfile_lib}]" \
87 ${test_name}
88 }
89 "brief" {
90 gdb_test "set solib-search-path [file dirname ${binfile_lib}]" \
91 "Loading symbols for shared libraries\\." \
92 ${test_name}
93 }
94 "full" {
95 gdb_test "set solib-search-path [file dirname ${binfile_lib}]" \
96 "Reading symbols from.*Loaded symbols for.*" \
97 ${test_name}
98 }
99 }
100 gdb_test "frame" "#0 \[^\r\n\]* lib .*" "library got loaded"
101 }
102 }
103
104 test_load_core off
105 test_load_core brief
106 test_load_core full
107
108 # Now test the sharedlibrary command.
109
110 proc test_load_shlib { print_symbol_loading } {
111 global binfile
112 with_test_prefix "shlib ${print_symbol_loading}" {
113 clean_restart ${binfile}
114 gdb_test_no_output "set auto-solib-add off"
115 if ![runto_main] {
116 return -1
117 }
118 gdb_test_no_output "set print symbol-loading $print_symbol_loading"
119 set test_name "load shared-lib"
120 switch ${print_symbol_loading} {
121 "off" {
122 gdb_test_no_output "sharedlibrary .*" \
123 ${test_name}
124 }
125 "brief" {
126 gdb_test "sharedlibrary .*" \
127 "Loading symbols for shared libraries: \\.\\*" \
128 ${test_name}
129 }
130 "full" {
131 gdb_test "sharedlibrary .*" \
132 "Reading symbols from.*Loaded symbols for.*" \
133 ${test_name}
134 }
135 }
136 gdb_breakpoint "lib"
137 gdb_continue_to_breakpoint "lib"
138 gdb_test "frame" "#0 \[^\r\n\]* lib .*" "library got loaded"
139 }
140 }
141
142 test_load_shlib off
143 test_load_shlib brief
144 test_load_shlib full
This page took 0.032544 seconds and 3 git commands to generate.