1load_lib dwarf.exp 2 3# This test can only be run on targets which support DWARF-2 and use gas. 4if {![dwarf2_support]} { 5 return 0 6}; 7 8standard_testfile main-foo.c .S 9 10set executable ${testfile} 11set asm_file [standard_output_file ${srcfile2}] 12 13# We need to know the size of integer and address types in order 14# to write some of the debugging info we'd like to generate. 15if [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug}] { 16 return -1 17} 18 19# Create the DWARF. 20Dwarf::assemble $asm_file { 21 declare_labels cu_label cu2_label int_label int2_label 22 set int_size [get_sizeof "int" 4] 23 24 # imported CU 1: inty unsigned 25 cu {} { 26 cu_label: compile_unit { 27 {language @DW_LANG_C} 28 {name "<artificial>"} 29 } { 30 int_label: base_type { 31 {byte_size $int_size sdata} 32 {encoding @DW_ATE_unsigned} 33 {name {unsigned int}} 34 } 35 DW_TAG_typedef { 36 {DW_AT_name inty} 37 {DW_AT_type :$int_label} 38 } 39 } 40 } 41 42 # imported CU 2: inty signed 43 cu {} { 44 cu2_label: compile_unit { 45 {language @DW_LANG_C} 46 {name "<artificial>"} 47 } { 48 int2_label: base_type { 49 {byte_size $int_size sdata} 50 {encoding @DW_ATE_signed} 51 {name {int}} 52 } 53 DW_TAG_typedef { 54 {DW_AT_name inty} 55 {DW_AT_type :$int2_label} 56 } 57 } 58 } 59 60 # main CU 61 cu {} { 62 compile_unit { 63 {language @DW_LANG_C} 64 {name "<artificial>"} 65 } { 66 imported_unit { 67 {import %$cu2_label} 68 } 69 70 subprogram { 71 {MACRO_AT_func {main}} 72 {external 1 flag} 73 } 74 } 75 } 76 77 # foo CU 78 cu {} { 79 compile_unit { 80 {language @DW_LANG_C} 81 {name "<artificial>"} 82 } { 83 imported_unit { 84 {import %$cu_label} 85 } 86 87 subprogram { 88 {MACRO_AT_func {foo}} 89 {external 1 flag} 90 } 91 } 92 } 93 94} 95 96if { [prepare_for_testing "failed to prepare" ${testfile} \ 97 [list $srcfile $asm_file] {nodebug}] } { 98 return -1 99} 100 101if ![runto_main] { 102 return -1 103} 104 105gdb_test "ptype inty" "type = int" "ptype in main" 106 107gdb_breakpoint "foo" 108gdb_continue_to_breakpoint "continue to breakpoint for foo" 109 110gdb_test "ptype inty" "type = unsigned int" "ptype in foo" 111