OSDev.org https://forum.osdev.org/ |
|
[SOLVED] UEFI debugging https://forum.osdev.org/viewtopic.php?f=1&t=31192 |
Page 1 of 1 |
Author: | chris13524 [ Tue Jan 10, 2017 11:42 am ] |
Post subject: | [SOLVED] UEFI debugging |
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: Code: 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 the image base displayed: 0x6738000 Here's my GDB commands and the error produced: Code: 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) Here's my makefile stuff: Code: 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 |
Author: | dozniak [ Tue Jan 10, 2017 12:00 pm ] |
Post subject: | Re: UEFI debugging |
Self-explanatory wrote: (gdb) file
No executable file now. ... warning: No executable has been specified and target does not support determining executable automatically. Try using the "file" command. |
Author: | chris13524 [ Tue Jan 10, 2017 12:22 pm ] |
Post subject: | Re: UEFI debugging |
dozniak wrote: Self-explanatory wrote: (gdb) file No executable file now. ... warning: No executable has been specified and target does not support determining executable automatically. Try using the "file" command. But I did, I did exactly what the tutorial told me to do. Is it inaccurate? |
Author: | bzt [ Tue Jan 10, 2017 4:23 pm ] |
Post subject: | Re: UEFI debugging |
One thing, it's not gdb related: you should call InitializeLib() as the first thing in your executable, and always, not just when you're debugging. Chances are good that without it, your first uefi_call_wrapper() will misbehave. |
Author: | robbiedobbie [ Wed Jan 11, 2017 12:19 am ] |
Post subject: | Re: UEFI debugging |
Code: 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. Your problem is that it's simply not finding any symbols. Did you strip them out of the binary? Or do you have some custom linkerscript or something? |
Author: | chris13524 [ Wed Jan 11, 2017 10:13 am ] |
Post subject: | Re: UEFI debugging |
Figured it out, I was adding the section Code: .debug_debugstr instead of Code: .debug_str
|
Page 1 of 1 | All times are UTC - 6 hours |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |