# This test can only be run on targets which support DWARF-2 and use gas.
require dwarf2_support
-standard_testfile .c -dw.S -dwo.S
+standard_testfile .c -dw.S
-set main_asm_file [standard_output_file $srcfile2]
-set dwo_asm_file [standard_output_file $srcfile3]
+set asm_file [standard_output_file $srcfile2]
-# Debug info in the main file.
-Dwarf::assemble $main_asm_file {
+Dwarf::assemble $asm_file {
+ # In the main file.
cu {
version 5
dwo_id 0xF00D
} {
compile_unit {
- DW_AT_dwo_name ${::gdb_test_file_name}.dwo DW_FORM_strp
+ DW_AT_dwo_name ${::gdb_test_file_name}-dw.dwo DW_FORM_strp
} {}
}
-}
-# Debug info in the DWO file.
-Dwarf::assemble $dwo_asm_file {
+ # In the .dwo file.
tu {
fission 1
version 5
}
}
-# Build main file.
-if { [build_executable "${testfile}.exp" $binfile \
- [list ${srcfile} ${main_asm_file}] {nodebug}] } {
- return
-}
-
-# Build DWO file.
-set dwo_file [standard_output_file ${testfile}.dwo]
-if { [gdb_compile_shlib $dwo_asm_file $dwo_file nodebug] != "" } {
+set obj [standard_output_file "${testfile}-dw.o"]
+if {[build_executable_and_dwo_files "$testfile.exp" "${binfile}" {} \
+ [list $asm_file {nodebug split-dwo} $obj] \
+ [list $srcfile {nodebug}]]} {
return
}
-if { [is_remote host] } {
- gdb_remote_download host $dwo_file
-}
-
clean_restart ${testfile}
# This would cause an internal error.
# table.
variable _abbrev_num
+ # The next available abbrev number in the (single) DWO abbrev table.
+ variable _dwo_abbrev_num
+
# The string table for this assembly. The key is the string; the
# value is the label for that string.
variable _strings
# table.
proc _get_abbrev_num {} {
variable _abbrev_num
- set res $_abbrev_num
- incr _abbrev_num
+ variable _dwo_abbrev_num
+ variable _cu_is_fission
+
+ if { $_cu_is_fission } {
+ set res $_dwo_abbrev_num
+ incr _dwo_abbrev_num
+ } else {
+ set res $_abbrev_num
+ incr _abbrev_num
+ }
+
return $res
}
_section $section
set cu_num [incr _cu_count]
- set my_abbrevs [_compute_label "abbrev${cu_num}_begin"]
- set _abbrev_num 1
+
+ # Since .dwo files are not linked, we can't use a label to point to a
+ # specific place in the .debug_abbrev section. For .dwo files, we
+ # therefore use a single abbrev table (at offset 0) shared by all units
+ # in that file.
+ if { $_cu_is_fission } {
+ set my_abbrevs 0
+ } else {
+ set my_abbrevs [_compute_label "abbrev${cu_num}_begin"]
+ set _abbrev_num 1
+ }
set _cu_label [_compute_label "cu${cu_num}_begin"]
set start_label [_compute_label "cu${cu_num}_start"]
uplevel $_level $body
- _defer_output $_abbrev_section {
- # Emit the terminator.
- _op .byte 0x0 "Abbrev end - Terminator"
+ if { !$_cu_is_fission } {
+ _defer_output $_abbrev_section {
+ # Emit the terminator.
+ _op .byte 0x0 "Abbrev end - Terminator"
+ }
}
define_label $end_label
_section $section
set cu_num [incr _cu_count]
- set my_abbrevs [_compute_label "abbrev${cu_num}_begin"]
- set _abbrev_num 1
+
+ # Since .dwo files are not linked, we can't use a label to point to a
+ # specific place in the .debug_abbrev section. For .dwo files, we
+ # therefore use a single abbrev table (at offset 0) shared by all units
+ # in that file.
+ if { $_cu_is_fission } {
+ set my_abbrevs 0
+ } else {
+ set my_abbrevs [_compute_label "abbrev${cu_num}_begin"]
+ set _abbrev_num 1
+ }
set _cu_label [_compute_label "cu${cu_num}_begin"]
set start_label [_compute_label "cu${cu_num}_start"]
uplevel $_level $body
- _defer_output $_abbrev_section {
- # Emit the terminator.
- _op .byte 0x0 "Abbrev end - Terminator"
+ if { !$_cu_is_fission } {
+ _defer_output $_abbrev_section {
+ # Emit the terminator.
+ _op .byte 0x0 "Abbrev end - Terminator"
+ }
}
define_label $end_label
variable _debug_ranges_64_bit
variable _debug_addr_index
variable _level
+ variable _dwo_abbrev_num
if { [llength $options] == 1 } {
set options [list filename [lindex $options 0]]
set _line_count 0
set _debug_ranges_64_bit [is_64_target]
-
set _debug_addr_index 0
+ set _dwo_abbrev_num 1
# Dummy CU at the start to ensure that the first CU in $body is not
# the first in .debug_info.
dummy_cu
}
+ # If we wrote any abbrev in .debug_abbrev.dwo, write the terminator.
+ if { $_dwo_abbrev_num > 1 } {
+ _defer_output .debug_abbrev.dwo {
+ # Emit the terminator.
+ _op .byte 0x0 "Abbrev end - Terminator"
+ }
+ }
+
_write_deferred_output
_section .note.GNU-stack "" progbits