[haiku-commits] r33893 - haiku/trunk/src/add-ons/kernel/network/stack

  • From: axeld@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 5 Nov 2009 12:40:33 +0100 (CET)

Author: axeld
Date: 2009-11-05 12:40:33 +0100 (Thu, 05 Nov 2009)
New Revision: 33893
Changeset: http://dev.haiku-os.org/changeset/33893/haiku

Modified:
   haiku/trunk/src/add-ons/kernel/network/stack/net_buffer.cpp
Log:
* Replaced ENABLE_DEBUGGER_COMMANDS with ENABLE_STATS.
* Added new ENABLE_DEBUGGER_COMMANDS that enables the new "net_buffer" KDL
  command to dump a net buffer.


Modified: haiku/trunk/src/add-ons/kernel/network/stack/net_buffer.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/network/stack/net_buffer.cpp 2009-11-05 
11:14:12 UTC (rev 33892)
+++ haiku/trunk/src/add-ons/kernel/network/stack/net_buffer.cpp 2009-11-05 
11:40:33 UTC (rev 33893)
@@ -41,8 +41,9 @@
 #define BUFFER_SIZE 2048
        // maximum implementation derived buffer size is 65536
 
-//#define ENABLE_DEBUGGER_COMMANDS     1
-#define PARANOID_BUFFER_CHECK  NET_BUFFER_PARANOIA
+#define ENABLE_DEBUGGER_COMMANDS       1
+//#define ENABLE_STATS                         1
+#define PARANOID_BUFFER_CHECK          NET_BUFFER_PARANOIA
 
 #define COMPONENT_PARANOIA_LEVEL       NET_BUFFER_PARANOIA
 #include <debug_paranoia.h>
@@ -156,7 +157,7 @@
                                        size_t size);
 
 
-#if ENABLE_DEBUGGER_COMMANDS
+#if ENABLE_STATS
 static vint32 sAllocatedDataHeaderCount = 0;
 static vint32 sAllocatedNetBufferCount = 0;
 static vint32 sEverAllocatedDataHeaderCount = 0;
@@ -571,7 +572,6 @@
 #endif // NET_BUFFER_TRACING
 
 
-#if 1
 static void
 dump_buffer(net_buffer* _buffer)
 {
@@ -588,12 +588,26 @@
                dump_block((char*)node->start, min_c(node->used, 32), "    ");
        }
 }
-#endif
 
-
 #if ENABLE_DEBUGGER_COMMANDS
 
 static int
+dump_net_buffer(int argc, char** argv)
+{
+       if (argc != 2) {
+               kprintf("usage: %s [address]\n", argv[0]);
+               return 0;
+       }
+
+       dump_buffer((net_buffer*)parse_expression(argv[1]));
+       return 0;
+}
+
+#endif // ENABLE_DEBUGGER_COMMANDS
+
+#if ENABLE_STATS
+
+static int
 dump_net_buffer_stats(int argc, char** argv)
 {
        kprintf("allocated data headers: %7ld / %7ld\n", 
sAllocatedDataHeaderCount,
@@ -603,9 +617,8 @@
        return 0;
 }
 
-#endif // ENABLE_DEBUGGER_COMMANDS
+#endif // ENABLE_STATS
 
-
 #if PARANOID_BUFFER_CHECK
 
 static void
@@ -691,7 +704,7 @@
 static inline data_header*
 allocate_data_header()
 {
-#if ENABLE_DEBUGGER_COMMANDS
+#if ENABLE_STATS
        atomic_add(&sAllocatedDataHeaderCount, 1);
        atomic_add(&sEverAllocatedDataHeaderCount, 1);
 #endif
@@ -702,7 +715,7 @@
 static inline net_buffer_private*
 allocate_net_buffer()
 {
-#if ENABLE_DEBUGGER_COMMANDS
+#if ENABLE_STATS
        atomic_add(&sAllocatedNetBufferCount, 1);
        atomic_add(&sEverAllocatedNetBufferCount, 1);
 #endif
@@ -714,7 +727,7 @@
 static inline void
 free_data_header(data_header* header)
 {
-#if ENABLE_DEBUGGER_COMMANDS
+#if ENABLE_STATS
        if (header != NULL)
                atomic_add(&sAllocatedDataHeaderCount, -1);
 #endif
@@ -725,7 +738,7 @@
 static inline void
 free_net_buffer(net_buffer_private* buffer)
 {
-#if ENABLE_DEBUGGER_COMMANDS
+#if ENABLE_STATS
        if (buffer != NULL)
                atomic_add(&sAllocatedNetBufferCount, -1);
 #endif
@@ -2113,18 +2126,25 @@
                                return B_NO_MEMORY;
                        }
 
-#if ENABLE_DEBUGGER_COMMANDS
+#if ENABLE_STATS
                        add_debugger_command_etc("net_buffer_stats", 
&dump_net_buffer_stats,
                                "Print net buffer statistics",
                                "\nPrint net buffer statistics.\n", 0);
 #endif
-
+#if ENABLE_DEBUGGER_COMMANDS
+                       add_debugger_command_etc("net_buffer", &dump_net_buffer,
+                               "Dump net buffer",
+                               "\nDump the net buffer's internal 
structures.\n", 0);
+#endif
                        return B_OK;
 
                case B_MODULE_UNINIT:
-#if ENABLE_DEBUGGER_COMMANDS
+#if ENABLE_STATS
                        remove_debugger_command("net_buffer_stats", 
&dump_net_buffer_stats);
 #endif
+#if ENABLE_DEBUGGER_COMMANDS
+                       remove_debugger_command("net_buffer", &dump_net_buffer);
+#endif
                        delete_object_cache(sNetBufferCache);
                        delete_object_cache(sDataNodeCache);
                        return B_OK;


Other related posts:

  • » [haiku-commits] r33893 - haiku/trunk/src/add-ons/kernel/network/stack - axeld