1 # Copyright 2023-2024 Free Software Foundation, Inc.
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.
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.
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/>.
16 # Check that an optimized out static variable is printed the same independent
17 # of state of symtab expansion. See also gdb.opt/static-optimized-out.exp.
21 # This test can only be run on targets which support DWARF-2 and use gas.
22 require dwarf2_support
24 standard_testfile main.c -dw.S
26 # Make DWARF for the test.
27 set asm_file [standard_output_file $srcfile2]
28 Dwarf::assemble $asm_file {
35 declare_labels integer_label
37 integer_label: DW_TAG_base_type {
38 {DW_AT_byte_size 4 DW_FORM_sdata}
39 {DW_AT_encoding @DW_ATE_signed}
45 {type :$integer_label}
51 if { [prepare_for_testing "failed to prepare" ${testfile} \
52 [list $srcfile $asm_file] {nodebug}] } {
56 gdb_test "print var" " = <optimized out>"
58 # Expand all symbol tables.
59 gdb_test_no_output "maint expand-symtabs"
61 # Make sure we do an actual lookup rather than just returning the same as
63 gdb_test_no_output "maint flush symbol-cache"
65 with_test_prefix "after expand-symtabs" {
66 gdb_test "print var" " = <optimized out>"