Parcourir la source

* Crash debug buffer output updates

Bryan Drewery il y a 16 ans
Parent
commit
b3033ad2f9
3 fichiers modifiés avec 21 ajouts et 25 suppressions
  1. 17 19
      src/debug.c
  2. 1 1
      src/debug.h
  3. 3 5
      src/net.c

+ 17 - 19
src/debug.c

@@ -110,30 +110,28 @@ void init_debug()
 
 
 void sdprintf (const char *format, ...)
 void sdprintf (const char *format, ...)
 {
 {
-#ifndef DEBUG
-  if (sdebug) {
-#endif
-    char s[2001] = "";
-    va_list va;
+  char s[2001] = "";
+  va_list va;
+
+  va_start(va, format);
+  egg_vsnprintf(s, sizeof(s), format, va);
+  va_end(va);
 
 
-    va_start(va, format);
-    egg_vsnprintf(s, sizeof(s), format, va);
-    va_end(va);
-    
-    remove_crlf(s);
+  remove_crlf(s);
+
+  simple_snprintf(get_buf[current_get_buf], sizeof(get_buf[current_get_buf]), "dbg: %s", s);
+  get_buf_inc();
 
 
 #ifdef DEBUG
 #ifdef DEBUG
-    if (sdebug) {
+  if (sdebug) {
 #endif
 #endif
-      if (!backgrd)
-        dprintf(DP_STDOUT, "[D:%lu] %s%s%s\n", (unsigned long) mypid, BOLD(-1), s, BOLD_END(-1));
-      else
-        printf("[D:%lu] %s%s%s\n", (unsigned long) mypid, BOLD(-1), s, BOLD_END(-1));
+    if (!backgrd)
+      dprintf(DP_STDOUT, "[D:%lu] %s%s%s\n", (unsigned long) mypid, BOLD(-1), s, BOLD_END(-1));
+    else
+      printf("[D:%lu] %s%s%s\n", (unsigned long) mypid, BOLD(-1), s, BOLD_END(-1));
 #ifdef DEBUG
 #ifdef DEBUG
-    }
-    logfile(LOG_DEBUG, s);
-#else
   }
   }
+  logfile(LOG_DEBUG, s);
 #endif
 #endif
 }
 }
 
 
@@ -156,7 +154,7 @@ static void write_debug()
   putlog(LOG_MISC, "*", "** Paste to bryan:");
   putlog(LOG_MISC, "*", "** Paste to bryan:");
   const size_t cur_buf = (current_get_buf == 0) ? GET_BUFS - 1 : current_get_buf - 1;
   const size_t cur_buf = (current_get_buf == 0) ? GET_BUFS - 1 : current_get_buf - 1;
   for (size_t i = 0; i < GET_BUFS; i++)
   for (size_t i = 0; i < GET_BUFS; i++)
-    putlog(LOG_MISC, "*", "%c %02zu: %s", i == cur_buf ? '*' : '+', i, get_buf[i]);
+    putlog(LOG_MISC, "*", "%c %02zu: %s", i == cur_buf ? '*' : '_', i, get_buf[i]);
   putlog(LOG_MISC, "*", "** end");
   putlog(LOG_MISC, "*", "** end");
 }
 }
 
 

+ 1 - 1
src/debug.h

@@ -12,7 +12,7 @@
 
 
 #undef DEBUG_CONTEXT
 #undef DEBUG_CONTEXT
 
 
-#define GET_BUFS 5
+#define GET_BUFS 30
 #define get_buf_inc() if (++current_get_buf == GET_BUFS) current_get_buf = 0;
 #define get_buf_inc() if (++current_get_buf == GET_BUFS) current_get_buf = 0;
 
 
 /*
 /*

+ 3 - 5
src/net.c

@@ -1486,13 +1486,11 @@ bool socket_run() {
   if (xx >= 0) {		/* Non-error */
   if (xx >= 0) {		/* Non-error */
     if ((idx = findanyidx(xx)) != -1) {
     if ((idx = findanyidx(xx)) != -1) {
       if (likely(dcc[idx].type->activity)) {
       if (likely(dcc[idx].type->activity)) {
-        if (buf[0]) {
-          strlcpy(get_buf[current_get_buf], buf, sizeof(get_buf[current_get_buf]));
-          get_buf_inc();
-        }
-
         /* Traffic stats */
         /* Traffic stats */
         if (dcc[idx].type->name) {
         if (dcc[idx].type->name) {
+          simple_snprintf(get_buf[current_get_buf], sizeof(get_buf[current_get_buf]), "%s: %s", dcc[idx].type->name, buf);
+          get_buf_inc();
+
           if (!strncmp(dcc[idx].type->name, "BOT", 3))
           if (!strncmp(dcc[idx].type->name, "BOT", 3))
             traffic.in_today.bn += i + 1;
             traffic.in_today.bn += i + 1;
           else if (!strcmp(dcc[idx].type->name, "SERVER"))
           else if (!strcmp(dcc[idx].type->name, "SERVER"))