Subversion Repositories HelenOS

Rev

Rev 2804 | Rev 2823 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /** @addtogroup generic
  2.  * @{
  3.  */
  4.  
  5. /**
  6.  * @file
  7.  * @brief   Tdebug.
  8.  */
  9.  
  10. #include <synch/waitq.h>
  11. #include <console/klog.h>
  12. #include <udebug.h>
  13. #include <arch.h>
  14.  
  15. void udebug_stoppable_begin(void)
  16. {
  17.     int nsc;
  18.     call_t *db_call;
  19.  
  20.     spinlock_lock(&TASK->lock);
  21.  
  22.     nsc = --TASK->not_stoppable_count;
  23.     db_call = TASK->debug_begin_call;
  24.  
  25.     if (TASK->stop_request == true) {
  26.         klog_printf("udebug_stoppable_begin");
  27.         klog_printf(" - nsc := %d", nsc);
  28.     }
  29.  
  30.     if (TASK->stop_request == true && nsc == 0) {
  31.         TASK->stop_request = false;
  32.         TASK->debug_begin_call = NULL;
  33.         spinlock_unlock(&TASK->lock);
  34.  
  35.         IPC_SET_RETVAL(db_call->data, 0);
  36.         klog_printf("udebug_stoppable_begin/ipc_answer");
  37.         ipc_answer(&TASK->answerbox, db_call);     
  38.     } else {
  39.             spinlock_unlock(&TASK->lock);
  40.     }
  41. }
  42.  
  43. void udebug_stoppable_end(void)
  44. {
  45. restart:
  46.     spinlock_lock(&TASK->lock);
  47.  
  48.     if (TASK->stop_request) {
  49.         TASK->debug_begin_call = NULL;
  50.         spinlock_unlock(&TASK->lock);
  51.         klog_printf("udebug_stoppable_end: waitq_sleep");
  52.         waitq_sleep(&THREAD->go_wq);
  53.         goto restart;
  54.         /* must try again - have to lose stoppability atomically */
  55.     } else {
  56.         ++TASK->not_stoppable_count;
  57.         spinlock_unlock(&TASK->lock);
  58.     }
  59. }
  60.  
  61. void udebug_syscall_event(unative_t a1, unative_t a2, unative_t a3,
  62.     unative_t a4, unative_t a5, unative_t a6, unative_t id, unative_t rc)
  63. {
  64.     call_t *call;
  65.  
  66.     spinlock_lock(&TASK->lock);
  67.     /* being debugged + have go */
  68.     if (TASK->being_debugged && !TASK->stop_request) { /* locking! */
  69.         klog_printf("udebug_syscall_event");
  70.         call = TASK->debug_go_call;
  71.         IPC_SET_RETVAL(call->data, 0);
  72.         IPC_SET_ARG1(call->data, UDEBUG_EVENT_SYSCALL);
  73.         IPC_SET_ARG2(call->data, id);
  74.         IPC_SET_ARG3(call->data, rc);
  75.         klog_printf("udebug_syscall_event/ipc_answer");
  76.  
  77.         THREAD->syscall_args[0] = a1;
  78.         THREAD->syscall_args[1] = a2;
  79.         THREAD->syscall_args[2] = a3;
  80.         THREAD->syscall_args[3] = a4;
  81.         THREAD->syscall_args[4] = a5;
  82.         THREAD->syscall_args[5] = a6;
  83.  
  84.         ipc_answer(&TASK->answerbox, TASK->debug_go_call);
  85.         spinlock_unlock(&TASK->lock);
  86.         waitq_sleep(&THREAD->go_wq);
  87.     } else {
  88.         spinlock_unlock(&TASK->lock);
  89.     }
  90. }
  91.  
  92. /** @}
  93.  */
  94.