From: "Andrew Fish" <afish@apple.com>
To: edk2-devel-groups-io <devel@edk2.groups.io>
Subject: OVMF gdb seems to require "stone knives and bearskins" to debug code?
Date: Sun, 24 May 2020 20:30:58 -0700 [thread overview]
Message-ID: <50EEBF6E-8BB1-461D-B252-D37D2990957D@apple.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 11121 bytes --]
The full Star Trek quote from Spock is: " I am endeavoring, ma'am, to construct a mnemonic memory circuit using stone knives and bearskins.", but I ran across this [1], and it felt like "stone knives and bearskins." vs my experience with lldb debugging EFI.
So a few questions:
1) Is this Wiki [1] actually up to date?
2) Do we have a location to add debugger scripts to the edk2? If not what location should we chose?
3) Is anyone interested in writing gdb scripts to do better?
I've got no clue about writing gdb Python and I don't even have gdb installed on my system, but due to an accident of history I ended up owning my teams lldb Python debugger scripts so I know how lldb works in great detail. My expectation would be you have a standard way to to invoke the debugger and you get a symbolicated stack frame for free [2].
I could open source an lldb symbolication Python script and I'm happy to explain the common logic to some one to make it easier to port this lldb command [3] to gdb. The command can load symbols for any address that is located in a loaded PE/COFF image, and when you import the command into lldb it symbolicates the current frame.
[1] https://github.com/tianocore/tianocore.github.io/wiki/How-to-debug-OVMF-with-QEMU-using-GDB
[2] OVMF lldb attach: $ lldb -o "settings set plugin.process.gdb-remote.target-definition-file x86_64_target_definition.py" -o "gdb-remote 9000" -o "command script import efi_symbolicate.py"
...
The "efi_symbols" command has been installed, type "help efi_symbols" for detailed help.
.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Symbols Loaded for mach-O UUID 0AEF5192-F2D6-32D6-B739-54752B2D6B42 @ 0xfffcc094 /Volumes/Case/edk2-github/Build/OvmfX64/DEBUG_XCODE5/X64/OvmfPkg/Sec/SecMain/DEBUG/SecMain.dll
Symbols Loaded for mach-O UUID 7686209C-91AF-3D52-952C-BB2068CA682E @ 0x64e3000 /Volumes/Case/edk2-github/Build/OvmfX64/DEBUG_XCODE5/X64/ShellPkg/Application/Shell/Shell/DEBUG/Shell.dll
Symbols Loaded for mach-O UUID FE5F915E-F2BF-3E7A-AE4D-7722043096CA @ 0x7eac000 /Volumes/Case/edk2-github/Build/OvmfX64/DEBUG_XCODE5/X64/MdeModulePkg/Core/Dxe/DxeMain/DEBUG/DxeCore.dll
PE/COFF Image not found. Can not load EFI Symbols
Symbols Loaded for mach-O UUID 86957245-00DA-3D0A-8060-295EAEB4A336 @ 0x7087000 /Volumes/Case/edk2-github/Build/OvmfX64/DEBUG_XCODE5/X64/MdeModulePkg/Universal/BdsDxe/BdsDxe/DEBUG/BdsDxe.dll
Symbols already loaded for mach-O UUID FE5F915E-F2BF-3E7A-AE4D-7722043096CA DxeCore
PE/COFF Image not found. Can not load EFI Symbols
Symbols already loaded for mach-O UUID FE5F915E-F2BF-3E7A-AE4D-7722043096CA DxeCore
PE/COFF Image not found. Can not load EFI Symbols
Symbols already loaded for mach-O UUID 7686209C-91AF-3D52-952C-BB2068CA682E Shell
Symbols Loaded for mach-O UUID 8000874A-80F4-37E3-9702-CB9A686F2260 @ 0x7167000 /Volumes/Case/edk2-github/Build/OvmfX64/DEBUG_XCODE5/X64/UefiCpuPkg/CpuDxe/CpuDxe/DEBUG/CpuDxe.dll
Symbols Loaded for mach-O UUID 89AB51B5-EB01-32B0-AA0A-5113E9882A82 @ 0x7ee3000 /Volumes/Case/edk2-github/Build/OvmfX64/DEBUG_XCODE5/X64/MdeModulePkg/Core/DxeIplPeim/DxeIpl/DEBUG/DxeIpl.dll
PE/COFF Image not found. Can not load EFI Symbols
Symbols already loaded for mach-O UUID 86957245-00DA-3D0A-8060-295EAEB4A336 BdsDxe
Symbols already loaded for mach-O UUID FE5F915E-F2BF-3E7A-AE4D-7722043096CA DxeCore
Symbols already loaded for mach-O UUID 89AB51B5-EB01-32B0-AA0A-5113E9882A82 DxeIpl
Symbols already loaded for mach-O UUID 0AEF5192-F2D6-32D6-B739-54752B2D6B42 SecMain
Symbols already loaded for mach-O UUID FE5F915E-F2BF-3E7A-AE4D-7722043096CA DxeCore
Symbols Loaded for mach-O UUID 5FDE6480-128B-3D18-9901-391924F9E54E @ 0x7ee8000 /Volumes/Case/edk2-github/Build/OvmfX64/DEBUG_XCODE5/X64/MdeModulePkg/Core/Pei/PeiMain/DEBUG/PeiCore.dll
PE/COFF Image not found. Can not load EFI Symbols
Symbols already loaded for mach-O UUID FE5F915E-F2BF-3E7A-AE4D-7722043096CA DxeCore
Symbols already loaded for mach-O UUID 7686209C-91AF-3D52-952C-BB2068CA682E Shell
Symbols already loaded for mach-O UUID 0AEF5192-F2D6-32D6-B739-54752B2D6B42 SecMain
Symbols already loaded for mach-O UUID 89AB51B5-EB01-32B0-AA0A-5113E9882A82 DxeIpl
Symbols already loaded for mach-O UUID 86957245-00DA-3D0A-8060-295EAEB4A336 BdsDxe
Symbols already loaded for mach-O UUID 7686209C-91AF-3D52-952C-BB2068CA682E Shell
Symbols already loaded for mach-O UUID FE5F915E-F2BF-3E7A-AE4D-7722043096CA DxeCore
Symbols already loaded for mach-O UUID FE5F915E-F2BF-3E7A-AE4D-7722043096CA DxeCore
(lldb) bt
* thread #1, stop reason = signal SIGTRAP
* #0: 0x000000000716796f CpuDxe.dll`CpuSleep + 1
#1: 0x0000000007ebae33 DxeCore.dll`CoreRestoreTpl [inlined] CoreDispatchEventNotifies(Priority=<unavailable>) + 192 at /Volumes/Case/edk2-github/MdeModulePkg/Core/Dxe/Event/Event.c:194
#2: 0x0000000007ebad73 DxeCore.dll`CoreRestoreTpl(NewTpl=4) + 290 at /Volumes/Case/edk2-github/MdeModulePkg/Core/Dxe/Event/Tpl.c:131
#3: 0x0000000007ebb5f5 DxeCore.dll`CoreSignalEvent(UserEvent=<unavailable>) + 111 at /Volumes/Case/edk2-github/MdeModulePkg/Core/Dxe/Event/Event.c:566
#4: 0x0000000007ebb71b DxeCore.dll`CoreWaitForEvent(NumberOfEvents=1, UserEvents=0x0000000007016f08, UserIndex=0x0000000007eab840) + 94 at /Volumes/Case/edk2-github/MdeModulePkg/Core/Dxe/Event/Event.c:707
#5: 0x00000000064ebf0e Shell.dll`FileInterfaceStdInRead(This=<unavailable>, BufferSize=0x0000000007eab998, Buffer=<unavailable>) + 310 at /Volumes/Case/edk2-github/ShellPkg/Application/Shell/FileHandleWrappers.c:532
#6: 0x00000000065071ce Shell.dll`_ModuleEntryPoint [inlined] DoShellPrompt + 267 at /Volumes/Case/edk2-github/ShellPkg/Application/Shell/Shell.c:1346
#7: 0x00000000065070c3 Shell.dll`_ModuleEntryPoint [inlined] UefiMain(ImageHandle=<unavailable>, SystemTable=<unavailable>) + 5536 at /Volumes/Case/edk2-github/ShellPkg/Application/Shell/Shell.c:621
#8: 0x0000000006505b23 Shell.dll`_ModuleEntryPoint [inlined] ProcessModuleEntryPointList(ImageHandle=<unavailable>, SystemTable=<unavailable>) at /Volumes/Case/edk2-github/Build/OvmfX64/DEBUG_XCODE5/X64/ShellPkg/Application/Shell/Shell/DEBUG/AutoGen.c:1000
#9: 0x0000000006505b23 Shell.dll`_ModuleEntryPoint(ImageHandle=0x0000000006d1bf18, SystemTable=<unavailable>) + 8668 at /Volumes/Case/edk2-github/MdePkg/Library/UefiApplicationEntryPoint/ApplicationEntryPoint.c:59
#10: 0x0000000007eb08e7 DxeCore.dll`CoreStartImage(ImageHandle=0x0000000006d1bf18, ExitDataSize=0x00000000067987f0, ExitData=0x00000000067987e8) + 311 at /Volumes/Case/edk2-github/MdeModulePkg/Core/Dxe/Image/Image.c:1654
#11: 0x0000000007090005 BdsDxe.dll`EfiBootManagerBoot(BootOption=0x00000000067987a0) + 1758 at /Volumes/Case/edk2-github/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c:1982
#12: 0x0000000007088fb4 BdsDxe.dll`BdsEntry [inlined] BootBootOptions(BootOptions=0x0000000006798698, BootOptionCount=4, BootManagerMenu=0x0000000007eabc78) + 47 at /Volumes/Case/edk2-github/MdeModulePkg/Universal/BdsDxe/BdsEntry.c:408
#13: 0x0000000007088f85 BdsDxe.dll`BdsEntry(This=<unavailable>) + 5252 at /Volumes/Case/edk2-github/MdeModulePkg/Universal/BdsDxe/BdsEntry.c:1062
#14: 0x0000000007ebfa3b DxeCore.dll`DxeMain(HobStart=<unavailable>) + 7725 at /Volumes/Case/edk2-github/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c:543
#15: 0x0000000007ec146a DxeCore.dll`_ModuleEntryPoint [inlined] ProcessModuleEntryPointList(HobStart=<unavailable>) + 20 at /Volumes/Case/edk2-github/Build/OvmfX64/DEBUG_XCODE5/X64/MdeModulePkg/Core/Dxe/DxeMain/DEBUG/AutoGen.c:462
#16: 0x0000000007ec1465 DxeCore.dll`_ModuleEntryPoint(HobStart=<unavailable>) + 15 at /Volumes/Case/edk2-github/MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.c:48
#17: 0x0000000007ee3617 DxeIpl.dll`InternalSwitchStack + 15
#18: 0x0000000007ee4970 DxeIpl.dll`DxeLoadCore [inlined] HandOffToDxeCore(HobList=EFI_PEI_HOB_POINTERS @ 0x0000000003f54900) + 4152 at /Volumes/Case/edk2-github/MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c:117
#19: 0x0000000007ee3fcd DxeIpl.dll`DxeLoadCore(This=<unavailable>, PeiServices=<unavailable>, HobList=EFI_PEI_HOB_POINTERS @ 0x0000000003f54900) + 1685 at /Volumes/Case/edk2-github/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c:449
#20: 0x0000000007ee982a PeiCore.dll`PeiCore(SecCoreDataPtr=<unavailable>, PpiList=0x0000000000000000, Data=<unavailable>) + 732 at /Volumes/Case/edk2-github/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c:494
#21: 0x0000000000821d3e
#22: 0x000000000082674e
#23: 0x0000000000827067
#24: 0x0000000000821869
#25: 0x0000000000828dd1
#26: 0x00000000fffcd5b7 SecMain.dll`SecCoreStartupWithStack [inlined] SecStartupPhase2(Context=<unavailable>) + 49 at /Volumes/Case/edk2-github/OvmfPkg/Sec/SecMain.c:858
#27: 0x00000000fffcd586 SecMain.dll`SecCoreStartupWithStack [inlined] InitializeDebugAgent(InitFlag=<unavailable>, Context=<unavailable>) at /Volumes/Case/edk2-github/MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.c:42
#28: 0x00000000fffcd586 SecMain.dll`SecCoreStartupWithStack(BootFv=<unavailable>, TopOfCurrentStack=<unavailable>) + 421 at /Volumes/Case/edk2-github/OvmfPkg/Sec/SecMain.c:821
#29: 0x00000000fffcc301 SecMain.dll`_ModuleEntryPoint + 45
[3] (lldb) efi_symbols -h
Usage: efi_symbols [options]
Stand alone script that can load EFI PE/COFF and TE image symbols.
Options:
-p, --pc Load symbols for pc
-f, --frame Load symbols for current stack frame
-a ADDRESS, --address=ADDRESS
Load symbols for image at address
-r RANGE, --range=RANGE
How far to search backward for start of PE/COFF Image
-t, --terse Only display filenames not paths
-h, --help Show help for the command
Thanks,
Andrew Fish
[-- Attachment #2: Type: text/html, Size: 30227 bytes --]
next reply other threads:[~2020-05-25 3:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-25 3:30 Andrew Fish [this message]
2020-05-25 19:15 ` [edk2-devel] OVMF gdb seems to require "stone knives and bearskins" to debug code? Laszlo Ersek
2020-05-25 23:14 ` Andrew Fish
2020-05-26 11:22 ` Laszlo Ersek
2020-05-26 2:19 ` Rebecca Cran
2020-05-26 3:11 ` Andrew Fish
2020-05-26 5:57 ` Andrei Warkentin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50EEBF6E-8BB1-461D-B252-D37D2990957D@apple.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox