Commit | Line | Data |
---|---|---|
afba63f1 JB |
1 | # Copyright 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 | set executable ctxobj-m | |
17 | ||
18 | # The sources used to build two shared libraries (SO). We use the exact | |
19 | # same sources to build both SOs, but differentiate them through the use | |
20 | # of macros defined when calling the compiler. | |
21 | # | |
22 | # We need two source files per SO, because we need to test the situation | |
23 | # where we are trying to print the value of a global variable defined | |
24 | # in that SO while the variable's associated symtab has not been created | |
25 | # yet. | |
26 | set libsrc [list "${srcdir}/${subdir}/ctxobj-v.c" \ | |
27 | "${srcdir}/${subdir}/ctxobj-f.c"] | |
28 | ||
29 | set libobj1 "${objdir}/${subdir}/libctxobj1.so" | |
30 | set libobj2 "${objdir}/${subdir}/libctxobj2.so" | |
31 | ||
32 | set libobj1_opts { debug additional_flags=-fPIC | |
33 | additional_flags=-DVERSION=104 | |
34 | additional_flags=-DGET_VERSION=get_version_1 } | |
35 | set libobj2_opts { debug additional_flags=-fPIC | |
36 | additional_flags=-DVERSION=203 | |
37 | additional_flags=-DGET_VERSION=get_version_2 } | |
38 | ||
39 | if { [gdb_compile_shlib $libsrc $libobj1 $libobj1_opts ] != "" } { | |
40 | return -1 | |
41 | } | |
42 | if { [gdb_compile_shlib $libsrc $libobj2 $libobj2_opts ] != "" } { | |
43 | return -1 | |
44 | } | |
45 | if { [gdb_compile "${srcdir}/${subdir}/${executable}.c" \ | |
46 | "${objdir}/${subdir}/${executable}" \ | |
47 | executable \ | |
48 | [list debug shlib=${libobj1} shlib=${libobj2}]] | |
49 | != ""} { | |
50 | return -1 | |
51 | } | |
52 | ||
53 | clean_restart $executable | |
54 | ||
55 | if ![runto_main] { | |
56 | untested "could not run to main" | |
57 | return -1 | |
58 | } | |
59 | ||
60 | gdb_breakpoint "get_version_1" | |
61 | gdb_test "continue" \ | |
62 | "Breakpoint $decimal, get_version_1 \\(\\).*" \ | |
63 | "continue to get_version_1" | |
64 | ||
65 | # Try printing "this_version_num". There are two global variables | |
66 | # with that name, but we should pick the one in the shared library | |
67 | # we are currently debugging. We will know we picked the correct one | |
68 | # if the value printed is 104. The first print test verifies that | |
69 | # we're doing things right when the partial symtab hasn't been | |
70 | # expanded. And the second print test will do the same, but after | |
71 | # the partial symtab has been expanded. | |
72 | ||
73 | gdb_test "print this_version_num" \ | |
74 | " = 104" \ | |
75 | "print libctxobj1's this_version_num from partial symtab" | |
76 | ||
77 | gdb_test "print this_version_num" \ | |
78 | " = 104" \ | |
79 | "print libctxobj1's this_version_num from symtab" | |
80 | ||
81 | # Do the same, but from get_version_2. | |
82 | ||
83 | gdb_breakpoint "get_version_2" | |
84 | gdb_test "continue" \ | |
85 | "Breakpoint $decimal, get_version_2 \\(\\).*" \ | |
86 | "continue to get_version_2" | |
87 | ||
88 | gdb_test "print this_version_num" \ | |
89 | " = 203" \ | |
90 | "print libctxobj2's this_version_num from partial symtab" | |
91 | ||
92 | gdb_test "print this_version_num" \ | |
93 | " = 203" \ | |
94 | "print libctxobj2's this_version_num from symtab" |