7 $(basename $0) <leaksFile> [<options>] [<excludePatterns>]
11 A file containing the allocations with stack traces from
12 the guarded heap output.
14 To generate such a file run a program with the following
15 environment variables prefixed and pipe the output to a file:
17 LD_PRELOAD=libroot_debug.so MALLOC_DEBUG=ges50 program > file
19 The number after the "s" is the stack trace depth. Note that
20 there is an implementation defined maximum.
24 Do not exclude known statics and globals. By default a list of
25 excludes is used that removes known allocations that are never
26 freed by the system libraries.
30 Do not exclude allocations with no stack trace. By default
31 allocations without a stack trace are excluded. This should
32 only happen for very early allocations where the stack trace
33 setting has not yet been applied. The program should not be
34 able to generate such allocations.
38 Exclude allocations that match a regular expression. The
39 expression is matched against the whole text block of the
40 allocation, so can match in the header line as well as any
41 stack trace lines. Note that the whole block is on a single
42 line and newlines have been replaced with the caret (^)
45 Multiple exclude patterns can be specified as one argument each
46 and they will be ored to form the final expression.
61 while [ -z "$DONE_PARSING_OPTIONS" ]
64 --no-default-excludes)
73 echo "unrecognized option \"$1\" ignored"
77 DONE_PARSING_OPTIONS
=yes
83 function append_pattern
{
84 if [ -z "$EXCLUDE_PATTERN" ]
88 EXCLUDE_PATTERN
="$EXCLUDE_PATTERN|$1"
94 if [ -z "$NO_DEFAULTS" ]
96 declare -a DEFAULT_EXCLUDE_LIST
=( \
97 "<libroot.so> initialize_before " \
98 "<libroot.so> __cxa_atexit " \
99 "<libroot.so> BPrivate::Libroot::LocaleBackend::LoadBackend" \
100 "<libbe.so> initialize_before " \
101 "<libbe.so> initialize_after " \
102 "<libbe.so> _control_input_server_" \
103 "<libbe.so> BApplication::_InitGUIContext" \
104 "<libbe.so> BApplication::_InitAppResources" \
105 "<libbe.so> BResources::LoadResource" \
106 "<libbe.so> BClipboard::_DownloadFromSystem" \
107 "<libbe.so> BToolTipManager::_InitSingleton" \
108 "<libbe.so> BPrivate::WidthBuffer::StringWidth" \
109 "<libtracker.so> _init " \
110 "<libtranslation.so> BTranslatorRoster::Default" \
112 "<libicu[^.]+.so.[0-9]+> icu(_[0-9]+)?::" \
115 for EXCLUDE
in "${DEFAULT_EXCLUDE_LIST[@]}"
117 append_pattern
"$EXCLUDE"
122 if [ -z "$NO_EXCLUDE_EMPTY" ]
124 append_pattern
"^[^^]*\^$"
135 ALLOCATIONS
=$
(cat "$FILENAME" |
egrep "^allocation: |^ " |
tr '\n' '^' \
136 |
sed 's/\^a/~a/g' |
tr '~' '\n' |
sed 's/$/^/' | c
++filt
)
138 if [ ! -z "$EXCLUDE_PATTERN" ]
140 ALLOCATIONS
=$
(echo "$ALLOCATIONS" |
egrep -v "$EXCLUDE_PATTERN")
143 if [ -z "$ALLOCATIONS" ]
147 COUNT
=$
(echo "$ALLOCATIONS" |
wc -l)
151 echo "$ALLOCATIONS^total leaks: $COUNT" |
tr '^' '\n' |
less