Overview

The functracer is a specialized, tracing-based debugging tool. It collects backtraces, arguments and return value of functions specified in a plugin. It works with optimized (-O2) code, where debugging symbols are available either in the application binaries themselves, or in separate debug files.

Currently, functracer has the following plugins implemented: "memory" (used by default, when no plugin is specified), "file", "memtransfer", "gobject", "thread-resource", "shmsysv", "shmposix" and "audit".

Project Information

  • functracer is distributed under the terms of the GPLv2+ license

  • the code is managed with git at: git://gitorious.org/maemo-tools/functracer.git

Installation

Unfortunately blocked by https://bugs.launchpad.net/linaro-ubuntu/+bug/832686. Once available it should be included automatically at the developer image, and also available at the Overlay PPA for any other Linaro based image.

Using functracer

$ functracer -s -r uname
version=2.0, arch=i686, timestamp=24.08.2011 06:29:02, process=uname, pid=14250, backtrace depth=10, origin=functracer 1.2.1, 
<1> : memory (memory allocation in bytes)
Process/Thread 14250 (uname) was created
: /bin/uname => 0x8048000-0x804d000
: /lib/i386-linux-gnu/ld-2.13.so => 0xed9000-0xef5000
0. [02:10:32.697] memalign(745) = 0xef6918
        0xeeddc5 in malloc+0x25
        0xeede08 in calloc+0x38
        0xee3843 in _dl_rtld_di_serinfo+0x21f3
        0xedb00e <undefined>
        0xeeceee in _dl_make_stack_executable+0x229e
        0xedda10 <undefined>
        0xed9857 <undefined>

1. [02:10:32.699] memalign(184) = 0xef6c08
        0xeeddc5 in malloc+0x25
        0xeed61c in _dl_make_stack_executable+0x29cc
        0xee0877 <undefined>
        0xedb9bd <undefined>
        0xeeceee in _dl_make_stack_executable+0x229e
        0xedda10 <undefined>
        0xed9857 <undefined>

2. [02:10:32.703] memalign(20) = 0xef6cc0
        0xeeddc5 in malloc+0x25
        0xee088c <undefined>
        0xedb9bd <undefined>
        0xeeceee in _dl_make_stack_executable+0x229e
        0xedda10 <undefined>
        0xed9857 <undefined>

3. [02:10:32.705] memalign(6200) = 0xb78a9000
        0xeeddc5 in malloc+0x25
        0xee08c6 <undefined>
        0xedb9bd <undefined>
        0xeeceee in _dl_make_stack_executable+0x229e
        0xedda10 <undefined>
        0xed9857 <undefined>

4. [02:10:32.708] memalign(30) = 0xb78aa838
        0xeeddc5 in malloc+0x25
        0xedde3f <undefined>
        0xee1093 <undefined>
        0xee5a50 in _dl_rtld_di_serinfo+0x4400
        0xee74d6 in _dl_rtld_di_serinfo+0x5e86
        0xee5bfa in _dl_rtld_di_serinfo+0x45aa
        0xedbb67 <undefined>
        0xeeceee in _dl_make_stack_executable+0x229e
        0xedda10 <undefined>
        0xed9857 <undefined>

5. [02:10:32.713] memalign(626) = 0xb78aa858
        0xeeddc5 in malloc+0x25
        0xeede08 in calloc+0x38
        0xee3843 in _dl_rtld_di_serinfo+0x21f3
        0xedef90 <undefined>
        0xee0e93 <undefined>
        0xee5a50 in _dl_rtld_di_serinfo+0x4400
        0xee74d6 in _dl_rtld_di_serinfo+0x5e86
        0xee5bfa in _dl_rtld_di_serinfo+0x45aa
        0xedbb67 <undefined>
        0xeeceee in _dl_make_stack_executable+0x229e

6. [02:10:32.714] memalign(30) = 0xb78aaad0
        0xeeddc5 in malloc+0x25
        0xee3a71 in _dl_rtld_di_serinfo+0x2421
        0xedef90 <undefined>
        0xee0e93 <undefined>
        0xee5a50 in _dl_rtld_di_serinfo+0x4400
        0xee74d6 in _dl_rtld_di_serinfo+0x5e86
        0xee5bfa in _dl_rtld_di_serinfo+0x45aa
        0xedbb67 <undefined>
        0xeeceee in _dl_make_stack_executable+0x229e
        0xedda10 <undefined>

7. [02:10:32.715] memalign(20) = 0xb78aaaf0
        0xeeddc5 in malloc+0x25
        0xee5c67 in _dl_rtld_di_serinfo+0x4617
        0xedbb67 <undefined>
        0xeeceee in _dl_make_stack_executable+0x229e
        0xedda10 <undefined>
        0xed9857 <undefined>

8. [02:10:32.716] memalign(28) = 0xb78aab08
        0xeeddc5 in malloc+0x25
        0xee5de9 in _dl_rtld_di_serinfo+0x4799
        0xedbb67 <undefined>
        0xeeceee in _dl_make_stack_executable+0x229e
        0xedda10 <undefined>
        0xed9857 <undefined>

9. [02:10:32.717] memalign(144) = 0xb78aab28
        0xeeddc5 in malloc+0x25
        0xeede08 in calloc+0x38
        0xee8c85 in _dl_debug_state+0xe15
        0xee8ee9 in _dl_debug_state+0x1079
        0xedd73e <undefined>
        0xee75aa in _dl_rtld_di_serinfo+0x5f5a
        0xedbc2c <undefined>
        0xeeceee in _dl_make_stack_executable+0x229e
        0xedda10 <undefined>
        0xed9857 <undefined>

10. [02:10:32.718] memalign(512) = 0xb78aabb8
        0xeeddc5 in malloc+0x25
        0xeede08 in calloc+0x38
        0xee8c85 in _dl_debug_state+0xe15
        0xee8ee9 in _dl_debug_state+0x1079
        0xedd73e <undefined>
        0xee75aa in _dl_rtld_di_serinfo+0x5f5a
        0xedbc2c <undefined>
        0xeeceee in _dl_make_stack_executable+0x229e
        0xedda10 <undefined>
        0xed9857 <undefined>

11. [02:10:32.719] memalign(112) = 0xb78aadb8
        0xeeddc5 in malloc+0x25
        0xeede08 in calloc+0x38
        0xee8c85 in _dl_debug_state+0xe15
        0xee8ee9 in _dl_debug_state+0x1079
        0xedd73e <undefined>
        0xee75aa in _dl_rtld_di_serinfo+0x5f5a
        0xedbc2c <undefined>
        0xeeceee in _dl_make_stack_executable+0x229e
        0xedda10 <undefined>
        0xed9857 <undefined>

12. [02:10:32.721] memalign(520) = 0xb789c000
        0xeeddc5 in malloc+0x25
        0xeede08 in calloc+0x38
        0xedab20 <undefined>
        0xedc564 <undefined>
        0xeeceee in _dl_make_stack_executable+0x229e
        0xedda10 <undefined>
        0xed9857 <undefined>

13. [02:10:32.722] memalign(2896) = 0xb789c210
        0xeea152 in _dl_get_tls_static_info+0x62
        0xedab75 <undefined>
        0xedc564 <undefined>
        0xeeceee in _dl_make_stack_executable+0x229e
        0xedda10 <undefined>
        0xed9857 <undefined>

14. [02:10:32.722] memalign(136) = 0xb789cd60
        0xeeddc5 in malloc+0x25
        0xeede08 in calloc+0x38
        0xee9cb8 in _dl_mcount+0x518
        0xeea19d in _dl_get_tls_static_info+0xad
        0xedab75 <undefined>
        0xedc564 <undefined>
        0xeeceee in _dl_make_stack_executable+0x229e
        0xedda10 <undefined>
        0xed9857 <undefined>

: /lib/i386-linux-gnu/libc-2.13.so => 0xa21000-0xb7b000
Process/Thread 14250 received signal 11
Process/Thread 14250 has exited with code 11

The traces output by functracer can be post-processed (resolved, visualized) by the sp-rtrace tools.

Save the trace output into a file.

functracer -s -r uname > func-out.txt

After the output is saved, one can do something like:

sp-rtrace-postproc -cl < func-out.txt > rtrace-out.txt

to merge identical backtraces (loses their order) and remove freed allocations from the trace.

Then one can use:

sp-rtrace-resolve < rtrace-out.txt > resolved-out.txt

to resolve the function & C++ method names. Resolving is as good as by Gdb & Valgrind, if debug symbols are installed.

After that, e.g. rtrace-calltree can be used to get callgraphs.

rtrace-calltree rtrace-out.txt > rtrace-calltree.dot

which can later be viewed by tools like dotty etc.

Note

The functracer "-a" option allows getting backtraces to calls of specified set of functions/methods (which can be hidden/static if debug symbols are present). "-a" option cannot track resources, but if one needs that for arbitrary functions, one can (fairly easily) write his own module for that.


CategoryHowTo

Platform/DevPlatform/Tools/Functracer (last modified 2011-09-21 11:38:00)