1 | /*
|
---|
2 | * Copyright (c) 2008 Jiri Svoboda
|
---|
3 | * All rights reserved.
|
---|
4 | *
|
---|
5 | * Redistribution and use in source and binary forms, with or without
|
---|
6 | * modification, are permitted provided that the following conditions
|
---|
7 | * are met:
|
---|
8 | *
|
---|
9 | * - Redistributions of source code must retain the above copyright
|
---|
10 | * notice, this list of conditions and the following disclaimer.
|
---|
11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer in the
|
---|
13 | * documentation and/or other materials provided with the distribution.
|
---|
14 | * - The name of the author may not be used to endorse or promote products
|
---|
15 | * derived from this software without specific prior written permission.
|
---|
16 | *
|
---|
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
27 | */
|
---|
28 |
|
---|
29 | /** @addtogroup generic
|
---|
30 | * @{
|
---|
31 | */
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * @file
|
---|
35 | * @brief Udebug operations.
|
---|
36 | *
|
---|
37 | * Udebug operations on tasks and threads are implemented here. The
|
---|
38 | * functions defined here are called from the udebug_ipc module
|
---|
39 | * when servicing udebug IPC messages.
|
---|
40 | */
|
---|
41 |
|
---|
42 | #include <debug.h>
|
---|
43 | #include <proc/task.h>
|
---|
44 | #include <proc/thread.h>
|
---|
45 | #include <arch.h>
|
---|
46 | #include <errno.h>
|
---|
47 | #include <print.h>
|
---|
48 | #include <syscall/copy.h>
|
---|
49 | #include <ipc/ipc.h>
|
---|
50 | #include <udebug/udebug.h>
|
---|
51 | #include <udebug/udebug_ops.h>
|
---|
52 | #include <memstr.h>
|
---|
53 |
|
---|
54 | /**
|
---|
55 | * Prepare a thread for a debugging operation.
|
---|
56 | *
|
---|
57 | * Simply put, return thread t with t->udebug.lock held,
|
---|
58 | * but only if it verifies all conditions.
|
---|
59 | *
|
---|
60 | * Specifically, verifies that thread t exists, is a userspace thread,
|
---|
61 | * and belongs to the current task (TASK). Verifies, that the thread
|
---|
62 | * is (or is not) go according to being_go (typically false).
|
---|
63 | * It also locks t->udebug.lock, making sure that t->udebug.active
|
---|
64 | * is true - that the thread is in a valid debugging session.
|
---|
65 | *
|
---|
66 | * With this verified and the t->udebug.lock mutex held, it is ensured
|
---|
67 | * that the thread cannot leave the debugging session, let alone cease
|
---|
68 | * to exist.
|
---|
69 | *
|
---|
70 | * In this function, holding the TASK->udebug.lock mutex prevents the
|
---|
71 | * thread from leaving the debugging session, while relaxing from
|
---|
72 | * the t->lock spinlock to the t->udebug.lock mutex.
|
---|
73 | *
|
---|
74 | * @param t Pointer, need not at all be valid.
|
---|
75 | * @param being_go Required thread state.
|
---|
76 | *
|
---|
77 | * Returns EOK if all went well, or an error code otherwise.
|
---|
78 | */
|
---|
79 | static int _thread_op_begin(thread_t *t, bool being_go)
|
---|
80 | {
|
---|
81 | task_id_t taskid;
|
---|
82 | ipl_t ipl;
|
---|
83 |
|
---|
84 | taskid = TASK->taskid;
|
---|
85 |
|
---|
86 | mutex_lock(&TASK->udebug.lock);
|
---|
87 |
|
---|
88 | /* thread_exists() must be called with threads_lock held */
|
---|
89 | ipl = interrupts_disable();
|
---|
90 | spinlock_lock(&threads_lock);
|
---|
91 |
|
---|
92 | if (!thread_exists(t)) {
|
---|
93 | spinlock_unlock(&threads_lock);
|
---|
94 | interrupts_restore(ipl);
|
---|
95 | mutex_unlock(&TASK->udebug.lock);
|
---|
96 | return ENOENT;
|
---|
97 | }
|
---|
98 |
|
---|
99 | /* t->lock is enough to ensure the thread's existence */
|
---|
100 | spinlock_lock(&t->lock);
|
---|
101 | spinlock_unlock(&threads_lock);
|
---|
102 |
|
---|
103 | /* Verify that 't' is a userspace thread. */
|
---|
104 | if ((t->flags & THREAD_FLAG_USPACE) == 0) {
|
---|
105 | /* It's not, deny its existence */
|
---|
106 | spinlock_unlock(&t->lock);
|
---|
107 | interrupts_restore(ipl);
|
---|
108 | mutex_unlock(&TASK->udebug.lock);
|
---|
109 | return ENOENT;
|
---|
110 | }
|
---|
111 |
|
---|
112 | /* Verify debugging state. */
|
---|
113 | if (t->udebug.active != true) {
|
---|
114 | /* Not in debugging session or undesired GO state */
|
---|
115 | spinlock_unlock(&t->lock);
|
---|
116 | interrupts_restore(ipl);
|
---|
117 | mutex_unlock(&TASK->udebug.lock);
|
---|
118 | return ENOENT;
|
---|
119 | }
|
---|
120 |
|
---|
121 | /*
|
---|
122 | * Since the thread has active == true, TASK->udebug.lock
|
---|
123 | * is enough to ensure its existence and that active remains
|
---|
124 | * true.
|
---|
125 | */
|
---|
126 | spinlock_unlock(&t->lock);
|
---|
127 | interrupts_restore(ipl);
|
---|
128 |
|
---|
129 | /* Only mutex TASK->udebug.lock left. */
|
---|
130 |
|
---|
131 | /* Now verify that the thread belongs to the current task. */
|
---|
132 | if (t->task != TASK) {
|
---|
133 | /* No such thread belonging this task*/
|
---|
134 | mutex_unlock(&TASK->udebug.lock);
|
---|
135 | return ENOENT;
|
---|
136 | }
|
---|
137 |
|
---|
138 | /*
|
---|
139 | * Now we need to grab the thread's debug lock for synchronization
|
---|
140 | * of the threads stoppability/stop state.
|
---|
141 | */
|
---|
142 | mutex_lock(&t->udebug.lock);
|
---|
143 |
|
---|
144 | /* The big task mutex is no longer needed. */
|
---|
145 | mutex_unlock(&TASK->udebug.lock);
|
---|
146 |
|
---|
147 | if (t->udebug.go != being_go) {
|
---|
148 | /* Not in debugging session or undesired GO state. */
|
---|
149 | mutex_unlock(&t->udebug.lock);
|
---|
150 | return EINVAL;
|
---|
151 | }
|
---|
152 |
|
---|
153 | /* Only t->udebug.lock left. */
|
---|
154 |
|
---|
155 | return EOK; /* All went well. */
|
---|
156 | }
|
---|
157 |
|
---|
158 | /** End debugging operation on a thread. */
|
---|
159 | static void _thread_op_end(thread_t *t)
|
---|
160 | {
|
---|
161 | mutex_unlock(&t->udebug.lock);
|
---|
162 | }
|
---|
163 |
|
---|
164 | /** Begin debugging the current task.
|
---|
165 | *
|
---|
166 | * Initiates a debugging session for the current task (and its threads).
|
---|
167 | * When the debugging session has started a reply will be sent to the
|
---|
168 | * UDEBUG_BEGIN call. This may happen immediately in this function if
|
---|
169 | * all the threads in this task are stoppable at the moment and in this
|
---|
170 | * case the function returns 1.
|
---|
171 | *
|
---|
172 | * Otherwise the function returns 0 and the reply will be sent as soon as
|
---|
173 | * all the threads become stoppable (i.e. they can be considered stopped).
|
---|
174 | *
|
---|
175 | * @param call The BEGIN call we are servicing.
|
---|
176 | * @return 0 (OK, but not done yet), 1 (done) or negative error code.
|
---|
177 | */
|
---|
178 | int udebug_begin(call_t *call)
|
---|
179 | {
|
---|
180 | int reply;
|
---|
181 |
|
---|
182 | thread_t *t;
|
---|
183 | link_t *cur;
|
---|
184 |
|
---|
185 | LOG("Debugging task %llu", TASK->taskid);
|
---|
186 | mutex_lock(&TASK->udebug.lock);
|
---|
187 |
|
---|
188 | if (TASK->udebug.dt_state != UDEBUG_TS_INACTIVE) {
|
---|
189 | mutex_unlock(&TASK->udebug.lock);
|
---|
190 | return EBUSY;
|
---|
191 | }
|
---|
192 |
|
---|
193 | TASK->udebug.dt_state = UDEBUG_TS_BEGINNING;
|
---|
194 | TASK->udebug.begin_call = call;
|
---|
195 | TASK->udebug.debugger = call->sender;
|
---|
196 |
|
---|
197 | if (TASK->udebug.not_stoppable_count == 0) {
|
---|
198 | TASK->udebug.dt_state = UDEBUG_TS_ACTIVE;
|
---|
199 | TASK->udebug.begin_call = NULL;
|
---|
200 | reply = 1; /* immediate reply */
|
---|
201 | } else {
|
---|
202 | reply = 0; /* no reply */
|
---|
203 | }
|
---|
204 |
|
---|
205 | /* Set udebug.active on all of the task's userspace threads. */
|
---|
206 |
|
---|
207 | for (cur = TASK->th_head.next; cur != &TASK->th_head; cur = cur->next) {
|
---|
208 | t = list_get_instance(cur, thread_t, th_link);
|
---|
209 |
|
---|
210 | mutex_lock(&t->udebug.lock);
|
---|
211 | if ((t->flags & THREAD_FLAG_USPACE) != 0) {
|
---|
212 | t->udebug.active = true;
|
---|
213 | mutex_unlock(&t->udebug.lock);
|
---|
214 | condvar_broadcast(&t->udebug.active_cv);
|
---|
215 | } else {
|
---|
216 | mutex_unlock(&t->udebug.lock);
|
---|
217 | }
|
---|
218 | }
|
---|
219 |
|
---|
220 | mutex_unlock(&TASK->udebug.lock);
|
---|
221 | return reply;
|
---|
222 | }
|
---|
223 |
|
---|
224 | /** Finish debugging the current task.
|
---|
225 | *
|
---|
226 | * Closes the debugging session for the current task.
|
---|
227 | * @return Zero on success or negative error code.
|
---|
228 | */
|
---|
229 | int udebug_end(void)
|
---|
230 | {
|
---|
231 | int rc;
|
---|
232 |
|
---|
233 | LOG("Task %" PRIu64, TASK->taskid);
|
---|
234 |
|
---|
235 | mutex_lock(&TASK->udebug.lock);
|
---|
236 | rc = udebug_task_cleanup(TASK);
|
---|
237 | mutex_unlock(&TASK->udebug.lock);
|
---|
238 |
|
---|
239 | return rc;
|
---|
240 | }
|
---|
241 |
|
---|
242 | /** Set the event mask.
|
---|
243 | *
|
---|
244 | * Sets the event mask that determines which events are enabled.
|
---|
245 | *
|
---|
246 | * @param mask Or combination of events that should be enabled.
|
---|
247 | * @return Zero on success or negative error code.
|
---|
248 | */
|
---|
249 | int udebug_set_evmask(udebug_evmask_t mask)
|
---|
250 | {
|
---|
251 | LOG("mask = 0x%x", mask);
|
---|
252 |
|
---|
253 | mutex_lock(&TASK->udebug.lock);
|
---|
254 |
|
---|
255 | if (TASK->udebug.dt_state != UDEBUG_TS_ACTIVE) {
|
---|
256 | mutex_unlock(&TASK->udebug.lock);
|
---|
257 | return EINVAL;
|
---|
258 | }
|
---|
259 |
|
---|
260 | TASK->udebug.evmask = mask;
|
---|
261 | mutex_unlock(&TASK->udebug.lock);
|
---|
262 |
|
---|
263 | return 0;
|
---|
264 | }
|
---|
265 |
|
---|
266 | /** Give thread GO.
|
---|
267 | *
|
---|
268 | * Upon recieving a go message, the thread is given GO. Being GO
|
---|
269 | * means the thread is allowed to execute userspace code (until
|
---|
270 | * a debugging event or STOP occurs, at which point the thread loses GO.
|
---|
271 | *
|
---|
272 | * @param t The thread to operate on (unlocked and need not be valid).
|
---|
273 | * @param call The GO call that we are servicing.
|
---|
274 | */
|
---|
275 | int udebug_go(thread_t *t, call_t *call)
|
---|
276 | {
|
---|
277 | int rc;
|
---|
278 |
|
---|
279 | /* On success, this will lock t->udebug.lock. */
|
---|
280 | rc = _thread_op_begin(t, false);
|
---|
281 | if (rc != EOK) {
|
---|
282 | return rc;
|
---|
283 | }
|
---|
284 |
|
---|
285 | t->udebug.go_call = call;
|
---|
286 | t->udebug.go = true;
|
---|
287 | t->udebug.cur_event = 0; /* none */
|
---|
288 |
|
---|
289 | /*
|
---|
290 | * Neither t's lock nor threads_lock may be held during wakeup.
|
---|
291 | */
|
---|
292 | waitq_wakeup(&t->udebug.go_wq, WAKEUP_FIRST);
|
---|
293 |
|
---|
294 | _thread_op_end(t);
|
---|
295 |
|
---|
296 | return 0;
|
---|
297 | }
|
---|
298 |
|
---|
299 | /** Stop a thread (i.e. take its GO away)
|
---|
300 | *
|
---|
301 | * Generates a STOP event as soon as the thread becomes stoppable (i.e.
|
---|
302 | * can be considered stopped).
|
---|
303 | *
|
---|
304 | * @param t The thread to operate on (unlocked and need not be valid).
|
---|
305 | * @param call The GO call that we are servicing.
|
---|
306 | */
|
---|
307 | int udebug_stop(thread_t *t, call_t *call)
|
---|
308 | {
|
---|
309 | int rc;
|
---|
310 |
|
---|
311 | LOG("udebug_stop()");
|
---|
312 |
|
---|
313 | /*
|
---|
314 | * On success, this will lock t->udebug.lock. Note that this makes sure
|
---|
315 | * the thread is not stopped.
|
---|
316 | */
|
---|
317 | rc = _thread_op_begin(t, true);
|
---|
318 | if (rc != EOK) {
|
---|
319 | return rc;
|
---|
320 | }
|
---|
321 |
|
---|
322 | /* Take GO away from the thread. */
|
---|
323 | t->udebug.go = false;
|
---|
324 |
|
---|
325 | if (t->udebug.stoppable != true) {
|
---|
326 | /* Answer will be sent when the thread becomes stoppable. */
|
---|
327 | _thread_op_end(t);
|
---|
328 | return 0;
|
---|
329 | }
|
---|
330 |
|
---|
331 | /*
|
---|
332 | * Answer GO call.
|
---|
333 | */
|
---|
334 |
|
---|
335 | /* Make sure nobody takes this call away from us. */
|
---|
336 | call = t->udebug.go_call;
|
---|
337 | t->udebug.go_call = NULL;
|
---|
338 |
|
---|
339 | IPC_SET_RETVAL(call->data, 0);
|
---|
340 | IPC_SET_ARG1(call->data, UDEBUG_EVENT_STOP);
|
---|
341 |
|
---|
342 | THREAD->udebug.cur_event = UDEBUG_EVENT_STOP;
|
---|
343 |
|
---|
344 | _thread_op_end(t);
|
---|
345 |
|
---|
346 | mutex_lock(&TASK->udebug.lock);
|
---|
347 | ipc_answer(&TASK->answerbox, call);
|
---|
348 | mutex_unlock(&TASK->udebug.lock);
|
---|
349 |
|
---|
350 | return 0;
|
---|
351 | }
|
---|
352 |
|
---|
353 | /** Read the list of userspace threads in the current task.
|
---|
354 | *
|
---|
355 | * The list takes the form of a sequence of thread hashes (i.e. the pointers
|
---|
356 | * to thread structures). A buffer of size @a buf_size is allocated and
|
---|
357 | * a pointer to it written to @a buffer. The sequence of hashes is written
|
---|
358 | * into this buffer.
|
---|
359 | *
|
---|
360 | * If the sequence is longer than @a buf_size bytes, only as much hashes
|
---|
361 | * as can fit are copied. The number of bytes copied is stored in @a stored.
|
---|
362 | * The total number of thread bytes that could have been saved had there been
|
---|
363 | * enough space is stored in @a needed.
|
---|
364 | *
|
---|
365 | * The rationale for having @a buf_size is that this function is only
|
---|
366 | * used for servicing the THREAD_READ message, which always specifies
|
---|
367 | * a maximum size for the userspace buffer.
|
---|
368 | *
|
---|
369 | * @param buffer The buffer for storing thread hashes.
|
---|
370 | * @param buf_size Buffer size in bytes.
|
---|
371 | * @param stored The actual number of bytes copied will be stored here.
|
---|
372 | * @param needed Total number of hashes that could have been saved.
|
---|
373 | */
|
---|
374 | int udebug_thread_read(void **buffer, size_t buf_size, size_t *stored,
|
---|
375 | size_t *needed)
|
---|
376 | {
|
---|
377 | thread_t *t;
|
---|
378 | link_t *cur;
|
---|
379 | unative_t tid;
|
---|
380 | size_t copied_ids;
|
---|
381 | size_t extra_ids;
|
---|
382 | ipl_t ipl;
|
---|
383 | unative_t *id_buffer;
|
---|
384 | int flags;
|
---|
385 | size_t max_ids;
|
---|
386 |
|
---|
387 | LOG("udebug_thread_read()");
|
---|
388 |
|
---|
389 | /* Allocate a buffer to hold thread IDs */
|
---|
390 | id_buffer = malloc(buf_size + 1, 0);
|
---|
391 |
|
---|
392 | mutex_lock(&TASK->udebug.lock);
|
---|
393 |
|
---|
394 | /* Verify task state */
|
---|
395 | if (TASK->udebug.dt_state != UDEBUG_TS_ACTIVE) {
|
---|
396 | mutex_unlock(&TASK->udebug.lock);
|
---|
397 | return EINVAL;
|
---|
398 | }
|
---|
399 |
|
---|
400 | ipl = interrupts_disable();
|
---|
401 | spinlock_lock(&TASK->lock);
|
---|
402 | /* Copy down the thread IDs */
|
---|
403 |
|
---|
404 | max_ids = buf_size / sizeof(unative_t);
|
---|
405 | copied_ids = 0;
|
---|
406 | extra_ids = 0;
|
---|
407 |
|
---|
408 | /* FIXME: make sure the thread isn't past debug shutdown... */
|
---|
409 | for (cur = TASK->th_head.next; cur != &TASK->th_head; cur = cur->next) {
|
---|
410 | t = list_get_instance(cur, thread_t, th_link);
|
---|
411 |
|
---|
412 | spinlock_lock(&t->lock);
|
---|
413 | flags = t->flags;
|
---|
414 | spinlock_unlock(&t->lock);
|
---|
415 |
|
---|
416 | /* Not interested in kernel threads. */
|
---|
417 | if ((flags & THREAD_FLAG_USPACE) == 0)
|
---|
418 | continue;
|
---|
419 |
|
---|
420 | if (copied_ids < max_ids) {
|
---|
421 | /* Using thread struct pointer as identification hash */
|
---|
422 | tid = (unative_t) t;
|
---|
423 | id_buffer[copied_ids++] = tid;
|
---|
424 | } else {
|
---|
425 | extra_ids++;
|
---|
426 | }
|
---|
427 | }
|
---|
428 |
|
---|
429 | spinlock_unlock(&TASK->lock);
|
---|
430 | interrupts_restore(ipl);
|
---|
431 |
|
---|
432 | mutex_unlock(&TASK->udebug.lock);
|
---|
433 |
|
---|
434 | *buffer = id_buffer;
|
---|
435 | *stored = copied_ids * sizeof(unative_t);
|
---|
436 | *needed = (copied_ids + extra_ids) * sizeof(unative_t);
|
---|
437 |
|
---|
438 | return 0;
|
---|
439 | }
|
---|
440 |
|
---|
441 | /** Read the arguments of a system call.
|
---|
442 | *
|
---|
443 | * The arguments of the system call being being executed are copied
|
---|
444 | * to an allocated buffer and a pointer to it is written to @a buffer.
|
---|
445 | * The size of the buffer is exactly such that it can hold the maximum number
|
---|
446 | * of system-call arguments.
|
---|
447 | *
|
---|
448 | * Unless the thread is currently blocked in a SYSCALL_B or SYSCALL_E event,
|
---|
449 | * this function will fail with an EINVAL error code.
|
---|
450 | *
|
---|
451 | * @param buffer The buffer for storing thread hashes.
|
---|
452 | */
|
---|
453 | int udebug_args_read(thread_t *t, void **buffer)
|
---|
454 | {
|
---|
455 | int rc;
|
---|
456 | unative_t *arg_buffer;
|
---|
457 |
|
---|
458 | /* Prepare a buffer to hold the arguments. */
|
---|
459 | arg_buffer = malloc(6 * sizeof(unative_t), 0);
|
---|
460 |
|
---|
461 | /* On success, this will lock t->udebug.lock. */
|
---|
462 | rc = _thread_op_begin(t, false);
|
---|
463 | if (rc != EOK) {
|
---|
464 | return rc;
|
---|
465 | }
|
---|
466 |
|
---|
467 | /* Additionally we need to verify that we are inside a syscall. */
|
---|
468 | if (t->udebug.cur_event != UDEBUG_EVENT_SYSCALL_B &&
|
---|
469 | t->udebug.cur_event != UDEBUG_EVENT_SYSCALL_E) {
|
---|
470 | _thread_op_end(t);
|
---|
471 | return EINVAL;
|
---|
472 | }
|
---|
473 |
|
---|
474 | /* Copy to a local buffer before releasing the lock. */
|
---|
475 | memcpy(arg_buffer, t->udebug.syscall_args, 6 * sizeof(unative_t));
|
---|
476 |
|
---|
477 | _thread_op_end(t);
|
---|
478 |
|
---|
479 | *buffer = arg_buffer;
|
---|
480 | return 0;
|
---|
481 | }
|
---|
482 |
|
---|
483 | /** Read the memory of the debugged task.
|
---|
484 | *
|
---|
485 | * Reads @a n bytes from the address space of the debugged task, starting
|
---|
486 | * from @a uspace_addr. The bytes are copied into an allocated buffer
|
---|
487 | * and a pointer to it is written into @a buffer.
|
---|
488 | *
|
---|
489 | * @param uspace_addr Address from where to start reading.
|
---|
490 | * @param n Number of bytes to read.
|
---|
491 | * @param buffer For storing a pointer to the allocated buffer.
|
---|
492 | */
|
---|
493 | int udebug_mem_read(unative_t uspace_addr, size_t n, void **buffer)
|
---|
494 | {
|
---|
495 | void *data_buffer;
|
---|
496 | int rc;
|
---|
497 |
|
---|
498 | /* Verify task state */
|
---|
499 | mutex_lock(&TASK->udebug.lock);
|
---|
500 |
|
---|
501 | if (TASK->udebug.dt_state != UDEBUG_TS_ACTIVE) {
|
---|
502 | mutex_unlock(&TASK->udebug.lock);
|
---|
503 | return EBUSY;
|
---|
504 | }
|
---|
505 |
|
---|
506 | data_buffer = malloc(n, 0);
|
---|
507 |
|
---|
508 | /* NOTE: this is not strictly from a syscall... but that shouldn't
|
---|
509 | * be a problem */
|
---|
510 | rc = copy_from_uspace(data_buffer, (void *)uspace_addr, n);
|
---|
511 | mutex_unlock(&TASK->udebug.lock);
|
---|
512 |
|
---|
513 | if (rc != 0) return rc;
|
---|
514 |
|
---|
515 | *buffer = data_buffer;
|
---|
516 | return 0;
|
---|
517 | }
|
---|
518 |
|
---|
519 | /** @}
|
---|
520 | */
|
---|