]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.cp/call-method-register.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.cp / call-method-register.exp
CommitLineData
213516ef 1# Copyright 1992-2023 Free Software Foundation, Inc.
d5f96005
PA
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 callling a method on a variable that has been put in a
17# register.
18
19if { [skip_cplus_tests] } { continue }
20
21load_lib "cp-support.exp"
f9f88aed 22load_lib dwarf.exp
d5f96005 23
f9f88aed 24standard_testfile .cc -dw.S
d5f96005 25
f9f88aed
AB
26if {[prepare_for_testing "failed to prepare" $testfile $srcfile \
27 {debug c++}]} {
d5f96005
PA
28 return -1
29}
30
f9f88aed
AB
31set asm_file [standard_output_file $srcfile2]
32Dwarf::assemble $asm_file {
33
34 set main_result \
35 [function_range main ${::srcdir}/${::subdir}/${::srcfile}]
36 set main_start [lindex $main_result 0]
37 set main_length [lindex $main_result 1]
38
39 cu {} {
40 compile_unit {
41 {DW_AT_language @DW_LANG_C_plus_plus}
42 {DW_AT_name $::srcfile}
43 {DW_AT_comp_dir /tmp}
44 } {
45 declare_labels int_type_label struct_type_label \
46 struct_ptr_type_label
47 set ptr_size [get_sizeof "void *" 96]
48
49 DW_TAG_subprogram {
50 {name main}
51 {low_pc $main_start addr}
52 {high_pc $main_length data8}
53 {DW_AT_type :$int_type_label}
54 }
55
56 int_type_label: DW_TAG_base_type {
57 {DW_AT_byte_size 4 DW_FORM_sdata}
58 {DW_AT_encoding @DW_ATE_signed}
59 {DW_AT_name int}
60 }
61
62 struct_type_label: DW_TAG_structure_type {
63 {DW_AT_byte_size 4 DW_FORM_sdata}
64 {DW_AT_name small}
65 } {
66 member {
67 {name xxx}
68 {type :$int_type_label}
69 {data_member_location 0 data1}
70 }
71 subprogram {
72 {name yyy}
73 {type :$int_type_label}
74 } {
75 formal_parameter {
76 {type :$struct_ptr_type_label}
77 {artificial 1 flag_present}
78 }
79 }
80 }
db2e277d 81
f9f88aed
AB
82 struct_ptr_type_label: DW_TAG_pointer_type {
83 {DW_AT_byte_size $ptr_size DW_FORM_data1}
84 {type :$struct_type_label}
85 }
d5f96005 86
f9f88aed
AB
87 DW_TAG_variable {
88 {DW_AT_name global_var}
89 {DW_AT_type :$struct_type_label}
90 {DW_AT_location {
91 DW_OP_reg0
92 } SPECIAL_expr}
93 {external 1 flag}
94 }
95 }
d5f96005 96 }
f9f88aed 97}
d5f96005 98
f9f88aed
AB
99if { [prepare_for_testing "failed to prepare" ${testfile} \
100 [list $srcfile $asm_file] {nodebug}] } {
101 return -1
102}
103
104if ![runto_main] {
105 return -1
d5f96005
PA
106}
107
f9f88aed
AB
108gdb_test "print global_var.yyy ()" \
109 "Address requested for identifier \"global_var\" which is in register .*" \
110 "call method on register local"