Skip to content

Commit 9462d33

Browse files
committed
upload client stack dump to event logs
1 parent 93583d7 commit 9462d33

File tree

3 files changed

+34
-10
lines changed

3 files changed

+34
-10
lines changed

direct/src/showbase/ExceptionVarDump.py

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,22 @@ def _varDump__print(exc):
6464
oldExcepthook = None
6565
# store these values here so that Task.py can always reliably access them
6666
# from its main exception handler
67-
wantVariableDump = False
67+
wantStackDumpLog = False
68+
wantStackDumpUpload = False
69+
variableDumpReasons = []
6870
dumpOnExceptionInit = False
6971

7072
class _AttrNotFound:
7173
pass
7274

7375
def _excepthookDumpVars(eType, eValue, tb):
74-
excStrs = traceback.format_exception(eType, eValue, tb)
76+
origTb = tb
77+
excStrs = traceback.format_exception(eType, eValue, origTb)
7578
s = 'printing traceback in case variable repr crashes the process...\n'
7679
for excStr in excStrs:
7780
s += excStr
7881
notify.info(s)
7982
s = 'DUMPING STACK FRAME VARIABLES'
80-
origTb = tb
8183
#import pdb;pdb.set_trace()
8284
#foundRun = False
8385
foundRun = True
@@ -158,15 +160,34 @@ def _excepthookDumpVars(eType, eValue, tb):
158160

159161
if foundRun:
160162
s += '\n'
161-
notify.info(s)
163+
if wantStackDumpLog:
164+
notify.info(s)
165+
if wantStackDumpUpload:
166+
excStrs = traceback.format_exception(eType, eValue, origTb)
167+
for excStr in excStrs:
168+
s += excStr
169+
timeMgr = None
170+
try:
171+
timeMgr = base.cr.timeManager
172+
except:
173+
try:
174+
timeMgr = simbase.air.timeManager
175+
except:
176+
pass
177+
if timeMgr:
178+
timeMgr.setStackDump(s)
179+
162180
oldExcepthook(eType, eValue, origTb)
163181

164-
def install():
182+
def install(log, upload):
165183
global oldExcepthook
166-
global wantVariableDump
184+
global wantStackDumpLog
185+
global wantStackDumpUpload
167186
global dumpOnExceptionInit
168187

169-
wantVariableDump = True
188+
wantStackDumpLog = log
189+
wantStackDumpUpload = upload
190+
170191
dumpOnExceptionInit = config.GetBool('variable-dump-on-exception-init', 0)
171192
if dumpOnExceptionInit:
172193
# this mode doesn't completely work because exception objects

direct/src/showbase/ShowBase.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,11 @@ class ShowBase(DirectObject.DirectObject):
5656

5757
def __init__(self, fStartDirect = True, windowType = None):
5858
__builtin__.__dev__ = config.GetBool('want-dev', 0)
59-
if config.GetBool('want-variable-dump', 0):
60-
ExceptionVarDump.install()
59+
logStackDump = (config.GetBool('log-stack-dump', 0) or
60+
config.GetBool('client-log-stack-dump', 0))
61+
uploadStackDump = config.GetBool('upload-stack-dump', (not __dev__))
62+
if logStackDump or uploadStackDump:
63+
ExceptionVarDump.install(logStackDump, uploadStackDump)
6164

6265
# Locate the directory containing the main program
6366
self.mainDir = ExecutionEnvironment.getEnvironmentVariable("MAIN_DIR")

direct/src/task/Task.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ def _profileFunc(numFrames=numFrames):
519519
self.stop()
520520
print_exc_plus()
521521
else:
522-
if (ExceptionVarDump.wantVariableDump and
522+
if (ExceptionVarDump.wantStackDumpLog and
523523
ExceptionVarDump.dumpOnExceptionInit):
524524
ExceptionVarDump._varDump__print(e)
525525
raise

0 commit comments

Comments
 (0)