Ignore:
Timestamp:
2010-01-25T21:40:13Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e515b21a
Parents:
0d21b53
Message:

Allow taskdump to read register state and extract PC, FP (not implemented for all arches).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/udebug/udebug_ops.c

    r0d21b53 r80487bc5  
    449449 * this function will fail with an EINVAL error code.
    450450 *
    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.
    452455 */
    453456int udebug_args_read(thread_t *t, void **buffer)
     
    481484}
    482485
     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 */
     501int 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
    483530/** Read the memory of the debugged task.
    484531 *
Note: See TracChangeset for help on using the changeset viewer.