Преглед изворни кода

upload client stack dump to event logs

Darren Ranalli пре 15 година
родитељ
комит
9462d332dc
3 измењених фајлова са 34 додато и 10 уклоњено
  1. 28 7
      direct/src/showbase/ExceptionVarDump.py
  2. 5 2
      direct/src/showbase/ShowBase.py
  3. 1 1
      direct/src/task/Task.py

+ 28 - 7
direct/src/showbase/ExceptionVarDump.py

@@ -64,20 +64,22 @@ def _varDump__print(exc):
 oldExcepthook = None
 # store these values here so that Task.py can always reliably access them
 # from its main exception handler
-wantVariableDump = False
+wantStackDumpLog = False
+wantStackDumpUpload = False
+variableDumpReasons = []
 dumpOnExceptionInit = False
 
 class _AttrNotFound:
     pass
 
 def _excepthookDumpVars(eType, eValue, tb):
-    excStrs = traceback.format_exception(eType, eValue, tb)
+    origTb = tb
+    excStrs = traceback.format_exception(eType, eValue, origTb)
     s = 'printing traceback in case variable repr crashes the process...\n'
     for excStr in excStrs:
         s += excStr
     notify.info(s)
     s = 'DUMPING STACK FRAME VARIABLES'
-    origTb = tb
     #import pdb;pdb.set_trace()
     #foundRun = False
     foundRun = True
@@ -158,15 +160,34 @@ def _excepthookDumpVars(eType, eValue, tb):
 
     if foundRun:
         s += '\n'
-        notify.info(s)
+        if wantStackDumpLog:
+            notify.info(s)
+        if wantStackDumpUpload:
+            excStrs = traceback.format_exception(eType, eValue, origTb)
+            for excStr in excStrs:
+                s += excStr
+            timeMgr = None
+            try:
+                timeMgr = base.cr.timeManager
+            except:
+                try:
+                    timeMgr = simbase.air.timeManager
+                except:
+                    pass
+            if timeMgr:
+                timeMgr.setStackDump(s)
+
     oldExcepthook(eType, eValue, origTb)
 
-def install():
+def install(log, upload):
     global oldExcepthook
-    global wantVariableDump
+    global wantStackDumpLog
+    global wantStackDumpUpload
     global dumpOnExceptionInit
 
-    wantVariableDump = True
+    wantStackDumpLog = log
+    wantStackDumpUpload = upload
+
     dumpOnExceptionInit = config.GetBool('variable-dump-on-exception-init', 0)
     if dumpOnExceptionInit:
         # this mode doesn't completely work because exception objects

+ 5 - 2
direct/src/showbase/ShowBase.py

@@ -56,8 +56,11 @@ class ShowBase(DirectObject.DirectObject):
 
     def __init__(self, fStartDirect = True, windowType = None):
         __builtin__.__dev__ = config.GetBool('want-dev', 0)
-        if config.GetBool('want-variable-dump', 0):
-            ExceptionVarDump.install()
+        logStackDump = (config.GetBool('log-stack-dump', 0) or
+                        config.GetBool('client-log-stack-dump', 0))
+        uploadStackDump = config.GetBool('upload-stack-dump', (not __dev__))
+        if logStackDump or uploadStackDump:
+            ExceptionVarDump.install(logStackDump, uploadStackDump)
 
         # Locate the directory containing the main program
         self.mainDir = ExecutionEnvironment.getEnvironmentVariable("MAIN_DIR")

+ 1 - 1
direct/src/task/Task.py

@@ -519,7 +519,7 @@ class TaskManager:
                         self.stop()
                         print_exc_plus()
                     else:
-                        if (ExceptionVarDump.wantVariableDump and
+                        if (ExceptionVarDump.wantStackDumpLog and
                             ExceptionVarDump.dumpOnExceptionInit):
                             ExceptionVarDump._varDump__print(e)
                         raise