Ignore:
File:
1 edited

Legend:

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

    r44a7ee5 ra53ed3a  
    4646#include <errno.h>
    4747#include <print.h>
     48#include <stdbool.h>
    4849#include <str.h>
    4950#include <syscall/copy.h>
     
    7879 *
    7980 */
    80 static int _thread_op_begin(thread_t *thread, bool being_go)
     81static errno_t _thread_op_begin(thread_t *thread, bool being_go)
    8182{
    8283        mutex_lock(&TASK->udebug.lock);
     
    157158 *
    158159 * Initiates a debugging session for the current task (and its threads).
    159  * When the debugging session has started a reply will be sent to the
     160 * When the debugging session has started a reply should be sent to the
    160161 * UDEBUG_BEGIN call. This may happen immediately in this function if
    161162 * all the threads in this task are stoppable at the moment and in this
    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).
     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).
    166168 *
    167169 * @param call The BEGIN call we are servicing.
    168  *
    169  * @return 0 (OK, but not done yet), 1 (done) or negative error code.
    170  *
    171  */
    172 int udebug_begin(call_t *call)
     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 */
     176errno_t udebug_begin(call_t *call, bool *active)
    173177{
    174178        LOG("Debugging task %" PRIu64, TASK->taskid);
     
    185189        TASK->udebug.debugger = call->sender;
    186190       
    187         int reply;
    188        
    189191        if (TASK->udebug.not_stoppable_count == 0) {
    190192                TASK->udebug.dt_state = UDEBUG_TS_ACTIVE;
    191193                TASK->udebug.begin_call = NULL;
    192                 reply = 1;  /* immediate reply */
     194                *active = true;  /* directly to active state */
    193195        } else
    194                 reply = 0;  /* no reply */
     196                *active = false;  /* only in beginning state */
    195197       
    196198        /* Set udebug.active on all of the task's userspace threads. */
     
    207209       
    208210        mutex_unlock(&TASK->udebug.lock);
    209         return reply;
     211        return EOK;
    210212}
    211213
     
    214216 * Closes the debugging session for the current task.
    215217 *
    216  * @return Zero on success or negative error code.
    217  *
    218  */
    219 int udebug_end(void)
     218 * @return Zero on success or an error code.
     219 *
     220 */
     221errno_t udebug_end(void)
    220222{
    221223        LOG("Task %" PRIu64, TASK->taskid);
    222224       
    223225        mutex_lock(&TASK->udebug.lock);
    224         int rc = udebug_task_cleanup(TASK);
     226        errno_t rc = udebug_task_cleanup(TASK);
    225227        mutex_unlock(&TASK->udebug.lock);
    226228       
     
    234236 * @param mask Or combination of events that should be enabled.
    235237 *
    236  * @return Zero on success or negative error code.
    237  *
    238  */
    239 int udebug_set_evmask(udebug_evmask_t mask)
     238 * @return Zero on success or an error code.
     239 *
     240 */
     241errno_t udebug_set_evmask(udebug_evmask_t mask)
    240242{
    241243        LOG("mask = 0x%x", mask);
     
    251253        mutex_unlock(&TASK->udebug.lock);
    252254       
    253         return 0;
     255        return EOK;
    254256}
    255257
     
    264266 *
    265267 */
    266 int udebug_go(thread_t *thread, call_t *call)
     268errno_t udebug_go(thread_t *thread, call_t *call)
    267269{
    268270        /* On success, this will lock thread->udebug.lock. */
    269         int rc = _thread_op_begin(thread, false);
     271        errno_t rc = _thread_op_begin(thread, false);
    270272        if (rc != EOK)
    271273                return rc;
     
    283285        _thread_op_end(thread);
    284286       
    285         return 0;
     287        return EOK;
    286288}
    287289
     
    295297 *
    296298 */
    297 int udebug_stop(thread_t *thread, call_t *call)
     299errno_t udebug_stop(thread_t *thread, call_t *call)
    298300{
    299301        LOG("udebug_stop()");
     
    304306         *
    305307         */
    306         int rc = _thread_op_begin(thread, true);
     308        errno_t rc = _thread_op_begin(thread, true);
    307309        if (rc != EOK)
    308310                return rc;
     
    314316                /* Answer will be sent when the thread becomes stoppable. */
    315317                _thread_op_end(thread);
    316                 return 0;
     318                return EOK;
    317319        }
    318320       
     
    337339        mutex_unlock(&TASK->udebug.lock);
    338340       
    339         return 0;
     341        return EOK;
    340342}
    341343
     
    362364 *
    363365 */
    364 int udebug_thread_read(void **buffer, size_t buf_size, size_t *stored,
     366errno_t udebug_thread_read(void **buffer, size_t buf_size, size_t *stored,
    365367    size_t *needed)
    366368{
     
    412414        *needed = (copied_ids + extra_ids) * sizeof(sysarg_t);
    413415       
    414         return 0;
     416        return EOK;
    415417}
    416418
     
    426428 *
    427429 */
    428 int udebug_name_read(char **data, size_t *data_size)
     430errno_t udebug_name_read(char **data, size_t *data_size)
    429431{
    430432        size_t name_size = str_size(TASK->name) + 1;
     
    435437        memcpy(*data, TASK->name, name_size);
    436438       
    437         return 0;
     439        return EOK;
    438440}
    439441
     
    455457 *
    456458 */
    457 int udebug_args_read(thread_t *thread, void **buffer)
     459errno_t udebug_args_read(thread_t *thread, void **buffer)
    458460{
    459461        /* On success, this will lock t->udebug.lock. */
    460         int rc = _thread_op_begin(thread, false);
     462        errno_t rc = _thread_op_begin(thread, false);
    461463        if (rc != EOK)
    462464                return rc;
     
    478480       
    479481        *buffer = arg_buffer;
    480         return 0;
     482        return EOK;
    481483}
    482484
     
    498500 *
    499501 */
    500 int udebug_regs_read(thread_t *thread, void **buffer)
     502errno_t udebug_regs_read(thread_t *thread, void **buffer)
    501503{
    502504        /* On success, this will lock t->udebug.lock */
    503         int rc = _thread_op_begin(thread, false);
     505        errno_t rc = _thread_op_begin(thread, false);
    504506        if (rc != EOK)
    505507                return rc;
     
    520522       
    521523        *buffer = (void *) state_buf;
    522         return 0;
     524        return EOK;
    523525}
    524526
     
    534536 *
    535537 */
    536 int udebug_mem_read(sysarg_t uspace_addr, size_t n, void **buffer)
     538errno_t udebug_mem_read(sysarg_t uspace_addr, size_t n, void **buffer)
    537539{
    538540        /* Verify task state */
     
    551553         *
    552554         */
    553         int rc = copy_from_uspace(data_buffer, (void *) uspace_addr, n);
    554         mutex_unlock(&TASK->udebug.lock);
    555        
    556         if (rc != 0)
     555        errno_t rc = copy_from_uspace(data_buffer, (void *) uspace_addr, n);
     556        mutex_unlock(&TASK->udebug.lock);
     557       
     558        if (rc != EOK)
    557559                return rc;
    558560       
    559561        *buffer = data_buffer;
    560         return 0;
     562        return EOK;
    561563}
    562564
Note: See TracChangeset for help on using the changeset viewer.