summaryrefslogtreecommitdiffstats
path: root/UefiPayloadPkg/UefiPayloadPkg.dsc
diff options
context:
space:
mode:
authorNate DeSimone <nathaniel.l.desimone@intel.com>2023-09-22 13:32:41 -0700
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2025-01-22 00:27:46 +0000
commitcbfae3e8a945e0621cfb6ca77c067806e8693056 (patch)
tree251dff0bd9955ede14e640443c65f482038b5c3f /UefiPayloadPkg/UefiPayloadPkg.dsc
parent58766a472932c485d41163b1746fb1d9e7984f07 (diff)
downloadedk2-cbfae3e8a945e0621cfb6ca77c067806e8693056.tar.gz
EmulatorPkg: Fix Source Level Debug on Windows
The Visual Studio Windows debugger will only load symbols for PE/COFF images that Windows is aware of. Therefore, to enable source level debugging, all PEI/DXE modules must be loaded via LoadLibrary() or LoadLibraryEx() and the the instance in memory created by LoadLibrary() must be the one that is actually executed. The current source level debug implementation in EmulatorPkg for Windows is inherited from the old Nt32Pkg. This implementation makes the assumption that all PEI/DXE modules have a DLL export tables with a symbol named InitializeDriver. Therefore, this source level debug implementation requires all modules to be linked in a non-PI spec defined manner. Support for adding the InitializeDriver symbol was removed in EmulatorPkg, which broke source level debugging. To fix this, the source level debugging implementation has been modified to use the PE/COFF entry point directly. This brings the implementation into compliance with the PI spec and should work with any PEIM/DXE driver. Implementing this requires parsing the in-memory instance of the PE/COFF image created by Windows to find the entrypoint and since PEIMs/DXE drivers are not garunteed to have 4KB aligned sections, it also requires explicit configuration of the page table using VirtualProtect(). With this fix, the debugging experience is now so good it is unprecedented! In Visual Studio Code, add the following to launch.json: { "version": "0.2.0", "configurations": [ { "name": "EmulatorPkg Launch", "type": "cppvsdbg", "request": "launch", "program": "${workspaceFolder}/<path_to_build>/Build/EmulatorX64/DEBUG_<tool_chain>/X64/WinHost", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}/<path_to_build>/Build/EmulatorX64/DEBUG_<tool_chain>/X64/", "environment": [], "console": false, } ] } Make modifications to the above template as nessesary and build EmulatorPkg. Now, just add breakpoints directly in Visual Studio Code the way you would with any other software project. When you start the debugger, it will halt at the breakpoint automatically without any extra configuration required. Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com> Cc: Andrew Fish <afish@apple.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Chasel Chiu <chasel.chiu@intel.com> Signed-off-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
Diffstat (limited to 'UefiPayloadPkg/UefiPayloadPkg.dsc')
0 files changed, 0 insertions, 0 deletions