Rev 2935 | Rev 2941 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2935 | Rev 2936 | ||
---|---|---|---|
Line 36... | Line 36... | ||
36 | #include <stdlib.h> |
36 | #include <stdlib.h> |
37 | #include <sys/types.h> |
37 | #include <sys/types.h> |
38 | #include <udebug.h> |
38 | #include <udebug.h> |
39 | #include <kernel/arch/context_offset.h> |
39 | #include <kernel/arch/context_offset.h> |
40 | 40 | ||
- | 41 | #include "../../../cons.h" |
|
41 | #include "../../../main.h" |
42 | #include "../../../main.h" |
42 | #include "../../../include/arch.h" |
43 | #include "../../../include/arch.h" |
43 | 44 | ||
44 | #define OPCODE_BREAK 0x0000000d |
45 | #define OPCODE_BREAK 0x0000000d |
45 | 46 | ||
Line 56... | Line 57... | ||
56 | brk = brk_list+i; |
57 | brk = brk_list+i; |
57 | break; |
58 | break; |
58 | } |
59 | } |
59 | 60 | ||
60 | if (!brk) { |
61 | if (!brk) { |
61 | printf("too many breakpoints\n"); |
62 | cons_printf("too many breakpoints\n"); |
62 | return; |
63 | return; |
63 | } |
64 | } |
64 | 65 | ||
65 | rc = udebug_mem_read(app_phone, &brk->arch.back, addr, sizeof(&brk->arch.back)); |
66 | rc = udebug_mem_read(app_phone, &brk->arch.back, addr, sizeof(&brk->arch.back)); |
66 | printf("udebug_mem_read() -> %d\n", rc); |
67 | cons_printf("udebug_mem_read() -> %d\n", rc); |
67 | brkp = OPCODE_BREAK; |
68 | brkp = OPCODE_BREAK; |
68 | rc = udebug_mem_write(app_phone, &brkp, addr, sizeof(brkp)); |
69 | rc = udebug_mem_write(app_phone, &brkp, addr, sizeof(brkp)); |
69 | // for (i=0; i<256; i++) rc = udebug_mem_write(app_phone, &brkp, addr+4*i, sizeof(brkp)); |
70 | // for (i=0; i<256; i++) rc = udebug_mem_write(app_phone, &brkp, addr+4*i, sizeof(brkp)); |
70 | printf("udebug_mem_write() -> %d\n", rc); |
71 | cons_printf("udebug_mem_write() -> %d\n", rc); |
71 | 72 | ||
72 | brk->addr = addr; |
73 | brk->addr = addr; |
73 | brk->set = 1; |
74 | brk->set = 1; |
74 | } |
75 | } |
75 | 76 | ||
Line 84... | Line 85... | ||
84 | uint32_t brkp; |
85 | uint32_t brkp; |
85 | 86 | ||
86 | brkp = OPCODE_BREAK; |
87 | brkp = OPCODE_BREAK; |
87 | 88 | ||
88 | rc = udebug_regs_read(app_phone, thread_hash, buffer); |
89 | rc = udebug_regs_read(app_phone, thread_hash, buffer); |
89 | printf("udebug_regs_read -> %d\n", rc); |
90 | cons_printf("udebug_regs_read -> %d\n", rc); |
90 | epc = buffer[EOFFSET_EPC/sizeof(unsigned)]; |
91 | epc = buffer[EOFFSET_EPC/sizeof(unsigned)]; |
91 | printf("EPC was 0x%08x\n", epc); |
92 | cons_printf("EPC was 0x%08x\n", epc); |
92 | brk_addr = epc; |
93 | brk_addr = epc; |
93 | 94 | ||
94 | int bi; |
95 | int bi; |
95 | for (bi = 0; bi < MAX_BRKPTS; bi++) { |
96 | for (bi = 0; bi < MAX_BRKPTS; bi++) { |
96 | if (brk_list[bi].set && brk_list[bi].addr == brk_addr) |
97 | if (brk_list[bi].set && brk_list[bi].addr == brk_addr) |
97 | break; |
98 | break; |
98 | } |
99 | } |
99 | if (bi < MAX_BRKPTS) { |
100 | if (bi < MAX_BRKPTS) { |
100 | printf("breakpoint %d hit\n", bi); |
101 | cons_printf("breakpoint %d hit\n", bi); |
101 | breakpoint_hit(); |
102 | breakpoint_hit(); |
102 | 103 | ||
103 | rc = udebug_mem_write(app_phone, &brk_list[bi].arch.back, brk_addr, 4); |
104 | rc = udebug_mem_write(app_phone, &brk_list[bi].arch.back, brk_addr, 4); |
104 | printf("udebug_mem_write(phone, 0x%x, 0x%02x, 1) -> %d\n", brk_addr, brk_list[bi].arch.back, rc); |
105 | cons_printf("udebug_mem_write(phone, 0x%x, 0x%02x, 1) -> %d\n", brk_addr, brk_list[bi].arch.back, rc); |
105 | rc = udebug_mem_read(app_phone, &brk_list[bi].arch.back, brk_addr+4, 4); |
106 | rc = udebug_mem_read(app_phone, &brk_list[bi].arch.back, brk_addr+4, 4); |
106 | rc = udebug_mem_write(app_phone, &brkp, brk_addr+4, 4); |
107 | rc = udebug_mem_write(app_phone, &brkp, brk_addr+4, 4); |
107 | lifted_brkpt = &brk_list[bi]; |
108 | lifted_brkpt = &brk_list[bi]; |
108 | return; |
109 | return; |
109 | } |
110 | } |
Line 111... | Line 112... | ||
111 | for (bi = 0; bi < MAX_BRKPTS; bi++) { |
112 | for (bi = 0; bi < MAX_BRKPTS; bi++) { |
112 | if (brk_list[bi].set && brk_list[bi].addr + 4 == brk_addr) |
113 | if (brk_list[bi].set && brk_list[bi].addr + 4 == brk_addr) |
113 | break; |
114 | break; |
114 | } |
115 | } |
115 | if (bi < MAX_BRKPTS) { |
116 | if (bi < MAX_BRKPTS) { |
116 | printf("restoring breakpoint %d\n", bi); |
117 | cons_printf("restoring breakpoint %d\n", bi); |
117 | rc = udebug_mem_write(app_phone, &brk_list[bi].arch.back, brk_addr, 4); |
118 | rc = udebug_mem_write(app_phone, &brk_list[bi].arch.back, brk_addr, 4); |
118 | rc = udebug_mem_read(app_phone, &brk_list[bi].arch.back, brk_addr-4, 4); |
119 | rc = udebug_mem_read(app_phone, &brk_list[bi].arch.back, brk_addr-4, 4); |
119 | rc = udebug_mem_write(app_phone, &brkp, brk_addr-4, 4); |
120 | rc = udebug_mem_write(app_phone, &brkp, brk_addr-4, 4); |
120 | lifted_brkpt = NULL; |
121 | lifted_brkpt = NULL; |
121 | return; |
122 | return; |
122 | } |
123 | } |
123 | 124 | ||
124 | printf("unrecognized breakpoint at 0x%x\n", brk_addr); |
125 | cons_printf("unrecognized breakpoint at 0x%x\n", brk_addr); |
125 | } |
126 | } |
126 | 127 | ||
127 | void arch_event_trap(thash_t thread_hash) |
128 | void arch_event_trap(thash_t thread_hash) |
128 | { |
129 | { |
129 | /* Unused */ |
130 | /* Unused */ |