Просмотр исходного кода

* stackdump() in write_debug() now

svn: 1082
Bryan Drewery 22 лет назад
Родитель
Сommit
07910a5963
3 измененных файлов с 13 добавлено и 9 удалено
  1. 1 1
      src/cmds.c
  2. 0 2
      src/conf.c
  3. 12 6
      src/debug.c

+ 1 - 1
src/cmds.c

@@ -2086,7 +2086,7 @@ static void cmd_debug(struct userrec *u, int idx, char *par)
   if (!cmd || (cmd &&!strcmp(cmd, "net")))
   if (!cmd || (cmd &&!strcmp(cmd, "net")))
     tell_netdebug(idx);
     tell_netdebug(idx);
   if (!cmd || (cmd &&!strcmp(cmd, "stackdump")))
   if (!cmd || (cmd &&!strcmp(cmd, "stackdump")))
-    stackdump(idx);
+    stackdump(0);
 }
 }
 
 
 static void cmd_timers(struct userrec *u, int idx, char *par)
 static void cmd_timers(struct userrec *u, int idx, char *par)

+ 0 - 2
src/conf.c

@@ -61,8 +61,6 @@ spawnbots()
       status = system(run);
       status = system(run);
       if (status == -1 || WEXITSTATUS(status))
       if (status == -1 || WEXITSTATUS(status))
         sdprintf("Failed to spawn '%s': %s", bot->nick, strerror(errno));
         sdprintf("Failed to spawn '%s': %s", bot->nick, strerror(errno));
-      else
-        bots_ran++;        
       free(run);
       free(run);
     }
     }
   }
   }

+ 12 - 6
src/debug.c

@@ -170,6 +170,7 @@ void write_debug()
     egg_strftime(date, sizeof date, "%c %Z", gmtime(&buildts));
     egg_strftime(date, sizeof date, "%c %Z", gmtime(&buildts));
     dprintf(-x, "Build: %s (%lu)\n", date, buildts);
     dprintf(-x, "Build: %s (%lu)\n", date, buildts);
 
 
+    stackdump(-x);
     dprintf(-x, "Context: ");
     dprintf(-x, "Context: ");
     cx_ptr = cx_ptr & 15;
     cx_ptr = cx_ptr & 15;
     for (y = ((cx_ptr + 1) & 15); y != cx_ptr; y = ((y + 1) & 15))
     for (y = ((cx_ptr + 1) & 15); y != cx_ptr; y = ((y + 1) & 15))
@@ -206,7 +207,7 @@ void write_debug()
     }
     }
     putlog(LOG_MISC, "*", "* Emailed DEBUG to development team...");
     putlog(LOG_MISC, "*", "* Emailed DEBUG to development team...");
 #endif /* !CYGWIN_HACKS */
 #endif /* !CYGWIN_HACKS */
-    unlink(buf);
+//    unlink(buf);
   }
   }
 }
 }
 #endif /* DEBUG_CONTEXT */
 #endif /* DEBUG_CONTEXT */
@@ -258,13 +259,13 @@ stackdump(int idx)
 {
 {
   __asm__("movl %EBP, %EAX");
   __asm__("movl %EBP, %EAX");
   __asm__("movl %EAX, sf");
   __asm__("movl %EAX, sf");
-  if (idx == -1)
+  if (idx == 0)
     putlog(LOG_MISC, "*", "STACK DUMP (%%ebp)");
     putlog(LOG_MISC, "*", "STACK DUMP (%%ebp)");
   else
   else
     dprintf(idx, "STACK DUMP (%%ebp)\n");
     dprintf(idx, "STACK DUMP (%%ebp)\n");
 
 
-  while (canaccess(sf) && stackdepth < 20) {
-    if (idx == -1)
+  while (canaccess(sf) && stackdepth < 20 && sf->ebp) {
+    if (idx == 0)
       putlog(LOG_MISC, "*", " %02d: 0x%08lx/0x%08lx", stackdepth, (unsigned long) sf->ebp, sf->addr);
       putlog(LOG_MISC, "*", " %02d: 0x%08lx/0x%08lx", stackdepth, (unsigned long) sf->ebp, sf->addr);
     else
     else
       dprintf(idx, " %02d: 0x%08lx/0x%08lx\n", stackdepth, (unsigned long) sf->ebp, sf->addr);
       dprintf(idx, " %02d: 0x%08lx/0x%08lx\n", stackdepth, (unsigned long) sf->ebp, sf->addr);
@@ -272,13 +273,18 @@ stackdump(int idx)
     stackdepth++;
     stackdepth++;
   }
   }
   stackdepth = 0;
   stackdepth = 0;
+  sf = NULL;
   sleep(1);
   sleep(1);
 };
 };
 
 
+static int nested_segv = 0;
 static void got_segv(int z)
 static void got_segv(int z)
 {
 {
-  signal(SIGSEGV, SIG_DFL);
-  stackdump(-1);
+  if (nested_segv)
+    signal(SIGSEGV, SIG_DFL);
+  else
+    nested_segv++;
+  stackdump(0);
 #ifdef DEBUG_CONTEXT
 #ifdef DEBUG_CONTEXT
   write_debug();
   write_debug();
 #endif
 #endif