Ignore:
Timestamp:
2018-03-02T20:10:49Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

File:
1 edited

Legend:

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

    r3061bc1 ra35b458  
    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.