-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: iipeace <[email protected]>
- Loading branch information
Showing
1 changed file
with
79 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
__credits__ = "Peace Lee" | ||
__license__ = "GPLv2" | ||
__version__ = "3.9.8" | ||
__revision__ = "231127" | ||
__revision__ = "231128" | ||
__maintainer__ = "Peace Lee" | ||
__email__ = "[email protected]" | ||
__repository__ = "https://github.com/iipeace/guider" | ||
|
@@ -8433,11 +8433,11 @@ def convUnit2Time(data, isFloat=False, verb=True): | |
elif data.upper().endswith("M"): | ||
ret = unit(data[:-1]) * 60 | ||
elif data.upper().endswith("H"): | ||
ret = unit(data[:-1]) * 60 * 60 | ||
ret = unit(data[:-1]) * 3600 | ||
elif data.upper().endswith("D"): | ||
ret = unit(data[:-1]) * 60 * 60 * 24 | ||
ret = unit(data[:-1]) * 86400 | ||
elif data.upper().endswith("W"): | ||
ret = unit(data[:-1]) * 60 * 60 * 24 * 7 | ||
ret = unit(data[:-1]) * 604800 | ||
else: | ||
ret = 0 | ||
if verb: | ||
|
@@ -20589,7 +20589,7 @@ def printMemUsage(self): | |
if not subStack: | ||
continue | ||
else: | ||
ilen = len("\t" * 4 * 9) | ||
ilen = len("\t" * 36) | ||
symbolStack = self.makeUserSymList(subStack, ilen) | ||
|
||
SysMgr.printPipe( | ||
|
@@ -20680,7 +20680,7 @@ def printMemUsage(self): | |
if not subStack: | ||
continue | ||
else: | ||
ilen = len("\t" * 4 * 9) | ||
ilen = len("\t" * 36) | ||
symbolStack = self.makeKernelSymList(subStack, ilen) | ||
|
||
SysMgr.printPipe( | ||
|
@@ -35164,6 +35164,10 @@ def printHelp(force=False, isExit=True): | |
- Print ld(loader) info | ||
# {0:1} {1:1} {2:1} -q PRINTLD | ||
|
||
- Print file access info | ||
# {0:1} {1:1} {2:1} -q PRINTFILE | ||
# {0:1} {1:1} {2:1} -c "write|rdfd:0" -q PRINTFILE -o | ||
|
||
- Except for ld(loader) info | ||
# {0:1} {1:1} {2:1} -q EXCEPTLD | ||
|
||
|
@@ -80636,6 +80640,7 @@ class Debugger(object): | |
"PRINTARG": False, | ||
"PRINTDIFF": False, | ||
"PRINTDELAY": False, | ||
"PRINTFILE": False, | ||
"PRINTHIST": False, | ||
"PYSTACK": False, | ||
"SHOWADDR": False, | ||
|
@@ -83614,6 +83619,8 @@ def _getFunc(): | |
# get path # | ||
try: | ||
path = self.readFdPath(fd) | ||
if Debugger.envFlags["PRINTFILE"]: | ||
self.addFileAccess(sym, path) | ||
except: | ||
path = "??" | ||
|
||
|
@@ -85050,6 +85057,24 @@ def loadPyLib(self): | |
) | ||
return False | ||
|
||
def addFileAccess(self, func, path, cnt=1): | ||
if not self.pathData: | ||
self.pathData["total"] = {"total": 0} | ||
self.pathData["total"]["total"] += cnt | ||
|
||
if func in self.pathData: | ||
self.pathData[func]["total"] += cnt | ||
else: | ||
self.pathData[func] = {"total": cnt} | ||
|
||
if path in self.pathData[func]: | ||
self.pathData[func][path] += cnt | ||
else: | ||
self.pathData[func] = { | ||
"total": cnt, | ||
path: cnt, | ||
} | ||
|
||
def dlopen(self, fname, flags=None): | ||
# check fname # | ||
if not os.path.exists(fname): | ||
|
@@ -86550,6 +86575,8 @@ def convSyscallParam( | |
if argname in ("fd", "sockfd"): | ||
try: | ||
path = self.readFdPath(value) | ||
if Debugger.envFlags["PRINTFILE"]: | ||
self.addFileAccess(syscall, path) | ||
return "%s>%s" % (value, path) | ||
except SystemExit: | ||
sys.exit(0) | ||
|
@@ -93099,6 +93126,7 @@ def initValues(self, fork=True): | |
self.prevPyIndent = {} | ||
self.pretty = not SysMgr.findOption("Q") | ||
self.mmapList = {} | ||
self.pathData = {} | ||
|
||
# save tgid info # | ||
try: | ||
|
@@ -94689,6 +94717,43 @@ def _printSystemStat(): | |
|
||
SysMgr.printPipe(oneLine + suffix) | ||
|
||
# print access files # | ||
if instance.envFlags["PRINTFILE"]: | ||
SysMgr.printPipe( | ||
"\n[Access File Summary] [NrFunc: %s] [NrAccess: %s] %s%s" | ||
% ( | ||
convert(len(instance.pathData) - 1), | ||
convert(instance.pathData["total"]["total"]), | ||
suffix, | ||
twoLine, | ||
) | ||
) | ||
SysMgr.printPipe( | ||
"{0:10} {1:>10} {2:1}\n{3:1}".format( | ||
"Func(Cnt)", "Cnt", "Path", oneLine | ||
) | ||
) | ||
|
||
for func, fval in sorted( | ||
instance.pathData.items(), | ||
key=lambda x: x[1]["total"], | ||
reverse=True, | ||
): | ||
if func == "total": | ||
continue | ||
SysMgr.printPipe( | ||
"%s(%s)" % (func, convert(fval.pop("total", 0))) | ||
) | ||
for fpath, fstat in sorted( | ||
fval.items(), key=lambda x: x[1], reverse=True | ||
): | ||
SysMgr.printPipe( | ||
"{0:10} {1:>10} {2:1}".format( | ||
" ", convert(fstat), fpath | ||
) | ||
) | ||
SysMgr.printPipe(oneLine) | ||
|
||
# print history # | ||
instance.printCallHistory(instance, ctype) | ||
|
||
|
@@ -126106,17 +126171,21 @@ def printFileStat(self, filters): | |
with open(fdinfoPath, "r") as infofd: | ||
for item in infofd.readlines(): | ||
name, val = item.split(":", 1) | ||
val = val.strip() | ||
|
||
if name == "pos": | ||
attr += "%s" % val.strip() | ||
attr += "%s" % val | ||
elif name == "flags": | ||
perm = long(val.strip(), 8) | ||
perm = long(val, 8) | ||
perm = UtilMgr.getFlagString( | ||
perm, ConfigMgr.OPEN_TYPE, num="oct" | ||
) | ||
attr += ", %s" % perm | ||
elif name in ("size", "count", "exp_name"): | ||
elif name in ("size", "exp_name", "count", "ino"): | ||
try: | ||
val = val.strip() | ||
if name != "size": | ||
raise Exception() | ||
|
||
val = long(val) | ||
if name == "size": | ||
val = UtilMgr.convSize2Unit( | ||
|