Changes in uspace/lib/libc/generic/stacktrace.c [e515b21a:7db4275] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libc/generic/stacktrace.c
re515b21a r7db4275 1 1 /* 2 2 * Copyright (c) 2009 Jakub Jermar 3 * Copyright (c) 2010 Jiri Svoboda4 3 * All rights reserved. 5 4 * … … 37 36 #include <stdio.h> 38 37 #include <sys/types.h> 39 #include <errno.h>40 38 41 static int stacktrace_read_uintptr(void *arg, uintptr_t addr, uintptr_t *data); 42 43 void stacktrace_print_fp_pc(uintptr_t fp, uintptr_t pc) 39 void stack_trace_fp_pc(uintptr_t fp, uintptr_t pc) 44 40 { 45 stacktrace_t st; 46 uintptr_t nfp; 47 48 st.op_arg = NULL; 49 st.read_uintptr = stacktrace_read_uintptr; 50 51 while (stacktrace_fp_valid(&st, fp)) { 41 while (frame_pointer_validate(fp)) { 52 42 printf("%p: %p()\n", fp, pc); 53 (void) stacktrace_ra_get(&st, fp, &pc); 54 (void) stacktrace_fp_prev(&st, fp, &nfp); 55 fp = nfp; 43 pc = return_address_get(fp); 44 fp = frame_pointer_prev(fp); 56 45 } 57 46 } 58 47 59 void stack trace_print(void)48 void stack_trace(void) 60 49 { 61 stacktrace_prepare(); 62 stacktrace_print_fp_pc(stacktrace_fp_get(), stacktrace_pc_get()); 50 stack_trace_fp_pc(frame_pointer_get(), program_counter_get()); 63 51 /* 64 52 * Prevent the tail call optimization of the previous call by 65 53 * making it a non-tail call. 66 54 */ 67 (void) stacktrace_fp_get(); 68 } 69 70 static int stacktrace_read_uintptr(void *arg, uintptr_t addr, uintptr_t *data) 71 { 72 (void) arg; 73 *data = *((uintptr_t *) addr); 74 return EOK; 55 (void) frame_pointer_get(); 75 56 } 76 57
Note:
See TracChangeset
for help on using the changeset viewer.