Changeset 80487bc5 in mainline
- Timestamp:
- 2010-01-25T21:40:13Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e515b21a
- Parents:
- 0d21b53
- Files:
-
- 8 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/udebug/udebug.h
r0d21b53 r80487bc5 27 27 */ 28 28 29 /** @addtogroup generic 29 /** @addtogroup generic 30 30 * @{ 31 31 */ … … 83 83 UDEBUG_M_ARGS_READ, 84 84 85 /** Read thread's userspace register state (istate_t). 86 * 87 * - ARG2 - thread identification 88 * - ARG3 - destination address in the caller's address space 89 * 90 * or, on error, retval will be 91 * - ENOENT - thread does not exist 92 * - EBUSY - register state not available 93 */ 94 UDEBUG_M_REGS_READ, 95 85 96 /** Read the list of the debugged tasks's threads. 86 97 * … … 122 133 } udebug_method_t; 123 134 124 135 125 136 typedef enum { 126 137 UDEBUG_EVENT_FINISHED = 1, /**< Debuging session has finished */ -
kernel/generic/include/udebug/udebug_ops.h
r0d21b53 r80487bc5 49 49 int udebug_args_read(thread_t *t, void **buffer); 50 50 51 int udebug_regs_read(thread_t *t, void **buffer); 52 51 53 int udebug_mem_read(unative_t uspace_addr, size_t n, void **buffer); 52 54 -
kernel/generic/src/udebug/udebug_ipc.c
r0d21b53 r80487bc5 287 287 ipc_answer(&TASK->kb.box, call); 288 288 } 289 290 /** Receive a REGS_READ call. 291 * 292 * Reads the thread's register state (istate structure). 293 */ 294 static void udebug_receive_regs_read(call_t *call) 295 { 296 thread_t *t; 297 unative_t uspace_addr; 298 unative_t to_copy; 299 void *buffer; 300 int rc; 301 302 t = (thread_t *) IPC_GET_ARG2(call->data); 303 304 rc = udebug_regs_read(t, &buffer); 305 if (rc < 0) { 306 IPC_SET_RETVAL(call->data, rc); 307 ipc_answer(&TASK->kb.box, call); 308 return; 309 } 310 311 /* 312 * Make use of call->buffer to transfer data to caller's userspace 313 */ 314 315 uspace_addr = IPC_GET_ARG3(call->data); 316 to_copy = sizeof(istate_t); 317 318 IPC_SET_RETVAL(call->data, 0); 319 /* ARG1=dest, ARG2=size as in IPC_M_DATA_READ so that 320 same code in process_answer() can be used 321 (no way to distinguish method in answer) */ 322 IPC_SET_ARG1(call->data, uspace_addr); 323 IPC_SET_ARG2(call->data, to_copy); 324 325 call->buffer = buffer; 326 327 ipc_answer(&TASK->kb.box, call); 328 } 329 289 330 290 331 /** Process an MEM_READ call. … … 374 415 udebug_receive_args_read(call); 375 416 break; 417 case UDEBUG_M_REGS_READ: 418 udebug_receive_regs_read(call); 419 break; 376 420 case UDEBUG_M_MEM_READ: 377 421 udebug_receive_mem_read(call); -
kernel/generic/src/udebug/udebug_ops.c
r0d21b53 r80487bc5 449 449 * this function will fail with an EINVAL error code. 450 450 * 451 * @param buffer The buffer for storing thread hashes. 451 * @param t Thread where call arguments are to be read. 452 * @param buffer Place to store pointer to new buffer. 453 * @return EOK on success, ENOENT if @a t is invalid, EINVAL 454 * if thread state is not valid for this operation. 452 455 */ 453 456 int udebug_args_read(thread_t *t, void **buffer) … … 481 484 } 482 485 486 /** Read the register state of the thread. 487 * 488 * The contents of the thread's istate structure are copied to a newly 489 * allocated buffer and a pointer to it is written to @a buffer. The size of 490 * the buffer will be sizeof(istate_t). 491 * 492 * Currently register state cannot be read if the thread is inside a system 493 * call (as opposed to an exception). This is an implementation limit. 494 * 495 * @param t Thread whose state is to be read. 496 * @param buffer Place to store pointer to new buffer. 497 * @return EOK on success, ENOENT if @a t is invalid, EINVAL 498 * if thread is not in valid state, EBUSY if istate 499 * is not available. 500 */ 501 int udebug_regs_read(thread_t *t, void **buffer) 502 { 503 istate_t *state, *state_buf; 504 int rc; 505 506 /* Prepare a buffer to hold the data. */ 507 state_buf = malloc(sizeof(istate_t), 0); 508 509 /* On success, this will lock t->udebug.lock */ 510 rc = _thread_op_begin(t, false); 511 if (rc != EOK) { 512 return rc; 513 } 514 515 state = t->udebug.uspace_state; 516 if (state == NULL) { 517 _thread_op_end(t); 518 return EBUSY; 519 } 520 521 /* Copy to the allocated buffer */ 522 memcpy(state_buf, state, sizeof(istate_t)); 523 524 _thread_op_end(t); 525 526 *buffer = (void *) state_buf; 527 return 0; 528 } 529 483 530 /** Read the memory of the debugged task. 484 531 * -
uspace/app/taskdump/taskdump.c
r0d21b53 r80487bc5 41 41 #include <task.h> 42 42 #include <kernel/mm/as.h> 43 #include <libarch/istate.h> 43 44 #include <macros.h> 44 45 #include <assert.h> … … 58 59 static void print_syntax(); 59 60 static int threads_dump(void); 61 static int thread_dump(uintptr_t thash); 60 62 static int areas_dump(void); 61 63 static int area_dump(as_area_info_t *area); … … 229 231 for (i = 0; i < n_threads; i++) { 230 232 printf(" [%d] hash: 0x%lx\n", 1+i, thash_buf[i]); 233 234 thread_dump(thash_buf[i]); 231 235 } 232 236 putchar('\n'); … … 291 295 } 292 296 297 static int thread_dump(uintptr_t thash) 298 { 299 istate_t istate; 300 uintptr_t pc, fp; 301 int rc; 302 303 rc = udebug_regs_read(phoneid, thash, &istate); 304 if (rc < 0) { 305 printf("Failed reading registers (%d).\n", rc); 306 return EIO; 307 } 308 309 pc = istate_get_pc(&istate); 310 fp = istate_get_fp(&istate); 311 312 printf("Thread 0x%lx crashed at PC 0x%lx. FP 0x%lx\n", thash, pc, fp); 313 printf("Istate hexdump:\n"); 314 hex_dump(0, &istate, (sizeof(istate_t) + 15) & ~15); 315 316 return EOK; 317 } 318 293 319 static int area_dump(as_area_info_t *area) 294 320 { -
uspace/lib/libc/generic/udebug.c
r0d21b53 r80487bc5 97 97 } 98 98 99 int udebug_regs_read(int phoneid, thash_t tid, void *buffer) 100 { 101 return async_req_3_0(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_REGS_READ, 102 tid, (sysarg_t)buffer); 103 } 104 99 105 int udebug_go(int phoneid, thash_t tid, udebug_event_t *ev_type, 100 106 sysarg_t *val0, sysarg_t *val1) -
uspace/lib/libc/include/udebug.h
r0d21b53 r80487bc5 51 51 int udebug_mem_read(int phoneid, void *buffer, uintptr_t addr, size_t n); 52 52 int udebug_args_read(int phoneid, thash_t tid, sysarg_t *buffer); 53 int udebug_regs_read(int phoneid, thash_t tid, void *buffer); 53 54 int udebug_go(int phoneid, thash_t tid, udebug_event_t *ev_type, 54 55 sysarg_t *val0, sysarg_t *val1);
Note:
See TracChangeset
for help on using the changeset viewer.