Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
halo
dalvik
Commits
8aa7e932
Commit
8aa7e932
authored
15 years ago
by
Wei Huang
Browse files
Options
Download
Email Patches
Plain Diff
modify gclog to take a procFilter argument, as well as the debug argument
Change-Id: Id897031b76f41600b7665ae27521167c70092247
parent
b257c944
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
16 deletions
+47
-16
tools/gclog.py
tools/gclog.py
+47
-16
No files found.
tools/gclog.py
View file @
8aa7e932
...
...
@@ -14,8 +14,6 @@
# See the License for the specific language governing permissions and
# 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."
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment