From: Yao Qi Date: Sat, 22 Nov 2014 13:28:31 +0000 (+0800) Subject: Use MACRO_AT_func in entry-values.exp X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=84429e27c826c74b99791b8f1efe8dce03cfa6ca;p=binutils-gdb.git Use MACRO_AT_func in entry-values.exp MACRO_AT_func can be used in gdb.trace/entry-values.exp to correctly get function's address in generated debug info. As a result, the test is more friendly to clang. Currently, there are some fails in entry-values.exp when the test is compiled by clang. With this patch applied, all fails go away. gdb/testsuite: 2014-11-22 Yao Qi * gdb.trace/entry-values.c: Remove asms. (foo): Add foo_label. (bar): Add bar_label. * gdb.trace/entry-values.exp: Remove code computing foo's length and bar's length. (Dwarf::assemble): Invoke function_range for bar and use MACRO_AT_func for foo. --- diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 7b490eeb624..6bbd72b95f5 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2014-11-22 Yao Qi + + * gdb.trace/entry-values.c: Remove asms. + (foo): Add foo_label. + (bar): Add bar_label. + * gdb.trace/entry-values.exp: Remove code computing foo's + length and bar's length. + (Dwarf::assemble): Invoke function_range for bar and use + MACRO_AT_func for foo. + 2014-11-22 Yao Qi * gdb.dwarf2/dw2-compdir-oldgcc.S: Define label .Lgcc42_procstart diff --git a/gdb/testsuite/gdb.trace/entry-values.c b/gdb/testsuite/gdb.trace/entry-values.c index 11bb73995d5..c0d561a39c6 100644 --- a/gdb/testsuite/gdb.trace/entry-values.c +++ b/gdb/testsuite/gdb.trace/entry-values.c @@ -15,23 +15,19 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -asm (".section \".text\""); -asm (".balign 8"); -asm ("foo_start: .globl foo_start"); - int foo (int i, int j) { + asm ("foo_label: .globl foo_label"); return 0; } -asm ("bar_start: .globl bar_start"); - int bar (int i) { int j = 2; + asm ("bar_label: .globl bar_label"); return foo (i, j); } diff --git a/gdb/testsuite/gdb.trace/entry-values.exp b/gdb/testsuite/gdb.trace/entry-values.exp index 4838004d869..1b4d5cdfa2b 100644 --- a/gdb/testsuite/gdb.trace/entry-values.exp +++ b/gdb/testsuite/gdb.trace/entry-values.exp @@ -35,44 +35,6 @@ gdb_start 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) :\[^\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*-*-*"] } { @@ -85,23 +47,18 @@ 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 @@ -109,32 +66,18 @@ if { [string equal $bar_call_foo ""] || [string equal $bar_length ""] } { return -1 } -# Calculate the size of the last instruction. - -set test "disassemble bar+$bar_length,+10" -gdb_test_multiple $test $test { - -re ".*($hex) :\[^\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}} { @@ -145,10 +88,8 @@ Dwarf::assemble $asm_file { } 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} @@ -165,8 +106,8 @@ Dwarf::assemble $asm_file { 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 { @@ -175,7 +116,7 @@ Dwarf::assemble $asm_file { } 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'