Rev 2894 | Rev 2897 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2894 | Rev 2896 | ||
|---|---|---|---|
| Line 265... | Line 265... | ||
| 265 | /* Count all threads, to be on the safe side */ |
265 | /* Count all threads, to be on the safe side */ |
| 266 | ++num_threads; |
266 | ++num_threads; |
| 267 | } |
267 | } |
| 268 | 268 | ||
| 269 | /* Allocate a buffer and copy down the threads' ids */ |
269 | /* Allocate a buffer and copy down the threads' ids */ |
| - | 270 | //FIXME!!! must not malloc when locks are held |
|
| 270 | id_buffer = malloc(num_threads * sizeof(unative_t), 0); // ??? |
271 | id_buffer = malloc(num_threads * sizeof(unative_t), 0); |
| - | 272 | if (!id_buffer) { |
|
| - | 273 | spinlock_unlock(&TASK->lock); |
|
| - | 274 | interrupts_restore(ipl); |
|
| - | 275 | ||
| - | 276 | return ENOMEM; |
|
| - | 277 | } |
|
| 271 | 278 | ||
| 272 | copied_ids = 0; |
279 | copied_ids = 0; |
| 273 | for (cur = TASK->th_head.next; cur != &TASK->th_head; cur = cur->next) { |
280 | for (cur = TASK->th_head.next; cur != &TASK->th_head; cur = cur->next) { |
| 274 | t = list_get_instance(cur, thread_t, th_link); |
281 | t = list_get_instance(cur, thread_t, th_link); |
| 275 | 282 | ||
| Line 300... | Line 307... | ||
| 300 | ipl_t ipl; |
307 | ipl_t ipl; |
| 301 | unative_t *arg_buffer; |
308 | unative_t *arg_buffer; |
| 302 | 309 | ||
| 303 | klog_printf("udebug_args_read()"); |
310 | klog_printf("udebug_args_read()"); |
| 304 | 311 | ||
| - | 312 | /* Prepare a buffer to hold the arguments */ |
|
| - | 313 | arg_buffer = malloc(6 * sizeof(unative_t), 0); |
|
| - | 314 | if (!arg_buffer) return ENOMEM; |
|
| - | 315 | ||
| 305 | ipl = interrupts_disable(); |
316 | ipl = interrupts_disable(); |
| 306 | 317 | ||
| 307 | /* On success, this will lock t->debug_lock */ |
318 | /* On success, this will lock t->debug_lock */ |
| 308 | rc = _thread_op_begin(t); |
319 | rc = _thread_op_begin(t); |
| 309 | if (rc != EOK) { |
320 | if (rc != EOK) { |
| Line 318... | Line 329... | ||
| 318 | 329 | ||
| 319 | return EINVAL; |
330 | return EINVAL; |
| 320 | } |
331 | } |
| 321 | 332 | ||
| 322 | /* Copy to a local buffer before releasing the lock */ |
333 | /* Copy to a local buffer before releasing the lock */ |
| 323 | arg_buffer = malloc(6 * sizeof(unative_t), 0); // ??? |
- | |
| 324 | memcpy(arg_buffer, t->syscall_args, 6 * sizeof(unative_t)); |
334 | memcpy(arg_buffer, t->syscall_args, 6 * sizeof(unative_t)); |
| 325 | 335 | ||
| 326 | _thread_op_end(t); |
336 | _thread_op_end(t); |
| 327 | interrupts_restore(ipl); |
337 | interrupts_restore(ipl); |
| 328 | 338 | ||
| Line 337... | Line 347... | ||
| 337 | int rc; |
347 | int rc; |
| 338 | ipl_t ipl; |
348 | ipl_t ipl; |
| 339 | 349 | ||
| 340 | klog_printf("udebug_regs_read()"); |
350 | klog_printf("udebug_regs_read()"); |
| 341 | 351 | ||
| - | 352 | /* Prepare a buffer to hold the registers */ |
|
| - | 353 | regs_buffer = malloc(sizeof(istate_t), 0); |
|
| - | 354 | if (!regs_buffer) return ENOMEM; |
|
| - | 355 | ||
| 342 | ipl = interrupts_disable(); |
356 | ipl = interrupts_disable(); |
| 343 | 357 | ||
| 344 | /* On success, this will lock t->debug_lock */ |
358 | /* On success, this will lock t->debug_lock */ |
| 345 | rc = _thread_op_begin(t); |
359 | rc = _thread_op_begin(t); |
| 346 | if (rc != EOK) { |
360 | if (rc != EOK) { |
| Line 354... | Line 368... | ||
| 354 | interrupts_restore(ipl); |
368 | interrupts_restore(ipl); |
| 355 | klog_printf("udebug_regs_read() - istate not available"); |
369 | klog_printf("udebug_regs_read() - istate not available"); |
| 356 | return EBUSY; |
370 | return EBUSY; |
| 357 | } |
371 | } |
| 358 | 372 | ||
| 359 | /* Copy to an allocated buffer */ |
373 | /* Copy to the allocated buffer */ |
| 360 | regs_buffer = malloc(sizeof(istate_t), 0); // ??? |
- | |
| 361 | memcpy(regs_buffer, state, sizeof(istate_t)); |
374 | memcpy(regs_buffer, state, sizeof(istate_t)); |
| 362 | 375 | ||
| 363 | _thread_op_end(t); |
376 | _thread_op_end(t); |
| 364 | interrupts_restore(ipl); |
377 | interrupts_restore(ipl); |
| 365 | 378 | ||
| Line 411... | Line 424... | ||
| 411 | void *data_buffer; |
424 | void *data_buffer; |
| 412 | int rc; |
425 | int rc; |
| 413 | 426 | ||
| 414 | klog_printf("udebug_mem_read()"); |
427 | klog_printf("udebug_mem_read()"); |
| 415 | 428 | ||
| 416 | data_buffer = malloc(n, 0); // ??? |
429 | data_buffer = malloc(n, 0); |
| - | 430 | if (!data_buffer) return ENOMEM; |
|
| - | 431 | ||
| 417 | klog_printf("udebug_mem_read: src=%u, size=%u", uspace_addr, n); |
432 | klog_printf("udebug_mem_read: src=%u, size=%u", uspace_addr, n); |
| 418 | 433 | ||
| 419 | /* NOTE: this is not strictly from a syscall... but that shouldn't |
434 | /* NOTE: this is not strictly from a syscall... but that shouldn't |
| 420 | * be a problem */ |
435 | * be a problem */ |
| 421 | rc = copy_from_uspace(data_buffer, (void *)uspace_addr, n); |
436 | rc = copy_from_uspace(data_buffer, (void *)uspace_addr, n); |