Changes in kernel/generic/src/udebug/udebug_ops.c [a074b4f:3698e44] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/udebug/udebug_ops.c
ra074b4f r3698e44 46 46 #include <errno.h> 47 47 #include <print.h> 48 #include <string.h> 48 49 #include <syscall/copy.h> 49 50 #include <ipc/ipc.h> … … 439 440 } 440 441 442 /** Read task name. 443 * 444 * Returns task name as non-terminated string in a newly allocated buffer. 445 * Also returns the size of the data. 446 * 447 * @param data Place to store pointer to newly allocated block. 448 * @param data_size Place to store size of the data. 449 * 450 * @returns EOK. 451 */ 452 int udebug_name_read(char **data, size_t *data_size) 453 { 454 size_t name_size; 455 456 name_size = str_size(TASK->name) + 1; 457 *data = malloc(name_size, 0); 458 *data_size = name_size; 459 460 memcpy(*data, TASK->name, name_size); 461 462 return 0; 463 } 464 441 465 /** Read the arguments of a system call. 442 466 * … … 449 473 * this function will fail with an EINVAL error code. 450 474 * 451 * @param buffer The buffer for storing thread hashes. 475 * @param t Thread where call arguments are to be read. 476 * @param buffer Place to store pointer to new buffer. 477 * @return EOK on success, ENOENT if @a t is invalid, EINVAL 478 * if thread state is not valid for this operation. 452 479 */ 453 480 int udebug_args_read(thread_t *t, void **buffer) … … 481 508 } 482 509 510 /** Read the register state of the thread. 511 * 512 * The contents of the thread's istate structure are copied to a newly 513 * allocated buffer and a pointer to it is written to @a buffer. The size of 514 * the buffer will be sizeof(istate_t). 515 * 516 * Currently register state cannot be read if the thread is inside a system 517 * call (as opposed to an exception). This is an implementation limit. 518 * 519 * @param t Thread whose state is to be read. 520 * @param buffer Place to store pointer to new buffer. 521 * @return EOK on success, ENOENT if @a t is invalid, EINVAL 522 * if thread is not in valid state, EBUSY if istate 523 * is not available. 524 */ 525 int udebug_regs_read(thread_t *t, void **buffer) 526 { 527 istate_t *state, *state_buf; 528 int rc; 529 530 /* Prepare a buffer to hold the data. */ 531 state_buf = malloc(sizeof(istate_t), 0); 532 533 /* On success, this will lock t->udebug.lock */ 534 rc = _thread_op_begin(t, false); 535 if (rc != EOK) { 536 return rc; 537 } 538 539 state = t->udebug.uspace_state; 540 if (state == NULL) { 541 _thread_op_end(t); 542 return EBUSY; 543 } 544 545 /* Copy to the allocated buffer */ 546 memcpy(state_buf, state, sizeof(istate_t)); 547 548 _thread_op_end(t); 549 550 *buffer = (void *) state_buf; 551 return 0; 552 } 553 483 554 /** Read the memory of the debugged task. 484 555 *
Note:
See TracChangeset
for help on using the changeset viewer.