Commit | Line | Data |
---|---|---|
8acc9f48 | 1 | # Copyright 2007-2013 Free Software Foundation, Inc. |
aa3edb8e JB |
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 | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
aa3edb8e | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
aa3edb8e JB |
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. | |
e22f8b7c | 12 | # |
aa3edb8e | 13 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
810cfdbb | 15 | load_lib dwarf.exp |
aa3edb8e JB |
16 | |
17 | # This test can only be run on targets which support DWARF-2 and use gas. | |
810cfdbb | 18 | if {![dwarf2_support]} { |
aa3edb8e JB |
19 | return 0 |
20 | } | |
21 | ||
442ddf59 | 22 | if { [prepare_for_testing dw2-noloc.exp "dw2-noloc" {dw2-noloc-main.c dw2-noloc.S} {nodebug}] } { |
aa3edb8e JB |
23 | return -1 |
24 | } | |
25 | ||
442ddf59 JK |
26 | # Symbols have the form: {file,main}_loc{addr,empty,no}_{,un}resolvable |
27 | # file: Symbol DIE is placed in DW_TAG_compile_unit. | |
28 | # main: Symbol DIE is placed in DW_TAG_subprogram. | |
29 | # locaddr: DW_AT_location is using DW_FORM_block DW_OP_addr <addr>. | |
30 | # locempty: DW_AT_location has zero DW_FORM_block size. | |
31 | # locno: DW_AT_location is not present. | |
32 | # resolvable: .symtab entry exists for this symbol name. | |
33 | # unresolvable: .symtab entry does not exist for this symbol name. | |
34 | # DW_AT_declaration is not present in any of these DIEs. | |
35 | ||
0a251e08 YQ |
36 | proc file_symbols {type} { |
37 | with_test_prefix "$type" { | |
442ddf59 | 38 | |
0a251e08 | 39 | global gdb_prompt |
442ddf59 | 40 | |
0a251e08 YQ |
41 | gdb_test "print file_locaddr_resolvable" "= 1234567890" |
42 | gdb_test "ptype file_locaddr_resolvable" "type = int" | |
442ddf59 | 43 | |
0a251e08 YQ |
44 | gdb_test "print file_locaddr_unresolvable" "= 1234567890" |
45 | gdb_test "ptype file_locaddr_unresolvable" "type = int" | |
442ddf59 | 46 | |
0a251e08 YQ |
47 | gdb_test "print file_locempty_resolvable" "= <optimized out>" |
48 | gdb_test "ptype file_locempty_resolvable" "type = int" | |
442ddf59 | 49 | |
0a251e08 YQ |
50 | gdb_test "print file_locempty_unresolvable" "= <optimized out>" |
51 | gdb_test "ptype file_locempty_unresolvable" "type = int" | |
442ddf59 | 52 | |
0a251e08 YQ |
53 | gdb_test "print file_locno_resolvable" "= <optimized out>" |
54 | gdb_test "ptype file_locno_resolvable" "type = int" | |
442ddf59 | 55 | |
0a251e08 YQ |
56 | gdb_test "print file_locno_unresolvable" "= <optimized out>" |
57 | gdb_test "ptype file_locno_unresolvable" "type = int" | |
442ddf59 | 58 | |
0a251e08 YQ |
59 | gdb_test "print file_extern_locaddr_resolvable" "= 1234567890" |
60 | gdb_test "ptype file_extern_locaddr_resolvable" "type = int" | |
442ddf59 | 61 | |
0a251e08 YQ |
62 | gdb_test "print file_extern_locaddr_unresolvable" "= 1234567890" |
63 | gdb_test "ptype file_extern_locaddr_unresolvable" "type = int" | |
442ddf59 | 64 | |
0a251e08 YQ |
65 | gdb_test "print file_extern_locempty_resolvable" "= <optimized out>" |
66 | gdb_test "ptype file_extern_locempty_resolvable" "type = int" | |
442ddf59 | 67 | |
0a251e08 YQ |
68 | gdb_test "print file_extern_locempty_unresolvable" "= <optimized out>" |
69 | gdb_test "ptype file_extern_locempty_unresolvable" "type = int" | |
442ddf59 | 70 | |
0a251e08 YQ |
71 | gdb_test "print file_extern_locno_resolvable" "= 1234567890" |
72 | gdb_test "ptype file_extern_locno_resolvable" "type = int" | |
442ddf59 | 73 | |
0a251e08 YQ |
74 | # `print file_extern_locno_unresolvable' currently prints |
75 | # Address of symbol "file_extern_locno_unresolvable" is unknown. | |
76 | # As DW_AT_declaration is not present in this DIE | |
77 | # it should print <optimized out>. As usefulness of such DIE is not | |
78 | # clear its resolution is not being tested. | |
79 | } | |
80 | } | |
aa3edb8e | 81 | |
442ddf59 JK |
82 | file_symbols no-run |
83 | ||
84 | if ![runto_main] { | |
aa3edb8e JB |
85 | return -1 |
86 | } | |
87 | ||
442ddf59 JK |
88 | file_symbols in-main |
89 | ||
90 | ||
91 | gdb_test "print main_local_locaddr_resolvable" "= 1234567890" | |
92 | gdb_test "ptype main_local_locaddr_resolvable" "type = int" | |
93 | ||
94 | gdb_test "print main_local_locaddr_unresolvable" "= 1234567890" | |
95 | gdb_test "ptype main_local_locaddr_unresolvable" "type = int" | |
96 | ||
585fdaa1 | 97 | gdb_test "print main_local_locempty_resolvable" "= <optimized out>" |
442ddf59 JK |
98 | gdb_test "ptype main_local_locempty_resolvable" "type = int" |
99 | ||
585fdaa1 | 100 | gdb_test "print main_local_locempty_unresolvable" "= <optimized out>" |
442ddf59 JK |
101 | gdb_test "ptype main_local_locempty_unresolvable" "type = int" |
102 | ||
585fdaa1 | 103 | gdb_test "print main_local_locno_resolvable" "= <optimized out>" |
442ddf59 JK |
104 | gdb_test "ptype main_local_locno_resolvable" "type = int" |
105 | ||
585fdaa1 | 106 | gdb_test "print main_local_locno_unresolvable" "= <optimized out>" |
442ddf59 JK |
107 | gdb_test "ptype main_local_locno_unresolvable" "type = int" |
108 | ||
109 | gdb_test "print main_extern_locaddr_resolvable" "= 1234567890" | |
110 | gdb_test "ptype main_extern_locaddr_resolvable" "type = int" | |
111 | ||
112 | gdb_test "print main_extern_locaddr_unresolvable" "= 1234567890" | |
113 | gdb_test "ptype main_extern_locaddr_unresolvable" "type = int" | |
114 | ||
585fdaa1 | 115 | gdb_test "print main_extern_locempty_resolvable" "= <optimized out>" |
442ddf59 JK |
116 | gdb_test "ptype main_extern_locempty_resolvable" "type = int" |
117 | ||
585fdaa1 | 118 | gdb_test "print main_extern_locempty_unresolvable" "= <optimized out>" |
442ddf59 JK |
119 | gdb_test "ptype main_extern_locempty_unresolvable" "type = int" |
120 | ||
121 | gdb_test "print main_extern_locno_resolvable" "= 1234567890" | |
122 | gdb_test "ptype main_extern_locno_resolvable" "type = int" | |
aa3edb8e | 123 | |
442ddf59 | 124 | # For `main_extern_locno_unresolvable' see `file_extern_locno_unresolvable'. |