fail cap checks if CONFIG_DEBUG_BUILD is not set Signed-off-by: Axel Heider <axelheider@gmx.de> (cherry picked from commit fcbc1944a948c651cabaa509c55dc0dcdf3ed377) Change-Id: I75c19cd32e6712bb56c88c59d3cd36751297a289
diff --git a/libsel4debug/include/sel4debug/debug.h b/libsel4debug/include/sel4debug/debug.h index 7b2b04d..53aac59 100644 --- a/libsel4debug/include/sel4debug/debug.h +++ b/libsel4debug/include/sel4debug/debug.h
@@ -29,21 +29,33 @@ static inline int debug_cap_is_valid(seL4_CPtr cap) { +#ifdef CONFIG_DEBUG_BUILD return (0 != seL4_DebugCapIdentify(cap)); +#else + return 0; /* fail check on non-debug kernels */ +#endif } static inline int debug_cap_is_endpoint(seL4_CPtr cap) { +#ifdef CONFIG_DEBUG_BUILD // there is kernel/generated/arch/object/structures_gen.h that defines // cap_endpoint_cap = 4, but we can't include it here return (4 == seL4_DebugCapIdentify(cap)); +#else + return 0; /* fail check on non-debug kernels */ +#endif } static inline int debug_cap_is_notification(seL4_CPtr cap) { +#ifdef CONFIG_DEBUG_BUILD // there is kernel/generated/arch/object/structures_gen.h that defines // cap_notification_cap = 6, but we can't include it here return (6 == seL4_DebugCapIdentify(cap)); +#else + return 0; /* fail check on non-debug kernels */ +#endif }
diff --git a/libsel4debug/src/caps.c b/libsel4debug/src/caps.c index 49baa05..4d7d8fc 100644 --- a/libsel4debug/src/caps.c +++ b/libsel4debug/src/caps.c
@@ -20,7 +20,8 @@ { #ifdef CONFIG_DEBUG_BUILD int type = seL4_DebugCapIdentify(cap); - - printf("Cap type number is %d\n", type); -#endif /* CONFIG_DEBUG_BUILD */ + printf("Cap %d has type %d\n", cap, type); +#else + printf("DEBUG_BUILD not set, can't get type of cap %d", cap); +#endif }