From patchwork Sat Nov 15 13:45:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 3767 Received: (qmail 8327 invoked by alias); 15 Nov 2014 13:45:52 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 8318 invoked by uid 89); 15 Nov 2014 13:45:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 15 Nov 2014 13:45:50 +0000 Received: from svr-orw-fem-02x.mgc.mentorg.com ([147.34.96.206] helo=SVR-ORW-FEM-02.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1Xpdff-00034F-Cb from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Sat, 15 Nov 2014 05:45:47 -0800 Received: from qiyao.dyndns.org.com (147.34.91.1) by svr-orw-fem-02.mgc.mentorg.com (147.34.96.168) with Microsoft SMTP Server id 14.3.181.6; Sat, 15 Nov 2014 05:45:45 -0800 From: Yao Qi To: Subject: [PATCH] Use MACRO_AT_func in entry-values.exp Date: Sat, 15 Nov 2014 21:45:29 +0800 Message-ID: <1416059129-32024-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 X-IsSubscribed: yes 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-15 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. --- gdb/testsuite/gdb.trace/entry-values.c | 8 +-- gdb/testsuite/gdb.trace/entry-values.exp | 85 +++++--------------------------- 2 files changed, 15 insertions(+), 78 deletions(-) diff --git a/gdb/testsuite/gdb.trace/entry-values.c b/gdb/testsuite/gdb.trace/entry-values.c index 11bb739..c0d561a 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 4838004..1b4d5cd 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'