2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2009 Free Software Foundation, Inc.
5 * GRUB is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * GRUB is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
19 #include <grub/misc.h>
20 #include <grub/command.h>
24 #include <grub/term.h>
25 #include <grub/backtrace.h>
27 #define MAX_STACK_FRAME 102400
30 grub_backtrace_pointer (void *ebp
)
38 grub_printf ("%p: ", ptr
);
39 grub_backtrace_print_address (((void **) ptr
)[1]);
41 for (i
= 0; i
< 2; i
++)
42 grub_printf ("%p,", ((void **)ptr
) [i
+ 2]);
43 grub_printf ("%p)\n", ((void **)ptr
) [i
+ 2]);
45 if (nptr
< ptr
|| (void **) nptr
- (void **) ptr
> MAX_STACK_FRAME
48 grub_printf ("Invalid stack frame at %p (%p)\n", ptr
, nptr
);
59 asm volatile ("movq %rbp, %rdi\n"
60 "call " EXT_C("grub_backtrace_pointer"));
62 asm volatile ("movl %ebp, %eax\n"
63 "call " EXT_C("grub_backtrace_pointer"));