gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}1.o
-set foo_length ""
-
-# Calculate the offset of the last instruction from the beginning.
-set test "disassemble foo"
-gdb_test_multiple $test $test {
- -re ".*$hex <\\+($decimal)>:\[^\r\n\]+\r\nEnd of assembler dump\.\r\n$gdb_prompt $" {
- set foo_length $expect_out(1,string)
- pass $test
- }
- -re ".*$gdb_prompt $" {
- fail $test
- # Bail out here, because we can't do the following tests if
- # $foo_length is unknown.
- return -1
- }
-}
-
-# Calculate the size of the last instruction. Single instruction
-# shouldn't be longer than 10 bytes.
-
-set test "disassemble foo+$foo_length,+10"
-gdb_test_multiple $test $test {
- -re ".*($hex) <foo\\+$foo_length>:\[^\r\n\]+\r\n\[ \]+($hex).*\.\r\n$gdb_prompt $" {
- set start $expect_out(1,string)
- set end $expect_out(2,string)
-
- set foo_length [expr $foo_length + $end - $start]
- pass $test
- }
- -re ".*$gdb_prompt $" {
- fail $test
- # Bail out here, because we can't do the following tests if
- # $foo_length is unknown.
- return -1
- }
-}
-
-set bar_length ""
set bar_call_foo ""
if { [istarget "arm*-*-*"] || [istarget "aarch64*-*-*"] } {
set call_insn "call"
}
-# Calculate the offset of the last instruction from the beginning.
+# Calculate the offset of the instruction bar calls foo.
set test "disassemble bar"
gdb_test_multiple $test $test {
- -re ".*$hex <\\+$decimal>:\[ \t\]+$call_insn\[^\r\n\]+\r\n\[ \]+$hex <\\+($decimal)>:" {
+ -re ".*$hex <\\+$decimal>:\[ \t\]+$call_insn\[^\r\n\]+\r\n\[ \]+$hex <\\+($decimal)>:.*$gdb_prompt $" {
set bar_call_foo $expect_out(1,string)
- exp_continue
- }
- -re ".*$hex <\\+($decimal)>:\[^\r\n\]+\r\nEnd of assembler dump\.\r\n$gdb_prompt $" {
- set bar_length $expect_out(1,string)
- pass $test
}
-re ".*$gdb_prompt $" {
fail $test
}
}
-if { [string equal $bar_call_foo ""] || [string equal $bar_length ""] } {
+if { [string equal $bar_call_foo ""] } {
fail "Find the call or branch instruction offset in bar"
# The following test makes no sense if the offset is unknown. We need
# to update the pattern above to match call or branch instruction for
return -1
}
-# Calculate the size of the last instruction.
-
-set test "disassemble bar+$bar_length,+10"
-gdb_test_multiple $test $test {
- -re ".*($hex) <bar\\+$bar_length>:\[^\r\n\]+\r\n\[ \]+($hex).*\.\r\n$gdb_prompt $" {
- set start $expect_out(1,string)
- set end $expect_out(2,string)
-
- set bar_length [expr $bar_length + $end - $start]
- pass $test
- }
- -re ".*$gdb_prompt $" {
- fail $test
- # Bail out here, because we can't do the following tests if
- # $bar_length is unknown.
- return -1
- }
-}
-
gdb_exit
# Make some DWARF for the test.
set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
declare_labels int_label foo_label
- global foo_length bar_length bar_call_foo
+ global bar_call_foo
+ global srcdir subdir srcfile
+
+ set bar_result [function_range bar ${srcdir}/${subdir}/${srcfile}]
+ set bar_start [lindex $bar_result 0]
+ set bar_length [lindex $bar_result 1]
cu {} {
compile_unit {{language @DW_LANG_C}} {
}
foo_label: subprogram {
- {name foo}
{decl_file 1}
- {low_pc foo_start addr}
- {high_pc "foo_start + $foo_length" addr}
+ {MACRO_AT_func { foo ${srcdir}/${subdir}/${srcfile} }}
} {
formal_parameter {
{type :$int_label}
subprogram {
{name bar}
{decl_file 1}
- {low_pc bar_start addr}
- {high_pc "bar_start + $bar_length" addr}
+ {low_pc $bar_start addr}
+ {high_pc "$bar_start + $bar_length" addr}
{GNU_all_call_sites 1}
} {
formal_parameter {
}
GNU_call_site {
- {low_pc "bar_start + $bar_call_foo" addr}
+ {low_pc "$bar_start + $bar_call_foo" addr}
{abstract_origin :$foo_label}
} {
# Faked entry values are reference to variables 'global1'