Changeset e515b21a in mainline
- Timestamp:
- 2010-01-26T21:31:56Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3698e44
- Parents:
- 80487bc5
- Location:
- uspace
- Files:
-
- 8 added
- 1 deleted
- 13 edited
- 6 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/taskdump/Makefile
r80487bc5 re515b21a 29 29 USPACE_PREFIX = ../.. 30 30 LIBS = $(LIBC_PREFIX)/libc.a 31 EXTRA_CFLAGS = -Iinclude 31 32 32 33 OUTPUT = taskdump -
uspace/app/taskdump/taskdump.c
r80487bc5 re515b21a 46 46 #include <bool.h> 47 47 48 #include <stacktrace.h> 49 48 50 #define LINE_BYTES 16 49 51 … … 57 59 static int connect_task(task_id_t task_id); 58 60 static int parse_args(int argc, char *argv[]); 59 static void print_syntax( );61 static void print_syntax(void); 60 62 static int threads_dump(void); 61 63 static int thread_dump(uintptr_t thash); … … 63 65 static int area_dump(as_area_info_t *area); 64 66 static void hex_dump(uintptr_t addr, void *buffer, size_t size); 67 static int td_read_uintptr(void *arg, uintptr_t addr, uintptr_t *value); 65 68 66 69 int main(int argc, char *argv[]) … … 184 187 } 185 188 186 static void print_syntax( )189 static void print_syntax(void) 187 190 { 188 191 printf("Syntax: taskdump [-m] -t <task_id>\n"); … … 298 301 { 299 302 istate_t istate; 300 uintptr_t pc, fp; 303 uintptr_t pc, fp, nfp; 304 stacktrace_t st; 301 305 int rc; 302 306 … … 311 315 312 316 printf("Thread 0x%lx crashed at PC 0x%lx. FP 0x%lx\n", thash, pc, fp); 313 printf("Istate hexdump:\n"); 314 hex_dump(0, &istate, (sizeof(istate_t) + 15) & ~15); 317 318 st.op_arg = NULL; 319 st.read_uintptr = td_read_uintptr; 320 321 while (stacktrace_fp_valid(&st, fp)) { 322 printf("%p: %p()\n", fp, pc); 323 324 rc = stacktrace_ra_get(&st, fp, &pc); 325 if (rc != EOK) 326 return rc; 327 328 rc = stacktrace_fp_prev(&st, fp, &nfp); 329 if (rc != EOK) 330 return rc; 331 332 fp = nfp; 333 } 315 334 316 335 return EOK; … … 376 395 } 377 396 397 static int td_read_uintptr(void *arg, uintptr_t addr, uintptr_t *value) 398 { 399 uintptr_t data; 400 int rc; 401 402 (void) arg; 403 404 rc = udebug_mem_read(phoneid, &data, addr, sizeof(data)); 405 if (rc < 0) { 406 printf("Warning: udebug_mem_read() failed.\n"); 407 return rc; 408 } 409 410 *value = data; 411 return EOK; 412 } 413 378 414 /** @} 379 415 */ -
uspace/lib/libc/arch/amd64/Makefile.inc
r80487bc5 re515b21a 37 37 arch/$(UARCH)/src/fibril.S \ 38 38 arch/$(UARCH)/src/tls.c \ 39 arch/$(UARCH)/src/stacktrace.S 39 arch/$(UARCH)/src/stacktrace.c \ 40 arch/$(UARCH)/src/stacktrace_asm.S 40 41 41 42 GCC_CFLAGS += -fno-omit-frame-pointer -
uspace/lib/libc/arch/amd64/src/stacktrace_asm.S
r80487bc5 re515b21a 29 29 .text 30 30 31 .global frame_pointer_get 32 .global frame_pointer_prev 33 .global frame_pointer_validate 34 .global return_address_get 35 .global program_counter_get 31 .global stacktrace_prepare 32 .global stacktrace_fp_get 33 .global stacktrace_pc_get 36 34 37 frame_pointer_get: 35 stacktrace_prepare: 36 ret 37 38 stacktrace_fp_get: 38 39 movq %rbp, %rax 39 40 ret 40 41 41 frame_pointer_prev: 42 movq (%rdi), %rax 43 ret 44 45 frame_pointer_validate: 46 movq %rdi, %rax 47 ret 48 49 return_address_get: 50 movq 8(%rdi), %rax 51 ret 52 53 program_counter_get: 42 stacktrace_pc_get: 54 43 movq (%rsp), %rax 55 44 ret -
uspace/lib/libc/arch/arm32/Makefile.inc
r80487bc5 re515b21a 38 38 arch/$(UARCH)/src/tls.c \ 39 39 arch/$(UARCH)/src/eabi.S \ 40 arch/$(UARCH)/src/stacktrace.S 40 arch/$(UARCH)/src/stacktrace.c \ 41 arch/$(UARCH)/src/stacktrace_asm.S 41 42 42 43 GCC_CFLAGS += -ffixed-r9 -mtp=soft -mapcs-frame -fno-omit-frame-pointer -
uspace/lib/libc/arch/arm32/src/stacktrace_asm.S
r80487bc5 re515b21a 29 29 .text 30 30 31 .global frame_pointer_get 32 .global frame_pointer_prev 33 .global frame_pointer_validate 34 .global return_address_get 35 .global program_counter_get 31 .global stacktrace_prepare 32 .global stacktrace_fp_get 33 .global stacktrace_pc_get 36 34 37 frame_pointer_get: 35 stacktrace_prepare: 36 mov pc, lr 37 38 stacktrace_fp_get: 38 39 mov r0, fp 39 40 mov pc, lr 40 41 41 frame_pointer_prev: 42 ldr r0, [r0, #-12] 43 mov pc, lr 44 45 frame_pointer_validate: 46 mov pc, lr 47 48 return_address_get: 49 ldr r0, [r0, #-4] 50 mov pc, lr 51 52 program_counter_get: 42 stacktrace_pc_get: 53 43 mov r0, lr 54 44 mov pc, lr 55 -
uspace/lib/libc/arch/ia32/Makefile.inc
r80487bc5 re515b21a 38 38 arch/$(UARCH)/src/tls.c \ 39 39 arch/$(UARCH)/src/setjmp.S \ 40 arch/$(UARCH)/src/stacktrace.S 40 arch/$(UARCH)/src/stacktrace.c \ 41 arch/$(UARCH)/src/stacktrace_asm.S 41 42 42 43 GCC_CFLAGS += -march=pentium -
uspace/lib/libc/arch/ia32/src/stacktrace_asm.S
r80487bc5 re515b21a 29 29 .text 30 30 31 .global frame_pointer_get 32 .global frame_pointer_prev 33 .global frame_pointer_validate 34 .global return_address_get 35 .global program_counter_get 31 .global stacktrace_prepare 32 .global stacktrace_fp_get 33 .global stacktrace_pc_get 36 34 37 frame_pointer_get: 35 stacktrace_prepare: 36 ret 37 38 stacktrace_fp_get: 38 39 movl %ebp, %eax 39 40 ret 40 41 41 frame_pointer_prev: 42 movl 4(%esp), %eax 43 movl (%eax), %eax 44 ret 45 46 frame_pointer_validate: 47 movl 4(%esp), %eax 48 ret 49 50 return_address_get: 51 movl 4(%esp), %eax 52 movl 4(%eax), %eax 53 ret 54 55 program_counter_get: 42 stacktrace_pc_get: 56 43 movl (%esp), %eax 57 44 ret -
uspace/lib/libc/arch/ia64/Makefile.inc
r80487bc5 re515b21a 37 37 arch/$(UARCH)/src/tls.c \ 38 38 arch/$(UARCH)/src/ddi.c \ 39 arch/$(UARCH)/src/stacktrace.S 39 arch/$(UARCH)/src/stacktrace.c \ 40 arch/$(UARCH)/src/stacktrace_asm.S 40 41 41 42 GCC_CFLAGS += -fno-unwind-tables -
uspace/lib/libc/arch/ia64/src/stacktrace_asm.S
r80487bc5 re515b21a 29 29 .text 30 30 31 .global frame_pointer_get 32 .global frame_pointer_prev 33 .global frame_pointer_validate 34 .global return_address_get 35 .global program_counter_get 31 .global stacktrace_prepare 32 .global stacktrace_fp_get 33 .global stacktrace_pc_get 36 34 37 frame_pointer_get:38 frame_pointer_prev: 39 frame_pointer_validate: 40 return_address_get:41 program_counter_get:35 stacktrace_prepare: 36 br.ret.sptk.many b0 37 38 stacktrace_fp_get: 39 stacktrace_pc_get: 42 40 mov r8 = r0 43 41 br.ret.sptk.many b0 -
uspace/lib/libc/arch/mips32/Makefile.inc
r80487bc5 re515b21a 36 36 arch/$(UARCH)/src/fibril.S \ 37 37 arch/$(UARCH)/src/tls.c \ 38 arch/$(UARCH)/src/stacktrace.S 38 arch/$(UARCH)/src/stacktrace.c \ 39 arch/$(UARCH)/src/stacktrace_asm.S 39 40 40 41 GCC_CFLAGS += -mips3 -
uspace/lib/libc/arch/mips32/src/stacktrace_asm.S
r80487bc5 re515b21a 32 32 .set noreorder 33 33 34 .global frame_pointer_get 35 .global frame_pointer_prev 36 .global frame_pointer_validate 37 .global return_address_get 38 .global program_counter_get 34 .global stacktrace_prepare 35 .global stacktrace_fp_get 36 .global stacktrace_pc_get 39 37 40 frame_pointer_get: 41 frame_pointer_prev: 42 frame_pointer_validate: 43 return_address_get: 44 program_counter_get: 38 stacktrace_prepare: 39 stacktrace_fp_get: 40 stacktrace_pc_get: 45 41 j $ra 46 42 xor $v0, $v0 -
uspace/lib/libc/arch/mips32eb/Makefile.inc
r80487bc5 re515b21a 36 36 arch/$(UARCH)/src/fibril.S \ 37 37 arch/$(UARCH)/src/tls.c \ 38 arch/$(UARCH)/src/stacktrace.S 38 arch/$(UARCH)/src/stacktrace.c \ 39 arch/$(UARCH)/src/stacktrace_asm.S 39 40 40 41 GCC_CFLAGS += -mips3 -
uspace/lib/libc/arch/ppc32/Makefile.inc
r80487bc5 re515b21a 36 36 arch/$(UARCH)/src/fibril.S \ 37 37 arch/$(UARCH)/src/tls.c \ 38 arch/$(UARCH)/src/stacktrace.S 38 arch/$(UARCH)/src/stacktrace.c \ 39 arch/$(UARCH)/src/stacktrace_asm.S 39 40 40 41 GCC_CFLAGS += -mcpu=powerpc -msoft-float -m32 -
uspace/lib/libc/arch/ppc32/src/stacktrace_asm.S
r80487bc5 re515b21a 31 31 #include <libarch/regname.h> 32 32 33 .global frame_pointer_get 34 .global frame_pointer_prev 35 .global frame_pointer_validate 36 .global return_address_get 37 .global program_counter_get 33 .global stacktrace_prepare 34 .global stacktrace_fp_get 35 .global stacktrace_pc_get 38 36 39 frame_pointer_get: 37 stacktrace_prepare: 38 blr 39 40 stacktrace_fp_get: 40 41 mr r3, sp 41 42 blr 42 43 43 frame_pointer_prev: 44 lwz r3, 0(r3) 45 blr 46 47 frame_pointer_validate: 48 blr 49 50 return_address_get: 51 lwz r3, 4(r3) 52 blr 53 54 program_counter_get: 44 stacktrace_pc_get: 55 45 mflr r3 56 46 blr -
uspace/lib/libc/arch/sparc64/Makefile.inc
r80487bc5 re515b21a 35 35 ARCH_SOURCES += arch/$(UARCH)/src/fibril.S \ 36 36 arch/$(UARCH)/src/tls.c \ 37 arch/$(UARCH)/src/stacktrace.S 37 arch/$(UARCH)/src/stacktrace.c \ 38 arch/$(UARCH)/src/stacktrace_asm.S 38 39 39 40 GCC_CFLAGS += -mcpu=ultrasparc -m64 -
uspace/lib/libc/generic/stacktrace.c
r80487bc5 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 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)) { 42 52 printf("%p: %p()\n", fp, pc); 43 pc = return_address_get(fp); 44 fp = frame_pointer_prev(fp); 53 (void) stacktrace_ra_get(&st, fp, &pc); 54 (void) stacktrace_fp_prev(&st, fp, &nfp); 55 fp = nfp; 45 56 } 46 57 } 47 58 48 void stack _trace(void)59 void stacktrace_print(void) 49 60 { 50 stack_trace_fp_pc(frame_pointer_get(), program_counter_get()); 61 stacktrace_prepare(); 62 stacktrace_print_fp_pc(stacktrace_fp_get(), stacktrace_pc_get()); 51 63 /* 52 64 * Prevent the tail call optimization of the previous call by 53 65 * making it a non-tail call. 54 66 */ 55 (void) frame_pointer_get(); 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; 56 75 } 57 76 -
uspace/lib/libc/include/stacktrace.h
r80487bc5 re515b21a 1 1 /* 2 2 * Copyright (c) 2009 Jakub Jermar 3 * Copyright (c) 2010 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 39 40 #include <bool.h> 40 41 41 extern void stack_trace(void); 42 extern void stack_trace_fp_pc(uintptr_t, uintptr_t); 42 typedef struct { 43 void *op_arg; 44 int (*read_uintptr)(void *, uintptr_t, uintptr_t *); 45 } stacktrace_t; 46 47 extern void stacktrace_print(void); 48 extern void stacktrace_print_fp_pc(uintptr_t, uintptr_t); 43 49 44 50 /* 45 51 * The following interface is to be implemented by each architecture. 46 52 */ 47 extern bool frame_pointer_validate(uintptr_t); 48 extern uintptr_t frame_pointer_get(void); 49 extern uintptr_t frame_pointer_prev(uintptr_t); 50 extern uintptr_t return_address_get(uintptr_t); 51 extern uintptr_t program_counter_get(); 53 extern bool stacktrace_fp_valid(stacktrace_t *, uintptr_t); 54 extern int stacktrace_fp_prev(stacktrace_t *, uintptr_t, uintptr_t *); 55 extern int stacktrace_ra_get(stacktrace_t *, uintptr_t, uintptr_t *); 56 57 extern void stacktrace_prepare(void); 58 extern uintptr_t stacktrace_fp_get(void); 59 extern uintptr_t stacktrace_pc_get(); 52 60 53 61 #endif -
uspace/lib/libc/include/stdlib.h
r80487bc5 re515b21a 42 42 #define abort() \ 43 43 do { \ 44 stack _trace(); \44 stacktrace_print(); \ 45 45 _exit(1); \ 46 46 } while (0)
Note:
See TracChangeset
for help on using the changeset viewer.