mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-02-26 09:57:26 +03:00
boot: Simplify debug hook
This commit is contained in:
parent
19f08504c5
commit
831b6a7fb0
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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";
|
||||
|
@ -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__)
|
||||
|
Loading…
x
Reference in New Issue
Block a user