Subversion Repositories HelenOS

Rev

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

Rev 3474 Rev 3674
Line 71... Line 71...
71
    int rc;
71
    int rc;
72
 
72
 
73
    rc = udebug_begin(call);
73
    rc = udebug_begin(call);
74
    if (rc < 0) {
74
    if (rc < 0) {
75
        IPC_SET_RETVAL(call->data, rc);
75
        IPC_SET_RETVAL(call->data, rc);
76
        ipc_answer(&TASK->kernel_box, call);
76
        ipc_answer(&TASK->kb.box, call);
77
        return;
77
        return;
78
    }
78
    }
79
 
79
 
80
    /*
80
    /*
81
     * If the initialization of the debugging session has finished,
81
     * If the initialization of the debugging session has finished,
82
     * send a reply.
82
     * send a reply.
83
     */
83
     */
84
    if (rc != 0) {
84
    if (rc != 0) {
85
        IPC_SET_RETVAL(call->data, 0);
85
        IPC_SET_RETVAL(call->data, 0);
86
        ipc_answer(&TASK->kernel_box, call);
86
        ipc_answer(&TASK->kb.box, call);
87
    }
87
    }
88
}
88
}
89
 
89
 
90
/** Process an END call.
90
/** Process an END call.
91
 *
91
 *
Line 97... Line 97...
97
    int rc;
97
    int rc;
98
 
98
 
99
    rc = udebug_end();
99
    rc = udebug_end();
100
 
100
 
101
    IPC_SET_RETVAL(call->data, rc);
101
    IPC_SET_RETVAL(call->data, rc);
102
    ipc_answer(&TASK->kernel_box, call);
102
    ipc_answer(&TASK->kb.box, call);
103
}
103
}
104
 
104
 
105
/** Process a SET_EVMASK call.
105
/** Process a SET_EVMASK call.
106
 *
106
 *
107
 * Sets an event mask for the current debugging session.
107
 * Sets an event mask for the current debugging session.
Line 114... Line 114...
114
 
114
 
115
    mask = IPC_GET_ARG2(call->data);
115
    mask = IPC_GET_ARG2(call->data);
116
    rc = udebug_set_evmask(mask);
116
    rc = udebug_set_evmask(mask);
117
 
117
 
118
    IPC_SET_RETVAL(call->data, rc);
118
    IPC_SET_RETVAL(call->data, rc);
119
    ipc_answer(&TASK->kernel_box, call);
119
    ipc_answer(&TASK->kb.box, call);
120
}
120
}
121
 
121
 
122
 
122
 
123
/** Process a GO call.
123
/** Process a GO call.
124
 *
124
 *
Line 133... Line 133...
133
    t = (thread_t *)IPC_GET_ARG2(call->data);
133
    t = (thread_t *)IPC_GET_ARG2(call->data);
134
 
134
 
135
    rc = udebug_go(t, call);
135
    rc = udebug_go(t, call);
136
    if (rc < 0) {
136
    if (rc < 0) {
137
        IPC_SET_RETVAL(call->data, rc);
137
        IPC_SET_RETVAL(call->data, rc);
138
        ipc_answer(&TASK->kernel_box, call);
138
        ipc_answer(&TASK->kb.box, call);
139
        return;
139
        return;
140
    }
140
    }
141
}
141
}
142
 
142
 
143
/** Process a STOP call.
143
/** Process a STOP call.
Line 152... Line 152...
152
 
152
 
153
    t = (thread_t *)IPC_GET_ARG2(call->data);
153
    t = (thread_t *)IPC_GET_ARG2(call->data);
154
 
154
 
155
    rc = udebug_stop(t, call);
155
    rc = udebug_stop(t, call);
156
    IPC_SET_RETVAL(call->data, rc);
156
    IPC_SET_RETVAL(call->data, rc);
157
    ipc_answer(&TASK->kernel_box, call);
157
    ipc_answer(&TASK->kb.box, call);
158
}
158
}
159
 
159
 
160
/** Process a THREAD_READ call.
160
/** Process a THREAD_READ call.
161
 *
161
 *
162
 * Reads the list of hashes of the (userspace) threads in the current task.
162
 * Reads the list of hashes of the (userspace) threads in the current task.
Line 180... Line 180...
180
     * of threads times thread-id size.
180
     * of threads times thread-id size.
181
     */
181
     */
182
    rc = udebug_thread_read(&buffer, buf_size, &n);
182
    rc = udebug_thread_read(&buffer, buf_size, &n);
183
    if (rc < 0) {
183
    if (rc < 0) {
184
        IPC_SET_RETVAL(call->data, rc);
184
        IPC_SET_RETVAL(call->data, rc);
185
        ipc_answer(&TASK->kernel_box, call);
185
        ipc_answer(&TASK->kb.box, call);
186
        return;
186
        return;
187
    }
187
    }
188
 
188
 
189
    total_bytes = n;
189
    total_bytes = n;
190
 
190
 
Line 207... Line 207...
207
    IPC_SET_ARG2(call->data, to_copy);
207
    IPC_SET_ARG2(call->data, to_copy);
208
 
208
 
209
    IPC_SET_ARG3(call->data, total_bytes);
209
    IPC_SET_ARG3(call->data, total_bytes);
210
    call->buffer = buffer;
210
    call->buffer = buffer;
211
 
211
 
212
    ipc_answer(&TASK->kernel_box, call);
212
    ipc_answer(&TASK->kb.box, call);
213
}
213
}
214
 
214
 
215
/** Process an ARGS_READ call.
215
/** Process an ARGS_READ call.
216
 *
216
 *
217
 * Reads the argument of a current syscall event (SYSCALL_B or SYSCALL_E).
217
 * Reads the argument of a current syscall event (SYSCALL_B or SYSCALL_E).
Line 227... Line 227...
227
    t = (thread_t *)IPC_GET_ARG2(call->data);
227
    t = (thread_t *)IPC_GET_ARG2(call->data);
228
 
228
 
229
    rc = udebug_args_read(t, &buffer);
229
    rc = udebug_args_read(t, &buffer);
230
    if (rc != EOK) {
230
    if (rc != EOK) {
231
        IPC_SET_RETVAL(call->data, rc);
231
        IPC_SET_RETVAL(call->data, rc);
232
        ipc_answer(&TASK->kernel_box, call);
232
        ipc_answer(&TASK->kb.box, call);
233
        return;
233
        return;
234
    }
234
    }
235
 
235
 
236
    /*
236
    /*
237
     * Make use of call->buffer to transfer data to caller's userspace
237
     * Make use of call->buffer to transfer data to caller's userspace
Line 245... Line 245...
245
       (no way to distinguish method in answer) */
245
       (no way to distinguish method in answer) */
246
    IPC_SET_ARG1(call->data, uspace_addr);
246
    IPC_SET_ARG1(call->data, uspace_addr);
247
    IPC_SET_ARG2(call->data, 6 * sizeof(unative_t));
247
    IPC_SET_ARG2(call->data, 6 * sizeof(unative_t));
248
    call->buffer = buffer;
248
    call->buffer = buffer;
249
 
249
 
250
    ipc_answer(&TASK->kernel_box, call);
250
    ipc_answer(&TASK->kb.box, call);
251
}
251
}
252
 
252
 
253
/** Process an MEM_READ call.
253
/** Process an MEM_READ call.
254
 *
254
 *
255
 * Reads memory of the current (debugged) task.
255
 * Reads memory of the current (debugged) task.
Line 268... Line 268...
268
    size = IPC_GET_ARG4(call->data);
268
    size = IPC_GET_ARG4(call->data);
269
 
269
 
270
    rc = udebug_mem_read(uspace_src, size, &buffer);
270
    rc = udebug_mem_read(uspace_src, size, &buffer);
271
    if (rc < 0) {
271
    if (rc < 0) {
272
        IPC_SET_RETVAL(call->data, rc);
272
        IPC_SET_RETVAL(call->data, rc);
273
        ipc_answer(&TASK->kernel_box, call);
273
        ipc_answer(&TASK->kb.box, call);
274
        return;
274
        return;
275
    }
275
    }
276
 
276
 
277
    IPC_SET_RETVAL(call->data, 0);
277
    IPC_SET_RETVAL(call->data, 0);
278
    /* ARG1=dest, ARG2=size as in IPC_M_DATA_READ so that
278
    /* ARG1=dest, ARG2=size as in IPC_M_DATA_READ so that
Line 280... Line 280...
280
       (no way to distinguish method in answer) */
280
       (no way to distinguish method in answer) */
281
    IPC_SET_ARG1(call->data, uspace_dst);
281
    IPC_SET_ARG1(call->data, uspace_dst);
282
    IPC_SET_ARG2(call->data, size);
282
    IPC_SET_ARG2(call->data, size);
283
    call->buffer = buffer;
283
    call->buffer = buffer;
284
 
284
 
285
    ipc_answer(&TASK->kernel_box, call);
285
    ipc_answer(&TASK->kb.box, call);
286
}
286
}
287
 
287
 
288
/** Handle a debug call received on the kernel answerbox.
288
/** Handle a debug call received on the kernel answerbox.
289
 *
289
 *
290
 * This is called by the kbox servicing thread. Verifies that the sender
290
 * This is called by the kbox servicing thread. Verifies that the sender
Line 304... Line 304...
304
         * and the sender can be safely considered valid until
304
         * and the sender can be safely considered valid until
305
         * control exits this function.
305
         * control exits this function.
306
         */
306
         */
307
        if (TASK->udebug.debugger != call->sender) {
307
        if (TASK->udebug.debugger != call->sender) {
308
            IPC_SET_RETVAL(call->data, EINVAL);
308
            IPC_SET_RETVAL(call->data, EINVAL);
309
            ipc_answer(&TASK->kernel_box, call);
309
            ipc_answer(&TASK->kb.box, call);
310
            return;
310
            return;
311
        }
311
        }
312
    }
312
    }
313
 
313
 
314
    switch (debug_method) {
314
    switch (debug_method) {