Debugging is enabled by adding CONFIG_DEBUG in config.h Signed-off-by: Andrea Bastoni <andrea.bast...@tum.de> --- hypervisor/include/jailhouse/assert.h | 37 +++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 hypervisor/include/jailhouse/assert.h
diff --git a/hypervisor/include/jailhouse/assert.h b/hypervisor/include/jailhouse/assert.h new file mode 100644 index 00000000..eedb1b9f --- /dev/null +++ b/hypervisor/include/jailhouse/assert.h @@ -0,0 +1,37 @@ +/* + * Runtime assert. + * + * Copyright (C) Technical University of Munich, 2020 + * + * Authors: + * Andrea Bastoni <andrea.bast...@tum.de> + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + */ +#ifndef _ASSERT_H +#define _ASSERT_H + +#ifndef CONFIG_DEBUG +/* runtime assert does nothing in non-debug configurations */ +#define assert(e) do { } while(0) + +#else +extern void __assert_fail( + const char *file, + unsigned int line, + const char *func, + const char *expr) __attribute__((noreturn)); + +#define assert(e) \ + do { \ + if (e) { \ + /* empty */ \ + } else { \ + __assert_fail(__FILE__, __LINE__, __FUNCTION__, #e); \ + } \ + } while (0) + +#endif /* CONFIG_DEBUG */ + +#endif -- 2.29.2 -- You received this message because you are subscribed to the Google Groups "Jailhouse" group. To unsubscribe from this group and stop receiving emails from it, send an email to jailhouse-dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jailhouse-dev/20210125120044.56794-11-andrea.bastoni%40tum.de.