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