Index: uspace/lib/libc/arch/amd64/src/entry.s
===================================================================
--- uspace/lib/libc/arch/amd64/src/entry.s	(revision ee2f1aaeb2d07b5feb8371fefc38f45bb6f0aa9b)
+++ uspace/lib/libc/arch/amd64/src/entry.s	(revision 47246f498a260fcfa5acd11fd1eaf859caf396ae)
@@ -39,7 +39,8 @@
 __entry:
 	#
-	# Stop stack traces in this function.
+	# Create the first stack frame.
 	#
-	xorq %rbp, %rbp
+	pushq $0
+	mov %rsp, %rbp
 	
 	# %rdi was deliberately chosen as the first argument is also in %rdi
Index: uspace/lib/libc/arch/amd64/src/stacktrace.S
===================================================================
--- uspace/lib/libc/arch/amd64/src/stacktrace.S	(revision ee2f1aaeb2d07b5feb8371fefc38f45bb6f0aa9b)
+++ uspace/lib/libc/arch/amd64/src/stacktrace.S	(revision 47246f498a260fcfa5acd11fd1eaf859caf396ae)
@@ -33,4 +33,5 @@
 .global frame_pointer_validate
 .global return_address_get
+.global program_counter_get
 
 frame_pointer_get:
@@ -49,2 +50,6 @@
 	movq 8(%rdi), %rax
 	ret
+
+program_counter_get:
+	movq (%rsp), %rax
+	ret
Index: uspace/lib/libc/arch/amd64/src/thread_entry.s
===================================================================
--- uspace/lib/libc/arch/amd64/src/thread_entry.s	(revision ee2f1aaeb2d07b5feb8371fefc38f45bb6f0aa9b)
+++ uspace/lib/libc/arch/amd64/src/thread_entry.s	(revision 47246f498a260fcfa5acd11fd1eaf859caf396ae)
@@ -36,7 +36,8 @@
 __thread_entry:
 	#
-	# Stop stack traces in this function.
+	# Create the first stack frame.
 	#
-	xorq %rbp, %rbp
+	pushq $0
+	movq %rsp, %rbp
 
 	#
Index: uspace/lib/libc/arch/arm32/src/stacktrace.S
===================================================================
--- uspace/lib/libc/arch/arm32/src/stacktrace.S	(revision ee2f1aaeb2d07b5feb8371fefc38f45bb6f0aa9b)
+++ uspace/lib/libc/arch/arm32/src/stacktrace.S	(revision 47246f498a260fcfa5acd11fd1eaf859caf396ae)
@@ -33,4 +33,5 @@
 .global frame_pointer_validate
 .global return_address_get
+.global program_counter_get
 
 frame_pointer_get:
@@ -38,4 +39,5 @@
 frame_pointer_validate:
 return_address_get:
+program_counter_get:
 	mov r0, #0
 	mov pc, lr
Index: uspace/lib/libc/arch/ia32/src/entry.s
===================================================================
--- uspace/lib/libc/arch/ia32/src/entry.s	(revision ee2f1aaeb2d07b5feb8371fefc38f45bb6f0aa9b)
+++ uspace/lib/libc/arch/ia32/src/entry.s	(revision 47246f498a260fcfa5acd11fd1eaf859caf396ae)
@@ -56,7 +56,8 @@
 0:
 	#
-	# Stop stack traces in this function.
+	# Create the first stack frame.
 	#
-	xorl %ebp, %ebp
+	pushl $0 
+	movl %esp, %ebp
 
 	# Pass the PCB pointer to __main as the first argument
Index: uspace/lib/libc/arch/ia32/src/stacktrace.S
===================================================================
--- uspace/lib/libc/arch/ia32/src/stacktrace.S	(revision ee2f1aaeb2d07b5feb8371fefc38f45bb6f0aa9b)
+++ uspace/lib/libc/arch/ia32/src/stacktrace.S	(revision 47246f498a260fcfa5acd11fd1eaf859caf396ae)
@@ -33,4 +33,5 @@
 .global frame_pointer_validate
 .global return_address_get
+.global program_counter_get
 
 frame_pointer_get:
@@ -51,2 +52,6 @@
 	movl 4(%eax), %eax
 	ret
+
+program_counter_get:
+	movl (%esp), %eax
+	ret
Index: uspace/lib/libc/arch/ia32/src/thread_entry.s
===================================================================
--- uspace/lib/libc/arch/ia32/src/thread_entry.s	(revision ee2f1aaeb2d07b5feb8371fefc38f45bb6f0aa9b)
+++ uspace/lib/libc/arch/ia32/src/thread_entry.s	(revision 47246f498a260fcfa5acd11fd1eaf859caf396ae)
@@ -42,7 +42,8 @@
 
 	#
-	# Stop stack traces in this function.
+	# Create the first stack frame.
 	#
-	xorl %ebp, %ebp
+	pushl $0
+	mov %esp, %ebp
 
 	#
Index: uspace/lib/libc/arch/sparc64/include/fibril.h
===================================================================
--- uspace/lib/libc/arch/sparc64/include/fibril.h	(revision ee2f1aaeb2d07b5feb8371fefc38f45bb6f0aa9b)
+++ uspace/lib/libc/arch/sparc64/include/fibril.h	(revision 47246f498a260fcfa5acd11fd1eaf859caf396ae)
@@ -53,5 +53,4 @@
 		(c)->fp = -STACK_BIAS; \
 		(c)->tp = ptls; \
-		(c)->i7 = 0; \
 	} while (0)
 	
Index: uspace/lib/libc/arch/sparc64/src/entry.s
===================================================================
--- uspace/lib/libc/arch/sparc64/src/entry.s	(revision ee2f1aaeb2d07b5feb8371fefc38f45bb6f0aa9b)
+++ uspace/lib/libc/arch/sparc64/src/entry.s	(revision 47246f498a260fcfa5acd11fd1eaf859caf396ae)
@@ -40,10 +40,12 @@
 __entry:
 	#
-	# Stop stack traces in this function.
+	# Create the first stack frame.
 	#
-	clr %i7
+	save %sp, -176, %sp
+	flushw
+	add %g0, -0x7ff, %fp
 
 	# Pass pcb_ptr as the first argument to __main()
-	mov %o1, %o0
+	mov %i1, %o0
 	sethi %hi(_gp), %l7
 	call __main
Index: uspace/lib/libc/arch/sparc64/src/stacktrace.S
===================================================================
--- uspace/lib/libc/arch/sparc64/src/stacktrace.S	(revision ee2f1aaeb2d07b5feb8371fefc38f45bb6f0aa9b)
+++ uspace/lib/libc/arch/sparc64/src/stacktrace.S	(revision 47246f498a260fcfa5acd11fd1eaf859caf396ae)
@@ -27,4 +27,6 @@
 #
 
+#include <libarch/stack.h>
+
 .text
 
@@ -33,12 +35,13 @@
 .global frame_pointer_validate
 .global return_address_get
+.global program_counter_get
 
 frame_pointer_get:
 	# Add the stack bias to %sp to get the actual address.
 	retl
-	add %sp, 0x7ff, %o0
+	add %sp, STACK_BIAS, %o0
 
 frame_pointer_prev:
-	save %sp, -176, %sp
+	save %sp, -(STACK_WINDOW_SAVE_AREA_SIZE+STACK_ARG_SAVE_AREA_SIZE), %sp
 	# Flush all other windows to memory so that we can read their contents.
 	flushw
@@ -46,15 +49,14 @@
 	ldx [%i0 + 14 * 8], %i0
 	# Add the stack bias to the %fp read from the window save area.
-	add %i0, 0x7ff, %i0
+	add %i0, STACK_BIAS, %i0
 	ret
 	restore
 
 frame_pointer_validate:
-	#
-	# Fall through - we detect the last frame in the trace by zero %i7.
-	#
+	retl
+	nop
 
 return_address_get:
-	save %sp, -176, %sp
+	save %sp, -(STACK_WINDOW_SAVE_AREA_SIZE+STACK_ARG_SAVE_AREA_SIZE), %sp
 	# Flush all other windows to memory so that we can read their contents.
 	flushw
@@ -63,2 +65,7 @@
 	ret
 	restore
+
+program_counter_get:
+	retl
+	mov %o7, %o0
+
Index: uspace/lib/libc/arch/sparc64/src/thread_entry.s
===================================================================
--- uspace/lib/libc/arch/sparc64/src/thread_entry.s	(revision ee2f1aaeb2d07b5feb8371fefc38f45bb6f0aa9b)
+++ uspace/lib/libc/arch/sparc64/src/thread_entry.s	(revision 47246f498a260fcfa5acd11fd1eaf859caf396ae)
@@ -36,7 +36,9 @@
 __thread_entry:
 	#
-	# Stop stack traces in this function.
+	# Create the first stack frame.
 	#
-	clr %i7
+	save %sp, -176, %sp
+	flushw
+	add %g0, -0x7ff, %fp
 
 	sethi %hi(_gp), %l7
Index: uspace/lib/libc/generic/stacktrace.c
===================================================================
--- uspace/lib/libc/generic/stacktrace.c	(revision ee2f1aaeb2d07b5feb8371fefc38f45bb6f0aa9b)
+++ uspace/lib/libc/generic/stacktrace.c	(revision 47246f498a260fcfa5acd11fd1eaf859caf396ae)
@@ -37,18 +37,19 @@
 #include <sys/types.h>
 
-void stack_trace_fp(uintptr_t fp)
+void stack_trace_fp_pc(uintptr_t fp, uintptr_t pc)
 {
-	uintptr_t ra;
-
+	printf("Printing stack trace:\n");
+	printf("=====================\n");
 	while (frame_pointer_validate(fp)) {
-		ra = return_address_get(fp);
-		printf("%p: %p()\n", fp, ra);
+		printf("%p: %p()\n", fp, pc);
+		pc = return_address_get(fp);
 		fp = frame_pointer_prev(fp);
 	}
+	printf("=====================\n");
 }
 
 void stack_trace(void)
 {
-	stack_trace_fp(frame_pointer_get());
+	stack_trace_fp_pc(frame_pointer_get(), program_counter_get());
 }
 
Index: uspace/lib/libc/include/stacktrace.h
===================================================================
--- uspace/lib/libc/include/stacktrace.h	(revision ee2f1aaeb2d07b5feb8371fefc38f45bb6f0aa9b)
+++ uspace/lib/libc/include/stacktrace.h	(revision 47246f498a260fcfa5acd11fd1eaf859caf396ae)
@@ -40,5 +40,5 @@
 
 extern void stack_trace(void);
-extern void stack_trace_fp(uintptr_t);
+extern void stack_trace_fp_pc(uintptr_t, uintptr_t);
 
 /*
@@ -49,4 +49,5 @@
 extern uintptr_t frame_pointer_prev(uintptr_t);
 extern uintptr_t return_address_get(uintptr_t);
+extern uintptr_t program_counter_get();
 
 #endif
