Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 0d21b53 in mainline


Ignore:
Timestamp:
2010-01-25T20:15:00Z (12 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master
Children:
80487bc5
Parents:
bc310a05
Message:

Move code code waiting for debugger to udebug.c:udebug_thread_fault(). Do not call it if nobody is subscribed for FAULT events. Make thread stoppable during all waiting in udebug_thread_fault().

Location:
kernel/generic
Files:
3 edited

Legend:

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

    rbc310a05 r0d21b53  
    218218
    219219int udebug_task_cleanup(struct task *ta);
     220void udebug_thread_fault(void);
    220221
    221222#endif
  • kernel/generic/src/interrupt/interrupt.c

    rbc310a05 r0d21b53  
    134134        printf("\n");
    135135
     136        /*
     137         * Userspace can subscribe for FAULT events to take action
     138         * whenever a thread faults. (E.g. take a dump, run a debugger).
     139         * The notification is always available, but unless Udebug is enabled,
     140         * that's all you get.
     141         */
    136142        if (event_is_subscribed(EVENT_FAULT)) {
     143                /* Notify the subscriber that a fault occurred. */
    137144                event_notify_3(EVENT_FAULT, LOWER32(TASK->taskid),
    138145                    UPPER32(TASK->taskid), (unative_t) THREAD);
     146
     147#ifdef CONFIG_UDEBUG
     148                /* Wait for a debugging session. */
     149                udebug_thread_fault();
     150#endif
    139151        }
    140 
    141 #ifdef CONFIG_UDEBUG
    142         /* Wait until a debugger attends to us. */
    143         mutex_lock(&THREAD->udebug.lock);
    144         while (!THREAD->udebug.active)
    145                 condvar_wait(&THREAD->udebug.active_cv, &THREAD->udebug.lock);
    146         mutex_unlock(&THREAD->udebug.lock);
    147 
    148         udebug_stoppable_begin();
    149         udebug_stoppable_end();
    150 
    151         /* Make sure the debugging session is over before proceeding. */
    152         mutex_lock(&THREAD->udebug.lock);
    153         while (THREAD->udebug.active)
    154                 condvar_wait(&THREAD->udebug.active_cv, &THREAD->udebug.lock);
    155         mutex_unlock(&THREAD->udebug.lock);
    156 #endif
    157152
    158153        task_kill(task->taskid);
  • kernel/generic/src/udebug/udebug.c

    rbc310a05 r0d21b53  
    460460}
    461461
     462/** Wait for debugger to handle a fault in this thread.
     463 *
     464 * When a thread faults and someone is subscribed to the FAULT kernel event,
     465 * this function is called to wait for a debugging session to give userspace
     466 * a chance to examine the faulting thead/task. When the debugging session
     467 * is over, this function returns (so that thread/task cleanup can continue).
     468 */
     469void udebug_thread_fault(void)
     470{
     471        udebug_stoppable_begin();
     472
     473        /* Wait until a debugger attends to us. */
     474        mutex_lock(&THREAD->udebug.lock);
     475        while (!THREAD->udebug.active)
     476                condvar_wait(&THREAD->udebug.active_cv, &THREAD->udebug.lock);
     477        mutex_unlock(&THREAD->udebug.lock);
     478
     479        /* Make sure the debugging session is over before proceeding. */
     480        mutex_lock(&THREAD->udebug.lock);
     481        while (THREAD->udebug.active)
     482                condvar_wait(&THREAD->udebug.active_cv, &THREAD->udebug.lock);
     483        mutex_unlock(&THREAD->udebug.lock);
     484
     485        udebug_stoppable_end();
     486}
    462487
    463488/** @}
Note: See TracChangeset for help on using the changeset viewer.