Subversion Repositories HelenOS

Rev

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

Rev 3611 Rev 3623
Line 130... Line 130...
130
    int rc;
130
    int rc;
131
 
131
 
132
    rc = udebug_begin(call);
132
    rc = udebug_begin(call);
133
    if (rc < 0) {
133
    if (rc < 0) {
134
        IPC_SET_RETVAL(call->data, rc);
134
        IPC_SET_RETVAL(call->data, rc);
135
        ipc_answer(&TASK->kernel_box, call);
135
        ipc_answer(&TASK->kb.box, call);
136
        return;
136
        return;
137
    }
137
    }
138
 
138
 
139
    /*
139
    /*
140
     * If the initialization of the debugging session has finished,
140
     * If the initialization of the debugging session has finished,
141
     * send a reply.
141
     * send a reply.
142
     */
142
     */
143
    if (rc != 0) {
143
    if (rc != 0) {
144
        IPC_SET_RETVAL(call->data, 0);
144
        IPC_SET_RETVAL(call->data, 0);
145
        ipc_answer(&TASK->kernel_box, call);
145
        ipc_answer(&TASK->kb.box, call);
146
    }
146
    }
147
}
147
}
148
 
148
 
149
/** Process an END call.
149
/** Process an END call.
150
 *
150
 *
Line 156... Line 156...
156
    int rc;
156
    int rc;
157
 
157
 
158
    rc = udebug_end();
158
    rc = udebug_end();
159
 
159
 
160
    IPC_SET_RETVAL(call->data, rc);
160
    IPC_SET_RETVAL(call->data, rc);
161
    ipc_answer(&TASK->kernel_box, call);
161
    ipc_answer(&TASK->kb.box, call);
162
}
162
}
163
 
163
 
164
/** Process a SET_EVMASK call.
164
/** Process a SET_EVMASK call.
165
 *
165
 *
166
 * Sets an event mask for the current debugging session.
166
 * Sets an event mask for the current debugging session.
Line 173... Line 173...
173
 
173
 
174
    mask = IPC_GET_ARG2(call->data);
174
    mask = IPC_GET_ARG2(call->data);
175
    rc = udebug_set_evmask(mask);
175
    rc = udebug_set_evmask(mask);
176
 
176
 
177
    IPC_SET_RETVAL(call->data, rc);
177
    IPC_SET_RETVAL(call->data, rc);
178
    ipc_answer(&TASK->kernel_box, call);
178
    ipc_answer(&TASK->kb.box, call);
179
}
179
}
180
 
180
 
181
 
181
 
182
/** Process a GO call.
182
/** Process a GO call.
183
 *
183
 *
Line 192... Line 192...
192
    t = (thread_t *)IPC_GET_ARG2(call->data);
192
    t = (thread_t *)IPC_GET_ARG2(call->data);
193
 
193
 
194
    rc = udebug_go(t, call);
194
    rc = udebug_go(t, call);
195
    if (rc < 0) {
195
    if (rc < 0) {
196
        IPC_SET_RETVAL(call->data, rc);
196
        IPC_SET_RETVAL(call->data, rc);
197
        ipc_answer(&TASK->kernel_box, call);
197
        ipc_answer(&TASK->kb.box, call);
198
        return;
198
        return;
199
    }
199
    }
200
}
200
}
201
 
201
 
202
/** Process a STOP call.
202
/** Process a STOP call.
Line 211... Line 211...
211
 
211
 
212
    t = (thread_t *)IPC_GET_ARG2(call->data);
212
    t = (thread_t *)IPC_GET_ARG2(call->data);
213
 
213
 
214
    rc = udebug_stop(t, call);
214
    rc = udebug_stop(t, call);
215
    IPC_SET_RETVAL(call->data, rc);
215
    IPC_SET_RETVAL(call->data, rc);
216
    ipc_answer(&TASK->kernel_box, call);
216
    ipc_answer(&TASK->kb.box, call);
217
}
217
}
218
 
218
 
219
/** Process a THREAD_READ call.
219
/** Process a THREAD_READ call.
220
 *
220
 *
221
 * Reads the list of hashes of the (userspace) threads in the current task.
221
 * Reads the list of hashes of the (userspace) threads in the current task.
Line 239... Line 239...
239
     * of threads times thread-id size.
239
     * of threads times thread-id size.
240
     */
240
     */
241
    rc = udebug_thread_read(&buffer, buf_size, &n);
241
    rc = udebug_thread_read(&buffer, buf_size, &n);
242
    if (rc < 0) {
242
    if (rc < 0) {
243
        IPC_SET_RETVAL(call->data, rc);
243
        IPC_SET_RETVAL(call->data, rc);
244
        ipc_answer(&TASK->kernel_box, call);
244
        ipc_answer(&TASK->kb.box, call);
245
        return;
245
        return;
246
    }
246
    }
247
 
247
 
248
    total_bytes = n;
248
    total_bytes = n;
249
 
249
 
Line 266... Line 266...
266
    IPC_SET_ARG2(call->data, to_copy);
266
    IPC_SET_ARG2(call->data, to_copy);
267
 
267
 
268
    IPC_SET_ARG3(call->data, total_bytes);
268
    IPC_SET_ARG3(call->data, total_bytes);
269
    call->buffer = buffer;
269
    call->buffer = buffer;
270
 
270
 
271
    ipc_answer(&TASK->kernel_box, call);
271
    ipc_answer(&TASK->kb.box, call);
272
}
272
}
273
 
273
 
274
/** Process an ARGS_READ call.
274
/** Process an ARGS_READ call.
275
 *
275
 *
276
 * Reads the argument of a current syscall event (SYSCALL_B or SYSCALL_E).
276
 * Reads the argument of a current syscall event (SYSCALL_B or SYSCALL_E).
Line 286... Line 286...
286
    t = (thread_t *)IPC_GET_ARG2(call->data);
286
    t = (thread_t *)IPC_GET_ARG2(call->data);
287
 
287
 
288
    rc = udebug_args_read(t, &buffer);
288
    rc = udebug_args_read(t, &buffer);
289
    if (rc != EOK) {
289
    if (rc != EOK) {
290
        IPC_SET_RETVAL(call->data, rc);
290
        IPC_SET_RETVAL(call->data, rc);
291
        ipc_answer(&TASK->kernel_box, call);
291
        ipc_answer(&TASK->kb.box, call);
292
        return;
292
        return;
293
    }
293
    }
294
 
294
 
295
    /*
295
    /*
296
     * Make use of call->buffer to transfer data to caller's userspace
296
     * Make use of call->buffer to transfer data to caller's userspace
Line 304... Line 304...
304
       (no way to distinguish method in answer) */
304
       (no way to distinguish method in answer) */
305
    IPC_SET_ARG1(call->data, uspace_addr);
305
    IPC_SET_ARG1(call->data, uspace_addr);
306
    IPC_SET_ARG2(call->data, 6 * sizeof(unative_t));
306
    IPC_SET_ARG2(call->data, 6 * sizeof(unative_t));
307
    call->buffer = buffer;
307
    call->buffer = buffer;
308
 
308
 
309
    ipc_answer(&TASK->kernel_box, call);
309
    ipc_answer(&TASK->kb.box, call);
310
}
310
}
311
 
311
 
312
static void udebug_receive_regs_read(call_t *call)
312
static void udebug_receive_regs_read(call_t *call)
313
{
313
{
314
    thread_t *t;
314
    thread_t *t;
Line 323... Line 323...
323
    buffer = malloc(sizeof(istate_t), 0);
323
    buffer = malloc(sizeof(istate_t), 0);
324
 
324
 
325
    rc = udebug_regs_read(t, buffer);
325
    rc = udebug_regs_read(t, buffer);
326
    if (rc < 0) {
326
    if (rc < 0) {
327
        IPC_SET_RETVAL(call->data, rc);
327
        IPC_SET_RETVAL(call->data, rc);
328
        ipc_answer(&TASK->kernel_box, call);
328
        ipc_answer(&TASK->kb.box, call);
329
        return;
329
        return;
330
    }
330
    }
331
 
331
 
332
    /*
332
    /*
333
     * Make use of call->buffer to transfer data to caller's userspace
333
     * Make use of call->buffer to transfer data to caller's userspace
Line 343... Line 343...
343
    IPC_SET_ARG1(call->data, uspace_addr);
343
    IPC_SET_ARG1(call->data, uspace_addr);
344
    IPC_SET_ARG2(call->data, to_copy);
344
    IPC_SET_ARG2(call->data, to_copy);
345
 
345
 
346
    call->buffer = buffer;
346
    call->buffer = buffer;
347
 
347
 
348
    ipc_answer(&TASK->kernel_box, call);
348
    ipc_answer(&TASK->kb.box, call);
349
}
349
}
350
 
350
 
351
static void udebug_receive_regs_write(call_t *call)
351
static void udebug_receive_regs_write(call_t *call)
352
{
352
{
353
    thread_t *t;
353
    thread_t *t;
Line 358... Line 358...
358
    uspace_data = (void *)IPC_GET_ARG3(call->data);
358
    uspace_data = (void *)IPC_GET_ARG3(call->data);
359
 
359
 
360
    rc = udebug_regs_write(t, call->buffer);
360
    rc = udebug_regs_write(t, call->buffer);
361
    if (rc < 0) {
361
    if (rc < 0) {
362
        IPC_SET_RETVAL(call->data, rc);
362
        IPC_SET_RETVAL(call->data, rc);
363
        ipc_answer(&TASK->kernel_box, call);
363
        ipc_answer(&TASK->kb.box, call);
364
        return;
364
        return;
365
    }
365
    }
366
 
366
 
367
    /* Set answer values */
367
    /* Set answer values */
368
 
368
 
369
    IPC_SET_RETVAL(call->data, 0);
369
    IPC_SET_RETVAL(call->data, 0);
370
    free(call->buffer);
370
    free(call->buffer);
371
    call->buffer = NULL;
371
    call->buffer = NULL;
372
 
372
 
373
    ipc_answer(&TASK->kernel_box, call);
373
    ipc_answer(&TASK->kb.box, call);
374
}
374
}
375
 
375
 
376
/** Process an MEM_READ call.
376
/** Process an MEM_READ call.
377
 *
377
 *
378
 * Reads memory of the current (debugged) task.
378
 * Reads memory of the current (debugged) task.
Line 391... Line 391...
391
    size = IPC_GET_ARG4(call->data);
391
    size = IPC_GET_ARG4(call->data);
392
 
392
 
393
    rc = udebug_mem_read(uspace_src, size, &buffer);
393
    rc = udebug_mem_read(uspace_src, size, &buffer);
394
    if (rc < 0) {
394
    if (rc < 0) {
395
        IPC_SET_RETVAL(call->data, rc);
395
        IPC_SET_RETVAL(call->data, rc);
396
        ipc_answer(&TASK->kernel_box, call);
396
        ipc_answer(&TASK->kb.box, call);
397
        return;
397
        return;
398
    }
398
    }
399
 
399
 
400
    IPC_SET_RETVAL(call->data, 0);
400
    IPC_SET_RETVAL(call->data, 0);
401
    /* ARG1=dest, ARG2=size as in IPC_M_DATA_READ so that
401
    /* ARG1=dest, ARG2=size as in IPC_M_DATA_READ so that
Line 403... Line 403...
403
       (no way to distinguish method in answer) */
403
       (no way to distinguish method in answer) */
404
    IPC_SET_ARG1(call->data, uspace_dst);
404
    IPC_SET_ARG1(call->data, uspace_dst);
405
    IPC_SET_ARG2(call->data, size);
405
    IPC_SET_ARG2(call->data, size);
406
    call->buffer = buffer;
406
    call->buffer = buffer;
407
 
407
 
408
    ipc_answer(&TASK->kernel_box, call);
408
    ipc_answer(&TASK->kb.box, call);
409
}
409
}
410
 
410
 
411
static void udebug_receive_mem_write(call_t *call)
411
static void udebug_receive_mem_write(call_t *call)
412
{
412
{
413
    unative_t uspace_dst;
413
    unative_t uspace_dst;
Line 420... Line 420...
420
    size = IPC_GET_ARG4(call->data);
420
    size = IPC_GET_ARG4(call->data);
421
 
421
 
422
    rc = udebug_mem_write(uspace_dst, call->buffer, size);
422
    rc = udebug_mem_write(uspace_dst, call->buffer, size);
423
    if (rc < 0) {
423
    if (rc < 0) {
424
        IPC_SET_RETVAL(call->data, rc);
424
        IPC_SET_RETVAL(call->data, rc);
425
        ipc_answer(&TASK->kernel_box, call);
425
        ipc_answer(&TASK->kb.box, call);
426
        return;
426
        return;
427
    }
427
    }
428
 
428
 
429
    IPC_SET_RETVAL(call->data, 0);
429
    IPC_SET_RETVAL(call->data, 0);
430
    free(call->buffer);
430
    free(call->buffer);
431
    call->buffer = NULL;
431
    call->buffer = NULL;
432
 
432
 
433
    ipc_answer(&TASK->kernel_box, call);
433
    ipc_answer(&TASK->kb.box, call);
434
}
434
}
435
 
435
 
436
 
436
 
437
/** Handle a debug call received on the kernel answerbox.
437
/** Handle a debug call received on the kernel answerbox.
438
 *
438
 *
Line 453... Line 453...
453
         * and the sender can be safely considered valid until
453
         * and the sender can be safely considered valid until
454
         * control exits this function.
454
         * control exits this function.
455
         */
455
         */
456
        if (TASK->udebug.debugger != call->sender) {
456
        if (TASK->udebug.debugger != call->sender) {
457
            IPC_SET_RETVAL(call->data, EINVAL);
457
            IPC_SET_RETVAL(call->data, EINVAL);
458
            ipc_answer(&TASK->kernel_box, call);
458
            ipc_answer(&TASK->kb.box, call);
459
            return;
459
            return;
460
        }
460
        }
461
    }
461
    }
462
 
462
 
463
    switch (debug_method) {
463
    switch (debug_method) {