Changeset c1b979a in mainline
- Timestamp:
- 2014-07-11T23:06:30Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 78192cc7
- Parents:
- 8e4a408
- Location:
- uspace
- Files:
-
- 3 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/taskdump/Makefile
r8e4a408 rc1b979a 33 33 SOURCES = \ 34 34 elf_core.c \ 35 fibrildump.c \ 35 36 taskdump.c \ 36 37 symtab.c -
uspace/app/taskdump/include/symtab.h
r8e4a408 rc1b979a 50 50 extern int symtab_load(const char *file_name, symtab_t **symtab); 51 51 extern void symtab_delete(symtab_t *st); 52 extern int symtab_name_to_addr(symtab_t *st, c har *name, uintptr_t *addr);52 extern int symtab_name_to_addr(symtab_t *st, const char *name, uintptr_t *addr); 53 53 extern int symtab_addr_to_name(symtab_t *symtab, uintptr_t addr, char **name, 54 54 size_t *offs); -
uspace/app/taskdump/symtab.c
r8e4a408 rc1b979a 202 202 * @return EOK on success, ENOENT if no such symbol was found. 203 203 */ 204 int symtab_name_to_addr(symtab_t *st, c har *name, uintptr_t *addr)204 int symtab_name_to_addr(symtab_t *st, const char *name, uintptr_t *addr) 205 205 { 206 206 size_t i; -
uspace/app/taskdump/taskdump.c
r8e4a408 rc1b979a 35 35 #include <async.h> 36 36 #include <elf/elf_linux.h> 37 #include <fibrildump.h> 37 38 #include <stdio.h> 38 39 #include <stdlib.h> … … 52 53 #include <elf_core.h> 53 54 #include <stacktrace.h> 55 #include <taskdump.h> 54 56 55 57 #define LINE_BYTES 16 … … 76 78 static istate_t reg_state; 77 79 80 static stacktrace_ops_t td_stacktrace_ops = { 81 .read_uintptr = td_read_uintptr 82 }; 83 78 84 int main(int argc, char *argv[]) 79 85 { … … 106 112 if (rc < 0) 107 113 printf("Failed dumping address space areas.\n"); 114 115 rc = fibrils_dump(app_symtab, sess); 116 if (rc < 0) 117 printf("Failed dumping fibrils.\n"); 108 118 109 119 udebug_end(sess); … … 311 321 } 312 322 323 int td_stacktrace(uintptr_t fp, uintptr_t pc) 324 { 325 uintptr_t nfp; 326 stacktrace_t st; 327 char *sym_pc; 328 int rc; 329 330 st.op_arg = NULL; 331 st.ops = &td_stacktrace_ops; 332 333 while (stacktrace_fp_valid(&st, fp)) { 334 sym_pc = fmt_sym_address(pc); 335 printf(" %p: %s\n", (void *) fp, sym_pc); 336 free(sym_pc); 337 338 rc = stacktrace_ra_get(&st, fp, &pc); 339 if (rc != EOK) 340 return rc; 341 342 rc = stacktrace_fp_prev(&st, fp, &nfp); 343 if (rc != EOK) 344 return rc; 345 346 fp = nfp; 347 } 348 349 return EOK; 350 } 351 313 352 static int thread_dump(uintptr_t thash) 314 353 { 315 354 istate_t istate; 316 uintptr_t pc, fp, nfp; 317 stacktrace_t st; 355 uintptr_t pc, fp; 318 356 char *sym_pc; 319 357 int rc; … … 336 374 free(sym_pc); 337 375 338 st.op_arg = NULL; 339 st.read_uintptr = td_read_uintptr; 340 341 while (stacktrace_fp_valid(&st, fp)) { 342 sym_pc = fmt_sym_address(pc); 343 printf(" %p: %s\n", (void *) fp, sym_pc); 344 free(sym_pc); 345 346 rc = stacktrace_ra_get(&st, fp, &pc); 347 if (rc != EOK) 348 return rc; 349 350 rc = stacktrace_fp_prev(&st, fp, &nfp); 351 if (rc != EOK) 352 return rc; 353 354 fp = nfp; 355 } 376 (void) td_stacktrace(fp, pc); 356 377 357 378 return EOK; -
uspace/lib/c/arch/amd64/src/stacktrace.c
r8e4a408 rc1b979a 51 51 int stacktrace_fp_prev(stacktrace_t *st, uintptr_t fp, uintptr_t *prev) 52 52 { 53 return (*st-> read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV, prev);53 return (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV, prev); 54 54 } 55 55 56 56 int stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra) 57 57 { 58 return (*st-> read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra);58 return (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra); 59 59 } 60 60 -
uspace/lib/c/arch/arm32/src/stacktrace.c
r8e4a408 rc1b979a 51 51 int stacktrace_fp_prev(stacktrace_t *st, uintptr_t fp, uintptr_t *prev) 52 52 { 53 return (*st-> read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV, prev);53 return (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV, prev); 54 54 } 55 55 56 56 int stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra) 57 57 { 58 return (*st-> read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra);58 return (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra); 59 59 } 60 60 -
uspace/lib/c/arch/ia32/src/stacktrace.c
r8e4a408 rc1b979a 51 51 int stacktrace_fp_prev(stacktrace_t *st, uintptr_t fp, uintptr_t *prev) 52 52 { 53 return (*st-> read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV, prev);53 return (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV, prev); 54 54 } 55 55 56 56 int stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra) 57 57 { 58 return (*st-> read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra);58 return (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra); 59 59 } 60 60 -
uspace/lib/c/arch/ppc32/src/stacktrace.c
r8e4a408 rc1b979a 51 51 int stacktrace_fp_prev(stacktrace_t *st, uintptr_t fp, uintptr_t *prev) 52 52 { 53 return (*st-> read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV, prev);53 return (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV, prev); 54 54 } 55 55 56 56 int stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra) 57 57 { 58 return (*st-> read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra);58 return (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra); 59 59 } 60 60 -
uspace/lib/c/arch/sparc32/src/stacktrace.c
r8e4a408 rc1b979a 53 53 { 54 54 uintptr_t bprev; 55 int rc = (*st-> read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV,55 int rc = (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV, 56 56 &bprev); 57 57 if (rc == EOK) … … 63 63 int stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra) 64 64 { 65 return (*st-> read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra);65 return (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra); 66 66 } 67 67 -
uspace/lib/c/arch/sparc64/src/stacktrace.c
r8e4a408 rc1b979a 55 55 int rc; 56 56 57 rc = (*st-> read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV, &bprev);57 rc = (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_FP_PREV, &bprev); 58 58 if (rc == EOK) 59 59 *prev = bprev + STACK_BIAS; … … 63 63 int stacktrace_ra_get(stacktrace_t *st, uintptr_t fp, uintptr_t *ra) 64 64 { 65 return (*st-> read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra);65 return (*st->ops->read_uintptr)(st->op_arg, fp + FRAME_OFFSET_RA, ra); 66 66 } 67 67 -
uspace/lib/c/generic/fibril.c
r8e4a408 rc1b979a 59 59 static LIST_INITIALIZE(serialized_list); 60 60 static LIST_INITIALIZE(manager_list); 61 static LIST_INITIALIZE(fibril_list); 61 62 62 63 /** Number of threads that are executing a manager fibril. */ … … 116 117 117 118 fibril->waits_for = NULL; 119 list_append(&fibril->all_link, &fibril_list); 118 120 119 121 return fibril; … … 122 124 void fibril_teardown(fibril_t *fibril) 123 125 { 126 list_remove(&fibril->all_link); 124 127 tls_free(fibril->tcb); 125 128 free(fibril); -
uspace/lib/c/generic/stacktrace.c
r8e4a408 rc1b979a 42 42 static int stacktrace_read_uintptr(void *arg, uintptr_t addr, uintptr_t *data); 43 43 44 void stacktrace_print_fp_pc(uintptr_t fp, uintptr_t pc) 44 static stacktrace_ops_t basic_ops = { 45 .read_uintptr = stacktrace_read_uintptr 46 }; 47 48 void stacktrace_print_generic(stacktrace_ops_t *ops, void *arg, uintptr_t fp, 49 uintptr_t pc) 45 50 { 46 51 stacktrace_t st; 47 52 uintptr_t nfp; 53 int rc; 48 54 49 st.op_arg = NULL;50 st. read_uintptr = stacktrace_read_uintptr;55 st.op_arg = arg; 56 st.ops = ops; 51 57 52 58 while (stacktrace_fp_valid(&st, fp)) { 53 59 printf("%p: %p()\n", (void *) fp, (void *) pc); 54 (void) stacktrace_ra_get(&st, fp, &pc); 55 (void) stacktrace_fp_prev(&st, fp, &nfp); 60 rc = stacktrace_ra_get(&st, fp, &pc); 61 if (rc != EOK) 62 break; 63 rc = stacktrace_fp_prev(&st, fp, &nfp); 64 if (rc != EOK) 65 break; 56 66 fp = nfp; 57 67 } 68 } 69 70 void stacktrace_print_fp_pc(uintptr_t fp, uintptr_t pc) 71 { 72 stacktrace_print_generic(&basic_ops, NULL, fp, pc); 58 73 } 59 74 -
uspace/lib/c/include/fibril.h
r8e4a408 rc1b979a 67 67 typedef struct fibril { 68 68 link_t link; 69 link_t all_link; 69 70 context_t ctx; 70 71 void *stack; -
uspace/lib/c/include/stacktrace.h
r8e4a408 rc1b979a 41 41 42 42 typedef struct { 43 int (*read_uintptr)(void *, uintptr_t, uintptr_t *); 44 } stacktrace_ops_t; 45 46 typedef struct { 43 47 void *op_arg; 44 int (*read_uintptr)(void *, uintptr_t, uintptr_t *);48 stacktrace_ops_t *ops; 45 49 } stacktrace_t; 46 50 47 51 extern void stacktrace_print(void); 48 52 extern void stacktrace_print_fp_pc(uintptr_t, uintptr_t); 53 extern void stacktrace_print_generic(stacktrace_ops_t *, void *, uintptr_t, 54 uintptr_t); 49 55 50 56 /*
Note:
See TracChangeset
for help on using the changeset viewer.