debug.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Debug macros for run-time debugging.
  3. * Turned on/off with CONFIG_RUNTIME_DEBUG option.
  4. *
  5. * Copyright (C) 2001 MontaVista Software Inc.
  6. * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2 of the License, or (at your
  11. * option) any later version.
  12. *
  13. */
  14. #ifndef _ASM_DEBUG_H
  15. #define _ASM_DEBUG_H
  16. #include <linux/config.h>
  17. /*
  18. * run-time macros for catching spurious errors. Eable CONFIG_RUNTIME_DEBUG in
  19. * kernel hacking config menu to use them.
  20. *
  21. * Use them as run-time debugging aid. NEVER USE THEM AS ERROR HANDLING CODE!!!
  22. */
  23. #ifdef CONFIG_RUNTIME_DEBUG
  24. #include <linux/kernel.h>
  25. #define db_assert(x) if (!(x)) { \
  26. panic("assertion failed at %s:%d: %s", __FILE__, __LINE__, #x); }
  27. #define db_warn(x) if (!(x)) { \
  28. printk(KERN_WARNING "warning at %s:%d: %s", __FILE__, __LINE__, #x); }
  29. #define db_verify(x, y) db_assert(x y)
  30. #define db_verify_warn(x, y) db_warn(x y)
  31. #define db_run(x) do { x; } while (0)
  32. #else
  33. #define db_assert(x)
  34. #define db_warn(x)
  35. #define db_verify(x, y) x
  36. #define db_verify_warn(x, y) x
  37. #define db_run(x)
  38. #endif
  39. #endif /* _ASM_DEBUG_H */