Ignore:
File:
1 edited

Legend:

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

    rd1582b50 rdfa4be62  
    5151#include <udebug/udebug.h>
    5252#include <udebug/udebug_ops.h>
    53 #include <mem.h>
     53#include <memw.h>
    5454#include <stdlib.h>
    5555
     
    8383        mutex_lock(&TASK->udebug.lock);
    8484
    85         /* thread_exists() must be called with threads_lock held */
    86         irq_spinlock_lock(&threads_lock, true);
    87 
    88         if (!thread_exists(thread)) {
    89                 irq_spinlock_unlock(&threads_lock, true);
     85        thread = thread_try_get(thread);
     86
     87        if (!thread) {
    9088                mutex_unlock(&TASK->udebug.lock);
    9189                return ENOENT;
    9290        }
    93 
    94         /* thread->lock is enough to ensure the thread's existence */
    95         irq_spinlock_exchange(&threads_lock, &thread->lock);
    9691
    9792        /* Verify that 'thread' is a userspace thread. */
    9893        if (!thread->uspace) {
    99                 /* It's not, deny its existence */
    100                 irq_spinlock_unlock(&thread->lock, true);
    101                 mutex_unlock(&TASK->udebug.lock);
    102                 return ENOENT;
    103         }
    104 
    105         /* Verify debugging state. */
    106         if (thread->udebug.active != true) {
    107                 /* Not in debugging session or undesired GO state */
    108                 irq_spinlock_unlock(&thread->lock, true);
    109                 mutex_unlock(&TASK->udebug.lock);
    110                 return ENOENT;
    111         }
    112 
    113         /*
    114          * Since the thread has active == true, TASK->udebug.lock
    115          * is enough to ensure its existence and that active remains
    116          * true.
    117          *
    118          */
    119         irq_spinlock_unlock(&thread->lock, true);
    120 
    121         /* Only mutex TASK->udebug.lock left. */
    122 
    123         /* Now verify that the thread belongs to the current task. */
    124         if (thread->task != TASK) {
    125                 /* No such thread belonging this task */
    12694                mutex_unlock(&TASK->udebug.lock);
    12795                return ENOENT;
     
    135103        mutex_lock(&thread->udebug.lock);
    136104
     105        /* Verify debugging state. */
     106        if (thread->udebug.active != true) {
     107                /* Not in debugging session or undesired GO state */
     108                mutex_unlock(&thread->udebug.lock);
     109                mutex_unlock(&TASK->udebug.lock);
     110                return ENOENT;
     111        }
     112
     113        /* Now verify that the thread belongs to the current task. */
     114        if (thread->task != TASK) {
     115                /* No such thread belonging this task */
     116                mutex_unlock(&thread->udebug.lock);
     117                mutex_unlock(&TASK->udebug.lock);
     118                return ENOENT;
     119        }
     120
    137121        /* The big task mutex is no longer needed. */
    138122        mutex_unlock(&TASK->udebug.lock);
     
    153137{
    154138        mutex_unlock(&thread->udebug.lock);
     139
     140        /* Drop reference from _thread_op_begin() */
     141        thread_put(thread);
    155142}
    156143
     
    281268         *
    282269         */
    283         waitq_wakeup(&thread->udebug.go_wq, WAKEUP_FIRST);
     270        waitq_wake_all(&thread->udebug.go_wq);
    284271
    285272        _thread_op_end(thread);
     
    393380        /* FIXME: make sure the thread isn't past debug shutdown... */
    394381        list_foreach(TASK->threads, th_link, thread_t, thread) {
    395                 irq_spinlock_lock(&thread->lock, false);
    396382                bool uspace = thread->uspace;
    397                 irq_spinlock_unlock(&thread->lock, false);
    398383
    399384                /* Not interested in kernel threads. */
Note: See TracChangeset for help on using the changeset viewer.