-
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.
hprof: Fix empty line parsing bug for java dump
Signed-off-by: iipeace <[email protected]>
- Loading branch information
Showing
1 changed file
with
58 additions
and
37 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__ = "241031" | ||
__revision__ = "241101" | ||
__maintainer__ = "Peace Lee" | ||
__email__ = "[email protected]" | ||
__repository__ = "https://github.com/iipeace/guider" | ||
|
@@ -42983,9 +42983,8 @@ def _getDesc(s, t=0): | |
- Report from perfetto data | ||
# {0:1} {1:1} -I prof.data | ||
|
||
- Report from perfetto data without report | ||
- Convert perfetto data to text | ||
# {0:1} {1:1} -I prof.data -q FROMSAMPLE | ||
|
||
""".format( | ||
cmd, | ||
mode, | ||
|
@@ -50531,6 +50530,8 @@ def _getPacket(fd): | |
if packet == b"": | ||
raise Exception() | ||
yield packet | ||
except GeneratorExit: | ||
return None | ||
except SystemExit: | ||
sys.exit(0) | ||
except: | ||
|
@@ -59554,7 +59555,7 @@ def _waitTask(pid): | |
elif os.path.isfile("./traceconv"): | ||
binPath = "./traceconv" | ||
elif not UtilMgr.which("traceconv"): | ||
_printErr("no found traceconv") | ||
_printErr("no found traceconv, refer to help") | ||
return -1 | ||
else: | ||
binPath = "traceconv" | ||
|
@@ -60040,7 +60041,12 @@ def convHeapProfSample(path, scripts=[], statusDict={}): | |
"profile_packet", | ||
"interned_data", | ||
] | ||
|
||
# define shortcuts # | ||
convNum = UtilMgr.convNum | ||
convSize = UtilMgr.convSize2Unit | ||
convColor = UtilMgr.convColor | ||
convDict = UtilMgr.convDict2Str | ||
|
||
# parse lines # | ||
pid = 0 | ||
|
@@ -60077,6 +60083,8 @@ def _getLine(scripts): | |
line = line.decode() | ||
yield idx, line.rstrip("\n") | ||
idx += 1 | ||
except GeneratorExit: | ||
return idx, None | ||
except SystemExit: | ||
sys.exit(0) | ||
except: | ||
|
@@ -60095,41 +60103,53 @@ def _getLine(scripts): | |
0 if totalLength == 0 else idx, totalLength | ||
) | ||
totalSize += len(l) | ||
l = l.rstrip() | ||
|
||
if l.startswith("packet {"): | ||
# parse a line # | ||
l = l.rstrip() | ||
if not l: | ||
continue | ||
elif l.startswith("packet {"): | ||
buf = ["{"] | ||
elif l.startswith("}"): | ||
# make JSON object # | ||
encoded = ("".join(buf).rstrip(",") + "}").replace("\\", "\\\\") | ||
json = UtilMgr.convStr2Dict(encoded, True, True) | ||
|
||
# save data # | ||
if json: | ||
# update timestamp # | ||
ts = json.get("timestamp") | ||
if ts: | ||
ts = long(ts) / 1000000000 | ||
if not start: | ||
start = ts | ||
else: | ||
last = ts | ||
|
||
# save packets # | ||
for s in sourceList: | ||
v = json.get(s) | ||
if not v: | ||
continue | ||
|
||
# duplicated # | ||
if s in packets: | ||
if not isinstance(type(packets[s]), list): | ||
packets[s] = [packets[s]] | ||
packets[s].append(v) | ||
else: | ||
packets[s] = v | ||
json = UtilMgr.convStr2Dict(encoded, False, True) | ||
|
||
# reset buffer # | ||
buf = [] | ||
|
||
# check object # | ||
if not json: | ||
SysMgr.printWarn( | ||
"failed to make JSON object at %s line in sample" | ||
% convNum(idx), | ||
True | ||
) | ||
continue | ||
|
||
# update timestamp # | ||
ts = json.get("timestamp") | ||
if ts: | ||
ts = long(ts) / 1000000000 | ||
if not start: | ||
start = ts | ||
else: | ||
last = ts | ||
|
||
# save packets # | ||
for s in sourceList: | ||
v = json.get(s) | ||
if not v: | ||
continue | ||
|
||
# add duplicated item to list # | ||
if s in packets: | ||
pitem = packets[s] | ||
if not isinstance(type(pitem), list): | ||
packets[s] = [pitem] | ||
packets[s].append(v) | ||
else: | ||
packets[s] = v | ||
elif l.endswith("{"): | ||
l = '"%s": {' % l.rsplit("{", 1)[0].strip() | ||
buf.append(l) | ||
|
@@ -60171,7 +60191,7 @@ def _saveSysInfo(pstr): | |
continue | ||
|
||
# convert meta info # | ||
pstr = UtilMgr.convDict2Str(packets[x]) | ||
pstr = convDict(packets[x]) | ||
if not pstr: | ||
continue | ||
|
||
|
@@ -60273,8 +60293,9 @@ def _saveSysInfo(pstr): | |
# process profile samples # | ||
# callstack_id, self_allocated, self_freed, alloc_count, free_count # | ||
for p in profData if isinstance(profData, list) else [profData]: | ||
# convert dict to list # | ||
if not isinstance(p, list): | ||
subp = [p] | ||
p = [p] | ||
|
||
for subp in p: | ||
# check type # | ||
|
@@ -60293,7 +60314,7 @@ def _saveSysInfo(pstr): | |
|
||
# print profiling info # | ||
if pdata: | ||
pstr = UtilMgr.convDict2Str(pdata) | ||
pstr = convDict(pdata) | ||
if SysMgr.warnEnable: | ||
_printWarn("[prof_info]: " + pstr, True) | ||
else: | ||
|
@@ -60464,8 +60485,6 @@ def _saveSysInfo(pstr): | |
return -1 | ||
|
||
# print stats # | ||
convNum = UtilMgr.convNum | ||
convSize = UtilMgr.convSize2Unit | ||
statStr = "" | ||
for sn, sv in totalStats.items(): | ||
if not sv: | ||
|
@@ -67516,6 +67535,8 @@ def _getPage(fd): | |
if page == b"": | ||
raise Exception() | ||
yield page | ||
except GeneratorExit: | ||
return None | ||
except SystemExit: | ||
sys.exit(0) | ||
except: | ||
|