Rev 2903 | Rev 2946 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2903 | Rev 2904 | ||
---|---|---|---|
Line 49... | Line 49... | ||
49 | #include "../../srv/console/console.h" |
49 | #include "../../srv/console/console.h" |
50 | 50 | ||
51 | #include "syscalls.h" |
51 | #include "syscalls.h" |
52 | #include "ipcp.h" |
52 | #include "ipcp.h" |
53 | #include "errors.h" |
53 | #include "errors.h" |
54 | #include "debug_api.h" |
- | |
55 | 54 | ||
56 | #define THBUF_SIZE 64 |
55 | #define THBUF_SIZE 64 |
57 | unsigned thread_hash_buf[THBUF_SIZE]; |
56 | unsigned thread_hash_buf[THBUF_SIZE]; |
58 | unsigned n_threads; |
57 | unsigned n_threads; |
59 | 58 | ||
Line 77... | Line 76... | ||
77 | rc = ipc_connect_kbox(taskid); |
76 | rc = ipc_connect_kbox(taskid); |
78 | printf("-> %d\n", rc); |
77 | printf("-> %d\n", rc); |
79 | phoneid = rc; |
78 | phoneid = rc; |
80 | if (rc < 0) return rc; |
79 | if (rc < 0) return rc; |
81 | 80 | ||
82 | printf("debug_begin()... "); |
81 | printf("udebug_begin()... "); |
83 | rc = debug_begin(phoneid); |
82 | rc = udebug_begin(phoneid); |
84 | printf("-> %d\n", rc); |
83 | printf("-> %d\n", rc); |
85 | if (rc < 0) return rc; |
84 | if (rc < 0) return rc; |
86 | 85 | ||
87 | printf("debug_set_evmask(0x%x)... ", UDEBUG_EM_ALL); |
86 | printf("udebug_set_evmask(0x%x)... ", UDEBUG_EM_ALL); |
88 | rc = debug_set_evmask(phoneid, UDEBUG_EM_ALL); |
87 | rc = udebug_set_evmask(phoneid, UDEBUG_EM_ALL); |
89 | printf("-> %d\n", rc); |
88 | printf("-> %d\n", rc); |
90 | if (rc < 0) return rc; |
89 | if (rc < 0) return rc; |
91 | 90 | ||
92 | return 0; |
91 | return 0; |
93 | } |
92 | } |
Line 99... | Line 98... | ||
99 | int tb_needed; |
98 | int tb_needed; |
100 | int i; |
99 | int i; |
101 | 100 | ||
102 | 101 | ||
103 | printf("send IPC_M_DEBUG_THREAD_READ message\n"); |
102 | printf("send IPC_M_DEBUG_THREAD_READ message\n"); |
104 | rc = debug_thread_read(phoneid, (unsigned)thread_hash_buf, |
103 | rc = udebug_thread_read(phoneid, (unsigned)thread_hash_buf, |
105 | THBUF_SIZE*sizeof(unsigned), &tb_copied, &tb_needed); |
104 | THBUF_SIZE*sizeof(unsigned), &tb_copied, &tb_needed); |
106 | printf("-> %d\n", rc); |
105 | printf("-> %d\n", rc); |
107 | if (rc < 0) return rc; |
106 | if (rc < 0) return rc; |
108 | 107 | ||
109 | n_threads = tb_copied / sizeof(unsigned); |
108 | n_threads = tb_copied / sizeof(unsigned); |
Line 183... | Line 182... | ||
183 | 182 | ||
184 | if (sc_rc == IPC_CALLRET_FATAL || sc_rc == IPC_CALLRET_TEMPORARY) |
183 | if (sc_rc == IPC_CALLRET_FATAL || sc_rc == IPC_CALLRET_TEMPORARY) |
185 | return; |
184 | return; |
186 | 185 | ||
187 | memset(&call, 0, sizeof(call)); |
186 | memset(&call, 0, sizeof(call)); |
188 | rc = debug_mem_read(phoneid, &call.args, sc_args[1], sizeof(call.args)); |
187 | rc = udebug_mem_read(phoneid, &call.args, sc_args[1], sizeof(call.args)); |
189 | 188 | ||
190 | if (rc >= 0) { |
189 | if (rc >= 0) { |
191 | ipcp_call_out(sc_args[0], &call, sc_rc); |
190 | ipcp_call_out(sc_args[0], &call, sc_rc); |
192 | } |
191 | } |
193 | } |
192 | } |
Line 208... | Line 207... | ||
208 | IPC_SET_ARG4(question, 0); |
207 | IPC_SET_ARG4(question, 0); |
209 | IPC_SET_ARG5(question, 0); |
208 | IPC_SET_ARG5(question, 0); |
210 | 209 | ||
211 | // printf("memset\n"); |
210 | // printf("memset\n"); |
212 | memset(&reply, 0, sizeof(reply)); |
211 | memset(&reply, 0, sizeof(reply)); |
213 | // printf("debug_mem_read(phone=%d, buffer_ptr=%u, src_addr=%d, n=%d\n", |
212 | // printf("udebug_mem_read(phone=%d, buffer_ptr=%u, src_addr=%d, n=%d\n", |
214 | // phoneid, &reply.args, sc_args[5], sizeof(reply.args)); |
213 | // phoneid, &reply.args, sc_args[5], sizeof(reply.args)); |
215 | rc = debug_mem_read(phoneid, &reply.args, sc_args[5], sizeof(reply.args)); |
214 | rc = udebug_mem_read(phoneid, &reply.args, sc_args[5], sizeof(reply.args)); |
216 | // printf("dmr->%d\n", rc); |
215 | // printf("dmr->%d\n", rc); |
217 | if (rc < 0) return; |
216 | if (rc < 0) return; |
218 | 217 | ||
219 | // printf("call ipc_call_sync\n"); |
218 | // printf("call ipc_call_sync\n"); |
220 | ipcp_call_sync(phoneidx, &question, &reply); |
219 | ipcp_call_sync(phoneidx, &question, &reply); |
Line 224... | Line 223... | ||
224 | { |
223 | { |
225 | ipc_call_t question, reply; |
224 | ipc_call_t question, reply; |
226 | int rc; |
225 | int rc; |
227 | 226 | ||
228 | memset(&question, 0, sizeof(question)); |
227 | memset(&question, 0, sizeof(question)); |
229 | rc = debug_mem_read(phoneid, &question.args, sc_args[1], sizeof(question.args)); |
228 | rc = udebug_mem_read(phoneid, &question.args, sc_args[1], sizeof(question.args)); |
230 | printf("dmr->%d\n", rc); |
229 | printf("dmr->%d\n", rc); |
231 | if (rc < 0) return; |
230 | if (rc < 0) return; |
232 | 231 | ||
233 | memset(&reply, 0, sizeof(reply)); |
232 | memset(&reply, 0, sizeof(reply)); |
234 | rc = debug_mem_read(phoneid, &reply.args, sc_args[2], sizeof(reply.args)); |
233 | rc = udebug_mem_read(phoneid, &reply.args, sc_args[2], sizeof(reply.args)); |
235 | printf("dmr->%d\n", rc); |
234 | printf("dmr->%d\n", rc); |
236 | if (rc < 0) return; |
235 | if (rc < 0) return; |
237 | 236 | ||
238 | ipcp_call_sync(sc_args[0], &question, &reply); |
237 | ipcp_call_sync(sc_args[0], &question, &reply); |
239 | } |
238 | } |
Line 244... | Line 243... | ||
244 | int rc; |
243 | int rc; |
245 | 244 | ||
246 | if (sc_rc == 0) return 0; |
245 | if (sc_rc == 0) return 0; |
247 | 246 | ||
248 | memset(&call, 0, sizeof(call)); |
247 | memset(&call, 0, sizeof(call)); |
249 | rc = debug_mem_read(phoneid, &call, sc_args[0], sizeof(call)); |
248 | rc = udebug_mem_read(phoneid, &call, sc_args[0], sizeof(call)); |
250 | // printf("debug_mem_read(phone %d, dest %d, app-mem src %d, size %d -> %d\n", |
249 | // printf("udebug_mem_read(phone %d, dest %d, app-mem src %d, size %d -> %d\n", |
251 | // phoneid, (int)&call, sc_args[0], sizeof(call), rc); |
250 | // phoneid, (int)&call, sc_args[0], sizeof(call), rc); |
252 | 251 | ||
253 | if (rc >= 0) { |
252 | if (rc >= 0) { |
254 | ipcp_call_in(&call, sc_rc); |
253 | ipcp_call_in(&call, sc_rc); |
255 | } |
254 | } |
Line 260... | Line 259... | ||
260 | unsigned sc_args[6]; |
259 | unsigned sc_args[6]; |
261 | int rv_type; |
260 | int rv_type; |
262 | int rc; |
261 | int rc; |
263 | 262 | ||
264 | /* Read syscall arguments */ |
263 | /* Read syscall arguments */ |
265 | rc = debug_args_read(phoneid, thread_hash, sc_args); |
264 | rc = udebug_args_read(phoneid, thread_hash, sc_args); |
266 | 265 | ||
267 | async_serialize_start(); |
266 | async_serialize_start(); |
268 | 267 | ||
269 | // printf("[%d] ", thread_id); |
268 | // printf("[%d] ", thread_id); |
270 | 269 | ||
Line 286... | Line 285... | ||
286 | unsigned sc_args[6]; |
285 | unsigned sc_args[6]; |
287 | int rv_type; |
286 | int rv_type; |
288 | int rc; |
287 | int rc; |
289 | 288 | ||
290 | /* Read syscall arguments */ |
289 | /* Read syscall arguments */ |
291 | rc = debug_args_read(phoneid, thread_hash, sc_args); |
290 | rc = udebug_args_read(phoneid, thread_hash, sc_args); |
292 | 291 | ||
293 | async_serialize_start(); |
292 | async_serialize_start(); |
294 | 293 | ||
295 | // printf("[%d] ", thread_id); |
294 | // printf("[%d] ", thread_id); |
296 | 295 | ||
Line 349... | Line 348... | ||
349 | printf("trace_loop(%d)\n", thread_id); |
348 | printf("trace_loop(%d)\n", thread_id); |
350 | 349 | ||
351 | while (!abort_trace) { |
350 | while (!abort_trace) { |
352 | 351 | ||
353 | /* Run thread until an event occurs */ |
352 | /* Run thread until an event occurs */ |
354 | rc = debug_go(phoneid, thread_hash, |
353 | rc = udebug_go(phoneid, thread_hash, |
355 | &ev_type, &val0, &val1); |
354 | &ev_type, &val0, &val1); |
356 | 355 | ||
357 | // printf("rc = %d, ev_type=%d\n", rc, ev_type); |
356 | // printf("rc = %d, ev_type=%d\n", rc, ev_type); |
358 | if (ev_type == UDEBUG_EVENT_FINISHED) { |
357 | if (ev_type == UDEBUG_EVENT_FINISHED) { |
359 | printf("thread %u debugging finished\n", thread_id); |
358 | printf("thread %u debugging finished\n", thread_id); |
Line 448... | Line 447... | ||
448 | while(1) { |
447 | while(1) { |
449 | c = getchar(); |
448 | c = getchar(); |
450 | if (c == 'q') break; |
449 | if (c == 'q') break; |
451 | if (c == 'p') { |
450 | if (c == 'p') { |
452 | paused = 1; |
451 | paused = 1; |
453 | rc = debug_stop(phoneid, thash); |
452 | rc = udebug_stop(phoneid, thash); |
454 | printf("stop -> %d\n", rc); |
453 | printf("stop -> %d\n", rc); |
455 | } |
454 | } |
456 | if (c == 'r') { |
455 | if (c == 'r') { |
457 | paused = 0; |
456 | paused = 0; |
458 | } |
457 | } |
459 | } |
458 | } |
460 | 459 | ||
461 | printf("terminate debugging session...\n"); |
460 | printf("terminate debugging session...\n"); |
462 | abort_trace = 1; |
461 | abort_trace = 1; |
463 | debug_end(phoneid); |
462 | udebug_end(phoneid); |
464 | ipc_hangup(phoneid); |
463 | ipc_hangup(phoneid); |
465 | 464 | ||
466 | ipcp_cleanup(); |
465 | ipcp_cleanup(); |
467 | 466 | ||
468 | printf("done\n"); |
467 | printf("done\n"); |