Subversion Repositories HelenOS

Rev

Rev 4055 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4055 Rev 4420
Line 179... Line 179...
179
    int reply;
179
    int reply;
180
 
180
 
181
    thread_t *t;
181
    thread_t *t;
182
    link_t *cur;
182
    link_t *cur;
183
 
183
 
184
    LOG("udebug_begin()\n");
184
    LOG("Debugging task %llu", TASK->taskid);
185
 
-
 
186
    mutex_lock(&TASK->udebug.lock);
185
    mutex_lock(&TASK->udebug.lock);
187
    LOG("debugging task %llu\n", TASK->taskid);
-
 
188
 
186
 
189
    if (TASK->udebug.dt_state != UDEBUG_TS_INACTIVE) {
187
    if (TASK->udebug.dt_state != UDEBUG_TS_INACTIVE) {
190
        mutex_unlock(&TASK->udebug.lock);
188
        mutex_unlock(&TASK->udebug.lock);
191
        LOG("udebug_begin(): busy error\n");
-
 
192
 
-
 
193
        return EBUSY;
189
        return EBUSY;
194
    }
190
    }
195
 
191
 
196
    TASK->udebug.dt_state = UDEBUG_TS_BEGINNING;
192
    TASK->udebug.dt_state = UDEBUG_TS_BEGINNING;
197
    TASK->udebug.begin_call = call;
193
    TASK->udebug.begin_call = call;
Line 215... Line 211...
215
            t->udebug.active = true;
211
            t->udebug.active = true;
216
        mutex_unlock(&t->udebug.lock);
212
        mutex_unlock(&t->udebug.lock);
217
    }
213
    }
218
 
214
 
219
    mutex_unlock(&TASK->udebug.lock);
215
    mutex_unlock(&TASK->udebug.lock);
220
 
-
 
221
    LOG("udebug_begin() done (%s)\n",
-
 
222
        reply ? "reply" : "stoppability wait");
-
 
223
 
-
 
224
    return reply;
216
    return reply;
225
}
217
}
226
 
218
 
227
/** Finish debugging the current task.
219
/** Finish debugging the current task.
228
 *
220
 *
Line 231... Line 223...
231
 */
223
 */
232
int udebug_end(void)
224
int udebug_end(void)
233
{
225
{
234
    int rc;
226
    int rc;
235
 
227
 
236
    LOG("udebug_end()\n");
228
    LOG("Task %" PRIu64, TASK->taskid);
237
 
229
 
238
    mutex_lock(&TASK->udebug.lock);
230
    mutex_lock(&TASK->udebug.lock);
239
    LOG("task %" PRIu64 "\n", TASK->taskid);
-
 
240
 
-
 
241
    rc = udebug_task_cleanup(TASK);
231
    rc = udebug_task_cleanup(TASK);
242
 
-
 
243
    mutex_unlock(&TASK->udebug.lock);
232
    mutex_unlock(&TASK->udebug.lock);
244
 
233
 
245
    return rc;
234
    return rc;
246
}
235
}
247
 
236
 
Line 252... Line 241...
252
 * @param mask  Or combination of events that should be enabled.
241
 * @param mask  Or combination of events that should be enabled.
253
 * @return  Zero on success or negative error code.
242
 * @return  Zero on success or negative error code.
254
 */
243
 */
255
int udebug_set_evmask(udebug_evmask_t mask)
244
int udebug_set_evmask(udebug_evmask_t mask)
256
{
245
{
257
    LOG("udebug_set_mask()\n");
246
    LOG("mask = 0x%x", mask);
258
 
247
 
259
    mutex_lock(&TASK->udebug.lock);
248
    mutex_lock(&TASK->udebug.lock);
260
 
249
 
261
    if (TASK->udebug.dt_state != UDEBUG_TS_ACTIVE) {
250
    if (TASK->udebug.dt_state != UDEBUG_TS_ACTIVE) {
262
        mutex_unlock(&TASK->udebug.lock);
251
        mutex_unlock(&TASK->udebug.lock);
263
        LOG("udebug_set_mask(): not active debuging session\n");
-
 
264
 
-
 
265
        return EINVAL;
252
        return EINVAL;
266
    }
253
    }
267
 
254
 
268
    TASK->udebug.evmask = mask;
255
    TASK->udebug.evmask = mask;
269
 
-
 
270
    mutex_unlock(&TASK->udebug.lock);
256
    mutex_unlock(&TASK->udebug.lock);
271
 
257
 
272
    return 0;
258
    return 0;
273
}
259
}
274
 
260
 
Line 315... Line 301...
315
 */
301
 */
316
int udebug_stop(thread_t *t, call_t *call)
302
int udebug_stop(thread_t *t, call_t *call)
317
{
303
{
318
    int rc;
304
    int rc;
319
 
305
 
320
    LOG("udebug_stop()\n");
306
    LOG("udebug_stop()");
321
 
307
 
322
    /*
308
    /*
323
     * On success, this will lock t->udebug.lock. Note that this makes sure
309
     * On success, this will lock t->udebug.lock. Note that this makes sure
324
     * the thread is not stopped.
310
     * the thread is not stopped.
325
     */
311
     */
Line 338... Line 324...
338
    }
324
    }
339
 
325
 
340
    /*
326
    /*
341
     * Answer GO call.
327
     * Answer GO call.
342
     */
328
     */
343
    LOG("udebug_stop - answering go call\n");
-
 
344
 
329
 
345
    /* Make sure nobody takes this call away from us. */
330
    /* Make sure nobody takes this call away from us. */
346
    call = t->udebug.go_call;
331
    call = t->udebug.go_call;
347
    t->udebug.go_call = NULL;
332
    t->udebug.go_call = NULL;
348
 
333
 
349
    IPC_SET_RETVAL(call->data, 0);
334
    IPC_SET_RETVAL(call->data, 0);
350
    IPC_SET_ARG1(call->data, UDEBUG_EVENT_STOP);
335
    IPC_SET_ARG1(call->data, UDEBUG_EVENT_STOP);
351
    LOG("udebug_stop/ipc_answer\n");
-
 
352
 
336
 
353
    THREAD->udebug.cur_event = UDEBUG_EVENT_STOP;
337
    THREAD->udebug.cur_event = UDEBUG_EVENT_STOP;
354
 
338
 
355
    _thread_op_end(t);
339
    _thread_op_end(t);
356
 
340
 
357
    mutex_lock(&TASK->udebug.lock);
341
    mutex_lock(&TASK->udebug.lock);
358
    ipc_answer(&TASK->answerbox, call);
342
    ipc_answer(&TASK->answerbox, call);
359
    mutex_unlock(&TASK->udebug.lock);
343
    mutex_unlock(&TASK->udebug.lock);
360
 
344
 
361
    LOG("udebog_stop/done\n");
-
 
362
    return 0;
345
    return 0;
363
}
346
}
364
 
347
 
365
/** Read the list of userspace threads in the current task.
348
/** Read the list of userspace threads in the current task.
366
 *
349
 *
Line 390... Line 373...
390
    ipl_t ipl;
373
    ipl_t ipl;
391
    unative_t *id_buffer;
374
    unative_t *id_buffer;
392
    int flags;
375
    int flags;
393
    size_t max_ids;
376
    size_t max_ids;
394
 
377
 
395
    LOG("udebug_thread_read()\n");
378
    LOG("udebug_thread_read()");
396
 
379
 
397
    /* Allocate a buffer to hold thread IDs */
380
    /* Allocate a buffer to hold thread IDs */
398
    id_buffer = malloc(buf_size, 0);
381
    id_buffer = malloc(buf_size, 0);
399
 
382
 
400
    mutex_lock(&TASK->udebug.lock);
383
    mutex_lock(&TASK->udebug.lock);