]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
boot: Simplify debug hook
authorJan Janssen <medhefgo@web.de>
Thu, 19 Jan 2023 14:46:43 +0000 (15:46 +0100)
committerJan Janssen <medhefgo@web.de>
Fri, 20 Jan 2023 19:55:11 +0000 (20:55 +0100)
src/boot/efi/boot.c
src/boot/efi/stub.c
src/boot/efi/util.c
src/boot/efi/util.h

index 4ff6398149c0f3b9add273684d6fc9f31a391e6f..e0a1ea7dd8c1f097acdd86c18c0175644c49414d 100644 (file)
@@ -2750,9 +2750,7 @@ out:
 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();
index b8e54286de854c23c36c0d46d237199c55431f7e..5f480f14cd4b93735e39e315d09813f924af35f9 100644 (file)
@@ -420,9 +420,7 @@ static EFI_STATUS real_main(EFI_HANDLE image) {
 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();
index 8cca73a07693331e35fdf6b9326a045933eb7685..353fc03ef039767e1c8fb97c5cac43c4e1441c88 100644 (file)
@@ -515,10 +515,14 @@ uint64_t get_os_indications_supported(void) {
 }
 
 #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__)
@@ -531,7 +535,6 @@ __attribute__((noinline)) void debug_break(void) {
 }
 #endif
 
-
 #ifdef EFI_DEBUG
 void hexdump(const char16_t *prefix, const void *data, UINTN size) {
         static const char hex[16] = "0123456789abcdef";
index 2cd35c828f9e988b2817b8a399b3e96ab8bc8474..6a78215b9dbe0b4e2887a1211bf04fa36a3691ec 100644 (file)
@@ -171,17 +171,12 @@ static inline void *PHYSICAL_ADDRESS_TO_POINTER(EFI_PHYSICAL_ADDRESS addr) {
 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__)