Changeset 985e26d2 in mainline for uspace/lib/libc/generic/stacktrace.c
- Timestamp:
- 2010-01-07T19:06:59Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8190e63
- Parents:
- 743e17b (diff), eca2435 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libc/generic/stacktrace.c
r743e17b r985e26d2 1 1 /* 2 * Copyright (c) 200 5Jakub Jermar2 * Copyright (c) 2009 Jakub Jermar 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup libc ia3229 /** @addtogroup libc 30 30 * @{ 31 31 */ … … 33 33 */ 34 34 35 /* 36 * Variable argument list manipulation macros 37 * for architectures using stack to pass arguments. 38 */ 39 40 #ifndef LIBC_ia32_STACKARG_H_ 41 #define LIBC_ia32_STACKARG_H_ 42 35 #include <stacktrace.h> 36 #include <stdio.h> 43 37 #include <sys/types.h> 44 38 45 /* dont allow to define it second time in stdarg.h */ 46 #define __VARARGS_DEFINED 39 void stack_trace_fp_pc(uintptr_t fp, uintptr_t pc) 40 { 41 printf("Printing stack trace:\n"); 42 printf("=====================\n"); 43 while (frame_pointer_validate(fp)) { 44 printf("%p: %p()\n", fp, pc); 45 pc = return_address_get(fp); 46 fp = frame_pointer_prev(fp); 47 } 48 printf("=====================\n"); 49 } 47 50 48 typedef struct va_list { 49 int pos; 50 uint8_t *last; 51 } va_list; 52 53 #define va_start(ap, lst) \ 54 (ap).pos = sizeof(lst); \ 55 (ap).last = (uint8_t *) &(lst) 56 57 #define va_arg(ap, type) \ 58 (*((type *)((ap).last + ((ap).pos += sizeof(type) ) - sizeof(type)))) 59 60 #define va_end(ap) 61 62 63 #endif 51 void stack_trace(void) 52 { 53 stack_trace_fp_pc(frame_pointer_get(), program_counter_get()); 54 /* 55 * Prevent the tail call optimization of the previous call by 56 * making it a non-tail call. 57 */ 58 (void) frame_pointer_get(); 59 } 64 60 65 61 /** @}
Note:
See TracChangeset
for help on using the changeset viewer.