This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch, testsuite] Add three new tests in arm-disp-step.exp


When preparing the test cases for thumb displaced stepping, I find some
cases can test arm displaced stepping as well, so it is better to send
this part first as an improvement to existing arm displaced stepping test.

Re-run arm-disp-step.exp with
{-marm,-mthumb\}\{-march=armv7-a,-march=armv5te\}, no regression and new
failures.  OK for mainline?

-- 
Yao (éå)
gdb/testsuite/
2011-05-03  Yao Qi  <yao@codesourcery.com>

        * gdb.arch/arm-disp-step.S (test_ldr_literal): New.
        (test_adr_32bit, test_pop_pc): New.
        * gdb.arch/arm-disp-step.exp (test_ldr_literal): New.
        (test_adr_32bit, test_pop_pc): New.

---
 gdb/testsuite/gdb.arch/arm-disp-step.S   |   79 ++++++++++++++++++++++++++
 gdb/testsuite/gdb.arch/arm-disp-step.exp |   90 ++++++++++++++++++++++++++++++
 2 files changed, 169 insertions(+), 0 deletions(-)

diff --git a/gdb/testsuite/gdb.arch/arm-disp-step.S b/gdb/testsuite/gdb.arch/arm-disp-step.S
index 1463555..fa69e31 100644
--- a/gdb/testsuite/gdb.arch/arm-disp-step.S
+++ b/gdb/testsuite/gdb.arch/arm-disp-step.S
@@ -48,6 +48,20 @@ test_ret_end:
 	bl test_ldm_stm_pc
 #endif
 
+	/* Test ldrX literal in ARM */
+#if !defined (__thumb__)
+	bl test_ldr_literal
+#endif
+
+	/* Test 32-bit adr in ARM */
+#if !defined(__thumb__)
+	bl test_adr_32bit
+#endif
+
+#if !defined(__thumb__)
+	bl test_pop_pc
+#endif
+
 	/* Test str in ARM mode and Thumb-2 */
 #if !defined(__thumb__)
 	bl test_str_pc
@@ -123,6 +137,71 @@ test_ldm_stm_pc_ret:
 	.size test_ldm_stm_pc, .-test_ldm_stm_pc
 #endif
 
+#if !defined (__thumb__)
+	.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_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__)
 	.code   16
diff --git a/gdb/testsuite/gdb.arch/arm-disp-step.exp b/gdb/testsuite/gdb.arch/arm-disp-step.exp
index 3bea521..8331197 100644
--- a/gdb/testsuite/gdb.arch/arm-disp-step.exp
+++ b/gdb/testsuite/gdb.arch/arm-disp-step.exp
@@ -68,6 +68,45 @@ 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
+
+    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.*"
+}
+
 ##########################################
 # Test call/ret.
 proc test_call_ret {} {
@@ -126,6 +165,51 @@ proc test_ldr_from_pc {} {
 	".*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.*"
+}
+
 ###########################################
 
 proc test_str_pc {} {
@@ -201,6 +285,12 @@ test_ldr_from_pc
 
 test_ldm_stm_pc
 
+test_ldr_literal
+
+test_adr_32bit
+
+test_pop_pc
+
 test_str_pc
 ##########################################
 
-- 
1.7.0.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]