def writeStackTraceSummary(stackLog): ''' Collapse duplicate stack traces... ''' traceDict = {} for id, traceList in StackInfo.getTraces().iteritems(): trace = ''.join(traceList) if trace not in traceDict: traceDict[trace] = [] traceDict[trace].append(id) for trace, idList in traceDict.iteritems(): for id in idList: stackLog.write(str(id) + '\n') stackLog.write("".join(trace)) stackLog.write('-----------------------------------------------------------------\n')
def printExcessThreads(self, finalThreads, originalThreads): """Prints a stack trace for any thread in 'lookIn' that doesn't exit in 'lookFor' """ origThreadIds = set([id(x) for x in originalThreads]) stacktraces = StackInfo.getTraces() for thread in finalThreads: if id(thread) not in origThreadIds: print "Thread: ", thread print 'Stack:\n', ''.join(stacktraces[thread.ident]) managedThread = ManagedThread.ManagedThread.threadByObjectId(id(thread)) if managedThread is not None: print "Thread Spawned From:" print ''.join(managedThread.creatorStacktrace) print
def writeStackTraceSummary(stackLog): ''' Collapse duplicate stack traces... ''' traceDict = {} for id, traceList in StackInfo.getTraces().iteritems(): trace = ''.join(traceList) if trace not in traceDict: traceDict[trace] = [] traceDict[trace].append(id) for trace, idList in traceDict.iteritems(): for id in idList: stackLog.write(str(id) + '\n') stackLog.write("".join(trace)) stackLog.write( '-----------------------------------------------------------------\n' )
def __str__(self): traces = StackInfo.getTraces() if self.ident in traces: return 'ManagedThread(%s)' % "".join(traces[self.ident]) else: return "ManagedThread(<unknown>)"