Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bcc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
bcc
Commits
40e55baa
Commit
40e55baa
authored
Feb 09, 2016
by
Sasha Goldshtein
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added interval and count options per *stat tool conventions
parent
e5b4ffeb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
7 deletions
+14
-7
tools/memleak.py
tools/memleak.py
+14
-7
No files found.
tools/memleak.py
View file @
40e55baa
...
@@ -174,30 +174,33 @@ allocations made with kmalloc/kfree.
...
@@ -174,30 +174,33 @@ allocations made with kmalloc/kfree.
parser
=
argparse
.
ArgumentParser
(
description
=
description
,
parser
=
argparse
.
ArgumentParser
(
description
=
description
,
formatter_class
=
argparse
.
RawDescriptionHelpFormatter
,
formatter_class
=
argparse
.
RawDescriptionHelpFormatter
,
epilog
=
examples
)
epilog
=
examples
)
parser
.
add_argument
(
"-p"
,
"--pid"
,
parser
.
add_argument
(
"-p"
,
"--pid"
,
type
=
int
,
help
=
"the PID to trace; if not specified, trace kernel allocs"
)
help
=
"the PID to trace; if not specified, trace kernel allocs"
)
parser
.
add_argument
(
"-t"
,
"--trace"
,
action
=
"store_true"
,
parser
.
add_argument
(
"-t"
,
"--trace"
,
action
=
"store_true"
,
help
=
"print trace messages for each alloc/free call"
)
help
=
"print trace messages for each alloc/free call"
)
parser
.
add_argument
(
"
-i"
,
"--interval"
,
default
=
5
,
parser
.
add_argument
(
"
interval"
,
nargs
=
"?"
,
default
=
5
,
type
=
int
,
help
=
"interval in seconds to print outstanding allocations"
)
help
=
"interval in seconds to print outstanding allocations"
)
parser
.
add_argument
(
"count"
,
nargs
=
"?"
,
type
=
int
,
help
=
"number of times to print the report before exiting"
)
parser
.
add_argument
(
"-a"
,
"--show-allocs"
,
default
=
False
,
action
=
"store_true"
,
parser
.
add_argument
(
"-a"
,
"--show-allocs"
,
default
=
False
,
action
=
"store_true"
,
help
=
"show allocation addresses and sizes as well as call stacks"
)
help
=
"show allocation addresses and sizes as well as call stacks"
)
parser
.
add_argument
(
"-o"
,
"--older"
,
default
=
500
,
parser
.
add_argument
(
"-o"
,
"--older"
,
default
=
500
,
type
=
int
,
help
=
"prune allocations younger than this age in milliseconds"
)
help
=
"prune allocations younger than this age in milliseconds"
)
parser
.
add_argument
(
"-c"
,
"--command"
,
parser
.
add_argument
(
"-c"
,
"--command"
,
help
=
"execute and trace the specified command"
)
help
=
"execute and trace the specified command"
)
parser
.
add_argument
(
"-s"
,
"--sample-rate"
,
default
=
1
,
parser
.
add_argument
(
"-s"
,
"--sample-rate"
,
default
=
1
,
type
=
int
,
help
=
"sample every N-th allocation to decrease the overhead"
)
help
=
"sample every N-th allocation to decrease the overhead"
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
pid
=
-
1
if
args
.
pid
is
None
else
int
(
args
.
pid
)
pid
=
-
1
if
args
.
pid
is
None
else
args
.
pid
command
=
args
.
command
command
=
args
.
command
kernel_trace
=
(
pid
==
-
1
and
command
is
None
)
kernel_trace
=
(
pid
==
-
1
and
command
is
None
)
trace_all
=
args
.
trace
trace_all
=
args
.
trace
interval
=
int
(
args
.
interval
)
interval
=
args
.
interval
min_age_ns
=
1e6
*
int
(
args
.
older
)
min_age_ns
=
1e6
*
args
.
older
sample_every_n
=
args
.
sample_rate
sample_every_n
=
args
.
sample_rate
num_prints
=
args
.
count
if
command
is
not
None
:
if
command
is
not
None
:
print
(
"Executing '%s' and tracing the resulting process."
%
command
)
print
(
"Executing '%s' and tracing the resulting process."
%
command
)
...
@@ -246,6 +249,7 @@ def print_outstanding():
...
@@ -246,6 +249,7 @@ def print_outstanding():
print
(
"
\
t
%d bytes in %d allocations from stack
\
n
\
t
\
t
%s"
%
print
(
"
\
t
%d bytes in %d allocations from stack
\
n
\
t
\
t
%s"
%
(
size
,
count
,
stack
.
replace
(
";"
,
"
\
n
\
t
\
t
"
)))
(
size
,
count
,
stack
.
replace
(
";"
,
"
\
n
\
t
\
t
"
)))
count_so_far
=
0
while
True
:
while
True
:
if
trace_all
:
if
trace_all
:
print
bpf_program
.
trace_fields
()
print
bpf_program
.
trace_fields
()
...
@@ -256,3 +260,6 @@ while True:
...
@@ -256,3 +260,6 @@ while True:
exit
()
exit
()
decoder
.
refresh_code_ranges
()
decoder
.
refresh_code_ranges
()
print_outstanding
()
print_outstanding
()
count_so_far
+=
1
if
num_prints
is
not
None
and
count_so_far
>=
num_prints
:
exit
()
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