LMDBG is an application that allows detecting memory leaksand double frees. However, unlike others, LMDBG generates *FULL* stacktracesand separates logging from analysis thusallowing to analyse an application on per-module basis.
- lmdbg-run is a main lmdbg utility. It runs an application and creates a log file (or fifo) where all called malloc/calloc/realloc/free/memalign/posix_memalign invocations are registered with their input (bytes count, pointer), output (pointer) and (!!!uniques feature!!!) FULL STACKTRACE (pointers).
Example:
$ cat tests/test2.c
#include
int main ()
{
void *p1 = NULL;
void *p2 = NULL;
p1 = malloc (555);
p2 = realloc (p2, 666);
p2 = realloc (p2, 777);
p2 = realloc (p2, 888);
return 0;
}
$ gcc -O0 -g -o _test2 tests/test2.c
$ lmdbg-run -o _log ./_test2
$ cat _log
malloc ( 555 ) --> 0xbb901400
0xbbbe58e8
0xbbbe5b03
0x8048738
0x8048584
0x80484e7
realloc ( NULL , 666 ) --> 0xbb901800
0xbbbe58e8
0xbbbe5a37
0x804874e
0x8048584
0x80484e7
realloc ( 0xbb901800 , 777 ) --> 0xbb901c00
0xbbbe58e8
0xbbbe5a37
0x8048764
0x8048584
0x80484e7
realloc ( 0xbb901c00 , 888 ) --> 0xbb901800
0xbbbe58e8
0xbbbe5a37
0x804877a
0x8048584
0x80484e7
$
NOTE: Full stacktrace allows you to analyse your application, i.e. you can detect what blocks/components require more memory than others and why. lmdbg-sym is a very important tool for this, see below.
- lmdbg-leaks analyses a log file generated by lmdbg-run and output all found memory leaks
Example:
$ lmdbg-leaks _log
realloc ( 0xbb901c00 , 888 ) --> 0xbb901800
0xbbbe58e8
0xbbbe5a37
0x804877a
0x8048584
0x80484e7
malloc ( 555 ) --> 0xbb901400
0xbbbe58e8
0xbbbe5b03
0x8048738
0x8048584
0x80484e7
$
- lmdbg-sym converts addresses to source.c:999 if it is possible
Example (gdb(1) is in action):
$ lmdbg-sym ./_test2 _log
malloc ( 555 ) --> 0xbb901400
0xbbbe58e8
0xbbbe5b03
0x8048738 tests/test2.c:8 main
0x8048584
0x80484e7
realloc ( NULL , 666 ) --> 0xbb901800
0xbbbe58e8
0xbbbe5a37
0x804874e tests/test2.c:9 main
0x8048584
0x80484e7
realloc ( 0xbb901800 , 777 ) --> 0xbb901c00
0xbbbe58e8
0xbbbe5a37
0x8048764 tests/test2.c:10 main
0x8048584
0x80484e7
realloc ( 0xbb901c00 , 888 ) --> 0xbb901800
0xbbbe58e8
0xbbbe5a37
0x804877a tests/test2.c:11 main
0x8048584
0x80484e7
$
Example (addr2line(1) works here):
$ lmdbg-sym -a ./_test2 _log
malloc ( 555 ) --> 0xbb901400
0xbbbe58e8
0xbbbe5b03
0x8048738 tests/test2.c:8
0x8048584
0x80484e7
realloc ( NULL , 666 ) --> 0xbb901800
0xbbbe58e8
0xbbbe5a37
0x804874e tests/test2.c:9
0x8048584
0x80484e7
realloc ( 0xbb901800 , 777 ) --> 0xbb901c00
0xbbbe58e8
0xbbbe5a37
0x8048764 tests/test2.c:10
0x8048584
0x80484e7
realloc ( 0xbb901c00 , 888 ) --> 0xbb901800
0xbbbe58e8
0xbbbe5a37
0x804877a tests/test2.c:11
0x8048584
0x80484e7
$
- lmdbg-sysleaks - greps or skips system memory leaks found in libc, libdl, C++ stl etc. See tests/lmdbg*.conf files. The default config files are: ~/.lmdbg.conf and /etc/lmdbg.conf
- lmdbg = lmdbg-run + lmdbg-leaks + lmdbg-sym + lmdbg-sysleaks
That is lmdbg is all-in-one higher level tool.
Example:
$ lmdbg -v -o _log ./_test2
Memory leaks were detected and saved to file '_log'
$ cat _log
realloc ( 0xbb901c00 , 888 ) --> 0xbb901800
0xbbbe58e8
0xbbbe5a37
0x804877a tests/test2.c:11 main
0x8048584
0x80484e7
malloc ( 555 ) --> 0xbb901400
0xbbbe58e8
0xbbbe5b03
0x8048738 tests/test2.c:8 main
0x8048584
0x80484e7
$
What is new in this release:
- lmdbg-sym no longer segfaults due to problems with stacktrace(3).
- A much simpler and correct address conversion method was added.
- There were significant speedups due to optimizations for gdb.
- In lmdbg-run, GLIBC malloc hooks are no longer used.
- lmdbg's own code is not included in stacktraces.
- A new -N option was added, and the -v option received a minor fix.
- lmdbg-stat received fixes for a NULL dereference that appeared if a free(3) or realloc(3) stacktrace was without an appropriate malloc/realloc(3) stacktrace.
- There were other minor fixes and improvements, improvements in regression tests, and improvements in stacktrace(3).
What is new in version 1.1.0:
- A fix in regression tests.
- lmdbg-run: zero addresses are removed from stacktraces generated by glibc's backtrace(3).
- This fixes asserts in lmdbg-stat(1).
- Double "0x" issues in the "info section" were fixed (seen on NetBSD).
- backtrace(3) from libexecinfo (if available) is used instead of the built-in implementation.
- lmdbg-sym: a few bugs were fixed in conversion of addresses to symbols.
- lmdbg-stat: incompletely read lines are now ignored, so there are no more assert(3)s when an application being debugged is killed.
- An alternative implementation written in awk was removed.
What is new in version 0.17.0:
- This version adds a lot of improvements and fixes in manual pages, new capabilities in lmdbg, lmdbg-run, and lmdbg-sym, and minor fixes to lmdbg-stat.
- lmdbg is now a meta tool which is able to do many more things, not just find memory leaks.
What is new in version 0.15.1:
- Logging of calloc(3) invocations is disabled on glibc-based systems (Linux, GNU/kFreeBSD, and maybe others) because lmdbg-run fails on them.
- Minor clean-ups, fixes, and improvements. mk-configure >= 0.20 is required for building.
What is new in version 0.14.0:
- New tools: lmdbg-stat, lmdbg-grep and lmdbg-sort for collecting and analysing statistical information about memory allocations.
- lmdbg-run: new options for lmdbg-run: -S and -M for generating shortened stacktraces.
- lmdbg-sym: new option -p for obtaining program name from lmdbg-run's output.
- fix: 'mkcmake test' removes its temporary files.
Comments not found