Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: gdb-patches@sourceware.org
Subject: [try 2nd 7/8] Test case
Date: Thu, 24 Mar 2011 14:11:00 -0000	[thread overview]
Message-ID: <4D8B4FAA.4000004@codesourcery.com> (raw)
In-Reply-To: <4D8B4947.1000000@codesourcery.com>

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

Test cases for Thumb displaced stepping.

-- 
Yao (齐尧)

[-- Attachment #2: 0007-test-cases.patch --]
[-- Type: text/x-patch, Size: 12328 bytes --]

2011-03-24  Yao Qi  <yao@codesourcery.com>

	* gdb.arch/arm-disp-step.S: Test Thumb instructions.
	* gdb.arch/arm-disp-step.exp: Likewse.

---
 gdb/testsuite/gdb.arch/arm-disp-step.S   |  164 ++++++++++++++++++++++-
 gdb/testsuite/gdb.arch/arm-disp-step.exp |  215 +++++++++++++++++++++++++++---
 2 files changed, 354 insertions(+), 25 deletions(-)

diff --git a/gdb/testsuite/gdb.arch/arm-disp-step.S b/gdb/testsuite/gdb.arch/arm-disp-step.S
index fb76974..276047d 100644
--- a/gdb/testsuite/gdb.arch/arm-disp-step.S
+++ b/gdb/testsuite/gdb.arch/arm-disp-step.S
@@ -18,7 +18,7 @@
 	.syntax unified
 	.text
 	.type main,%function
-#if defined (__thumb__) || defined (__thumb2__)
+#if defined (__thumb__)
 	.code   16
 	.thumb_func
 #endif
@@ -43,11 +43,37 @@ test_ret_end:
 	/* Test ldr from pc */
 	bl test_ldr_pc
 
-	/* Test ldm/stm only in ARM mode */
-#if !defined (__thumb__) && !defined (__thumb2__)
+	/* Test ldm/stm in ARM */
+#if !defined (__thumb__)
 	bl test_ldm_stm_pc
 #endif
 
+	/* Test ldrX literal in ARM and Thumb-2 */
+#if !defined (__thumb__) || defined(__thumb2__)
+	bl test_ldr_literal
+#endif
+
+	/* Test ldr literal in Thumb */
+#if defined(__thumb__)
+	bl test_ldr_literal_16
+#endif
+
+	/* Test cbnz/cbz in Thumb-2 */
+#if defined(__thumb2__)
+	bl test_cbz_cbnz
+#endif
+
+	/* Test adr in Thumb and Thumb-2 */
+#if defined(__thumb__)
+	bl test_adr
+#endif
+	/* Test 32-bit adr in ARM and Thumb-2 */
+#if defined(__thumb2__) || !defined(__thumb__)
+	bl test_adr_32bit
+#endif
+
+	bl test_pop_pc
+	
 	/* Test str in ARM mode and Thumb-2 */
 #if !defined(__thumb__)
 	bl test_str_pc
@@ -60,7 +86,7 @@ test_ret_end:
 	.size main, .-main
 	
 	.global test_call_subr
-#if defined (__thumb__) || defined (__thumb2__)
+#if defined (__thumb__)
 	.code   16
 	.thumb_func
 #endif
@@ -77,7 +103,7 @@ test_ret:
 
 	
 	.global test_branch
-#if defined (__thumb__) || defined (__thumb2__)
+#if defined (__thumb__)
 	.code   16
 	.thumb_func
 #endif
@@ -90,7 +116,7 @@ L_branch:
 	.size test_branch, .-test_branch
 
 	.global test_ldr_pc
-#if defined (__thumb__) || defined (__thumb2__)
+#if defined (__thumb__)
 	.code   16
 	.thumb_func
 #endif
@@ -103,7 +129,7 @@ test_ldr_pc_ret:
 	bx lr
 	.size test_ldr_pc, .-test_ldr_pc
 
-#if !defined (__thumb__) && !defined (__thumb2__)
+#if !defined (__thumb__) 
 	.global test_ldm_stm_pc
 	.type test_ldm_stm_pc, %function
 test_ldm_stm_pc:
@@ -122,6 +148,130 @@ test_ldm_stm_pc_ret:
 	.word	test_ldm_stm_pc_ret
 	.size test_ldm_stm_pc, .-test_ldm_stm_pc
 #endif
+	
+#if !defined (__thumb__) || defined(__thumb2__)
+	.global test_ldr_literal
+	.type test_ldr_literal, %function
+test_ldr_literal:
+	ldrh	r0, [pc]
+	.global test_ldrsb_literal
+test_ldrsb_literal:
+	ldrsb	r0, [pc]
+	.global test_ldrsh_literal
+test_ldrsh_literal:
+	ldrsh	r0, [pc]
+	.global test_ldr_literal_end
+test_ldr_literal_end:
+	bx lr
+	.size test_ldr_literal, .-test_ldr_literal
+#endif
+
+#if defined(__thumb__)
+	.global test_ldr_literal_16
+	.code   16
+	.thumb_func
+test_ldr_literal_16:
+	ldr	r0, .L2
+	.global test_ldr_literal_16_end
+test_ldr_literal_16_end:
+	bx lr
+	.align	2
+.L2:
+	.word	test_ldr_literal_16
+	.size test_ldr_literal_16, .-test_ldr_literal_16
+#endif
+
+#if defined(__thumb2__)
+	.global test_cbz_cbnz
+	.code   16
+	.thumb_func
+test_cbz_cbnz:
+	movs 	r0, #0
+	.global test_zero_cbnz
+test_zero_cbnz:
+	cbnz	r0, .L3
+	.global test_zero_cbz
+test_zero_cbz:
+	cbz	r0, .L3
+.L3:
+	movs	r0, #1
+	.global test_non_zero_cbz
+test_non_zero_cbz:
+	cbz	r0, .L4
+	.global test_non_zero_cbnz
+test_non_zero_cbnz:
+	cbnz	r0, .L4
+	nop
+.L4:
+	.global test_cbz_cbnz_end
+test_cbz_cbnz_end:
+	bx lr
+	.size test_cbz_cbnz, .-test_cbz_cbnz
+#endif
+
+#if defined(__thumb__)
+	.global test_adr
+	.code   16
+	.thumb_func
+test_adr:
+	adr	r0, .L8
+	nop
+	nop
+	nop
+.L8:
+	.global test_adr_end
+test_adr_end:
+	bx lr
+	.size test_adr, .-test_adr
+#endif
+
+#if defined(__thumb2__) || !defined(__thumb__)
+	.global test_adr_32bit
+#if defined(__thumb2__)
+	.code   16
+	.thumb_func
+#endif
+test_adr_32bit:
+	adr	r0, .L6
+	nop
+.L6:
+	nop
+	.global test_adr_32bit_after
+test_adr_32bit_after:
+	adr	r0, .L6
+
+	.global test_adr_32bit_end
+test_adr_32bit_end:
+	bx lr
+	.size test_adr_32bit, .-test_adr_32bit
+#endif
+	
+	.global test_pop_pc
+	.type test_pop_pc, %function
+#if defined(__thumb__)
+	.code   16
+	.thumb_func
+#endif
+
+test_pop_pc:
+	ldr	r1, .L5
+#if defined(__thumb__)
+	movs	r0, #1
+	orrs	r1, r0
+#endif
+	push	{r1}
+	push	{r1}
+	.global test_pop_pc_1
+test_pop_pc_1:
+	pop	{r1, pc}
+	.global test_pop_pc_ret
+test_pop_pc_ret:
+	bx lr
+	.align	2
+.L5:
+	.word	test_pop_pc_ret
+	.size test_pop_pc, .-test_pop_pc
+
 
 #if !defined(__thumb__)
 #if defined (__thumb2__)
diff --git a/gdb/testsuite/gdb.arch/arm-disp-step.exp b/gdb/testsuite/gdb.arch/arm-disp-step.exp
index 3bea521..b337335 100644
--- a/gdb/testsuite/gdb.arch/arm-disp-step.exp
+++ b/gdb/testsuite/gdb.arch/arm-disp-step.exp
@@ -50,7 +50,11 @@ proc 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
+	    return 0
+	}
+	-re "No symbol.*" {
+	    pass "break test_ldm_stm_pc"
+	    return 0
 	}
     }
 
@@ -68,10 +72,81 @@ proc test_ldm_stm_pc {} {
     gdb_continue_to_breakpoint "continue to test_ldm_stm_pc_ret" \
 	".*bx lr.*"
 }
+
+#########################################
+# Test ldrX literal
+proc test_ldr_literal {} {
+    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_ldr_literal" "break test_ldr_literal" {
+	-re "Breakpoint.*at.* file .*$srcfile, line.*" {
+	    pass "break test_ldr_literal"
+	}
+	-re "Function \"test_ldr_literal\" not defined\..*Make breakpoint pending on future shared library load.*y or .n.. $" {
+	    gdb_test "n" "" "Test case is compiled in Thumb mode"
+	    return 0
+	}
+	-re "No symbol.*" {
+	    return 0
+	}
+    }
+
+    gdb_test "break *test_ldrsb_literal" \
+	"Breakpoint.*at.* file .*$srcfile, line.*" \
+	"break test_ldrsb_literal"
+    gdb_test "break *test_ldrsh_literal" \
+	"Breakpoint.*at.* file .*$srcfile, line.*" \
+	"break test_ldrsh_literal"
+    gdb_test "break *test_ldr_literal_end" \
+	"Breakpoint.*at.* file .*$srcfile, line.*" \
+	"break test_test_ldr_literal_end"
+
+    gdb_continue_to_breakpoint "continue to test_ldr_literal" \
+	".*ldrh.*r0\,.*\[pc\].*"
+    gdb_continue_to_breakpoint "continue to test_ldrsb_literal" \
+	".*ldrsb.*r0\,.*\[pc\].*"
+    gdb_continue_to_breakpoint "continue to test_ldrsh_literal" \
+	".*ldrsh.*r0\,.*\[pc\].*"
+    gdb_continue_to_breakpoint "continue to test_ldr_literal_ret" \
+	".*bx lr.*"
+}
+
+proc test_ldr_literal_16 {} {
+    global srcfile
+    gdb_test_multiple "break *test_ldr_literal_16" "break test_ldr_literal_16" {
+	-re "Breakpoint.*at.* file .*$srcfile, line.*" {
+	    pass "break test_ldr_literal"
+	}
+	-re "Function \"test_ldr_literal_16\" not defined\..*Make breakpoint pending on future shared library load.*y or .n.. $" {
+	    gdb_test "n" "" "skip"
+	    return 0
+	}
+	-re "No symbol.*" {
+	    return 0
+	}
+    }
+    
+    gdb_test "break *test_ldr_literal_16_end" \
+	"Breakpoint.*at.* file .*$srcfile, line.*" \
+	"break test_ldr_literal_16_end"
+
+    gdb_continue_to_breakpoint "continue to test_ldr_literal_16" \
+	".*ldr.*r0\,.*L2.*"
+    gdb_continue_to_breakpoint "continue to test_ldr_literal_16_end" \
+	".*bx lr.*"
+}
+
 ##########################################
 # Test call/ret.
 proc test_call_ret {} {
     global srcfile
+    global testfile
+
+    gdb_test "break *test_call" \
+	"Breakpoint.*at.* file .*$srcfile, line.*" \
+	"break test_call"
+
     gdb_test "break *test_call_end" \
 	"Breakpoint.*at.* file .*$srcfile, line.*" \
 	"break test_call_end"
@@ -82,9 +157,10 @@ proc test_call_ret {} {
 	"Breakpoint.*at.* file .*$srcfile, line.*" \
 	"break test_ret_end"
 
-    gdb_continue_to_breakpoint "continue to test_call_end" \
+    gdb_continue_to_breakpoint "test_call" ".*bl test_call_subr.*"
+    gdb_continue_to_breakpoint "test_call_end" \
 	".*@ Location test_call_end.*"
-    gdb_continue_to_breakpoint "continue to test_ret" \
+    gdb_continue_to_breakpoint "test_ret" \
 	".*bx lr.*"
     gdb_continue_to_breakpoint "continue to test_ret_end" \
 	".*@ Location test_ret_end.*"
@@ -122,7 +198,111 @@ proc test_ldr_from_pc {} {
 
     gdb_continue_to_breakpoint "continue to test_ldr_pc" \
 	".*ldr.*r1\,.*\[pc, #0\].*"
-    gdb_continue_to_breakpoint "continue to Lbranch" \
+    gdb_continue_to_breakpoint "continue to test_ldr_pc_ret" \
+	".*bx lr.*"
+}
+
+#########################################
+
+# Test cbz and cbnz
+proc test_cbz_cbnz {} {
+    global srcfile
+
+    gdb_test_multiple "break *test_zero_cbnz" "break test_zero_cbnz" {
+	-re "Breakpoint.*at.* file .*$srcfile, line.*" {
+	    pass "break test_ldr_literal"
+	}
+	-re "No symbol.*" {
+	    return 0
+	}
+    }
+
+    gdb_test "break *test_zero_cbz" \
+	"Breakpoint.*at.* file .*$srcfile, line.*" \
+	"break test_zero_cbz"
+    gdb_test "break *test_non_zero_cbnz" \
+	"Breakpoint.*at.* file .*$srcfile, line.*" \
+	"break test_non_zero_cbnz"
+    gdb_test "break *test_non_zero_cbz" \
+	"Breakpoint.*at.* file .*$srcfile, line.*" \
+	"break test_non_zero_cbz"
+
+    gdb_continue_to_breakpoint "continue to test_zero_cbnz" \
+	".*cbnz.*r0\,.*\.L3.*"
+    gdb_continue_to_breakpoint "continue to test_zero_cbz" \
+	".*cbz.*r0\,.*\.L3.*"
+    gdb_continue_to_breakpoint "continue to test_non_zero_cbz" \
+	".*cbz.*r0\,.*\.L4.*"
+    gdb_continue_to_breakpoint "continue to test_non_zero_cbnz" \
+	".*cbnz.*r0\,.*\.L4.*"
+}
+
+# Test adr
+
+proc test_adr {} {
+    global srcfile
+
+    gdb_test_multiple "break *test_adr" "break test_adr" {
+	-re "Breakpoint.*at.* file .*$srcfile, line.*" {
+	    pass "break test_adr"
+	}
+	-re "No symbol.*" {
+	    return 0
+	}
+    }
+
+    gdb_test "break *test_adr_end" \
+	"Breakpoint.*at.* file .*$srcfile, line.*" \
+	"break test_adr_end"
+
+    gdb_continue_to_breakpoint "test_adr" \
+	".*adr.*r0\,.*\.L8.*"
+    gdb_continue_to_breakpoint "test_adr_end" \
+	".*bx lr.*"
+}
+
+proc test_adr_32bit {} {
+    global srcfile
+
+    gdb_test_multiple "break *test_adr_32bit" "break test_adr_32bit" {
+	-re "Breakpoint.*at.* file .*$srcfile, line.*" {
+	    pass "break test_adr"
+	}
+	-re "No symbol.*" {
+	    return 0
+	}
+    }
+
+    gdb_test "break *test_adr_32bit_after" \
+	"Breakpoint.*at.* file .*$srcfile, line.*" \
+	"break test_adr_32bit_after"
+
+    gdb_test "break *test_adr_32bit_end" \
+	"Breakpoint.*at.* file .*$srcfile, line.*" \
+	"break test_adr_32bit_end"
+
+    gdb_continue_to_breakpoint "test_adr_32bit" \
+	".*adr.*r0\,.*\.L6.*"
+    gdb_continue_to_breakpoint "test_adr_32bit_after" \
+	".*adr.*r0\,.*\.L6.*"
+    gdb_continue_to_breakpoint "test_adr_32bit_end" \
+	".*bx lr.*"
+}
+
+#########################################
+# Test pop to PC
+proc test_pop_pc {} {
+    global srcfile
+    gdb_test "break *test_pop_pc_1" \
+	"Breakpoint.*at.* file .*$srcfile, line.*" \
+	"break test_pop_pc"
+    gdb_test "break *test_pop_pc_ret" \
+	"Breakpoint.*at.* file .*$srcfile, line.*" \
+	"break test_pop_pc_ret"
+
+    gdb_continue_to_breakpoint "continue to test_pop_pc" \
+	".*b.*\{r1\, pc\}.*"
+    gdb_continue_to_breakpoint "continue to test_pop_pc_ret" \
 	".*bx lr.*"
 }
 
@@ -179,20 +359,6 @@ if ![runto_main] then {
 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
@@ -201,7 +367,20 @@ test_ldr_from_pc
 
 test_ldm_stm_pc
 
+test_ldr_literal
+
+test_ldr_literal_16
+
+test_cbz_cbnz
+
+test_adr
+
+test_adr_32bit
+
+test_pop_pc
+
 test_str_pc
+
 ##########################################
 
 # Done, run program to exit.
-- 
1.7.0.4


  parent reply	other threads:[~2011-03-24 14:05 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-25 14:17 [patch 0/3] Displaced stepping for 16-bit Thumb instructions Yao Qi
2010-12-25 14:22 ` [patch 1/3] " Yao Qi
2011-02-17 19:09   ` Ulrich Weigand
2010-12-25 17:09 ` [patch 2/3] " Yao Qi
2011-02-17 19:46   ` Ulrich Weigand
2011-02-18  6:33     ` Yao Qi
2011-02-18 12:18       ` Ulrich Weigand
2011-02-21  7:41         ` Yao Qi
2011-02-21 20:14           ` Ulrich Weigand
2011-02-25 18:09             ` Yao Qi
2011-02-25 20:17               ` Ulrich Weigand
2011-02-26 14:07                 ` Yao Qi
2011-02-28 17:37                   ` Ulrich Weigand
2011-03-01  9:01                     ` Yao Qi
2011-03-01 16:11                       ` Ulrich Weigand
2010-12-25 17:54 ` [patch 3/3] " Yao Qi
2010-12-27 15:15   ` Yao Qi
2011-02-17 20:55   ` Ulrich Weigand
2011-02-18  7:30     ` Yao Qi
2011-02-18 13:25       ` Ulrich Weigand
2011-02-28  2:04     ` Displaced stepping 0003: " Yao Qi
2010-12-29  5:48 ` [patch 0/3] Displaced stepping " Yao Qi
2011-01-13 12:38 ` Yao Qi
2011-02-10  6:48 ` Ping 2 " Yao Qi
2011-02-26 17:50 ` Displaced stepping 0002: refactor and create some copy helpers Yao Qi
2011-02-28 17:53   ` Ulrich Weigand
2011-02-28  2:15 ` Displaced stepping 0004: wip: 32-bit Thumb instructions Yao Qi
2011-03-24 13:49 ` [try 2nd 0/8] Displaced stepping for " Yao Qi
2011-03-24 13:56   ` [try 2nd 1/8] Fix cleanup_branch to take Thumb into account Yao Qi
2011-04-06 20:46     ` Ulrich Weigand
2011-04-07  3:45       ` Yao Qi
2011-03-24 13:58   ` [try 2nd 2/8] Rename copy_* functions to arm_copy_* Yao Qi
2011-04-06 20:51     ` Ulrich Weigand
2011-04-07  8:02       ` Yao Qi
2011-04-19  9:07         ` Yao Qi
2011-04-26 17:09         ` Ulrich Weigand
2011-04-27 10:27           ` Yao Qi
2011-04-27 13:32             ` Ulrich Weigand
2011-04-28  5:05               ` Yao Qi
2011-03-24 14:01   ` [try 2nd 3/8] Refactor copy_svc_os Yao Qi
2011-04-06 20:55     ` Ulrich Weigand
2011-04-07  4:19       ` Yao Qi
2011-03-24 14:05   ` [try 2nd 4/8] Displaced stepping for Thumb 16-bit insn Yao Qi
2011-05-05 13:24     ` Yao Qi
2011-05-10 13:58       ` Ulrich Weigand
2011-05-11 13:06         ` Yao Qi
2011-05-16 17:19           ` Ulrich Weigand
2011-05-17 14:29             ` Yao Qi
2011-05-17 17:20               ` Ulrich Weigand
2011-03-24 14:05   ` [try 2nd 5/8] Displaced stepping for Thumb 32-bit insns Yao Qi
2011-05-05 13:25     ` Yao Qi
2011-05-17 17:14       ` Ulrich Weigand
2011-05-23 11:32         ` Yao Qi
2011-05-27 22:11           ` Ulrich Weigand
2011-05-23 11:32         ` Yao Qi
2011-07-06 10:55         ` Yao Qi
2011-07-15 19:57           ` Ulrich Weigand
2011-07-18  9:26             ` Yao Qi
2011-03-24 14:06   ` [try 2nd 6/8] Rename some functions to arm_* Yao Qi
2011-04-06 20:52     ` Ulrich Weigand
2011-04-07  4:26       ` Yao Qi
2011-03-24 14:11   ` Yao Qi [this message]
2011-05-05 13:26     ` [try 2nd 7/8] Test case Yao Qi
2011-05-11 13:15       ` [try 2nd 7/8] Test case: V3 Yao Qi
2011-05-17 17:24         ` Ulrich Weigand
2011-03-24 15:14   ` [try 2nd 8/8] NEWS 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=4D8B4FAA.4000004@codesourcery.com \
    --to=yao@codesourcery.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