Skip site navigation (1)Skip section navigation (2)

  
 
  

home | help
LMDBG(1)								LMDBG(1)

NAME
     lmdbg - memory debugging tool

SYNOPSIS
     lmdbg [OPTIONS] <prog> [args...]

DESCRIPTION
     lmdbg  runs  an  external	program prog , collects run-time information and
     saves it to a specified log file. More particulary, lmdbg is able	of:  de-
     coding  all symbols in the source code (function names, file name and posi-
     tion in the file); discovering all memory leaks (	-M  default  );  finding
     per-stacktrace memory leaks and ranking them from the largest to the small-
     est  (  -M leaks ); gathering (and ranking) various types of per-stacktrace
     run time statistics, such as the highest memory consumption (  -M	peak  ),
     the  number  of  calls to memory allocation functions ( -M allocs ) and the
     highest size of memory allocated by a single invocation of malloc	function
     ( -M max ).  To accomplish the above tasks, lmdbg , as a meta tool, manages
     a	set  of  low  level  lmdbg-*  utilities, namely, lmdbg-run, lmdbg-leaks,
     lmdbg-sym, lmdbg-sysleaks, lmdbg-sort and lmdbg-stat.

OPTIONS
     -h     Display the help message.

     -V     Display the lmdbg version.

     -o filename
	    Specify the log file to save data to.

     -M mode
	    Specify the task to do, mode is either of the following:

	    d or default
		   Show all stacktraces with memory leaks. This is the default.

	    l or leaks
		   Rank stacktraces by memory leaks.

	    p or peak
		   Rank stacktraces by the peak memory consumption.

	    a or allocs
		   Rank stacktraces by the number of calls to memory  allocation
		   functions.

	    m or max
		   Rank stacktraces by the highest amount of memory allocated in
		   a single invocation of malloc function.

     -c filename
	    This option is passed to lmdbg-sysleaks(1).

     -a     This option is passed to lmdbg-sym(1).

     -g     This option is passed to lmdbg-sym(1).

     -n     This option is passed to lmdbg-run(1).

     -T num
	    This option is passed to lmdbg-run(1).

     -B num
	    This option is passed to lmdbg-run(1).

     -v     Enable verbose mode.

FILES
     ~/.lmdbg.conf or /usr/local/etc/lmdbg.conf
	    lmdbg configuration file

EXAMPLE
     $ cat test3.c
     #include <stdlib.h>

     int main ()
     {
	int i;
	void *p1, *p2;
	p1 = malloc (900);
	for (i=0; i < 3; ++i){
	   p2 = realloc (NULL, 10+300*i);
	}
	free (p1);
	free (p2);

	return 0;
     }
     $ cc -O0 -g -o test3 test3.c
     $ lmdbg -o log ./test3; cat log
     realloc ( NULL , 10 ) --> 0xbb901040 num: 2
	   lmdbg.c:140	   log_stacktrace
	   lmdbg.c:545	   realloc
	   test3.c:9	   main

     realloc ( NULL , 310 ) --> 0xbb912140 num: 3
	   lmdbg.c:140	   log_stacktrace
	   lmdbg.c:545	   realloc
	   test3.c:9	   main

     $ lmdbg -M leaks -o log ./test3; cat log
     info progname ./test3
     info stat total_allocs: 2
     info stat total_free_cnt: 0
     info stat total_leaks: 320
     stacktrace peak: 320 max: 310 allocs: 2 leaks: 320
	   lmdbg.c:140	   log_stacktrace
	   lmdbg.c:545	   realloc
	   test3.c:9	   main

     $ lmdbg -M peak -o log ./test3; cat log
     info progname ./test3
     info stat total_allocs: 4
     info stat total_free_cnt: 2
     info stat total_leaks: 320
     stacktrace peak: 930 max: 610 allocs: 3 leaks: 320
	   lmdbg.c:140	   log_stacktrace
	   lmdbg.c:545	   realloc
	   test3.c:9	   main

     stacktrace peak: 900 max: 900 allocs: 1
	   lmdbg.c:140	   log_stacktrace
	   lmdbg.c:509	   malloc
	   test3.c:7	   main

     $ lmdbg -M max -o log ./test3; cat log
     info progname ./test3
     info stat total_allocs: 4
     info stat total_free_cnt: 2
     info stat total_leaks: 320
     stacktrace peak: 900 max: 900 allocs: 1
	   lmdbg.c:140	   log_stacktrace
	   lmdbg.c:509	   malloc
	   test3.c:7	   main

     stacktrace peak: 930 max: 610 allocs: 3 leaks: 320
	   lmdbg.c:140	   log_stacktrace
	   lmdbg.c:545	   realloc
	   test3.c:9	   main

     $ lmdbg -M allocs -o log ./test3; cat log
     info progname ./test3
     info stat total_allocs: 4
     info stat total_free_cnt: 2
     info stat total_leaks: 320
     stacktrace peak: 930 max: 610 allocs: 3 leaks: 320
	   lmdbg.c:140	   log_stacktrace
	   lmdbg.c:545	   realloc
	   test3.c:9	   main

     stacktrace peak: 900 max: 900 allocs: 1
	   lmdbg.c:140	   log_stacktrace
	   lmdbg.c:509	   malloc
	   test3.c:7	   main

     $

SEE ALSO
     lmdbg-run(1),  lmdbg-sym(1),  lmdbg-stat(1),  lmdbg-sort(1), lmdbg-grep(1),
     lmdbg-leaks(1), lmdbg-sysleaks(1), lmdbg-strip(1), lmdbg-modules(1)

AUTHOR
     Aleksey Cheusov <vle@gmx.net>

				  Nov 26, 2011				LMDBG(1)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=lmdbg&sektion=1&manpath=FreeBSD+Ports+15.1.quarterly>

home | help