[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 3 of 3] xen/debug: Introduce ASSERT_RUN()
This is a variant of ASSERT() which takes a predicate, a function an argument for the function. It is designed for debugging in situations where ASSERT_PRINTK() is perhaps not powerful enough. It will run the given function with the given argument before the BUG() which kills Xen. Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> diff -r 477ccdb9870e -r 0a1a3f35f56a xen/include/xen/lib.h --- a/xen/include/xen/lib.h +++ b/xen/include/xen/lib.h @@ -48,6 +48,16 @@ do { } while (0) #endif /* assert_printk_failed */ +#ifndef assert_run_failed +#define assert_run_failed(p, func, arg) \ +do { \ + printk("Assertion '%s' failed, line %d, file %s\n", p , \ + __LINE__, __FILE__); \ + (func)((arg)); \ + BUG(); \ +} while (0) +#endif /* assert_run_failed */ + #ifdef CONFIG_ASSERTS #define ASSERT(p) \ do { if ( unlikely(!(p)) ) assert_failed(#p); } while (0) @@ -55,9 +65,15 @@ do { #define ASSERT_PRINTK(p, ...) \ do { if ( unlikely(!(p)) ) \ assert_printk_failed(#p, __VA_ARGS__); } while (0) + +/* func expected to be void, taking a single void * argument */ +#define ASSERT_RUN(p, func, arg) \ + do { if ( unlikely(!(p)) ) \ + assert_run_failed(#p, func, arg); } while (0) #else #define ASSERT(p) do { if ( 0 && (p) ); } while (0) #define ASSERT_PRINTK(p, ...) do { if ( 0 && (p) ); } while (0) +#define ASSERT_RUN(p, func, arg) do { if ( 0 && (p) ); } while (0) #endif #define ABS(_x) ({ \ _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |