# This test can only be run on targets which support DWARF-2 and use gas.
require dwarf2_support
-standard_testfile dw2-lines.c -dw2.S
+standard_testfile dw2-lines.c -dw2.S -dw2-one-diridx.S
with_shared_gdb {
set func_info_vars [get_func_info bar]
return [expr $line + 1]
}
-set asm_file [standard_output_file $srcfile2]
-Dwarf::assemble $asm_file {
- declare_labels Llines
- global srcdir subdir srcfile objdir
- global func_info_vars
- foreach var $func_info_vars {
- global $var
- }
+# A helper proc to create the DWARF assembly for the test.
+# If ONE_DIRIDX is true, then the directory table will be limited
+# to one entry.
+proc create_dwarf_assembly {source_file one_diridx} {
+ set asm_file [standard_output_file $source_file]
+ Dwarf::assemble $asm_file {
+ declare_labels Llines
+ global srcdir subdir srcfile objdir
+ global func_info_vars
+ upvar one_diridx one_diridx
+ foreach var $func_info_vars {
+ global $var
+ }
- cu { version 5 } {
- compile_unit {
- DW_AT_language @DW_LANG_Mips_Assembler
- DW_AT_name $srcfile
- DW_AT_comp_dir $objdir
- DW_AT_stmt_list $Llines DW_FORM_sec_offset
- DW_AT_producer "GNU AS 2.35.2"
- } {
- subprogram {
- DW_AT_external 1 flag
- DW_AT_name bar
- DW_AT_low_pc $bar_start addr
- DW_AT_high_pc "$bar_start + $bar_len" addr
+ cu { version 5 } {
+ compile_unit {
+ DW_AT_language @DW_LANG_Mips_Assembler
+ DW_AT_name $srcfile
+ DW_AT_comp_dir $objdir
+ DW_AT_stmt_list $Llines DW_FORM_sec_offset
+ DW_AT_producer "GNU AS 2.35.2"
+ } {
+ subprogram {
+ DW_AT_external 1 flag
+ DW_AT_name bar
+ DW_AT_low_pc $bar_start addr
+ DW_AT_high_pc "$bar_start + $bar_len" addr
+ }
}
}
- }
- lines [list version 5] Llines {
- set diridx1 [include_dir "${srcdir}/${subdir}"]
- set diridx2 [include_dir "${srcdir}/${subdir}"]
- file_name "$srcfile" $diridx1
- file_name "$srcfile" $diridx2
-
- program {
- DW_LNE_set_address bar_label
- line [line_for bar_label]
- DW_LNS_copy
+ lines [list version 5] Llines {
+ set diridx1 [include_dir "${srcdir}/${subdir}"]
+ file_name "$srcfile" $diridx1
+ if {!$one_diridx} {
+ set diridx2 [include_dir "${srcdir}/${subdir}"]
+ file_name "$srcfile" $diridx2
+ } else {
+ file_name "$srcfile" $diridx1
+ }
+ program {
+ DW_LNE_set_address bar_label
+ line [line_for bar_label]
+ DW_LNS_copy
- DW_LNE_set_address $bar_end
- DW_LNE_end_sequence
+ DW_LNE_set_address $bar_end
+ DW_LNE_end_sequence
+ }
}
}
+
+ return $asm_file
}
+set asm_file [create_dwarf_assembly $srcfile2 false]
if { [prepare_for_testing "failed to prepare" ${testfile} \
[list $srcfile $asm_file] {nodebug}] } {
return -1
pass $gdb_test_name
}
}
+
+# Test whether gdb crashes in the case where the number of
+# directory indexes is only one.
+set asm_file [create_dwarf_assembly $srcfile3 true]
+if {[prepare_for_testing "failed to prepare" ${testfile}-one-diridx \
+ [list $srcfile $asm_file] {nodebug}] } {
+ return -1
+}
+
+gdb_test "ptype bar" ".*" "do not crash with only one directory table entry"