Commit | Line | Data |
---|---|---|
88b9d363 | 1 | # Copyright 2021-2022 Free Software Foundation, Inc. |
a12a15e7 AB |
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 | load_lib dwarf.exp | |
17 | ||
18 | # This test can only be run on x86-64 targets. It checks for a bug | |
19 | # that existed in amd64-tdep.c, and depends on an error being produced | |
20 | # from within that file. | |
21 | if {![istarget x86_64-*] || ![is_lp64_target]} { | |
22 | return 0 | |
23 | } | |
24 | ||
25 | # This test can only be run on targets which support DWARF-2 and use gas. | |
26 | if {![dwarf2_support]} { | |
27 | return 0 | |
28 | } | |
29 | ||
30 | standard_testfile .c -dw.S | |
31 | ||
32 | # Make some DWARF for the test. | |
33 | set asm_file [standard_output_file $srcfile2] | |
34 | Dwarf::assemble $asm_file { | |
35 | global srcfile | |
36 | ||
37 | get_func_info main | |
38 | get_func_info get_bar | |
39 | ||
40 | cu {} { | |
41 | DW_TAG_compile_unit { | |
42 | {DW_AT_language @DW_LANG_C} | |
43 | {DW_AT_name $srcfile} | |
44 | {DW_AT_comp_dir /tmp} | |
45 | } { | |
46 | declare_labels integer_label foo_t_label bar_t_label | |
47 | ||
48 | foo_t_label: DW_TAG_structure_type { | |
49 | {name foo_t} | |
50 | {byte_size 3 DW_FORM_sdata} | |
51 | } { | |
52 | member { | |
53 | {name field} | |
54 | {type :$integer_label} | |
55 | {data_member_location 0 DW_FORM_sdata} | |
56 | } | |
57 | } | |
58 | ||
59 | integer_label: DW_TAG_base_type { | |
60 | {DW_AT_byte_size 3 DW_FORM_sdata} | |
61 | {DW_AT_encoding @DW_ATE_signed} | |
62 | {DW_AT_name integer} | |
63 | } | |
64 | ||
65 | bar_t_label: DW_TAG_structure_type { | |
66 | {name bar_t} | |
67 | {byte_size 3 DW_FORM_sdata} | |
68 | } { | |
69 | member { | |
70 | {name f} | |
71 | {type :$foo_t_label} | |
72 | {data_member_location 0 DW_FORM_sdata} | |
73 | } | |
74 | } | |
75 | ||
76 | DW_TAG_subprogram { | |
77 | {name main} | |
78 | {low_pc $main_start addr} | |
79 | {high_pc $main_len data8} | |
80 | {DW_AT_type :$integer_label} | |
81 | } | |
82 | ||
83 | DW_TAG_subprogram { | |
84 | {name get_bar} | |
85 | {low_pc $get_bar_start addr} | |
86 | {high_pc $get_bar_len data8} | |
87 | {DW_AT_type :$bar_t_label} | |
88 | } | |
89 | } | |
90 | } | |
91 | } | |
92 | ||
93 | if { [prepare_for_testing "failed to prepare" ${testfile} \ | |
94 | [list $srcfile $asm_file] {nodebug}] } { | |
95 | return -1 | |
96 | } | |
97 | ||
98 | if ![runto_main] { | |
99 | return -1 | |
100 | } | |
101 | ||
102 | # At one point this would trigger a divide by zero inside GDB. Now we | |
103 | # just get an error message. | |
104 | gdb_test "print get_bar ()" "could not determine alignment of type" | |
105 | ||
106 | # Check GDB is still running. | |
107 | gdb_test "p 1 + 2" " = 3" |