Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: Joel Brobecker <brobecker@adacore.com>
Cc: gdb-patches@sourceware.org
Subject: Re: New testcase arm-disp-step.exp
Date: Thu, 23 Dec 2010 09:11:00 -0000	[thread overview]
Message-ID: <4D12F7DF.6040900@codesourcery.com> (raw)
In-Reply-To: <20101223041625.GR2596@adacore.com>

[-- Attachment #1: Type: text/plain, Size: 1202 bytes --]

On 12/23/2010 12:16 PM, Joel Brobecker wrote:
>> +# Get things started.
>> +
>> +gdb_exit
>> +gdb_start
>> +gdb_reinitialize_dir $srcdir/$subdir
>> +gdb_load ${binfile}
> 
> Use "clean_restart"....

Done.


>> +# which is in library might be compiled in Thumb.
>> +gdb_test "set displaced-stepping off" ""
> 
> Use gdb_test_no_output.

Done.

>> +gdb_test "set displaced-stepping on" ""
> 
> Same here.
> 

Done.

>> +gdb_test_multiple "continue" "continue to test_call" {
>> +	-re ".*bl test_call_subr.*" {
>> +	    pass "continue to test_call"
>> +	}
>> +	-re "Displaced stepping is only supported in" {
>> +	    xfail $testfile
>> +	    return
> 
> I'm not sure about the xfail. Why did you decide to use it?

Because I misunderstood xfail.

> I thought we were supposed to use kfail in this case, since this is
> a debugger issue? xfail should be used when the failure is caused
> by the debugging environment (compiler bug, missing feature in kernel,
> etc).

Yes, we should use kfail here.

Now, run arm-disp-step.exp with with
\{-mthumb,-marm\}\{-march=armv5t,-march=armv7-a\}, get result like this,
		=== gdb Summary ===

# of expected passes		60
# of known failures		2

-- 
Yao (齐尧)

[-- Attachment #2: arm_disp_step_test_1223.patch --]
[-- Type: text/x-patch, Size: 8086 bytes --]

testsuite/

	* gdb.arch/arm-disp-step.exp: New.
	* gdb.arch/arm-disp-step.S: New.

--- /dev/null	2010-12-23 13:09:47.085306261 +0800
+++ gdb/testsuite/gdb.arch/arm-disp-step.exp	2010-12-23 15:07:24.000000000 +0800
@@ -0,0 +1,172 @@
+# Copyright 2010 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# This file is part of the gdb testsuite.
+
+# Test arm displaced stepping.
+
+if $tracelevel {
+    strace $tracelevel
+}
+
+if {![istarget "arm*-*-*"]} then {
+    verbose "Skipping arm displaced stepping tests."
+    return
+}
+
+set testfile "arm-disp-step"
+set srcfile ${testfile}.S
+set binfile ${objdir}/${subdir}/${testfile}
+
+set additional_flags "-Wa,-g"
+
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug $additional_flags]] != "" } {
+    untested arm-disp-step.exp
+    return -1
+}
+
+
+#########################################
+# Test ldm/stm related to PC.
+proc test_ldm_stm_pc {} {
+    global srcfile
+    # Try to set breakpoint on test_ldm_stm_pc.  If symbol 'test_ldm_stm_pc'
+    # can't be resolved, test case is compiled in Thumb mode, skip it.
+    gdb_test_multiple "break *test_ldm_stm_pc" "break test_ldm_stm_pc" {
+	-re "Breakpoint.*at.* file .*$srcfile, line.*" {
+	    pass "break test_ldm_stm_pc"
+	}
+	-re "Function \"test_ldm_stm_pc\" not defined\..*Make breakpoint pending on future shared library load.*y or .n.. $" {
+	    gdb_test "n" "" "Test case is compiled in Thumb mode"
+	    return
+	}
+    }
+
+    gdb_test "break *test_ldm_pc" \
+	"Breakpoint.*at.* file .*$srcfile, line.*" \
+	"break test_ldm_pc"
+    gdb_test "break *test_ldm_stm_pc_ret" \
+	"Breakpoint.*at.* file .*$srcfile, line.*" \
+	"break test_ldm_stm_pc_ret"
+
+    gdb_continue_to_breakpoint "continue to test_ldm_stm_pc" \
+	".*stmdb.*sp\!\,.*\{lr\, pc\}.*"
+    gdb_continue_to_breakpoint "continue to test_ldm_pc" \
+	".*ldmia.*sp\!\,.*\{pc\}.*"
+    gdb_continue_to_breakpoint "continue to test_ldm_stm_pc_ret" \
+	".*bx lr.*"
+}
+##########################################
+# Test call/ret.
+proc test_call_ret {} {
+    global srcfile
+    gdb_test "break *test_call_end" \
+	"Breakpoint.*at.* file .*$srcfile, line.*" \
+	"break test_call_end"
+    gdb_test "break *test_ret" \
+	"Breakpoint.*at.* file .*$srcfile, line.*" \
+	"break test_ret"
+    gdb_test "break *test_ret_end" \
+	"Breakpoint.*at.* file .*$srcfile, line.*" \
+	"break test_ret_end"
+
+    gdb_continue_to_breakpoint "continue to test_call_end" \
+	".*@ Location test_call_end.*"
+    gdb_continue_to_breakpoint "continue to test_ret" \
+	".*bx lr.*"
+    gdb_continue_to_breakpoint "continue to test_ret_end" \
+	".*@ Location test_ret_end.*"
+}
+
+
+#########################################
+# Test branch
+proc test_branch {} {
+    global srcfile
+    gdb_test "break *test_branch" \
+	"Breakpoint.*at.* file .*$srcfile, line.*" \
+	"break test_branch"
+    gdb_test "break *L_branch" \
+	"Breakpoint.*at.* file .*$srcfile, line.*" \
+	"break Lbranch"
+
+    gdb_continue_to_breakpoint "continue to test_branch" \
+	".*b.*L_branch.*"
+    gdb_continue_to_breakpoint "continue to Lbranch" \
+	".*bx lr.*"
+}
+
+#########################################
+
+# Test ldr from pc
+proc test_ldr_from_pc {} {
+    global srcfile
+    gdb_test "break *test_ldr_pc" \
+	"Breakpoint.*at.* file .*$srcfile, line.*" \
+	"break test_ldr_pc"
+    gdb_test "break test_ldr_pc_ret" \
+	"Breakpoint.*at.* file .*$srcfile, line.*" \
+	"break test_ldr_pc_ret"
+
+    gdb_continue_to_breakpoint "continue to test_ldr_pc" \
+	".*ldr.*r1\,.*\[pc, #0\].*"
+    gdb_continue_to_breakpoint "continue to Lbranch" \
+	".*bx lr.*"
+}
+
+# Get things started.
+
+clean_restart ${testfile}
+
+# Turn displaced stepping off before runto main. When displaced stepping
+# is on, and we type 'run', GDB will first try to single step on _dl_debug_state,
+# which is in library might be compiled in Thumb.
+gdb_test_no_output "set displaced-stepping off"
+
+if ![runto_main] then {
+    fail "Can't run to main"
+    return 0
+}
+
+gdb_test_no_output "set displaced-stepping on"
+gdb_test "show displaced-stepping" ".* displaced stepping .* is on.*"
+
+gdb_test "break *test_call" \
+	"Breakpoint.*at.* file .*$srcfile, line.*" \
+	"break test_call"
+
+gdb_test_multiple "continue" "continue to test_call" {
+	-re ".*bl test_call_subr.*" {
+	    pass "continue to test_call"
+	}
+	-re "Displaced stepping is only supported in" {
+	    kfail "gdb/NNNN" $testfile
+	    return
+	}
+    }
+
+test_call_ret
+
+test_branch
+
+test_ldr_from_pc
+
+test_ldm_stm_pc
+
+##########################################
+
+# Done, run program to exit.
+
+gdb_continue_to_end "arm-disp-step"
--- /dev/null	2010-12-23 13:09:47.085306261 +0800
+++ gdb/testsuite/gdb.arch/arm-disp-step.S	2010-12-23 15:07:20.000000000 +0800
@@ -0,0 +1,120 @@
+/* Copyright 2010 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+	.syntax unified
+	.text
+	.type main,%function
+#if defined (__thumb__) || defined (__thumb2__)
+	.code   16
+	.thumb_func
+#endif
+	.globl main
+main:
+	push {r7, lr}
+	add     sp, sp, #4
+	mov	r7, sp
+
+	
+	/* Test call and return */	
+	.global test_call
+test_call:
+	bl test_call_subr
+        .global test_ret_end
+test_ret_end:
+	nop			@ Location test_ret_end
+	
+	/* Test branch */
+	bl test_branch
+
+	/* Test ldr from pc */
+	bl test_ldr_pc
+
+	/* Test ldm/stm only in ARM mode */
+#if !defined (__thumb__) && !defined (__thumb2__)
+	bl test_ldm_stm_pc
+#endif
+
+	/* Return */
+	mov     sp, r7
+	sub     sp, sp, #4
+	movs 	r0, #0
+	pop	{r7, pc}
+	.size main, .-main
+	
+	.global test_call_subr
+#if defined (__thumb__) || defined (__thumb2__)
+	.code   16
+	.thumb_func
+#endif
+	.type test_call_subr, %function
+test_call_subr:
+	nop
+        .global test_call_end
+test_call_end:
+        nop			@ Location test_call_end
+        .global test_ret
+test_ret:
+        bx lr
+	.size test_call_subr, .-test_call_subr
+
+	
+	.global test_branch
+#if defined (__thumb__) || defined (__thumb2__)
+	.code   16
+	.thumb_func
+#endif
+	.type test_branch, %function
+test_branch:
+	b	L_branch
+	.global
+L_branch:
+	bx lr
+	.size test_branch, .-test_branch
+
+	.global test_ldr_pc
+#if defined (__thumb__) || defined (__thumb2__)
+	.code   16
+	.thumb_func
+#endif
+	.type test_ldr_pc, %function
+test_ldr_pc:
+	ldr	r1, [pc, #0]
+
+	.global
+test_ldr_pc_ret:
+	bx lr
+	.size test_ldr_pc, .-test_ldr_pc
+
+#if !defined (__thumb__) && !defined (__thumb2__)
+	.global test_ldm_stm_pc
+	.type test_ldm_stm_pc, %function
+test_ldm_stm_pc:
+	stmdb	sp!, {lr, pc}
+	ldmia	sp!, {r0, r1}
+	ldr	r0, .L1
+	stmdb	sp!, {r0}
+	.global
+test_ldm_pc:
+	ldmia	sp!, {pc}
+	.global
+test_ldm_stm_pc_ret:
+	bx lr
+	.align	2
+.L1:
+	.word	test_ldm_stm_pc_ret
+	.size test_ldm_stm_pc, .-test_ldm_stm_pc
+#endif

  reply	other threads:[~2010-12-23  7:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-21 13:48 Yao Qi
2010-12-23  4:38 ` Joel Brobecker
2010-12-23  9:11   ` Yao Qi [this message]
2010-12-23 17:56     ` Joel Brobecker
2010-12-24  8:34       ` Yao Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D12F7DF.6040900@codesourcery.com \
    --to=yao@codesourcery.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox