debug.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * linux/fs/9p/debug.h - V9FS Debug Definitions
  3. *
  4. * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com>
  5. * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2
  9. * as published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to:
  18. * Free Software Foundation
  19. * 51 Franklin Street, Fifth Floor
  20. * Boston, MA 02111-1301 USA
  21. *
  22. */
  23. #define DEBUG_ERROR (1<<0)
  24. #define DEBUG_CURRENT (1<<1)
  25. #define DEBUG_9P (1<<2)
  26. #define DEBUG_VFS (1<<3)
  27. #define DEBUG_CONV (1<<4)
  28. #define DEBUG_MUX (1<<5)
  29. #define DEBUG_TRANS (1<<6)
  30. #define DEBUG_SLABS (1<<7)
  31. #define DEBUG_FCALL (1<<8)
  32. #define DEBUG_DUMP_PKT 0
  33. extern int v9fs_debug_level;
  34. #define dprintk(level, format, arg...) \
  35. do { \
  36. if((v9fs_debug_level & level)==level) \
  37. printk(KERN_NOTICE "-- %s (%d): " \
  38. format , __FUNCTION__, current->pid , ## arg); \
  39. } while(0)
  40. #define eprintk(level, format, arg...) \
  41. do { \
  42. printk(level "v9fs: %s (%d): " \
  43. format , __FUNCTION__, current->pid , ## arg); \
  44. } while(0)
  45. #if DEBUG_DUMP_PKT
  46. static inline void dump_data(const unsigned char *data, unsigned int datalen)
  47. {
  48. int i, n;
  49. char buf[5*8];
  50. n = 0;
  51. i = 0;
  52. while (i < datalen) {
  53. n += snprintf(buf+n, sizeof(buf)-n, "%02x", data[i++]);
  54. if (i%4 == 0)
  55. n += snprintf(buf+n, sizeof(buf)-n, " ");
  56. if (i%16 == 0) {
  57. dprintk(DEBUG_ERROR, "%s\n", buf);
  58. n = 0;
  59. }
  60. }
  61. dprintk(DEBUG_ERROR, "%s\n", buf);
  62. }
  63. #else /* DEBUG_DUMP_PKT */
  64. static inline void dump_data(const unsigned char *data, unsigned int datalen)
  65. {
  66. }
  67. #endif /* DEBUG_DUMP_PKT */