diff options
author | Wei Huang <weih@google.com> | 2009-09-16 10:11:15 -0700 |
---|---|---|
committer | Wei Huang <weih@google.com> | 2009-09-16 16:00:10 -0700 |
commit | 8aa7e9325c26657a47a8b8ed82219c3c173bf5ed (patch) | |
tree | 7daa94e27ffbd90138d818c27a194760404d94de /tools | |
parent | b257c944e15c5be46a69143603426c7ce137e6a3 (diff) | |
download | android_dalvik-8aa7e9325c26657a47a8b8ed82219c3c173bf5ed.tar.gz android_dalvik-8aa7e9325c26657a47a8b8ed82219c3c173bf5ed.tar.bz2 android_dalvik-8aa7e9325c26657a47a8b8ed82219c3c173bf5ed.zip |
modify gclog to take a procFilter argument, as well as the debug argument
Change-Id: Id897031b76f41600b7665ae27521167c70092247
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/gclog.py | 63 |
1 files changed, 47 insertions, 16 deletions
diff --git a/tools/gclog.py b/tools/gclog.py index 4696965ed..4d5b7042f 100755 --- a/tools/gclog.py +++ b/tools/gclog.py @@ -15,8 +15,6 @@ # limitations under the License. # -# Version 1.0, 29-Apr-2009 -# # Parse event log output, looking for GC events. Format them for human # consumption. # @@ -28,10 +26,15 @@ # The data is generated by dalvik/vm/alloc/HeapDebug.c. # +import getopt +import sys import os import re import time +DEBUG = False # DEBUG is a global variable + + def unfloat12(f12): """Unpack a float12 value""" if f12 < 0: @@ -128,36 +131,41 @@ def parseExternalStats(value): return ( footprint, total, limit, bytes ) -def handleGcInfo(timestamp, pid, values): +def handleGcInfo(procFilter, timestamp, pid, values): """Handle a single dvm_gc_info event""" pid = int(pid) global_info = parseGlobalInfo(values[0]) + + if len(procFilter) > 0: + if global_info[0] != procFilter: + return + heap_stats = parseAggHeapStats(values[1]) zygote = parseZygoteStats(values[2]) external = parseExternalStats(values[3]) - debug = False - if debug: - print "RAW: %s %s (%s,%s,%s,%s)" % \ - (timestamp, pid, values[0], values[1], values[2], values[3]) + print "%s %s(%d) softlim=%dKB, extlim=%dKB, extalloc=%dKB" % \ + (timestamp, global_info[0], pid, zygote[0]/1024, external[2]/1024, external[3]/1024) - print "> id=\"%s\" time=%d freed=%d" % (global_info[0], global_info[1], global_info[2]) - print "> freed=%d foot=%d allow=%d objs=%d bytes=%d" % \ + if DEBUG: + # print "RAW: %s %s (%s,%s,%s,%s)" % \ + # (timestamp, pid, values[0], values[1], values[2], values[3]) + + print "+ id=\"%s\" time=%d freed=%d" % (global_info[0], global_info[1], global_info[2]) + print "+ freed=%d foot=%d allow=%d objs=%d bytes=%d" % \ (heap_stats[0], heap_stats[1], heap_stats[2], heap_stats[3], heap_stats[4]) - print "> soft=%d act=%d allow=%d objs=%d bytes=%d" % \ + print "+ soft=%d act=%d allow=%d objs=%d bytes=%d" % \ (zygote[0], zygote[1], zygote[2], zygote[3], zygote[4]) - print "> foot=%d total=%d limit=%d alloc=%d" % \ + print "+ foot=%d total=%d limit=%d alloc=%d" % \ (external[0], external[1], external[2], external[3]) - print "%s %s(%d) softlim=%dKB, extlim=%dKB, extalloc=%dKB" % \ - (timestamp, global_info[0], pid, zygote[0]/1024, external[2]/1024, external[3]/1024) print " freed %d objects / %d bytes in %dms" % \ (heap_stats[0], global_info[2], global_info[1]) -def filterInput(logPipe): +def filterInput(logPipe, processFilter): """Loop until EOF, pulling out GC events""" # 04-29 20:31:00.334 I/dvm_gc_info( 69): [8320808730292729543,-8916699241518090181,-4006371297196337158,8165229] @@ -182,18 +190,41 @@ def filterInput(logPipe): #print "no match on %s" % line.strip() continue else: - handleGcInfo(match.group(1), match.group(2), ( match.group(3), \ + handleGcInfo(processFilter, match.group(1), match.group(2), ( match.group(3), \ match.group(4), match.group(5), match.group(6) ) ) +def PrintUsage(): + print "usage: %s [-p procFilter] [-d]" % sys.argv[0] + + def start(): """Entry point""" + global DEBUG + + procFilter = "" + + opts, args = getopt.getopt(sys.argv[1:], "hdp:") + + for opt, val in opts: + if opt == "-h": + PrintUsage() + sys.exit(2) + elif opt == "-p": + procFilter = val + elif opt == "-d": + DEBUG = True + + print "procfilter = %s" % procFilter + print "DEBUG = %s" % DEBUG + # launch a logcat and read from it command = 'adb logcat -v time -b events' logPipe = os.popen(command) + try: - filterInput(logPipe) + filterInput(logPipe, procFilter) except KeyboardInterrupt, err: print "Stopping on keyboard interrupt." |