Ignore:
File:
1 edited

Legend:

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

    ra53ed3a r44a7ee5  
    4646#include <errno.h>
    4747#include <print.h>
    48 #include <stdbool.h>
    4948#include <str.h>
    5049#include <syscall/copy.h>
     
    7978 *
    8079 */
    81 static errno_t _thread_op_begin(thread_t *thread, bool being_go)
     80static int _thread_op_begin(thread_t *thread, bool being_go)
    8281{
    8382        mutex_lock(&TASK->udebug.lock);
     
    158157 *
    159158 * Initiates a debugging session for the current task (and its threads).
    160  * When the debugging session has started a reply should be sent to the
     159 * When the debugging session has started a reply will be sent to the
    161160 * UDEBUG_BEGIN call. This may happen immediately in this function if
    162161 * all the threads in this task are stoppable at the moment and in this
    163  * case the function sets @a *active to @c true.
    164  *
    165  * Otherwise the function sets @a *active to false and the resonse should
    166  * be sent as soon as all the threads become stoppable (i.e. they can be
    167  * considered stopped).
     162 * case the function returns 1.
     163 *
     164 * Otherwise the function returns 0 and the reply will be sent as soon as
     165 * all the threads become stoppable (i.e. they can be considered stopped).
    168166 *
    169167 * @param call The BEGIN call we are servicing.
    170  * @param active Place to store @c true iff we went directly to active state,
    171  *               @c false if we only went to beginning state
    172  *
    173  * @return EOK on success, EBUSY if the task is already has an active
    174  *         debugging session.
    175  */
    176 errno_t udebug_begin(call_t *call, bool *active)
     168 *
     169 * @return 0 (OK, but not done yet), 1 (done) or negative error code.
     170 *
     171 */
     172int udebug_begin(call_t *call)
    177173{
    178174        LOG("Debugging task %" PRIu64, TASK->taskid);
     
    189185        TASK->udebug.debugger = call->sender;
    190186       
     187        int reply;
     188       
    191189        if (TASK->udebug.not_stoppable_count == 0) {
    192190                TASK->udebug.dt_state = UDEBUG_TS_ACTIVE;
    193191                TASK->udebug.begin_call = NULL;
    194                 *active = true;  /* directly to active state */
     192                reply = 1;  /* immediate reply */
    195193        } else
    196                 *active = false;  /* only in beginning state */
     194                reply = 0;  /* no reply */
    197195       
    198196        /* Set udebug.active on all of the task's userspace threads. */
     
    209207       
    210208        mutex_unlock(&TASK->udebug.lock);
    211         return EOK;
     209        return reply;
    212210}
    213211
     
    216214 * Closes the debugging session for the current task.
    217215 *
    218  * @return Zero on success or an error code.
    219  *
    220  */
    221 errno_t udebug_end(void)
     216 * @return Zero on success or negative error code.
     217 *
     218 */
     219int udebug_end(void)
    222220{
    223221        LOG("Task %" PRIu64, TASK->taskid);
    224222       
    225223        mutex_lock(&TASK->udebug.lock);
    226         errno_t rc = udebug_task_cleanup(TASK);
     224        int rc = udebug_task_cleanup(TASK);
    227225        mutex_unlock(&TASK->udebug.lock);
    228226       
     
    236234 * @param mask Or combination of events that should be enabled.
    237235 *
    238  * @return Zero on success or an error code.
    239  *
    240  */
    241 errno_t udebug_set_evmask(udebug_evmask_t mask)
     236 * @return Zero on success or negative error code.
     237 *
     238 */
     239int udebug_set_evmask(udebug_evmask_t mask)
    242240{
    243241        LOG("mask = 0x%x", mask);
     
    253251        mutex_unlock(&TASK->udebug.lock);
    254252       
    255         return EOK;
     253        return 0;
    256254}
    257255
     
    266264 *
    267265 */
    268 errno_t udebug_go(thread_t *thread, call_t *call)
     266int udebug_go(thread_t *thread, call_t *call)
    269267{
    270268        /* On success, this will lock thread->udebug.lock. */
    271         errno_t rc = _thread_op_begin(thread, false);
     269        int rc = _thread_op_begin(thread, false);
    272270        if (rc != EOK)
    273271                return rc;
     
    285283        _thread_op_end(thread);
    286284       
    287         return EOK;
     285        return 0;
    288286}
    289287
     
    297295 *
    298296 */
    299 errno_t udebug_stop(thread_t *thread, call_t *call)
     297int udebug_stop(thread_t *thread, call_t *call)
    300298{
    301299        LOG("udebug_stop()");
     
    306304         *
    307305         */
    308         errno_t rc = _thread_op_begin(thread, true);
     306        int rc = _thread_op_begin(thread, true);
    309307        if (rc != EOK)
    310308                return rc;
     
    316314                /* Answer will be sent when the thread becomes stoppable. */
    317315                _thread_op_end(thread);
    318                 return EOK;
     316                return 0;
    319317        }
    320318       
     
    339337        mutex_unlock(&TASK->udebug.lock);
    340338       
    341         return EOK;
     339        return 0;
    342340}
    343341
     
    364362 *
    365363 */
    366 errno_t udebug_thread_read(void **buffer, size_t buf_size, size_t *stored,
     364int udebug_thread_read(void **buffer, size_t buf_size, size_t *stored,
    367365    size_t *needed)
    368366{
     
    414412        *needed = (copied_ids + extra_ids) * sizeof(sysarg_t);
    415413       
    416         return EOK;
     414        return 0;
    417415}
    418416
     
    428426 *
    429427 */
    430 errno_t udebug_name_read(char **data, size_t *data_size)
     428int udebug_name_read(char **data, size_t *data_size)
    431429{
    432430        size_t name_size = str_size(TASK->name) + 1;
     
    437435        memcpy(*data, TASK->name, name_size);
    438436       
    439         return EOK;
     437        return 0;
    440438}
    441439
     
    457455 *
    458456 */
    459 errno_t udebug_args_read(thread_t *thread, void **buffer)
     457int udebug_args_read(thread_t *thread, void **buffer)
    460458{
    461459        /* On success, this will lock t->udebug.lock. */
    462         errno_t rc = _thread_op_begin(thread, false);
     460        int rc = _thread_op_begin(thread, false);
    463461        if (rc != EOK)
    464462                return rc;
     
    480478       
    481479        *buffer = arg_buffer;
    482         return EOK;
     480        return 0;
    483481}
    484482
     
    500498 *
    501499 */
    502 errno_t udebug_regs_read(thread_t *thread, void **buffer)
     500int udebug_regs_read(thread_t *thread, void **buffer)
    503501{
    504502        /* On success, this will lock t->udebug.lock */
    505         errno_t rc = _thread_op_begin(thread, false);
     503        int rc = _thread_op_begin(thread, false);
    506504        if (rc != EOK)
    507505                return rc;
     
    522520       
    523521        *buffer = (void *) state_buf;
    524         return EOK;
     522        return 0;
    525523}
    526524
     
    536534 *
    537535 */
    538 errno_t udebug_mem_read(sysarg_t uspace_addr, size_t n, void **buffer)
     536int udebug_mem_read(sysarg_t uspace_addr, size_t n, void **buffer)
    539537{
    540538        /* Verify task state */
     
    553551         *
    554552         */
    555         errno_t rc = copy_from_uspace(data_buffer, (void *) uspace_addr, n);
    556         mutex_unlock(&TASK->udebug.lock);
    557        
    558         if (rc != EOK)
     553        int rc = copy_from_uspace(data_buffer, (void *) uspace_addr, n);
     554        mutex_unlock(&TASK->udebug.lock);
     555       
     556        if (rc != 0)
    559557                return rc;
    560558       
    561559        *buffer = data_buffer;
    562         return EOK;
     560        return 0;
    563561}
    564562
Note: See TracChangeset for help on using the changeset viewer.