diff options
| author | Peter Jones <pjones@redhat.com> | 2015-06-29 14:41:21 -0400 |
|---|---|---|
| committer | Peter Jones <pjones@redhat.com> | 2015-06-29 14:41:21 -0400 |
| commit | fef725de4d25fcb8516935e8acb7f48369eb531e (patch) | |
| tree | 8514a4c0c91b2e5a7f34139ef6b4a870f6904d33 /fallback.c | |
| parent | 15b5aae3959ef95a009d9ba49286ccb7b7183fb6 (diff) | |
| download | efi-boot-shim-fef725de4d25fcb8516935e8acb7f48369eb531e.tar.gz efi-boot-shim-fef725de4d25fcb8516935e8acb7f48369eb531e.zip | |
Add a conditional point for a debugger to attach.
Signed-off-by: Peter Jones <pjones@redhat.com>
Diffstat (limited to 'fallback.c')
| -rw-r--r-- | fallback.c | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -11,6 +11,7 @@ #include <efilib.h> #include "ucs2.h" +#include "variables.h" EFI_LOADED_IMAGE *this_image = NULL; @@ -791,6 +792,35 @@ try_start_first_option(EFI_HANDLE parent_image_handle) return rc; } +EFI_GUID SHIM_LOCK_GUID = { 0x605dab50, 0xe046, 0x4300, {0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23} }; +extern EFI_STATUS +efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *systab); + +static void +__attribute__((__optimize__("0"))) +debug_hook(void) +{ + EFI_GUID guid = SHIM_LOCK_GUID; + UINT8 *data = NULL; + UINTN dataSize = 0; + EFI_STATUS efi_status; + volatile register int x = 0; + extern char _etext, _edata; + + efi_status = get_variable(L"SHIM_DEBUG", &data, &dataSize, guid); + if (EFI_ERROR(efi_status)) { + return; + } + + if (x) + return; + + x = 1; + Print(L"add-symbol-file /usr/lib/debug/usr/share/shim/" + EFI_ARCH"/fallback.debug %p -s .data %p\n", &_etext, + &_edata); +} + EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *systab) { @@ -798,6 +828,11 @@ efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *systab) InitializeLib(image, systab); + /* + * if SHIM_DEBUG is set, wait for a debugger to attach. + */ + debug_hook(); + rc = uefi_call_wrapper(BS->HandleProtocol, 3, image, &LoadedImageProtocol, (void *)&this_image); if (EFI_ERROR(rc)) { Print(L"Error: could not find loaded image: %d\n", rc); |
