pastebin - collaborative debugging tool
rovema.kpaste.net RSS


libigbavb debug code
Posted by Anonymous on Tue 25th Jun 2024 10:13
raw | new post
view followups (newest first): libigbavb debug code by Anonymous

  1. diff --git a/lib/Makefile b/lib/Makefile
  2. index 8a0c415..6aebf3b 100644
  3. --- a/lib/Makefile
  4. +++ b/lib/Makefile
  5. @@ -1,7 +1,7 @@
  6.  OBJS=igb
  7.  INCL=e1000_82575.h e1000_defines.h e1000_hw.h e1000_osdep.h e1000_regs.h igb.h
  8.  AVBLIB=libigb.a
  9. -#CFLAGS=-ggdb
  10. +CFLAGS=-ggdb -Wall
  11.  
  12.  CC?=gcc
  13.  RANLIB?=ranlib
  14. diff --git a/lib/igb.c b/lib/igb.c
  15. index 647234f..7480ad8 100644
  16. --- a/lib/igb.c
  17. +++ b/lib/igb.c
  18. @@ -57,6 +57,21 @@
  19.  
  20.  #undef DEBUG
  21.  
  22. +
  23. +int g_debug_level = 2;
  24. +
  25. +#define dprintf_out printf
  26. +
  27. +#define DPRINTF_LEVEL_ENABLED(level) ((level) <= g_debug_level)
  28. +#define DPRINTF(level, args) \
  29. +       { \
  30. +               if (DPRINTF_LEVEL_ENABLED(level)) { \
  31. +                       int saved_errno = errno; \
  32. +                       dprintf_out args; \
  33. +                       errno = saved_errno; \
  34. +               } \
  35. +       }
  36. +
  37.  /*********************************************************************
  38.   *  PCI Device ID Table
  39.   *
  40. @@ -1008,8 +1023,10 @@ int igb_xmit(device_t *dev, unsigned int queue_index, struct igb_packet *packet)
  41.         if (packet == NULL)
  42.                 return -EINVAL;
  43.  
  44. -       if (igb_lock(dev) != 0)
  45. +       if (igb_lock(dev) != 0) {
  46. +               DPRINTF(1, ("igb_xmit: igb_lock() failed, errno=%d\n", errno));
  47.                 return errno;
  48. +       }
  49.  
  50.         packet->next = NULL; /* used for cleanup */
  51.  
  52. @@ -1100,8 +1117,10 @@ int igb_xmit(device_t *dev, unsigned int queue_index, struct igb_packet *packet)
  53.         ++txr->tx_packets;
  54.  
  55.  unlock:
  56. -       if (igb_unlock(dev) != 0)
  57. +       if (igb_unlock(dev) != 0) {
  58. +               DPRINTF(1, ("igb_xmit: igb_unlock() failed, errno=%d\n", errno));
  59.                 return errno;
  60. +       }
  61.  
  62.         return error;
  63.  }
  64. @@ -1179,11 +1198,15 @@ int igb_lock(device_t *dev)
  65.                 case 0:
  66.                         break;
  67.                 case EOWNERDEAD:
  68. +                       DPRINTF(0, ("igb_lock: trying to recover mutex %p\n", adapter->memlock));
  69.                         // some process terminated without unlocking the mutex
  70. -                       if (pthread_mutex_consistent(adapter->memlock) != 0)
  71. +                       if (pthread_mutex_consistent(adapter->memlock) != 0) {
  72. +                               DPRINTF(0, ("igb_lock: pthread_mutex_consistent() failed, errno=%d\n", errno));
  73.                                 return -errno;
  74. +                       }
  75.                         break;
  76.                 default:
  77. +                       DPRINTF(0, ("igb_lock: pthread_mutex_lock() failed, errno=%d\n", errno));
  78.                         return -errno;
  79.                         break;
  80.         }
  81. @@ -2486,6 +2509,8 @@ static int igb_create_lock(struct adapter *adapter)
  82.         bool attr_allocated = false;
  83.         pthread_mutexattr_t attr;
  84.  
  85. +       DPRINTF(2, ("--> igb_create_lock(adapter=%p)\n", adapter));
  86. +
  87.         if (!adapter) {
  88.                 errno = EINVAL;
  89.                 goto err;
  90. @@ -2541,13 +2566,17 @@ static int igb_create_lock(struct adapter *adapter)
  91.         fl.l_len = 1;
  92.         fl.l_pid = getpid();
  93.  
  94. -       if (fcntl(fd, F_SETLKW, &fl) != 0)
  95. +       if (fcntl(fd, F_SETLKW, &fl) != 0) {
  96. +               DPRINTF(1, ("igb_create_lock: F_SETLKW failed, errno=%d\n", errno));
  97.                 goto err;
  98. +       }
  99.  
  100.         locked = true;
  101.  
  102. -       if (fstat(fd, &stat) != 0)
  103. +       if (fstat(fd, &stat) != 0) {
  104. +               DPRINTF(1, ("igb_create_lock: fstat() failed, errno=%d\n", errno));
  105.                 goto err;
  106. +       }
  107.  
  108.         if (stat.st_size == 0) { // file is empty, do initialization
  109.                 /*
  110. @@ -2604,5 +2633,7 @@ err:
  111.                 (void) close(fd);
  112.         }
  113.  
  114. +       DPRINTF(2, ("<-- igb_create_lock, error=%d\n", (int)error));
  115. +
  116.         return error;
  117.  }

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at