Changeset 3698e44 in mainline
- Timestamp:
- 2010-01-26T22:46:29Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 196a1439, 2314381
- Parents:
- e515b21a
- Files:
-
- 3 added
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/udebug/udebug.h
re515b21a r3698e44 107 107 */ 108 108 UDEBUG_M_THREAD_READ, 109 110 /** Read the name of the debugged task. 111 * 112 * - ARG2 - destination address in the caller's address space 113 * - ARG3 - size of receiving buffer in bytes 114 * 115 * The kernel fills the buffer with a non-terminated string. 116 * 117 * - ARG2 - number of bytes that were actually copied 118 * - ARG3 - number of bytes of the complete data 119 * 120 */ 121 UDEBUG_M_NAME_READ, 109 122 110 123 /** Read the list of the debugged task's address space areas. -
kernel/generic/include/udebug/udebug_ops.h
re515b21a r3698e44 47 47 int udebug_thread_read(void **buffer, size_t buf_size, size_t *stored, 48 48 size_t *needed); 49 int udebug_name_read(char **data, size_t *data_size); 49 50 int udebug_args_read(thread_t *t, void **buffer); 50 51 -
kernel/generic/src/udebug/udebug_ipc.c
re515b21a r3698e44 198 198 IPC_SET_ARG3(call->data, needed); 199 199 call->buffer = buffer; 200 201 ipc_answer(&TASK->kb.box, call); 202 } 203 204 /** Process a NAME_READ call. 205 * 206 * Returns a string containing the name of the task. 207 * 208 * @param call The call structure. 209 */ 210 static void udebug_receive_name_read(call_t *call) 211 { 212 unative_t uspace_addr; 213 unative_t to_copy; 214 size_t data_size; 215 size_t buf_size; 216 void *data; 217 218 uspace_addr = IPC_GET_ARG2(call->data); /* Destination address */ 219 buf_size = IPC_GET_ARG3(call->data); /* Dest. buffer size */ 220 221 /* 222 * Read task name. 223 */ 224 udebug_name_read((char **) &data, &data_size); 225 226 /* Copy MAX(buf_size, data_size) bytes */ 227 228 if (buf_size > data_size) 229 to_copy = data_size; 230 else 231 to_copy = buf_size; 232 233 /* 234 * Make use of call->buffer to transfer data to caller's userspace 235 */ 236 237 IPC_SET_RETVAL(call->data, 0); 238 /* ARG1=dest, ARG2=size as in IPC_M_DATA_READ so that 239 same code in process_answer() can be used 240 (no way to distinguish method in answer) */ 241 IPC_SET_ARG1(call->data, uspace_addr); 242 IPC_SET_ARG2(call->data, to_copy); 243 244 IPC_SET_ARG3(call->data, data_size); 245 call->buffer = data; 200 246 201 247 ipc_answer(&TASK->kb.box, call); … … 409 455 udebug_receive_thread_read(call); 410 456 break; 457 case UDEBUG_M_NAME_READ: 458 udebug_receive_name_read(call); 459 break; 411 460 case UDEBUG_M_AREAS_READ: 412 461 udebug_receive_areas_read(call); -
kernel/generic/src/udebug/udebug_ops.c
re515b21a r3698e44 46 46 #include <errno.h> 47 47 #include <print.h> 48 #include <string.h> 48 49 #include <syscall/copy.h> 49 50 #include <ipc/ipc.h> … … 439 440 } 440 441 442 /** Read task name. 443 * 444 * Returns task name as non-terminated string in a newly allocated buffer. 445 * Also returns the size of the data. 446 * 447 * @param data Place to store pointer to newly allocated block. 448 * @param data_size Place to store size of the data. 449 * 450 * @returns EOK. 451 */ 452 int udebug_name_read(char **data, size_t *data_size) 453 { 454 size_t name_size; 455 456 name_size = str_size(TASK->name) + 1; 457 *data = malloc(name_size, 0); 458 *data_size = name_size; 459 460 memcpy(*data, TASK->name, name_size); 461 462 return 0; 463 } 464 441 465 /** Read the arguments of a system call. 442 466 * -
uspace/app/taskdump/Makefile
re515b21a r3698e44 34 34 35 35 SOURCES = \ 36 taskdump.c 36 taskdump.c \ 37 symtab.c 37 38 38 39 include ../Makefile.common -
uspace/app/taskdump/taskdump.c
re515b21a r3698e44 46 46 #include <bool.h> 47 47 48 #include <symtab.h> 48 49 #include <stacktrace.h> 49 50 … … 56 57 static task_id_t task_id; 57 58 static bool dump_memory; 59 static char *app_name; 60 static symtab_t *app_symtab; 58 61 59 62 static int connect_task(task_id_t task_id); … … 67 70 static int td_read_uintptr(void *arg, uintptr_t addr, uintptr_t *value); 68 71 72 static void autoload_syms(void); 73 static char *get_app_task_name(void); 74 static char *fmt_sym_address(uintptr_t addr); 75 69 76 int main(int argc, char *argv[]) 70 77 { … … 90 97 } 91 98 92 printf("Dumping task %lld.\n\n", task_id); 99 app_name = get_app_task_name(); 100 app_symtab = NULL; 101 102 printf("Dumping task '%s' (task ID %lld).\n", app_name, task_id); 103 autoload_syms(); 104 putchar('\n'); 93 105 94 106 rc = threads_dump(); … … 303 315 uintptr_t pc, fp, nfp; 304 316 stacktrace_t st; 317 char *sym_pc; 305 318 int rc; 306 319 … … 320 333 321 334 while (stacktrace_fp_valid(&st, fp)) { 322 printf("%p: %p()\n", fp, pc); 335 sym_pc = fmt_sym_address(pc); 336 printf(" %p: %s()\n", fp, sym_pc); 337 free(sym_pc); 323 338 324 339 rc = stacktrace_ra_get(&st, fp, &pc); … … 412 427 } 413 428 429 /** Attempt to find the right executable file and load the symbol table. */ 430 static void autoload_syms(void) 431 { 432 char *file_name; 433 int rc; 434 435 assert(app_name != NULL); 436 assert(app_symtab == NULL); 437 438 rc = asprintf(&file_name, "/app/%s", app_name); 439 if (rc < 0) { 440 printf("Memory allocation failure.\n"); 441 exit(1); 442 } 443 444 rc = symtab_load(file_name, &app_symtab); 445 if (rc == EOK) { 446 printf("Loaded symbol table from %s\n", file_name); 447 free(file_name); 448 return; 449 } 450 451 free(file_name); 452 453 rc = asprintf(&file_name, "/srv/%s", app_name); 454 if (rc < 0) { 455 printf("Memory allocation failure.\n"); 456 exit(1); 457 } 458 459 rc = symtab_load("/srv/xyz", &app_symtab); 460 if (rc == EOK) { 461 printf("Loaded symbol table from %s\n", file_name); 462 free(file_name); 463 return; 464 } 465 466 free(file_name); 467 printf("Failed autoloading symbol table.\n"); 468 } 469 470 static char *get_app_task_name(void) 471 { 472 char dummy_buf; 473 size_t copied, needed, name_size; 474 char *name; 475 int rc; 476 477 rc = udebug_name_read(phoneid, &dummy_buf, 0, &copied, &needed); 478 if (rc < 0) 479 return NULL; 480 481 name_size = needed; 482 name = malloc(name_size + 1); 483 rc = udebug_name_read(phoneid, name, name_size, &copied, &needed); 484 if (rc < 0) { 485 free(name); 486 return NULL; 487 } 488 489 assert(copied == name_size); 490 assert(copied == needed); 491 name[copied] = '\0'; 492 493 return name; 494 } 495 496 /** Format address in symbolic form. 497 * 498 * Formats address as <symbol_name>+<offset> (<address>), if possible, 499 * otherwise as <address>. 500 * 501 * @param addr Address to format. 502 * @return Newly allocated string, address in symbolic form. 503 */ 504 static char *fmt_sym_address(uintptr_t addr) 505 { 506 char *name; 507 size_t offs; 508 int rc; 509 char *str; 510 511 if (app_symtab != NULL) { 512 rc = symtab_addr_to_name(app_symtab, addr, &name, &offs); 513 } else { 514 rc = ENOTSUP; 515 } 516 517 if (rc == EOK) { 518 rc = asprintf(&str, "(%p) %s+%p", addr, name, offs); 519 } else { 520 rc = asprintf(&str, "%p", addr); 521 } 522 523 if (rc < 0) { 524 printf("Memory allocation error.\n"); 525 exit(1); 526 } 527 528 return str; 529 } 530 414 531 /** @} 415 532 */ -
uspace/lib/libc/arch/amd64/include/types.h
re515b21a r3698e44 36 36 #define LIBC_amd64_TYPES_H_ 37 37 38 #define __64_BITS__ 39 38 40 typedef unsigned long long sysarg_t; 39 41 -
uspace/lib/libc/arch/arm32/include/types.h
re515b21a r3698e44 37 37 #define LIBC_arm32_TYPES_H_ 38 38 39 #define __32_BITS__ 40 39 41 typedef unsigned int sysarg_t; 40 42 -
uspace/lib/libc/arch/ia32/include/types.h
re515b21a r3698e44 36 36 #define LIBC_ia32_TYPES_H_ 37 37 38 #define __32_BITS__ 39 38 40 typedef unsigned int sysarg_t; 39 41 -
uspace/lib/libc/arch/ia64/include/types.h
re515b21a r3698e44 36 36 #define LIBC_ia64_TYPES_H_ 37 37 38 #define __64_BITS__ 39 38 40 typedef unsigned long long sysarg_t; 39 41 -
uspace/lib/libc/arch/mips32/include/types.h
re515b21a r3698e44 37 37 #define LIBC_mips32_TYPES_H_ 38 38 39 #define __32_BITS__ 40 39 41 typedef unsigned int sysarg_t; 40 42 -
uspace/lib/libc/arch/ppc32/include/types.h
re515b21a r3698e44 36 36 #define LIBC_ppc32_TYPES_H_ 37 37 38 #define __32_BITS__ 39 38 40 typedef unsigned int sysarg_t; 39 41 -
uspace/lib/libc/arch/sparc64/include/types.h
re515b21a r3698e44 36 36 #define LIBC_sparc64_TYPES_H_ 37 37 38 #define __64_BITS__ 39 38 40 typedef unsigned long sysarg_t; 39 41 -
uspace/lib/libc/generic/udebug.c
re515b21a r3698e44 69 69 } 70 70 71 int udebug_name_read(int phoneid, void *buffer, size_t n, 72 size_t *copied, size_t *needed) 73 { 74 ipcarg_t a_copied, a_needed; 75 int rc; 76 77 rc = async_req_3_3(phoneid, IPC_M_DEBUG_ALL, UDEBUG_M_NAME_READ, 78 (sysarg_t)buffer, n, NULL, &a_copied, &a_needed); 79 80 *copied = (size_t)a_copied; 81 *needed = (size_t)a_needed; 82 83 return rc; 84 } 85 71 86 int udebug_areas_read(int phoneid, void *buffer, size_t n, 72 87 size_t *copied, size_t *needed) … … 83 98 return rc; 84 99 } 85 86 100 87 101 int udebug_mem_read(int phoneid, void *buffer, uintptr_t addr, size_t n) -
uspace/lib/libc/include/udebug.h
re515b21a r3698e44 47 47 int udebug_thread_read(int phoneid, void *buffer, size_t n, 48 48 size_t *copied, size_t *needed); 49 int udebug_name_read(int phoneid, void *buffer, size_t n, 50 size_t *copied, size_t *needed); 49 51 int udebug_areas_read(int phoneid, void *buffer, size_t n, 50 52 size_t *copied, size_t *needed); -
uspace/srv/loader/arch/amd64/Makefile.inc
re515b21a r3698e44 27 27 # 28 28 29 EXTRA_CFLAGS = -D__64_BITS__30 29 ARCH_SOURCES := arch/$(UARCH)/amd64.s -
uspace/srv/loader/arch/arm32/Makefile.inc
re515b21a r3698e44 27 27 # 28 28 29 EXTRA_CFLAGS = -D__32_BITS__30 29 ARCH_SOURCES := arch/$(UARCH)/arm32.s -
uspace/srv/loader/arch/ia32/Makefile.inc
re515b21a r3698e44 27 27 # 28 28 29 EXTRA_CFLAGS = -D__32_BITS__30 29 ARCH_SOURCES := arch/$(UARCH)/ia32.s -
uspace/srv/loader/arch/ia64/Makefile.inc
re515b21a r3698e44 27 27 # 28 28 29 EXTRA_CFLAGS = -D__64_BITS__30 29 ARCH_SOURCES := arch/$(UARCH)/ia64.s 31 30 AFLAGS += -xexplicit -
uspace/srv/loader/arch/mips32/Makefile.inc
re515b21a r3698e44 27 27 # 28 28 29 EXTRA_CFLAGS = -D__32_BITS__30 29 ARCH_SOURCES := arch/$(UARCH)/mips32.s -
uspace/srv/loader/arch/ppc32/Makefile.inc
re515b21a r3698e44 27 27 # 28 28 29 EXTRA_CFLAGS = -D__32_BITS__30 29 ARCH_SOURCES := arch/$(UARCH)/ppc32.s -
uspace/srv/loader/arch/sparc64/Makefile.inc
re515b21a r3698e44 27 27 # 28 28 29 EXTRA_CFLAGS = -D__64_BITS__30 29 ARCH_SOURCES := arch/$(UARCH)/sparc64.s
Note:
See TracChangeset
for help on using the changeset viewer.