Changeset 8565a42 in mainline for kernel/generic/src/udebug


Ignore:
Timestamp:
2018-03-02T20:34:50Z (8 years ago)
Author:
GitHub <noreply@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a1a81f69, d5e5fd1
Parents:
3061bc1 (diff), 34e1206 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:34:50)
git-committer:
GitHub <noreply@…> (2018-03-02 20:34:50)
Message:

Remove all trailing whitespace, everywhere.

See individual commit messages for details.

Location:
kernel/generic/src/udebug
Files:
2 edited

Legend:

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

    r3061bc1 r8565a42  
    7575        waitq_initialize(&ut->go_wq);
    7676        condvar_initialize(&ut->active_cv);
    77        
     77
    7878        ut->go_call = NULL;
    7979        ut->uspace_state = NULL;
     
    9696{
    9797        ipl_t ipl = waitq_sleep_prepare(wq);
    98        
     98
    9999        wq->missed_wakeups = 0;  /* Enforce blocking. */
    100100        bool blocked;
     
    119119        assert(THREAD);
    120120        assert(TASK);
    121        
     121
    122122        mutex_lock(&TASK->udebug.lock);
    123        
     123
    124124        int nsc = --TASK->udebug.not_stoppable_count;
    125        
     125
    126126        /* Lock order OK, THREAD->udebug.lock is after TASK->udebug.lock */
    127127        mutex_lock(&THREAD->udebug.lock);
    128128        assert(THREAD->udebug.stoppable == false);
    129129        THREAD->udebug.stoppable = true;
    130        
     130
    131131        if ((TASK->udebug.dt_state == UDEBUG_TS_BEGINNING) && (nsc == 0)) {
    132132                /*
     
    135135                 *
    136136                 */
    137                
     137
    138138                call_t *db_call = TASK->udebug.begin_call;
    139139                assert(db_call);
    140                
     140
    141141                TASK->udebug.dt_state = UDEBUG_TS_ACTIVE;
    142142                TASK->udebug.begin_call = NULL;
    143                
     143
    144144                IPC_SET_RETVAL(db_call->data, 0);
    145145                ipc_answer(&TASK->answerbox, db_call);
     
    148148                 * Active debugging session
    149149                 */
    150                
     150
    151151                if (THREAD->udebug.active == true &&
    152152                    THREAD->udebug.go == false) {
     
    155155                         *
    156156                         */
    157                        
     157
    158158                        /* Make sure nobody takes this call away from us */
    159159                        call_t *go_call = THREAD->udebug.go_call;
    160160                        THREAD->udebug.go_call = NULL;
    161161                        assert(go_call);
    162                        
     162
    163163                        IPC_SET_RETVAL(go_call->data, 0);
    164164                        IPC_SET_ARG1(go_call->data, UDEBUG_EVENT_STOP);
    165                        
     165
    166166                        THREAD->udebug.cur_event = UDEBUG_EVENT_STOP;
    167167                        ipc_answer(&TASK->answerbox, go_call);
    168168                }
    169169        }
    170        
     170
    171171        mutex_unlock(&THREAD->udebug.lock);
    172172        mutex_unlock(&TASK->udebug.lock);
     
    185185        mutex_lock(&TASK->udebug.lock);
    186186        mutex_lock(&THREAD->udebug.lock);
    187        
     187
    188188        if ((THREAD->udebug.active) && (THREAD->udebug.go == false)) {
    189189                mutex_unlock(&THREAD->udebug.lock);
    190190                mutex_unlock(&TASK->udebug.lock);
    191                
     191
    192192                udebug_wait_for_go(&THREAD->udebug.go_wq);
    193                
     193
    194194                goto restart;
    195195                /* Must try again - have to lose stoppability atomically. */
     
    198198                assert(THREAD->udebug.stoppable == true);
    199199                THREAD->udebug.stoppable = false;
    200                
     200
    201201                mutex_unlock(&THREAD->udebug.lock);
    202202                mutex_unlock(&TASK->udebug.lock);
     
    228228        udebug_event_t etype =
    229229            end_variant ? UDEBUG_EVENT_SYSCALL_E : UDEBUG_EVENT_SYSCALL_B;
    230        
     230
    231231        mutex_lock(&TASK->udebug.lock);
    232232        mutex_lock(&THREAD->udebug.lock);
    233        
     233
    234234        /* Must only generate events when in debugging session and is go. */
    235235        if (THREAD->udebug.active != true || THREAD->udebug.go == false ||
     
    239239                return;
    240240        }
    241        
     241
    242242        /* Fill in the GO response. */
    243243        call_t *call = THREAD->udebug.go_call;
    244244        THREAD->udebug.go_call = NULL;
    245        
     245
    246246        IPC_SET_RETVAL(call->data, 0);
    247247        IPC_SET_ARG1(call->data, etype);
    248248        IPC_SET_ARG2(call->data, id);
    249249        IPC_SET_ARG3(call->data, rc);
    250        
     250
    251251        THREAD->udebug.syscall_args[0] = a1;
    252252        THREAD->udebug.syscall_args[1] = a2;
     
    255255        THREAD->udebug.syscall_args[4] = a5;
    256256        THREAD->udebug.syscall_args[5] = a6;
    257        
     257
    258258        /*
    259259         * Make sure udebug.go is false when going to sleep
     
    264264        THREAD->udebug.go = false;
    265265        THREAD->udebug.cur_event = etype;
    266        
     266
    267267        ipc_answer(&TASK->answerbox, call);
    268        
     268
    269269        mutex_unlock(&THREAD->udebug.lock);
    270270        mutex_unlock(&TASK->udebug.lock);
    271        
     271
    272272        udebug_wait_for_go(&THREAD->udebug.go_wq);
    273273}
     
    294294        mutex_lock(&TASK->udebug.lock);
    295295        mutex_lock(&THREAD->udebug.lock);
    296        
     296
    297297        thread_attach(thread, task);
    298        
     298
    299299        LOG("Check state");
    300        
     300
    301301        /* Must only generate events when in debugging session */
    302302        if (THREAD->udebug.active != true) {
     
    304304                    THREAD->udebug.active ? "Yes(+)" : "No",
    305305                    THREAD->udebug.go ? "Yes(-)" : "No");
    306                
     306
    307307                mutex_unlock(&THREAD->udebug.lock);
    308308                mutex_unlock(&TASK->udebug.lock);
    309309                return;
    310310        }
    311        
     311
    312312        LOG("Trigger event");
    313        
     313
    314314        call_t *call = THREAD->udebug.go_call;
    315        
     315
    316316        THREAD->udebug.go_call = NULL;
    317317        IPC_SET_RETVAL(call->data, 0);
    318318        IPC_SET_ARG1(call->data, UDEBUG_EVENT_THREAD_B);
    319319        IPC_SET_ARG2(call->data, (sysarg_t) thread);
    320        
     320
    321321        /*
    322322         * Make sure udebug.go is false when going to sleep
     
    327327        THREAD->udebug.go = false;
    328328        THREAD->udebug.cur_event = UDEBUG_EVENT_THREAD_B;
    329        
     329
    330330        ipc_answer(&TASK->answerbox, call);
    331        
     331
    332332        mutex_unlock(&THREAD->udebug.lock);
    333333        mutex_unlock(&TASK->udebug.lock);
    334        
     334
    335335        LOG("Wait for Go");
    336336        udebug_wait_for_go(&THREAD->udebug.go_wq);
     
    347347        mutex_lock(&TASK->udebug.lock);
    348348        mutex_lock(&THREAD->udebug.lock);
    349        
     349
    350350        LOG("Check state");
    351        
     351
    352352        /* Must only generate events when in debugging session. */
    353353        if (THREAD->udebug.active != true) {
     
    355355                    THREAD->udebug.active ? "Yes" : "No",
    356356                    THREAD->udebug.go ? "Yes" : "No");
    357                
     357
    358358                mutex_unlock(&THREAD->udebug.lock);
    359359                mutex_unlock(&TASK->udebug.lock);
    360360                return;
    361361        }
    362        
     362
    363363        LOG("Trigger event");
    364        
     364
    365365        call_t *call = THREAD->udebug.go_call;
    366        
     366
    367367        THREAD->udebug.go_call = NULL;
    368368        IPC_SET_RETVAL(call->data, 0);
    369369        IPC_SET_ARG1(call->data, UDEBUG_EVENT_THREAD_E);
    370        
     370
    371371        /* Prevent any further debug activity in thread. */
    372372        THREAD->udebug.active = false;
    373373        THREAD->udebug.cur_event = 0;   /* None */
    374374        THREAD->udebug.go = false;      /* Set to initial value */
    375        
     375
    376376        ipc_answer(&TASK->answerbox, call);
    377        
     377
    378378        mutex_unlock(&THREAD->udebug.lock);
    379379        mutex_unlock(&TASK->udebug.lock);
    380        
     380
    381381        /*
    382382         * This event does not sleep - debugging has finished
     
    405405                return EINVAL;
    406406        }
    407        
     407
    408408        LOG("Task %" PRIu64, task->taskid);
    409        
     409
    410410        /* Finish debugging of all userspace threads */
    411411        list_foreach(task->threads, th_link, thread_t, thread) {
    412412                mutex_lock(&thread->udebug.lock);
    413                
     413
    414414                /* Only process userspace threads. */
    415415                if (thread->uspace) {
     
    417417                        thread->udebug.active = false;
    418418                        thread->udebug.cur_event = 0;   /* None */
    419                        
     419
    420420                        /* Is the thread still go? */
    421421                        if (thread->udebug.go == true) {
     
    426426                                 */
    427427                                thread->udebug.go = false;
    428                                
     428
    429429                                /* Answer GO call */
    430430                                LOG("Answer GO call with EVENT_FINISHED.");
    431                                
     431
    432432                                IPC_SET_RETVAL(thread->udebug.go_call->data, 0);
    433433                                IPC_SET_ARG1(thread->udebug.go_call->data,
    434434                                    UDEBUG_EVENT_FINISHED);
    435                                
     435
    436436                                ipc_answer(&task->answerbox, thread->udebug.go_call);
    437437                                thread->udebug.go_call = NULL;
     
    442442                                 *
    443443                                 */
    444                                
     444
    445445                                /*
    446446                                 * thread's lock must not be held when calling
     
    450450                                waitq_wakeup(&thread->udebug.go_wq, WAKEUP_FIRST);
    451451                        }
    452                        
     452
    453453                        mutex_unlock(&thread->udebug.lock);
    454454                        condvar_broadcast(&thread->udebug.active_cv);
     
    456456                        mutex_unlock(&thread->udebug.lock);
    457457        }
    458        
     458
    459459        task->udebug.dt_state = UDEBUG_TS_INACTIVE;
    460460        task->udebug.debugger = NULL;
    461        
     461
    462462        return 0;
    463463}
     
    474474{
    475475        udebug_stoppable_begin();
    476        
     476
    477477        /* Wait until a debugger attends to us. */
    478478        mutex_lock(&THREAD->udebug.lock);
     
    480480                condvar_wait(&THREAD->udebug.active_cv, &THREAD->udebug.lock);
    481481        mutex_unlock(&THREAD->udebug.lock);
    482        
     482
    483483        /* Make sure the debugging session is over before proceeding. */
    484484        mutex_lock(&THREAD->udebug.lock);
     
    486486                condvar_wait(&THREAD->udebug.active_cv, &THREAD->udebug.lock);
    487487        mutex_unlock(&THREAD->udebug.lock);
    488        
     488
    489489        udebug_stoppable_end();
    490490}
  • kernel/generic/src/udebug/udebug_ops.c

    r3061bc1 r8565a42  
    8282{
    8383        mutex_lock(&TASK->udebug.lock);
    84        
     84
    8585        /* thread_exists() must be called with threads_lock held */
    8686        irq_spinlock_lock(&threads_lock, true);
    87        
     87
    8888        if (!thread_exists(thread)) {
    8989                irq_spinlock_unlock(&threads_lock, true);
     
    9191                return ENOENT;
    9292        }
    93        
     93
    9494        /* thread->lock is enough to ensure the thread's existence */
    9595        irq_spinlock_exchange(&threads_lock, &thread->lock);
    96        
     96
    9797        /* Verify that 'thread' is a userspace thread. */
    9898        if (!thread->uspace) {
     
    102102                return ENOENT;
    103103        }
    104        
     104
    105105        /* Verify debugging state. */
    106106        if (thread->udebug.active != true) {
     
    110110                return ENOENT;
    111111        }
    112        
     112
    113113        /*
    114114         * Since the thread has active == true, TASK->udebug.lock
     
    118118         */
    119119        irq_spinlock_unlock(&thread->lock, true);
    120        
     120
    121121        /* Only mutex TASK->udebug.lock left. */
    122        
     122
    123123        /* Now verify that the thread belongs to the current task. */
    124124        if (thread->task != TASK) {
     
    127127                return ENOENT;
    128128        }
    129        
     129
    130130        /*
    131131         * Now we need to grab the thread's debug lock for synchronization
     
    134134         */
    135135        mutex_lock(&thread->udebug.lock);
    136        
     136
    137137        /* The big task mutex is no longer needed. */
    138138        mutex_unlock(&TASK->udebug.lock);
    139        
     139
    140140        if (thread->udebug.go != being_go) {
    141141                /* Not in debugging session or undesired GO state. */
     
    143143                return EINVAL;
    144144        }
    145        
     145
    146146        /* Only thread->udebug.lock left. */
    147        
     147
    148148        return EOK;  /* All went well. */
    149149}
     
    177177{
    178178        LOG("Debugging task %" PRIu64, TASK->taskid);
    179        
    180         mutex_lock(&TASK->udebug.lock);
    181        
     179
     180        mutex_lock(&TASK->udebug.lock);
     181
    182182        if (TASK->udebug.dt_state != UDEBUG_TS_INACTIVE) {
    183183                mutex_unlock(&TASK->udebug.lock);
    184184                return EBUSY;
    185185        }
    186        
     186
    187187        TASK->udebug.dt_state = UDEBUG_TS_BEGINNING;
    188188        TASK->udebug.begin_call = call;
    189189        TASK->udebug.debugger = call->sender;
    190        
     190
    191191        if (TASK->udebug.not_stoppable_count == 0) {
    192192                TASK->udebug.dt_state = UDEBUG_TS_ACTIVE;
     
    195195        } else
    196196                *active = false;  /* only in beginning state */
    197        
     197
    198198        /* Set udebug.active on all of the task's userspace threads. */
    199        
     199
    200200        list_foreach(TASK->threads, th_link, thread_t, thread) {
    201201                mutex_lock(&thread->udebug.lock);
     
    207207                        mutex_unlock(&thread->udebug.lock);
    208208        }
    209        
     209
    210210        mutex_unlock(&TASK->udebug.lock);
    211211        return EOK;
     
    222222{
    223223        LOG("Task %" PRIu64, TASK->taskid);
    224        
     224
    225225        mutex_lock(&TASK->udebug.lock);
    226226        errno_t rc = udebug_task_cleanup(TASK);
    227227        mutex_unlock(&TASK->udebug.lock);
    228        
     228
    229229        return rc;
    230230}
     
    242242{
    243243        LOG("mask = 0x%x", mask);
    244        
    245         mutex_lock(&TASK->udebug.lock);
    246        
     244
     245        mutex_lock(&TASK->udebug.lock);
     246
    247247        if (TASK->udebug.dt_state != UDEBUG_TS_ACTIVE) {
    248248                mutex_unlock(&TASK->udebug.lock);
    249249                return EINVAL;
    250250        }
    251        
     251
    252252        TASK->udebug.evmask = mask;
    253253        mutex_unlock(&TASK->udebug.lock);
    254        
     254
    255255        return EOK;
    256256}
     
    272272        if (rc != EOK)
    273273                return rc;
    274        
     274
    275275        thread->udebug.go_call = call;
    276276        thread->udebug.go = true;
    277277        thread->udebug.cur_event = 0;  /* none */
    278        
     278
    279279        /*
    280280         * Neither thread's lock nor threads_lock may be held during wakeup.
     
    282282         */
    283283        waitq_wakeup(&thread->udebug.go_wq, WAKEUP_FIRST);
    284        
     284
    285285        _thread_op_end(thread);
    286        
     286
    287287        return EOK;
    288288}
     
    300300{
    301301        LOG("udebug_stop()");
    302        
     302
    303303        /*
    304304         * On success, this will lock thread->udebug.lock. Note that this
     
    309309        if (rc != EOK)
    310310                return rc;
    311        
     311
    312312        /* Take GO away from the thread. */
    313313        thread->udebug.go = false;
    314        
     314
    315315        if (thread->udebug.stoppable != true) {
    316316                /* Answer will be sent when the thread becomes stoppable. */
     
    318318                return EOK;
    319319        }
    320        
     320
    321321        /*
    322322         * Answer GO call.
    323323         *
    324324         */
    325        
     325
    326326        /* Make sure nobody takes this call away from us. */
    327327        call = thread->udebug.go_call;
    328328        thread->udebug.go_call = NULL;
    329        
     329
    330330        IPC_SET_RETVAL(call->data, 0);
    331331        IPC_SET_ARG1(call->data, UDEBUG_EVENT_STOP);
    332        
     332
    333333        THREAD->udebug.cur_event = UDEBUG_EVENT_STOP;
    334        
     334
    335335        _thread_op_end(thread);
    336        
     336
    337337        mutex_lock(&TASK->udebug.lock);
    338338        ipc_answer(&TASK->answerbox, call);
    339339        mutex_unlock(&TASK->udebug.lock);
    340        
     340
    341341        return EOK;
    342342}
     
    368368{
    369369        LOG("udebug_thread_read()");
    370        
     370
    371371        /* Allocate a buffer to hold thread IDs */
    372372        sysarg_t *id_buffer = malloc(buf_size + 1, 0);
    373        
    374         mutex_lock(&TASK->udebug.lock);
    375        
     373
     374        mutex_lock(&TASK->udebug.lock);
     375
    376376        /* Verify task state */
    377377        if (TASK->udebug.dt_state != UDEBUG_TS_ACTIVE) {
     
    380380                return EINVAL;
    381381        }
    382        
     382
    383383        irq_spinlock_lock(&TASK->lock, true);
    384        
     384
    385385        /* Copy down the thread IDs */
    386        
     386
    387387        size_t max_ids = buf_size / sizeof(sysarg_t);
    388388        size_t copied_ids = 0;
    389389        size_t extra_ids = 0;
    390        
     390
    391391        /* FIXME: make sure the thread isn't past debug shutdown... */
    392392        list_foreach(TASK->threads, th_link, thread_t, thread) {
     
    394394                bool uspace = thread->uspace;
    395395                irq_spinlock_unlock(&thread->lock, false);
    396                
     396
    397397                /* Not interested in kernel threads. */
    398398                if (!uspace)
    399399                        continue;
    400                
     400
    401401                if (copied_ids < max_ids) {
    402402                        /* Using thread struct pointer as identification hash */
     
    405405                        extra_ids++;
    406406        }
    407        
     407
    408408        irq_spinlock_unlock(&TASK->lock, true);
    409        
    410         mutex_unlock(&TASK->udebug.lock);
    411        
     409
     410        mutex_unlock(&TASK->udebug.lock);
     411
    412412        *buffer = id_buffer;
    413413        *stored = copied_ids * sizeof(sysarg_t);
    414414        *needed = (copied_ids + extra_ids) * sizeof(sysarg_t);
    415        
     415
    416416        return EOK;
    417417}
     
    431431{
    432432        size_t name_size = str_size(TASK->name) + 1;
    433        
     433
    434434        *data = malloc(name_size, 0);
    435435        *data_size = name_size;
    436        
     436
    437437        memcpy(*data, TASK->name, name_size);
    438        
     438
    439439        return EOK;
    440440}
     
    463463        if (rc != EOK)
    464464                return rc;
    465        
     465
    466466        /* Additionally we need to verify that we are inside a syscall. */
    467467        if ((thread->udebug.cur_event != UDEBUG_EVENT_SYSCALL_B) &&
     
    470470                return EINVAL;
    471471        }
    472        
     472
    473473        /* Prepare a buffer to hold the arguments. */
    474474        sysarg_t *arg_buffer = malloc(6 * sizeof(sysarg_t), 0);
    475        
     475
    476476        /* Copy to a local buffer before releasing the lock. */
    477477        memcpy(arg_buffer, thread->udebug.syscall_args, 6 * sizeof(sysarg_t));
    478        
     478
    479479        _thread_op_end(thread);
    480        
     480
    481481        *buffer = arg_buffer;
    482482        return EOK;
     
    506506        if (rc != EOK)
    507507                return rc;
    508        
     508
    509509        istate_t *state = thread->udebug.uspace_state;
    510510        if (state == NULL) {
     
    512512                return EBUSY;
    513513        }
    514        
     514
    515515        /* Prepare a buffer to hold the data. */
    516516        istate_t *state_buf = malloc(sizeof(istate_t), 0);
    517        
     517
    518518        /* Copy to the allocated buffer */
    519519        memcpy(state_buf, state, sizeof(istate_t));
    520        
     520
    521521        _thread_op_end(thread);
    522        
     522
    523523        *buffer = (void *) state_buf;
    524524        return EOK;
     
    540540        /* Verify task state */
    541541        mutex_lock(&TASK->udebug.lock);
    542        
     542
    543543        if (TASK->udebug.dt_state != UDEBUG_TS_ACTIVE) {
    544544                mutex_unlock(&TASK->udebug.lock);
    545545                return EBUSY;
    546546        }
    547        
     547
    548548        void *data_buffer = malloc(n, 0);
    549        
     549
    550550        /*
    551551         * NOTE: this is not strictly from a syscall... but that shouldn't
     
    555555        errno_t rc = copy_from_uspace(data_buffer, (void *) uspace_addr, n);
    556556        mutex_unlock(&TASK->udebug.lock);
    557        
     557
    558558        if (rc != EOK)
    559559                return rc;
    560        
     560
    561561        *buffer = data_buffer;
    562562        return EOK;
Note: See TracChangeset for help on using the changeset viewer.