Index: kernel/arch/amd64/src/asm_utils.S
===================================================================
--- kernel/arch/amd64/src/asm_utils.S	(revision fabc883d64c4961d00f1413b0d4b3f6776217638)
+++ kernel/arch/amd64/src/asm_utils.S	(revision 304342e71a827f2aa2f3d2377ef7cc1d77e6c61a)
@@ -27,5 +27,5 @@
 #
 
-#define IREGISTER_SPACE	72 
+#define IREGISTER_SPACE	80
 
 #define IOFFSET_RAX	0x0
@@ -38,4 +38,5 @@
 #define IOFFSET_R10	0x38
 #define IOFFSET_R11	0x40
+#define IOFFSET_RBP	0x48
 
 #  Mask for interrupts 0 - 31 (bits 0 - 31) where 0 means that int has no error word
@@ -179,4 +180,5 @@
 	movq %r10, IOFFSET_R10(%rsp)
 	movq %r11, IOFFSET_R11(%rsp)
+	movq %rbp, IOFFSET_RBP(%rsp)
 .endm
 
@@ -191,4 +193,5 @@
 	movq IOFFSET_R10(%rsp), %r10
 	movq IOFFSET_R11(%rsp), %r11
+	movq IOFFSET_RBP(%rsp), %rbp
 .endm
 
@@ -235,4 +238,7 @@
 	cld
 
+	# Stop stack traces here
+	xorq %rbp, %rbp
+
 	movq $(\i), %rdi   	# %rdi - first parameter
 	movq %rsp, %rsi   	# %rsi - pointer to istate
Index: kernel/arch/amd64/src/boot/boot.S
===================================================================
--- kernel/arch/amd64/src/boot/boot.S	(revision fabc883d64c4961d00f1413b0d4b3f6776217638)
+++ kernel/arch/amd64/src/boot/boot.S	(revision 304342e71a827f2aa2f3d2377ef7cc1d77e6c61a)
@@ -174,4 +174,8 @@
 	call arch_pre_main
 	
+	# create the first stack frame
+	pushq $0
+	movq %rsp, %rbp
+
 	call main_bsp
 	
Index: kernel/arch/amd64/src/debug/stacktrace.c
===================================================================
--- kernel/arch/amd64/src/debug/stacktrace.c	(revision 304342e71a827f2aa2f3d2377ef7cc1d77e6c61a)
+++ kernel/arch/amd64/src/debug/stacktrace.c	(revision 304342e71a827f2aa2f3d2377ef7cc1d77e6c61a)
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2010 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup amd64
+ * @{
+ */
+/** @file
+ */
+
+#include <stacktrace.h>
+#include <syscall/copy.h>
+#include <arch/types.h>
+#include <typedefs.h>
+
+#define FRAME_OFFSET_FP_PREV	0
+#define FRAME_OFFSET_RA		1
+
+bool kernel_frame_pointer_validate(uintptr_t fp)
+{
+	return fp != 0;
+}
+
+bool kernel_frame_pointer_prev(uintptr_t fp, uintptr_t *prev)
+{
+	uint64_t *stack = (void *) fp;
+	*prev = stack[FRAME_OFFSET_FP_PREV];
+	return true;
+}
+
+bool kernel_return_address_get(uintptr_t fp, uintptr_t *ra)
+{
+	uint64_t *stack = (void *) fp;
+	*ra = stack[FRAME_OFFSET_RA];
+	return true;
+}
+
+bool uspace_frame_pointer_validate(uintptr_t fp)
+{
+	return fp != 0;
+}
+
+bool uspace_frame_pointer_prev(uintptr_t fp, uintptr_t *prev)
+{
+	return !copy_from_uspace((void *) prev,
+	    (uint64_t *) fp + FRAME_OFFSET_FP_PREV, sizeof(*prev));
+}
+
+bool uspace_return_address_get(uintptr_t fp, uintptr_t *ra)
+{
+	return !copy_from_uspace((void *) ra, (uint64_t *) fp + FRAME_OFFSET_RA,
+	    sizeof(*ra));
+}
+
+/** @}
+ */
Index: kernel/arch/amd64/src/debug/stacktrace_asm.S
===================================================================
--- kernel/arch/amd64/src/debug/stacktrace_asm.S	(revision 304342e71a827f2aa2f3d2377ef7cc1d77e6c61a)
+++ kernel/arch/amd64/src/debug/stacktrace_asm.S	(revision 304342e71a827f2aa2f3d2377ef7cc1d77e6c61a)
@@ -0,0 +1,40 @@
+#
+# Copyright (c) 2010 Jakub Jermar
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+.text
+
+.global frame_pointer_get
+.global program_counter_get
+
+frame_pointer_get:
+	movq %rbp, %rax
+	ret
+
+program_counter_get:
+	movq (%rsp), %rax
+	ret
Index: kernel/arch/amd64/src/interrupt.c
===================================================================
--- kernel/arch/amd64/src/interrupt.c	(revision fabc883d64c4961d00f1413b0d4b3f6776217638)
+++ kernel/arch/amd64/src/interrupt.c	(revision 304342e71a827f2aa2f3d2377ef7cc1d77e6c61a)
@@ -53,4 +53,5 @@
 #include <ddi/irq.h>
 #include <symtab.h>
+#include <stacktrace.h>
 
 /*
@@ -80,4 +81,6 @@
 	    istate->r10, istate->r11);
 	printf("%%rsp=%#llx\n", &istate->stack[0]);
+	
+	stack_trace_istate(istate);
 }
 
Index: kernel/arch/amd64/src/smp/ap.S
===================================================================
--- kernel/arch/amd64/src/smp/ap.S	(revision fabc883d64c4961d00f1413b0d4b3f6776217638)
+++ kernel/arch/amd64/src/smp/ap.S	(revision 304342e71a827f2aa2f3d2377ef7cc1d77e6c61a)
@@ -99,4 +99,6 @@
 start64:
 	movq (ctx), %rsp
+	pushq $0
+	movq %rsp, %rbp
 	call main_ap - AP_BOOT_OFFSET + BOOT_OFFSET   # never returns
 
