#include <kernel/panic.h>

#include <elf.h>
#include <macros.h>
#include <stdio.h>
#include <types.h>

#define MAX_STACK_FRAME 10000

/*
 * Walk up the stack and print the locations of each stack frame base.
 */
void bt(void) {
	u32 *ebp, *eip;
	unsigned int sf = 0;

	/* Start form the current stack base */
	asm volatile("mov %%ebp, %0" : "=r" (ebp));

	/* Continue until you reach a zeroed stack base pointer. The initial ebp
	 * value is zeroed at boot, but note that this could be corrupted in the
	 * case of serious memory corruption. To protect against this, we keep
	 * track of the frame number and break if it exceeds a reasonable
	 * maximum value. */
	while (ebp) {
		eip = ebp + 1;
		printf("#%d  [0x%x] %s\n",
		       sf, *eip, symbol_from_elf(&kelf, *eip));
		ebp = (u32*)*ebp;
		sf++;

		/* break if exceeded maximum */
		if (sf > MAX_STACK_FRAME)
			break;
	}
}

#include <kernel/panic.h>

#include <macros.h>
#include <stdio.h>
#include <types.h>

#define MAX_STACK_FRAME 10000

/*
 * Walk up the stack and print the locations of each stack frame base.
 */
void bt(void) {
	u32 *ebp, *eip;
	unsigned int sf = 0;

	/* Start form the current stack base */
	asm volatile("mov %%ebp, %0" : "=r" (ebp));

	/* Continue until you reach a zeroed stack base pointer. The initial ebp
	 * value is zeroed at boot, but note that this could be corrupted in the
	 * case of serious memory corruption. To protect against this, we keep
	 * track of the frame number and break if it exceeds a reasonable
	 * maximum value. */
	while (ebp) {
		eip = ebp + 1;
		printf("#%d  [0x%x]\n", sf, *eip);
		ebp = (u32*)*ebp;
		sf++;

		/* break if exceeded maximum */
		if (sf > MAX_STACK_FRAME)
			break;
	}
}

--- 
+++ 
@@ -1,5 +1,6 @@
 #include <kernel/panic.h>
 
+#include <elf.h>
 #include <macros.h>
 #include <stdio.h>
 #include <types.h>
@@ -23,7 +24,8 @@
 	 * maximum value. */
 	while (ebp) {
 		eip = ebp + 1;
-		printf("#%d  [0x%x]\n", sf, *eip);
+		printf("#%d  [0x%x] %s\n",
+		       sf, *eip, symbol_from_elf(&kelf, *eip));
 		ebp = (u32*)*ebp;
 		sf++;
 
arch/x86: Print symbol names in backtrace

This transforms:

#0  [0x1018C7]
#1  [0x101636]
#2  [0x100231]

into:

#0  [0x1018C7] panic
#1  [0x101636] k_main
#2  [0x100231] start
