- 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
- Location:
- kernel/generic
- Files:
-
- 4 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 *
Note:
See TracChangeset
for help on using the changeset viewer.