sdk/tools/heaptrack.git
10 years agoUse unw_backtrace instead of manual unw_step loop.
Milian Wolff [Mon, 2 Jun 2014 17:20:37 +0000 (19:20 +0200)]
Use unw_backtrace instead of manual unw_step loop.

The former is potentially much more performant but may require some
work on libunwind, which I'm currently investigating.

10 years agoAdd warning about unknown executable format
Milian Wolff [Mon, 2 Jun 2014 14:50:02 +0000 (16:50 +0200)]
Add warning about unknown executable format

10 years agoEnable per-thread unwind caching.
Milian Wolff [Sat, 31 May 2014 23:34:32 +0000 (01:34 +0200)]
Enable per-thread unwind caching.

This is much more performant as libunwind will not also add another
serialization point, it will also trigger calls to sigprocmask for
every mutex lock/unlock.

10 years agoRefactor DUMP_MALLOC_TRACE_OUTPUT handling.
Milian Wolff [Sat, 31 May 2014 23:16:54 +0000 (01:16 +0200)]
Refactor DUMP_MALLOC_TRACE_OUTPUT handling.

Now we can set it to stderr or stdout/- to print directly to the
console. Other files get $$ replaced by the PID of the host app.
This allows us to set DUMP_MALLOC_TRACE_OUTPUT to /dev/null to
disable output.

10 years agoDo not add garbadge null-ip's from end-of-line.
Milian Wolff [Sat, 31 May 2014 23:16:01 +0000 (01:16 +0200)]
Do not add garbadge null-ip's from end-of-line.

10 years agoPrepend output file with 'malloctrace.' even when env var is not set.
Milian Wolff [Sat, 31 May 2014 22:58:21 +0000 (00:58 +0200)]
Prepend output file with 'malloctrace.' even when env var is not set.

Also add some code comments on future things to do.

10 years agoSimplify code and reduce overhead at trace time.
Milian Wolff [Sat, 31 May 2014 22:45:57 +0000 (00:45 +0200)]
Simplify code and reduce overhead at trace time.

We now evaluate the IP to module connection at evaluation time,
rather than during tracing to reduce the overhead. This also gets
rid of the rather large IP cache, thereby reducing the memory
overhead.

10 years agoSave ptr start and end address instead of start + size.
Milian Wolff [Sat, 31 May 2014 22:04:56 +0000 (00:04 +0200)]
Save ptr start and end address instead of start + size.

Also output that size.

10 years agoReturn early for now, without bzipping output files.
Milian Wolff [Mon, 26 May 2014 19:08:57 +0000 (21:08 +0200)]
Return early for now, without bzipping output files.

10 years agoAdd a threaded test application
Milian Wolff [Mon, 26 May 2014 19:08:28 +0000 (21:08 +0200)]
Add a threaded test application

10 years agoExtract some more information on the allocation data, such as a size histogram.
Milian Wolff [Fri, 23 May 2014 13:04:42 +0000 (15:04 +0200)]
Extract some more information on the allocation data, such as a size histogram.

10 years agoUse stack-allocated trace buffer.
Milian Wolff [Wed, 21 May 2014 20:39:46 +0000 (22:39 +0200)]
Use stack-allocated trace buffer.

This seems to be required in multithreaded applications as otherwise
I get random crashes or deadlocks...

10 years agoBreak when encountering zero-IP.
Milian Wolff [Wed, 28 May 2014 12:37:33 +0000 (14:37 +0200)]
Break when encountering zero-IP.

This is senseless imo. Also, continuing would be very slow as
libunwind would try to ask dwarf info for the next IP for that
address which is bad, performance wise. And again, it will never
find anything and we just pay for nothing.

10 years agoTake trace size into account for hash generation.
Milian Wolff [Wed, 28 May 2014 11:19:52 +0000 (13:19 +0200)]
Take trace size into account for hash generation.

10 years agoSkip instructions which we cannot make sense of.
Milian Wolff [Wed, 21 May 2014 19:59:04 +0000 (21:59 +0200)]
Skip instructions which we cannot make sense of.

10 years agoFixup environment passing via gdb to the library.
Milian Wolff [Wed, 21 May 2014 19:41:29 +0000 (21:41 +0200)]
Fixup environment passing via gdb to the library.

10 years agoAbort on failure.
Milian Wolff [Wed, 21 May 2014 19:41:17 +0000 (21:41 +0200)]
Abort on failure.

10 years agoPreallocate trace buffer once.
Milian Wolff [Wed, 21 May 2014 19:41:09 +0000 (21:41 +0200)]
Preallocate trace buffer once.

10 years agoCleanup environment
Milian Wolff [Wed, 21 May 2014 14:22:06 +0000 (16:22 +0200)]
Cleanup environment

10 years agoDisable error messages when dwarf info is missing.
Milian Wolff [Wed, 21 May 2014 13:57:45 +0000 (15:57 +0200)]
Disable error messages when dwarf info is missing.

10 years agoGet file and line from dwarf info if possible.
Milian Wolff [Wed, 21 May 2014 13:56:00 +0000 (15:56 +0200)]
Get file and line from dwarf info if possible.

10 years agoUpdate trace script.
Milian Wolff [Wed, 21 May 2014 13:19:29 +0000 (15:19 +0200)]
Update trace script.

10 years agoUse vectors everywhere and be pedantic about input data.
Milian Wolff [Wed, 21 May 2014 13:13:56 +0000 (15:13 +0200)]
Use vectors everywhere and be pedantic about input data.

10 years agoPrint total leaked bytes and number of allocations.
Milian Wolff [Wed, 21 May 2014 12:58:28 +0000 (14:58 +0200)]
Print total leaked bytes and number of allocations.

10 years agoDon't do manual reserve calls, its slower than the default way.
Milian Wolff [Wed, 21 May 2014 12:58:09 +0000 (14:58 +0200)]
Don't do manual reserve calls, its slower than the default way.

10 years agoIntroduce a memleak in the test app.
Milian Wolff [Wed, 21 May 2014 12:42:33 +0000 (14:42 +0200)]
Introduce a memleak in the test app.

10 years agoPrint top allocators and all leaks in a sorted way.
Milian Wolff [Wed, 21 May 2014 12:42:12 +0000 (14:42 +0200)]
Print top allocators and all leaks in a sorted way.

10 years agoRefactor code: work with just a single file and use vector for traces.
Milian Wolff [Wed, 21 May 2014 12:34:04 +0000 (14:34 +0200)]
Refactor code: work with just a single file and use vector for traces.

The latter will allow us to sort the traces later on for evaluation
purposes easily.

10 years agoDemangle function names.
Milian Wolff [Wed, 21 May 2014 12:33:44 +0000 (14:33 +0200)]
Demangle function names.

10 years agoRefactor malloc tracing, synchronize most of the stuff after all.
Milian Wolff [Wed, 21 May 2014 10:04:59 +0000 (12:04 +0200)]
Refactor malloc tracing, synchronize most of the stuff after all.

I completely forgot before that a free can follow a malloc in a
different thread which is perfectly fine. To support this, we must
centralize our data handler after all.

This is not too bad as we can merge the multi-thread data into one
file that way and have it interleaved properly which will be good
for later evaluation.

From a contention point of view, I tried to minimize it as much as
possible. Further evaluation and profiling will be done later.

10 years agoBring back trace and ip cache to reduce generated filesize.
Milian Wolff [Tue, 20 May 2014 13:08:14 +0000 (15:08 +0200)]
Bring back trace and ip cache to reduce generated filesize.

Also speeds up things as repeated large prints are actually quite
slow. Furthermore we extend the tool to actually interpret the data.

10 years agoCheck for valid malloc/free before handling it.
Milian Wolff [Tue, 20 May 2014 09:48:58 +0000 (11:48 +0200)]
Check for valid malloc/free before handling it.

10 years agoReserve place for 32 modules.
Milian Wolff [Tue, 20 May 2014 08:06:49 +0000 (10:06 +0200)]
Reserve place for 32 modules.

10 years agoReimplement backtrace reading and offload dwarf info interpretation.
Milian Wolff [Tue, 20 May 2014 07:33:29 +0000 (09:33 +0200)]
Reimplement backtrace reading and offload dwarf info interpretation.

This makes the profiling run much faster. The later evaluation is
not so performance critical then thereafter.

10 years agoFix regression I introduced
Milian Wolff [Tue, 20 May 2014 07:32:22 +0000 (09:32 +0200)]
Fix regression I introduced

10 years agoUse relative module offsets instead of baseAddress + address.
Milian Wolff [Mon, 19 May 2014 14:35:34 +0000 (16:35 +0200)]
Use relative module offsets instead of baseAddress + address.

10 years agoAdd kdev project file.
Milian Wolff [Mon, 19 May 2014 14:24:19 +0000 (16:24 +0200)]
Add kdev project file.

10 years agoAdd start of a malloc trace evaluation executable.
Milian Wolff [Mon, 19 May 2014 14:24:10 +0000 (16:24 +0200)]
Add start of a malloc trace evaluation executable.

This shows that we can do post-mortem address resolution.
Not yet really functional but enough for a quick test.

10 years agoRemove uuid code, not required for my usecase afaik.
Milian Wolff [Mon, 19 May 2014 14:23:10 +0000 (16:23 +0200)]
Remove uuid code, not required for my usecase afaik.

10 years agoCleanup code, insert data directly in a sorted order.
Milian Wolff [Mon, 19 May 2014 13:07:56 +0000 (15:07 +0200)]
Cleanup code, insert data directly in a sorted order.

10 years agoPort bsearch to C++ STL's std::lower_bound.
Milian Wolff [Mon, 19 May 2014 12:55:10 +0000 (14:55 +0200)]
Port bsearch to C++ STL's std::lower_bound.

10 years agoAdapt code to my coding style.
Milian Wolff [Mon, 19 May 2014 12:31:03 +0000 (14:31 +0200)]
Adapt code to my coding style.

10 years agoCleanup code a bit by removing unused functions.
Milian Wolff [Mon, 19 May 2014 12:25:33 +0000 (14:25 +0200)]
Cleanup code a bit by removing unused functions.

10 years agoGet proper dwarf-based backtraces with filename and line numbers.
Milian Wolff [Mon, 19 May 2014 06:26:44 +0000 (08:26 +0200)]
Get proper dwarf-based backtraces with filename and line numbers.

This code is based on the libbacktrace from GCC, see:
https://github.com/mirrors/gcc/tree/master/libbacktrace

Furthermore, we include btrace.{cpp,h} and CMakeLists.txt, based
on Vogl from Valve Software/RAD Game Tools, see:
https://github.com/ValveSoftware/vogl.git

10 years agoAdd todo on sub-tree matching
Milian Wolff [Fri, 16 May 2014 00:46:04 +0000 (02:46 +0200)]
Add todo on sub-tree matching

10 years agoDon't create single-entry trees output.
Milian Wolff [Thu, 15 May 2014 20:47:48 +0000 (22:47 +0200)]
Don't create single-entry trees output.

10 years agoSave memory, use unsigned int instead of size_t for ids.
Milian Wolff [Thu, 15 May 2014 20:42:42 +0000 (22:42 +0200)]
Save memory, use unsigned int instead of size_t for ids.

The number of call stacks should hopefully fit into that range.

10 years agoOnly print a given call-tree once
Milian Wolff [Thu, 15 May 2014 20:33:46 +0000 (22:33 +0200)]
Only print a given call-tree once

10 years agoStop at static_initialization_and_destruction
Milian Wolff [Thu, 15 May 2014 20:33:07 +0000 (22:33 +0200)]
Stop at static_initialization_and_destruction

10 years agoMove test files and compile them in debug mode.
Milian Wolff [Thu, 15 May 2014 20:32:34 +0000 (22:32 +0200)]
Move test files and compile them in debug mode.

10 years agoUse namespace std;
Milian Wolff [Thu, 15 May 2014 19:10:42 +0000 (21:10 +0200)]
Use namespace std;

10 years agoAdd kateconfig
Milian Wolff [Thu, 15 May 2014 18:51:38 +0000 (20:51 +0200)]
Add kateconfig

10 years agoWrite output into per-thread files and merge that then later.
Milian Wolff [Thu, 15 May 2014 18:10:50 +0000 (20:10 +0200)]
Write output into per-thread files and merge that then later.

10 years agoSkip handleMalloc properly.
Milian Wolff [Thu, 15 May 2014 17:43:46 +0000 (19:43 +0200)]
Skip handleMalloc properly.

10 years agoAdd support for posix_memalign, aligned_alloc and valloc.
Milian Wolff [Thu, 15 May 2014 17:37:14 +0000 (19:37 +0200)]
Add support for posix_memalign, aligned_alloc and valloc.

10 years agoHandle calloc.
Milian Wolff [Thu, 15 May 2014 17:24:02 +0000 (19:24 +0200)]
Handle calloc.

10 years agoHandle realloc
Milian Wolff [Thu, 15 May 2014 17:07:15 +0000 (19:07 +0200)]
Handle realloc

10 years agoAlso output calls to free
Milian Wolff [Thu, 15 May 2014 17:01:14 +0000 (19:01 +0200)]
Also output calls to free

10 years agoPrint full backtraces
Milian Wolff [Thu, 15 May 2014 16:26:30 +0000 (18:26 +0200)]
Print full backtraces

10 years agoMake it possible to run the malloc tracer in GDB easily.
Milian Wolff [Thu, 15 May 2014 16:00:09 +0000 (18:00 +0200)]
Make it possible to run the malloc tracer in GDB easily.

10 years agoCleanup code and only output function names once.
Milian Wolff [Thu, 15 May 2014 15:59:21 +0000 (17:59 +0200)]
Cleanup code and only output function names once.

Also don't keep them in memory afterwards. This means we'll need a
separate tool to interpret the data, but its much faster this way.

10 years agoCache unw_get_proc_name for the ip's we encounter
Milian Wolff [Thu, 15 May 2014 15:32:30 +0000 (17:32 +0200)]
Cache unw_get_proc_name for the ip's we encounter

10 years agoPrint caller of malloc/operator new/operator new[] instead of full backtrace.
Milian Wolff [Thu, 15 May 2014 15:08:17 +0000 (17:08 +0200)]
Print caller of malloc/operator new/operator new[] instead of full backtrace.

10 years agoOn-demand initialize real_* func ptrs.
Milian Wolff [Thu, 15 May 2014 14:27:27 +0000 (16:27 +0200)]
On-demand initialize real_* func ptrs.

We must not rely on static initialization order here.

10 years agoOnly local unwind is required
Milian Wolff [Thu, 15 May 2014 14:10:22 +0000 (16:10 +0200)]
Only local unwind is required

10 years agoadd c++ example
Milian Wolff [Thu, 15 May 2014 14:10:11 +0000 (16:10 +0200)]
add c++ example

10 years agoextend test.c a bit.
Milian Wolff [Thu, 15 May 2014 14:09:58 +0000 (16:09 +0200)]
extend test.c a bit.

10 years agoAdd simple malloc/free tracer
Milian Wolff [Thu, 15 May 2014 12:47:25 +0000 (14:47 +0200)]
Add simple malloc/free tracer

11 years agodon't trace child apps
Milian Wolff [Fri, 31 May 2013 16:55:36 +0000 (18:55 +0200)]
don't trace child apps

11 years agoAppend PID to output files
Milian Wolff [Fri, 31 May 2013 16:55:30 +0000 (18:55 +0200)]
Append PID to output files

11 years agoadd simple run script
Milian Wolff [Fri, 31 May 2013 16:08:18 +0000 (18:08 +0200)]
add simple run script

11 years agosimplify
Milian Wolff [Fri, 31 May 2013 16:07:53 +0000 (18:07 +0200)]
simplify

11 years agoMake output actually usable and also possible to dump to a custom file
Milian Wolff [Fri, 31 May 2013 15:51:02 +0000 (17:51 +0200)]
Make output actually usable and also possible to dump to a custom file

11 years agoMake output destination configurable
Milian Wolff [Fri, 31 May 2013 12:27:49 +0000 (14:27 +0200)]
Make output destination configurable

11 years agoOnly enable c++11 for c++ files
Milian Wolff [Fri, 31 May 2013 12:27:37 +0000 (14:27 +0200)]
Only enable c++11 for c++ files

11 years agoAdd test binary to verify that this trick also works with pure C applications
Milian Wolff [Fri, 31 May 2013 12:18:49 +0000 (14:18 +0200)]
Add test binary to verify that this trick also works with pure C applications

11 years agotrue instead of 1
Milian Wolff [Wed, 29 May 2013 23:16:58 +0000 (01:16 +0200)]
true instead of 1

11 years agofix usage message
Milian Wolff [Wed, 29 May 2013 23:03:12 +0000 (01:03 +0200)]
fix usage message

11 years agoUse raw pointer to not get a double delete on exit.
Milian Wolff [Wed, 29 May 2013 23:02:48 +0000 (01:02 +0200)]
Use raw pointer to not get a double delete on exit.

11 years agoAdd snapshot ID and timestamp to output.
Milian Wolff [Wed, 29 May 2013 23:02:32 +0000 (01:02 +0200)]
Add snapshot ID and timestamp to output.

11 years agoadd LGPL v2+ license
Milian Wolff [Wed, 29 May 2013 22:40:08 +0000 (00:40 +0200)]
add LGPL v2+ license

11 years agoInitial import of dumpmallocinfo.
Milian Wolff [Wed, 29 May 2013 22:29:12 +0000 (00:29 +0200)]
Initial import of dumpmallocinfo.

This is a little library that you can LD_PRELOAD to your application.
It will then call malloc_info in user-defined intervals (configured
via DUMP_MALLOC_INFO_INTERVAL environment variable).

See `man malloc_info 3` for more information.