[SOLVED] UEFI debugging
Posted: Tue Jan 10, 2017 11:42 am
I'm trying to debug my UEFI application, however I'm having problems loading the debug symbol file. I followed this tutorial: http://wiki.osdev.org/Debugging_UEFI_ap ... s_with_GDB
Here's my UEFI boot file:
Here's the image base displayed: 0x6738000
Here's my GDB commands and the error produced:
Here's my makefile stuff:
Here's my UEFI boot file:
Code: Select all
EFI_SYSTEM_TABLE* systemTable;
EFI_LOADED_IMAGE* loadedImage;
extern "C" EFIAPI EFI_STATUS efi_main(EFI_HANDLE ImageHandle,
EFI_SYSTEM_TABLE* _systemTable) {
systemTable = _systemTable;
EFI_STATUS status = uefi_call_wrapper(
(void* ) systemTable->BootServices->HandleProtocol, 3, ImageHandle,
&LoadedImageProtocol, (void** )&loadedImage);
if (status != EFI_SUCCESS) {
crash("error while checking image base");
}
// disable the watchdog timer - if this is enabled, the firmware will reset the system after 5 minutes
EFI_STATUS watchdogStatus = uefi_call_wrapper((void*) systemTable->BootServices->SetWatchdogTimer, 4, 0, 0, 0, NULL);
if(watchdogStatus != EFI_SUCCESS) {
crash("error while disabling the watchdog timer");
}
#ifdef DEBUGGING
InitializeLib(ImageHandle, systemTable);
Print((CHAR16*) L"Image base: 0x%lx\n", loadedImage->ImageBase);
int wait = 1;
while (wait) {
__asm__ __volatile__("pause");
}
#endif
kernel_main();
return EFI_SUCCESS;
}
Here's my GDB commands and the error produced:
Code: Select all
chris13524@blueberry ~/programming/cpp/aura
% gdb build/aura.efi
GNU gdb (Ubuntu 7.11.90.20161005-0ubuntu1) 7.11.90.20161005-git
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from build/aura.efi...(no debugging symbols found)...done.
(gdb) info files
Symbols from "/home/chris13524/programming/cpp/aura/build/aura.efi".
Local exec file:
`/home/chris13524/programming/cpp/aura/build/aura.efi', file type pei-x86-64.
Entry point: 0x8a24
0x0000000000005000 - 0x000000000000eb90 is .text
0x000000000000f000 - 0x000000000000f00a is .reloc
0x0000000000010000 - 0x0000000000012d10 is .data
0x0000000000013000 - 0x0000000000013160 is .dynamic
0x0000000000014000 - 0x0000000000014e28 is .rela
0x0000000000016000 - 0x0000000000018928 is .dynsym
(gdb) file
No executable file now.
No symbol file now.
(gdb) add-symbol-file build/debug.aura.efi 0x673D000 -s .data 0x6748000
add symbol table from file "build/debug.aura.efi" at
.text_addr = 0x673d000
.data_addr = 0x6748000
(y or n) y
Reading symbols from build/debug.aura.efi...DW_FORM_strp used without .debug_str section [in module /home/chris13524/programming/cpp/aura/build/debug.aura.efi]
(no debugging symbols found)...done.
(gdb) set architecture i386:x86-64:intel
The target architecture is assumed to be i386:x86-64:intel
(gdb) target remote :1234
Remote debugging using :1234
warning: No executable has been specified and target does not support
determining executable automatically. Try using the "file" command.
0x000000000673d100 in efi_main ()
(gdb) set variable wait = 0
No symbol table is loaded. Use the "file" command.
(gdb)
Code: Select all
build/aura.so: $(OBJECTS-all) | build/.dirstamp
@ld $^ \
gnu-efi/crt0-efi-x86_64.o \
-nostdlib \
-znocombreloc \
-T gnu-efi/elf_x86_64_efi.lds \
-shared \
-fPIC \
-Bsymbolic \
-L gnu-efi/libs \
-l:libgnuefi.a \
-l:libefi.a \
$(LIB_FLAGS) \
-o $@
REGULAR_SECTIONS=-j .text \
-j .sdata \
-j .data \
-j .dynamic \
-j .dynsym \
-j .rel \
-j .rela \
-j .reloc \
-j .mish
DEBUG_SECTIONS=-j .debug_info \
-j .debug_abbrev \
-j .debug_loc \
-j .debug_aranges \
-j .debug_line \
-j .debug_macinfo \
-j .debug_debugstr \
OBJCOPY_FLAGS=--target=efi-app-x86_64
build/aura.efi: build/aura.so | build/.dirstamp
@objcopy $(REGULAR_SECTIONS) \
$(OBJCOPY_FLAGS) \
build/aura.so \
build/aura.efi
build/debug.aura.efi: build/aura.so | build/.dirstamp
@objcopy $(REGULAR_SECTIONS) $(DEBUG_SECTIONS) \
$(OBJCOPY_FLAGS) \
build/aura.so \
build/debug.aura.efi