9
thread = nt.typedVar( "_KTHREAD", getCurrentThread() )
11
stackPointer = addr64( reg("rsp") if is64bitSystem() else reg("esp") )
15
if stackPointer >= addr64(thread.StackLimit):
16
dprintln( "Stack Base: %x Limit: %x Current: %x Used: %x Unused: %x" %
17
( thread.InitialStack, thread.StackLimit, stackPointer, addr64(thread.InitialStack) - stackPointer, stackPointer - addr64(thread.StackLimit) ) )
19
dprintln( "Stack Base: %x Limit: %x Current: %x Used: %x !!!Overflow!!!: %x" %
20
( thread.InitialStack, thread.StackLimit, stackPointer, addr64(thread.InitialStack) - stackPointer, addr64(thread.StackLimit) - stackPointer ) )
34
for i in range( 0, len(stk) -1 ):
37
mod = module( stk[i].ret )
41
delta = stk[i+1].fp - stk[i].fp
44
moduleName = mod.name()
46
if moduleName in moduleLst:
47
moduleLst[moduleName] = moduleLst[moduleName] + delta
49
moduleLst[moduleName] = delta
51
func = moduleName + "!" + mod.findSymbol( stk[i].ret, showDisplacement = False )
54
funcLst[func] = funcLst[func] + delta
60
thread = nt.typedVar( "_KTHREAD", getThreadOffset( getCurrentThread() ) )
62
stackSize = thread.InitialStack - thread.StackLimit
65
dprintln( "%12s\t%s" % ("Stack usage:", "Module:" ) )
68
for mod,delta in sorted( moduleLst.iteritems(), key=lambda x: x[1], reverse=True ):
69
dprintln( "%7d%5s\t%s" % (delta, "(%%%d)" % (delta*100/stackSize), mod ) )
72
dprintln( "%12s\t%s" % ("Stack usage:", "Function" ) )
75
for func,delta in sorted( funcLst.iteritems(), key=lambda x: x[1], reverse=True ):
76
dprintln( "%7d%5s\t%s" % (delta, "(%%%d)" % (delta*100/stackSize), func ) )
84
dprintln( "Stack Delta:\tFunction:")
86
for i in range( 0, len(stk) -1 ):
87
dprint( "%12s\t" % long( stk[i+1].fp - stk[i].fp) )
89
mod = module( stk[i].ret )
90
dprintln( "%s!%s"% ( mod.name(), mod.findSymbol( stk[i].ret, showDisplacement = False ) ) )
92
dprintln( findSymbol( stk[i].ret ) )
97
if sys.argv[1] == "stat":
103
if __name__ == "__main__":