Subversion Repositories HelenOS

Rev

Rev 3448 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3448 Rev 3474
Line 31... Line 31...
31
 */
31
 */
32
 
32
 
33
/**
33
/**
34
 * @file
34
 * @file
35
 * @brief   Udebug IPC message handling.
35
 * @brief   Udebug IPC message handling.
-
 
36
 *
-
 
37
 * This module handles udebug IPC messages and calls the appropriate
-
 
38
 * functions from the udebug_ops module which implement them.
36
 */
39
 */
37
 
40
 
38
#include <proc/task.h>
41
#include <proc/task.h>
39
#include <proc/thread.h>
42
#include <proc/thread.h>
40
#include <arch.h>
43
#include <arch.h>
Line 54... Line 57...
54
    }
57
    }
55
 
58
 
56
    return 0;
59
    return 0;
57
}
60
}
58
 
61
 
-
 
62
/** Process a BEGIN call.
-
 
63
 *
-
 
64
 * Initiates a debugging session for the current task. The reply
-
 
65
 * to this call may or may not be sent before this function returns.
-
 
66
 *
-
 
67
 * @param call  The call structure.
-
 
68
 */
59
static void udebug_receive_begin(call_t *call)
69
static void udebug_receive_begin(call_t *call)
60
{
70
{
61
    int rc;
71
    int rc;
62
 
72
 
63
    rc = udebug_begin(call);
73
    rc = udebug_begin(call);
Line 65... Line 75...
65
        IPC_SET_RETVAL(call->data, rc);
75
        IPC_SET_RETVAL(call->data, rc);
66
        ipc_answer(&TASK->kernel_box, call);
76
        ipc_answer(&TASK->kernel_box, call);
67
        return;
77
        return;
68
    }
78
    }
69
 
79
 
-
 
80
    /*
-
 
81
     * If the initialization of the debugging session has finished,
-
 
82
     * send a reply.
-
 
83
     */
70
    if (rc != 0) {
84
    if (rc != 0) {
71
        IPC_SET_RETVAL(call->data, 0);
85
        IPC_SET_RETVAL(call->data, 0);
72
        ipc_answer(&TASK->kernel_box, call);
86
        ipc_answer(&TASK->kernel_box, call);
73
    }
87
    }
74
}
88
}
75
 
89
 
-
 
90
/** Process an END call.
-
 
91
 *
-
 
92
 * Terminates the debugging session for the current task.
-
 
93
 * @param call  The call structure.
-
 
94
 */
76
static void udebug_receive_end(call_t *call)
95
static void udebug_receive_end(call_t *call)
77
{
96
{
78
    int rc;
97
    int rc;
79
 
98
 
80
    rc = udebug_end();
99
    rc = udebug_end();
81
 
100
 
82
    IPC_SET_RETVAL(call->data, rc);
101
    IPC_SET_RETVAL(call->data, rc);
83
    ipc_answer(&TASK->kernel_box, call);
102
    ipc_answer(&TASK->kernel_box, call);
84
}
103
}
85
 
104
 
-
 
105
/** Process a SET_EVMASK call.
-
 
106
 *
-
 
107
 * Sets an event mask for the current debugging session.
-
 
108
 * @param call  The call structure.
-
 
109
 */
86
static void udebug_receive_set_evmask(call_t *call)
110
static void udebug_receive_set_evmask(call_t *call)
87
{
111
{
88
    int rc;
112
    int rc;
89
    udebug_evmask_t mask;
113
    udebug_evmask_t mask;
90
 
114
 
Line 94... Line 118...
94
    IPC_SET_RETVAL(call->data, rc);
118
    IPC_SET_RETVAL(call->data, rc);
95
    ipc_answer(&TASK->kernel_box, call);
119
    ipc_answer(&TASK->kernel_box, call);
96
}
120
}
97
 
121
 
98
 
122
 
-
 
123
/** Process a GO call.
-
 
124
 *
-
 
125
 * Resumes execution of the specified thread.
-
 
126
 * @param call  The call structure.
-
 
127
 */
99
static void udebug_receive_go(call_t *call)
128
static void udebug_receive_go(call_t *call)
100
{
129
{
101
    thread_t *t;
130
    thread_t *t;
102
    int rc;
131
    int rc;
103
 
132
 
Line 109... Line 138...
109
        ipc_answer(&TASK->kernel_box, call);
138
        ipc_answer(&TASK->kernel_box, call);
110
        return;
139
        return;
111
    }
140
    }
112
}
141
}
113
 
142
 
-
 
143
/** Process a STOP call.
-
 
144
 *
-
 
145
 * Suspends execution of the specified thread.
-
 
146
 * @param call  The call structure.
-
 
147
 */
114
static void udebug_receive_stop(call_t *call)
148
static void udebug_receive_stop(call_t *call)
115
{
149
{
116
    thread_t *t;
150
    thread_t *t;
117
    int rc;
151
    int rc;
118
 
152
 
Line 121... Line 155...
121
    rc = udebug_stop(t, call);
155
    rc = udebug_stop(t, call);
122
    IPC_SET_RETVAL(call->data, rc);
156
    IPC_SET_RETVAL(call->data, rc);
123
    ipc_answer(&TASK->kernel_box, call);
157
    ipc_answer(&TASK->kernel_box, call);
124
}
158
}
125
 
159
 
-
 
160
/** Process a THREAD_READ call.
-
 
161
 *
-
 
162
 * Reads the list of hashes of the (userspace) threads in the current task.
-
 
163
 * @param call  The call structure.
-
 
164
 */
126
static void udebug_receive_thread_read(call_t *call)
165
static void udebug_receive_thread_read(call_t *call)
127
{
166
{
128
    unative_t uspace_addr;
167
    unative_t uspace_addr;
129
    unative_t to_copy;
168
    unative_t to_copy;
130
    unsigned total_bytes;
169
    unsigned total_bytes;
Line 171... Line 210...
171
    call->buffer = buffer;
210
    call->buffer = buffer;
172
 
211
 
173
    ipc_answer(&TASK->kernel_box, call);
212
    ipc_answer(&TASK->kernel_box, call);
174
}
213
}
175
 
214
 
-
 
215
/** Process an ARGS_READ call.
-
 
216
 *
-
 
217
 * Reads the argument of a current syscall event (SYSCALL_B or SYSCALL_E).
-
 
218
 * @param call  The call structure.
-
 
219
 */
176
static void udebug_receive_args_read(call_t *call)
220
static void udebug_receive_args_read(call_t *call)
177
{
221
{
178
    thread_t *t;
222
    thread_t *t;
179
    unative_t uspace_addr;
223
    unative_t uspace_addr;
180
    int rc;
224
    int rc;
Line 204... Line 248...
204
    call->buffer = buffer;
248
    call->buffer = buffer;
205
 
249
 
206
    ipc_answer(&TASK->kernel_box, call);
250
    ipc_answer(&TASK->kernel_box, call);
207
}
251
}
208
 
252
 
-
 
253
/** Process an MEM_READ call.
-
 
254
 *
-
 
255
 * Reads memory of the current (debugged) task.
-
 
256
 * @param call  The call structure.
-
 
257
 */
209
static void udebug_receive_mem_read(call_t *call)
258
static void udebug_receive_mem_read(call_t *call)
210
{
259
{
211
    unative_t uspace_dst;
260
    unative_t uspace_dst;
212
    unative_t uspace_src;
261
    unative_t uspace_src;
213
    unsigned size;
262
    unsigned size;
Line 234... Line 283...
234
    call->buffer = buffer;
283
    call->buffer = buffer;
235
 
284
 
236
    ipc_answer(&TASK->kernel_box, call);
285
    ipc_answer(&TASK->kernel_box, call);
237
}
286
}
238
 
287
 
239
/**
-
 
240
 * Handle a debug call received on the kernel answerbox.
288
/** Handle a debug call received on the kernel answerbox.
241
 *
289
 *
242
 * This is called by the kbox servicing thread.
290
 * This is called by the kbox servicing thread. Verifies that the sender
-
 
291
 * is indeed the debugger and calls the appropriate processing function.
243
 */
292
 */
244
void udebug_call_receive(call_t *call)
293
void udebug_call_receive(call_t *call)
245
{
294
{
246
    int debug_method;
295
    int debug_method;
247
 
296