Changes in uspace/lib/libc/generic/stacktrace.c [47246f4:e515b21a] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libc/generic/stacktrace.c
r47246f4 re515b21a 1 1 /* 2 2 * Copyright (c) 2009 Jakub Jermar 3 * Copyright (c) 2010 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 36 37 #include <stdio.h> 37 38 #include <sys/types.h> 39 #include <errno.h> 38 40 39 void stack_trace_fp_pc(uintptr_t fp, uintptr_t pc) 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) 40 44 { 41 printf("Printing stack trace:\n"); 42 printf("=====================\n"); 43 while (frame_pointer_validate(fp)) { 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)) { 44 52 printf("%p: %p()\n", fp, pc); 45 pc = return_address_get(fp); 46 fp = frame_pointer_prev(fp); 53 (void) stacktrace_ra_get(&st, fp, &pc); 54 (void) stacktrace_fp_prev(&st, fp, &nfp); 55 fp = nfp; 47 56 } 48 printf("=====================\n");49 57 } 50 58 51 void stack _trace(void)59 void stacktrace_print(void) 52 60 { 53 stack_trace_fp_pc(frame_pointer_get(), program_counter_get()); 61 stacktrace_prepare(); 62 stacktrace_print_fp_pc(stacktrace_fp_get(), stacktrace_pc_get()); 63 /* 64 * Prevent the tail call optimization of the previous call by 65 * making it a non-tail call. 66 */ 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; 54 75 } 55 76
Note:
See TracChangeset
for help on using the changeset viewer.