aboutsummaryrefslogtreecommitdiff
path: root/Debugger/debug_test.S
blob: ed4ae145b0e55da99618f045e11b03faf389dc1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/** @file debug_test.S
 *  @brief Test Routines to trigger ARM and Thumb Manual Breakpoints
 *
 */

/* Copyright (C) 2007-2011 the NxOS developers
 *
 * Module Developed by: TC Wan <tcwan@cs.usm.my>
 *
 * See AUTHORS for a full list of the developers.
 *
 * See COPYING for redistribution license
 *
 */
#define __ASSEMBLY__
#include "debug_stub.h"

.text
.align 4
.code 32

/**********************************************
 * dbg__test_arm_bkpt Test Routine
 *
 */
	.global dbg__test_arm_bkpt
dbg__test_arm_bkpt:
	stmfd sp!,{lr}
	dbg__bkpt_arm                  /* Trigger ARM Manual Breakpoint */
    ldmfd sp!,{pc}


/**********************************************
 * dbg__test_arm_instrstep Test Routine
 *	Used to test GDB Stepping command
 *	This routine exercises the mov, add, ldr, ldm, b, bl,
 *	and bx instructions which modify the PC (R15)
 *	In addition, conditional instructions are also evaluated.
 *
 */
	.global dbg__test_arm_instrstep
dbg__test_arm_instrstep:
	stmfd	sp!, {lr}
	bl		dbg__test_arm_instr_sub1
	ldr		r1, =test_arm_2			/* R1: pointer to test_arm_2 */
	ldr		r2, =test_arm_2			/* R2: pointer to test_arm_2 (should not be triggered) */
	mov		pc, r1

test_arm_1:
	subs	r0, r0, #1
	addne	pc, r1, #4				/* If R0 > 0, keep branching to a new location */
	/* else R0 == 0 */
	b		exit_dbg__test_arm_instrstep

test_arm_2:
	sub		r0, r0, #1
	cmp		r0, #8
	bls		test_arm_1
	bhi		test_arm_3
	beq		test_arm_2
	ldr		pc, =test_arm_1

test_arm_3:
	/* case for r0 == 9 */
	sub		r0, r0, #1
	teq		r0, #5
	ldreq	r2, =test_arm_1
	ldrne	r2, =test_arm_3
	bx		r2

exit_dbg__test_arm_instrstep:
	bl		dbg__test_arm_instr_sub2
	ldmfd	sp!, {pc}

dbg__test_arm_instr_sub1:
	mov		r0, #10
	bx		lr

dbg__test_arm_instr_sub2:
	stmfd	sp!, {r4, lr}
	mov		r0, #TRUE
	ldmfd	sp!, {r4, pc}

/**********************************************
 * dbg__test_thumb_bkpt Test Routine
 *
 */
	.global dbg__test_thumb_bkpt
dbg__test_thumb_bkpt:
	stmfd sp!,{lr}
/*	ldr r0, =_thumb_entry
	orr	r0, r0, #1					@ Set Thumb mode
	mov	lr, pc
	bx	r0
*/
    bl  _thumb_entry
	ldmfd sp!,{pc}

.code 16
.thumb_func
_thumb_entry:
	dbg__bkpt_thumb
	bx	lr


/**********************************************
 * dbg__test_thumb_instrstep Test Routine
 *	Used to test GDB Stepping command
 *
 */
	.global dbg__test_thumb_instrstep
dbg__test_thumb_instrstep:
	bx	lr


.end