EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
InitializeLib(image, sys_table);
- debug_hook("systemd-boot");
- /* Uncomment the next line if you need to wait for debugger. */
- // debug_break();
+ notify_debugger("systemd-boot", /*wait_for_debugger=*/false);
EFI_STATUS err = real_main(image);
log_wait();
EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
InitializeLib(image, sys_table);
- debug_hook("systemd-stub");
- /* Uncomment the next line if you need to wait for debugger. */
- // debug_break();
+ notify_debugger("systemd-stub", /*wait_for_debugger=*/false);
EFI_STATUS err = real_main(image);
log_wait();
}
#ifdef EFI_DEBUG
-__attribute__((noinline)) void debug_break(void) {
+extern uint8_t _text, _data;
+__attribute__((noinline)) void notify_debugger(const char *identity, volatile bool wait) {
+ printf("%s@%p,%p\n", identity, &_text, &_data);
+ if (wait)
+ printf("Waiting for debugger to attach...\n");
+
/* This is a poor programmer's breakpoint to wait until a debugger
* has attached to us. Just "set variable wait = 0" or "return" to continue. */
- volatile bool wait = true;
while (wait)
/* Prefer asm based stalling so that gdb has a source location to present. */
#if defined(__i386__) || defined(__x86_64__)
}
#endif
-
#ifdef EFI_DEBUG
void hexdump(const char16_t *prefix, const void *data, UINTN size) {
static const char hex[16] = "0123456789abcdef";
uint64_t get_os_indications_supported(void);
#ifdef EFI_DEBUG
-void debug_break(void);
-extern uint8_t _text, _data;
/* Report the relocated position of text and data sections so that a debugger
* can attach to us. See debug-sd-boot.sh for how this can be done. */
-# define debug_hook(identity) printf(identity "@%p,%p\n", &_text, &_data)
+void notify_debugger(const char *identity, bool wait);
+void hexdump(const char16_t *prefix, const void *data, size_t size);
#else
-# define debug_hook(identity)
-#endif
-
-#ifdef EFI_DEBUG
-void hexdump(const char16_t *prefix, const void *data, UINTN size);
+# define notify_debugger(i, w)
#endif
#if defined(__i386__) || defined(__x86_64__)