Many targets, such as EFI, load GRUB at addresses that are determined at runtime. So the load addresses in kernel.exec will almost certainly be wrong. Given the address of the start of the text segment, these functions will tell GDB to load the symbols at the proper locations. It is left up to the user to determine how to get the text address of the loaded GRUB image. Signed-off-by: Glenn Washburn <development@efficientek.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
80 lines
1.8 KiB
Plaintext
80 lines
1.8 KiB
Plaintext
###
|
|
### Load debuging information about GNU GRUB 2 modules into GDB
|
|
### automatically. Needs readelf, objdump, Python and gdb_helper.py script
|
|
###
|
|
### Has to be launched from the writable and trusted
|
|
### directory containing *.image and *.module
|
|
###
|
|
### $Id: .gdbinit,v 1.1 2006/05/14 11:38:08 lkundrak Exp $
|
|
### Lubomir Kundrak <lkudrak@skosi.org>
|
|
###
|
|
|
|
source gdb_helper.py
|
|
|
|
|
|
define dynamic_load_symbols
|
|
dynamic_load_kernel_exec_symbols $arg0
|
|
|
|
# We may have been very late to loading the kernel.exec symbols and
|
|
# and modules may already be loaded. So load symbols for any already
|
|
# loaded.
|
|
load_all_modules
|
|
|
|
if $is_grub_loaded()
|
|
runtime_load_module
|
|
end
|
|
end
|
|
document dynamic_load_symbols
|
|
Load debugging symbols from kernel.exec and any loaded modules given
|
|
the address of the .text segment of the UEFI binary in memory. Also
|
|
setup session to automatically load module symbols for modules loaded
|
|
in the future.
|
|
end
|
|
|
|
define load_all_modules
|
|
set $this = grub_dl_head
|
|
while ($this != 0)
|
|
load_module $this
|
|
set $this = $this->next
|
|
end
|
|
end
|
|
document load_all_modules
|
|
Load debugging information for all loaded modules.
|
|
end
|
|
|
|
define runtime_load_module
|
|
break grub_dl_add
|
|
commands
|
|
silent
|
|
load_module mod
|
|
cont
|
|
end
|
|
end
|
|
document runtime_load_module
|
|
Load module symbols at runtime as they are loaded.
|
|
end
|
|
|
|
###
|
|
|
|
set confirm off
|
|
|
|
# Note: On EFI and other platforms that load GRUB to an address that is
|
|
# determined at runtime, the symbols in kernel.exec will be wrong.
|
|
# However, we must start by loading some executable file or GDB will
|
|
# fail.
|
|
|
|
set $platform_efi = $_streq("@platform@", "efi")
|
|
|
|
if ! $runonce
|
|
if $platform_efi
|
|
# Only load the executable file, not the symbols
|
|
exec-file kernel.exec
|
|
else
|
|
file kernel.exec
|
|
runtime_load_module
|
|
end
|
|
|
|
target remote :1234
|
|
set $runonce = 1
|
|
end
|