Add translations for various sub-directories
[binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / forward-spec-inter-cu.exp
blobb734c309f9c2c51b4dfdc462d682be559b42e293
1 # Copyright 2023 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 the DWARF reader works with a a DW_AT_specification that
17 # refers to a later DIE.  Inter-cu variant of forward-spec.exp.
19 load_lib dwarf.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 -debug.S
26 # Set up the DWARF for the test.
27 set asm_file [standard_output_file $srcfile2]
28 Dwarf::assemble $asm_file {
29     global srcfile
31     declare_labels spec
33     cu {} {
34         DW_TAG_compile_unit {
35             {DW_AT_language @DW_LANG_C_plus_plus}
36         } {
37             # The new indexer has special code to compute the full
38             # name of an object that uses a specification that appears
39             # later in the DWARF.
40             DW_TAG_variable {
41                 {DW_AT_specification %$spec}
42                 {DW_AT_location {
43                     DW_OP_const1u 23
44                     DW_OP_stack_value
45                 } SPECIAL_expr}
46             }
47         }
48     }
50     cu {} {
51         DW_TAG_compile_unit {
52             {DW_AT_language @DW_LANG_C_plus_plus}
53         } {
54             declare_labels myint
56             myint: DW_TAG_base_type {
57                 {DW_AT_byte_size 4 DW_FORM_sdata}
58                 {DW_AT_encoding  @DW_ATE_signed}
59                 {DW_AT_name      myint}
60             }
62             DW_TAG_namespace {
63                 {DW_AT_name ns}
64             } {
65                 spec: DW_TAG_variable {
66                     {DW_AT_name v}
67                     {DW_AT_type :$myint}
68                     {DW_AT_declaration 1 DW_FORM_flag_present}
69                 }
70             }
71         }
72     }
75 if {[build_executable "failed to build executable" ${testfile} \
76          [list $srcfile $asm_file] {nodebug}]} {
77     return -1
80 set eol "\r\n"
81 set ws "\[ \t\]"
83 set worker_threads_list {}
85 # Exercises the intra-shard case.
86 lappend worker_threads_list 0
88 # Might exercise the inter-shard case.
89 lappend worker_threads_list default
91 foreach_with_prefix worker_threads $worker_threads_list {
93     clean_restart
95     if { $worker_threads != "default" } {
96         gdb_test_no_output "maint set worker-threads $worker_threads"
97     }
99     gdb_load $binfile
101     gdb_test "pipe maint print objfiles | grep ns::v" \
102         "$ws+qualified:$ws+ns::v" \
103         "v has parent ns"