This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch, testsuite] Add three new tests in arm-disp-step.exp
On 05/03/2011 10:55 PM, Joel Brobecker wrote:
>> > + gdb_test_multiple "break *test_ldr_literal" "break test_ldr_literal" {
>> > + -re "Breakpoint.*at.* file .*$srcfile, line.*" {
>> > + pass "break test_ldr_literal"
>> > + }
> Aren't we supposed to consume the GDB prompt as well, when using
> gdb_test_multiple -re ?
Yes, we should. I read GDBTestcaseCookbook
(http://sourceware.org/gdb/wiki/GDBTestcaseCookbook) again, and this is
mentioned in it.
How about this one? Test result is same as the last patch.
--
Yao (éå)
2011-05-04 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 | 88 ++++++++++++++++++++++++++++++
2 files changed, 167 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..0427a04 100644
--- a/gdb/testsuite/gdb.arch/arm-disp-step.exp
+++ b/gdb/testsuite/gdb.arch/arm-disp-step.exp
@@ -68,6 +68,42 @@ 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
+ global gdb_prompt
+
+ gdb_test_multiple "break *test_ldr_literal" "break test_ldr_literal" {
+ -re "Breakpoint.*at.* file .*$srcfile, line.*\r\n$gdb_prompt $" {
+ pass "break test_ldr_literal"
+ }
+ -re "No symbol.*\r\n$gdb_prompt $" {
+ 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 +162,52 @@ proc test_ldr_from_pc {} {
".*bx lr.*"
}
+proc test_adr_32bit {} {
+ global srcfile
+ global gdb_prompt
+
+ gdb_test_multiple "break *test_adr_32bit" "break test_adr_32bit" {
+ -re "Breakpoint.*at.* file .*$srcfile, line.*\r\n$gdb_prompt $" {
+ pass "break test_adr"
+ }
+ -re "No symbol.*\r\n$gdb_prompt $" {
+ 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 +283,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