Commit 4178c47c authored by ussrhero's avatar ussrhero
Browse files

added filtering by bugcheck code

parent 699b938b
......@@ -31,6 +31,14 @@ class DumpModule(object):
def getUniqueId(self):
return "%s_%x" % (self.name, self.timestamp)
class DumpCrashInfo(object):
def __init__(self):
self.bugCheckCode, _, _, _, _ = pykd.bugCheckData()
def getUniqueId(self):
return self.bugCheckCode
def buildDumpDesc(name):
global moduleInfoProvider
......@@ -50,6 +58,8 @@ class DumpDesc(object):
self.modules = [ DumpModule(m) for m in targetSystem.currentProcess().modules() ]
self.desc = pykd.getSystemVersion().buildString
self.crashInfo = DumpCrashInfo()
self.status = DumpStatus.Success
except:
print ("error")
......@@ -95,7 +105,20 @@ def getUniqueModuleList(dumpDescList, moduleFilter):
uniqueModules[moduleId] = module
return uniqueModules.values()
def getUniqueCrashList(dumpDescList, crashFilter):
uniqueCrashInfo = {}
for dump in dumpDescList:
if crashFilter == '' or eval(crashFilter, globals(), dump.crashInfo ):
crashId = dump.crashInfo.getUniqueId()
if not crashId in uniqueCrashInfo:
uniqueCrashInfo[crashId] = dump.crashInfo
return uniqueCrashInfo
def printModuleDiff(dumpDescList, moduleFilter, verbose, rate):
print( "============ Module diff ============")
......@@ -140,7 +163,7 @@ def printOsDiff(dumpDescList, verbose):
dumps = [ d for d in dumpDescList if d.desc == systemdesc ]
print ("System: %s in %d dumps" % ( systemdesc, len(dumps) ) )
print ("System: %s in %d%% dumps" % ( systemdesc, len(dumps)*100/len(dumpDescList) ) )
if verbose:
if len(dumps) == len(dumpDescList):
......@@ -150,6 +173,23 @@ def printOsDiff(dumpDescList, verbose):
print ("\t\t%s" % dump.dumpName)
def printCrashDiff(dumpDescList, crashFilter, verbose, rate):
print( "============ Crash diff ============" )
crashInfoList = getUniqueCrashList(dumpDescList, crashFilter)
for crash in crashInfoList.values():
dumps = [ dump for dump in dumpDescList if dump.crashInfo.getUniqueId() == crash.getUniqueId() ]
print ("BugCheck Code: %x in %d%% dumps" % ( crash.bugCheckCode, len(dumps)*100/len(dumpDescList) ) )
if verbose:
if len(dumps) == len(dumpDescList):
print ("\t\tin all dumps")
else:
for dump in dumps:
print ("\t\t%s" % dump.dumpName)
def printDiff(args):
t1 = time.time()
......@@ -164,17 +204,39 @@ def printDiff(args):
else:
dumpDescList = multiprocessing.Pool(args.processNumber).map( buildDumpDesc, dumpList )
print ( "parsed %d dumps in %d sec" % ( len(dumpList), time.time() - t1 ) )
print ( "\n" )
print ( "parsed %d dumps in %d sec\n" % ( len(dumpList), time.time() - t1 ) )
if args.moduleFilter:
print ("Module filter: \"%s\"\n" % args.moduleFilter)
if args.moduleFilter=="off":
print ("Module diff: off")
else:
if args.moduleFilter == None:
args.moduleFilter = ''
if args.moduleFilter == '':
print ("Module diff: on")
else:
print ("Module filter: \"%s\"" % args.moduleFilter)
if args.crashFilter=="off":
print ("Crash diff: off")
else:
if args.crashFilter == None:
args.crashFilter = ''
if args.crashFilter == '':
print ("Crash diff: on")
else:
print ("Crash filter: \"%s\"" % args.crashFilter)
print("")
printOsDiff( dumpDescList, args.verbose )
print ( "\n" )
print("")
printModuleDiff(dumpDescList, args.moduleFilter, args.verbose, args.rate)
if args.moduleFilter !="off":
printModuleDiff(dumpDescList, args.moduleFilter, args.verbose, args.rate)
if args.crashFilter !="off":
printCrashDiff(dumpDescList, args.crashFilter, args.verbose, args.rate)
def printHeader():
......@@ -190,7 +252,8 @@ def main():
parser.add_argument('-f', '--files', metavar='FILE', nargs='+', help='list of dump files')
parser.add_argument('-d', '--dir', metavar='DIRECTORY', help='directory with dump files')
parser.add_argument('-m', '--module', metavar='FILTER', dest = 'moduleFilter', help='module filter', default='not manufactor in ("Microsoft")' )
parser.add_argument('-m', '--module', metavar='FILTER', nargs='?', dest='moduleFilter', help='module filter', default='not manufactor in ("Microsoft")' )
parser.add_argument('-c', '--crash', dest = 'crashFilter', nargs='?', help='crash filter')
parser.add_argument('-v', '--verbose', help='verbose output', action='store_true', default=False)
parser.add_argument('-r', '--rate', help='filter dump by rate', type=int, default=0)
parser.add_argument('-p', '--processes', help='load dump on multi core', dest='processNumber', type=int, default=-1)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment