blob: bfa53ebfc28e9d100230eb01dd954f5deecf1c5b [file] [log] [blame]
Sumit Garg444bd732019-04-09 18:40:02 +05301.. _ftrace:
2
3Ftrace
4######
5This section describes how to generate function call graph for user Trusted
6Applications using ``ftrace``.
7
8The configuration option ``CFG_TA_FTRACE_SUPPORT=y`` enables OP-TEE to collect
9function graph information from Trusted Applications running in user mode and
10compiled with ``-pg``. Once collected, the function graph data is formatted
11in the ``ftrace.out`` format and sent to ``tee-supplicant`` via RPC, so they
12can be saved to disk, later processed and displayed using helper script called
13``symbolize.py`` present as part of ``optee_os`` repo.
14
15Usage
16*****
17
18 - Build OP-TEE OS and OP-TEE Client with ``CFG_TA_FTRACE_SUPPORT=y``. You
19 may also set ``CFG_ULIBS_MCOUNT=y`` in OP-TEE OS to instrument the
20 user TA libraries (libutee, libutils, libmpa).
21
22 - Build user TAs with ``-pg``, for instance enable ``CFG_TA_MCOUNT=y`` to
23 instrument whole TA. Also, in case user wants to set ``-pg`` for a
24 particular file, following should go in corresponding sub.mk:
25 ``cflags-<file-name>-y+=-pg``. Note that instrumented TAs have a larger
26 ``.bss`` section. The memory overhead depends on ``CFG_FTRACE_BUF_SIZE``
27 macro which can be configured specific to user TAs using config:
28 ``CFG_FTRACE_BUF_SIZE=4096`` (default value: 2048, refer to the TA linker
29 script for details: ``ta/arch/arm/ta.ld.S``).
30
31 - Run the application normally. When the current session exits or there is
32 any abort during TA execution, ``tee-supplicant`` will write function
33 graph data to ``/tmp/ftrace-<ta_uuid>.out``. If the file already exists,
34 a number is appended, such as: ``ftrace-<ta_uuid>.1.out``.
35
36 - Run helper script called ``symbolize.py`` to translate the function graph
37 addresses into function names: ``cat ftrace-<ta_uuid>.out |
38 ./optee_os/scripts/symbolize.py -d <ta_uuid>.elf``