Changeset 3698e44 in mainline for kernel


Ignore:
Timestamp:
2010-01-26T22:46:29Z (15 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
196a1439, 2314381
Parents:
e515b21a
Message:

Add ability to determine task name and load symbol table from the binary executable. Resolve symbol names in stack traces when dumping.

Location:
kernel/generic
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/udebug/udebug.h

    re515b21a r3698e44  
    107107 */
    108108UDEBUG_M_THREAD_READ,
     109
     110/** Read the name of the debugged task.
     111 *
     112 * - ARG2 - destination address in the caller's address space
     113 * - ARG3 - size of receiving buffer in bytes
     114 *
     115 * The kernel fills the buffer with a non-terminated string.
     116 *
     117 * - ARG2 - number of bytes that were actually copied
     118 * - ARG3 - number of bytes of the complete data
     119 *
     120 */
     121UDEBUG_M_NAME_READ,
    109122
    110123/** Read the list of the debugged task's address space areas.
  • kernel/generic/include/udebug/udebug_ops.h

    re515b21a r3698e44  
    4747int udebug_thread_read(void **buffer, size_t buf_size, size_t *stored,
    4848    size_t *needed);
     49int udebug_name_read(char **data, size_t *data_size);
    4950int udebug_args_read(thread_t *t, void **buffer);
    5051
  • kernel/generic/src/udebug/udebug_ipc.c

    re515b21a r3698e44  
    198198        IPC_SET_ARG3(call->data, needed);
    199199        call->buffer = buffer;
     200
     201        ipc_answer(&TASK->kb.box, call);
     202}
     203
     204/** Process a NAME_READ call.
     205 *
     206 * Returns a string containing the name of the task.
     207 *
     208 * @param call  The call structure.
     209 */
     210static void udebug_receive_name_read(call_t *call)
     211{
     212        unative_t uspace_addr;
     213        unative_t to_copy;
     214        size_t data_size;
     215        size_t buf_size;
     216        void *data;
     217
     218        uspace_addr = IPC_GET_ARG2(call->data); /* Destination address */
     219        buf_size = IPC_GET_ARG3(call->data);    /* Dest. buffer size */
     220
     221        /*
     222         * Read task name.
     223         */
     224        udebug_name_read((char **) &data, &data_size);
     225
     226        /* Copy MAX(buf_size, data_size) bytes */
     227
     228        if (buf_size > data_size)
     229                to_copy = data_size;
     230        else
     231                to_copy = buf_size;
     232
     233        /*
     234         * Make use of call->buffer to transfer data to caller's userspace
     235         */
     236
     237        IPC_SET_RETVAL(call->data, 0);
     238        /* ARG1=dest, ARG2=size as in IPC_M_DATA_READ so that
     239           same code in process_answer() can be used
     240           (no way to distinguish method in answer) */
     241        IPC_SET_ARG1(call->data, uspace_addr);
     242        IPC_SET_ARG2(call->data, to_copy);
     243
     244        IPC_SET_ARG3(call->data, data_size);
     245        call->buffer = data;
    200246
    201247        ipc_answer(&TASK->kb.box, call);
     
    409455                udebug_receive_thread_read(call);
    410456                break;
     457        case UDEBUG_M_NAME_READ:
     458                udebug_receive_name_read(call);
     459                break;
    411460        case UDEBUG_M_AREAS_READ:
    412461                udebug_receive_areas_read(call);
  • kernel/generic/src/udebug/udebug_ops.c

    re515b21a r3698e44  
    4646#include <errno.h>
    4747#include <print.h>
     48#include <string.h>
    4849#include <syscall/copy.h>
    4950#include <ipc/ipc.h>
     
    439440}
    440441
     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 */
     452int 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
    441465/** Read the arguments of a system call.
    442466 *
Note: See TracChangeset for help on using the changeset viewer.