sd-boot: Add assert implementation
There is a ASSERT() macro from gnu-efi, but that does not show any output to ConOut. Having to do some additional setup just to get some debug output is tedious and outright difficult on real hardware.
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
||||
#include <efi.h>
|
||||
#include <efilib.h>
|
||||
#include "util.h"
|
||||
|
||||
void efi_assert(const char *expr, const char *file, unsigned line, const char *function) {
|
||||
log_error_stall(L"systemd-boot assertion '%a' failed at %a:%u, function %a(). Halting.", expr, file, line, function);
|
||||
for (;;)
|
||||
uefi_call_wrapper(BS->Stall, 1, 60 * 1000 * 1000);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -17,6 +17,7 @@ efi_headers = files('''
|
||||
'''.split())
|
||||
|
||||
common_sources = '''
|
||||
assert.c
|
||||
disk.c
|
||||
graphics.c
|
||||
measure.c
|
||||
@@ -219,12 +220,16 @@ if have_gnu_efi
|
||||
compile_args += ['-Werror']
|
||||
endif
|
||||
if get_option('buildtype') == 'debug'
|
||||
compile_args += ['-ggdb', '-O0']
|
||||
compile_args += ['-ggdb', '-O0', '-DEFI_DEBUG']
|
||||
elif get_option('buildtype') == 'debugoptimized'
|
||||
compile_args += ['-ggdb', '-Og']
|
||||
compile_args += ['-ggdb', '-Og', '-DEFI_DEBUG']
|
||||
else
|
||||
compile_args += ['-O2']
|
||||
endif
|
||||
if get_option('b_ndebug') == 'true' or (
|
||||
get_option('b_ndebug') == 'if-release' and ['plain', 'release'].contains(get_option('buildtype')))
|
||||
compile_args += ['-DNDEBUG']
|
||||
endif
|
||||
|
||||
efi_ldflags = ['-T', efi_lds,
|
||||
'-shared',
|
||||
|
||||
Reference in New Issue
Block a user