Forráskód Böngészése

* Add debug buffer output on crash - please give to bryan if it ever comes up.

Bryan Drewery 16 éve
szülő
commit
b93ee3ff28
5 módosított fájl, 30 hozzáadás és 9 törlés
  1. 1 0
      doc/UPDATES
  2. 11 8
      src/debug.c
  3. 5 1
      src/debug.h
  4. 5 0
      src/egg_timer.c
  5. 8 0
      src/net.c

+ 1 - 0
doc/UPDATES

@@ -127,6 +127,7 @@
   * Utilize CPRIVMSG/CNOTICE if available.
   * Chain WHO requests to try avoiding Max SendQ
   * More Auth channel commands are now available. Auth up and run +help to see them all.
+  * Add debug buffer output on crash - please give to bryan if it ever comes up.
 
 1.2.16.1
 * Fix linux compile errors

+ 11 - 8
src/debug.c

@@ -51,6 +51,8 @@
 
 bool		sdebug = 0;             /* enable debug output? */
 bool		segfaulted = 0;
+char	get_buf[GET_BUFS][SGRAB + 5];
+size_t	current_get_buf = 0;
 
 
 #ifdef DEBUG_CONTEXT
@@ -149,6 +151,15 @@ static void write_debug()
 }
 #endif /* DEBUG_CONTEXT */
 
+static void write_debug()
+{
+  putlog(LOG_MISC, "*", "** Paste to bryan:");
+  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++)
+    putlog(LOG_MISC, "*", "%c %02zu: %s", i == cur_buf ? '*' : '+', i, get_buf[i]);
+  putlog(LOG_MISC, "*", "** end");
+}
+
 #ifndef DEBUG
 static void got_bus(int) __attribute__ ((noreturn));
 #endif /* DEBUG */
@@ -156,9 +167,7 @@ static void got_bus(int) __attribute__ ((noreturn));
 static void got_bus(int z)
 {
   signal(SIGBUS, SIG_DFL);
-#ifdef DEBUG_CONTEXT
   write_debug();
-#endif
   fatal("BUS ERROR -- CRASHING!", 1);
 #ifdef DEBUG
   raise(SIGBUS);
@@ -176,9 +185,7 @@ static void got_segv(int z)
   segfaulted = 1;
   alarm(0);		/* dont let anything jump out of this signal! */
   signal(SIGSEGV, SIG_DFL);
-#ifdef DEBUG_CONTEXT
   write_debug();
-#endif
   fatal("SEGMENT VIOLATION -- CRASHING!", 1);
 #ifdef DEBUG
   char gdb[1024] = "", btfile[256] = "", std_in[101] = "", *out = NULL;
@@ -217,9 +224,7 @@ static void got_fpe(int) __attribute__ ((noreturn));
 
 static void got_fpe(int z)
 {
-#ifdef DEBUG_CONTEXT
   write_debug();
-#endif
   fatal("FLOATING POINT ERROR -- CRASHING!", 0);
   exit(1);		/* for GCC noreturn */
 }
@@ -241,9 +246,7 @@ static void got_abort(int) __attribute__ ((noreturn));
 static void got_abort(int z)
 {
   signal(SIGABRT, SIG_DFL);
-#ifdef DEBUG_CONTEXT
   write_debug();
-#endif
   fatal("GOT SIGABRT -- CRASHING!", 1);
 #ifdef DEBUG
   raise(SIGSEGV);

+ 5 - 1
src/debug.h

@@ -12,6 +12,8 @@
 
 #undef DEBUG_CONTEXT
 
+#define GET_BUFS 5
+
 /*
  *    Handy aliases for memory tracking and core dumps
  */
@@ -29,8 +31,10 @@
 #define debug3(x,a1,a2,a3)      putlog(LOG_DEBUG,"*",x,a1,a2,a3)
 #define debug4(x,a1,a2,a3,a4)   putlog(LOG_DEBUG,"*",x,a1,a2,a3,a4)
 
-
+#include "net.h"
 extern bool		sdebug, segfaulted;
+extern size_t		current_get_buf;
+extern char		get_buf[GET_BUFS][SGRAB + 5];
 
 void setlimits();
 void sdprintf (const char *, ...) __attribute__((format(printf, 1, 2)));

+ 5 - 0
src/egg_timer.c

@@ -253,6 +253,11 @@ static bool process_timer(egg_timer_t* timer) {
 		deleted = 1;
 	}
 
+	if (timer->name)
+		simple_snprintf(get_buf[current_get_buf], SGRAB + 10, "Execing timer: %s", timer->name);
+	if (++current_get_buf == GET_BUFS)
+		current_get_buf = 0;
+
 	callback(client_data);
 	return deleted;
 }

+ 8 - 0
src/net.c

@@ -1481,9 +1481,17 @@ bool socket_run() {
 
   int xx = sockgets(buf, &i);
 
+  get_buf[current_get_buf][0] = 0;
+
   if (xx >= 0) {		/* Non-error */
     if ((idx = findanyidx(xx)) != -1) {
       if (likely(dcc[idx].type->activity)) {
+        if (buf[0])
+          strlcpy(get_buf[current_get_buf], buf, i+1);
+
+        if (++current_get_buf == GET_BUFS)
+          current_get_buf = 0;
+
         /* Traffic stats */
         if (dcc[idx].type->name) {
           if (!strncmp(dcc[idx].type->name, "BOT", 3))