1、#EMBEDDEDOSSUMMITLeveraging Compiler Code Instrumentation for Tracing&ProfilingGustavo Romero andKevin Townsend,Linaro gromero microbuilderTuring:.every time the command goes around the loop it will put a pulse in the loudspeaker and you will hear a frequency equal to how long it takes to go around
2、that loop,.you would soon learn to listen to that and know whether when the program got hung up in a loop or something else or what it was doing all this time.(1950).Claude Shannon,in A Mind at Play,p.108.-Tracing and Profiling=dynamic analyses(runtime)-In theory,they can capture almost any info on
3、the system behavior or state as if it was running in real life/production conditions-However,they can cause an observer effect,so disturb the runtime.But the disturbances may be negligible,if properly designed and understoodMotivation-Trace&profile without any financial or license barrier-Dont depen
4、d on additional HW,or proprietary and expensive tooling/software(e.g.J-Link,etc)-Significant platform limitations(gprof,which only supports a few platforms,often emulated,with no timestamps)-Show at a very low level and complete way which function in kernel or application code is being called and wh
5、en-Have a simple CLI tool for tracing&profiling,like Linux perf and ftraceCompiler instrumentation-Several types of code instrumentation are supported by GCC and Clang:-code coverage analysis-profile-guided optimizations.also used for runtime checks(out-of-bound array check,nullptr,stack)-and,finall
6、y,for collecting profile statistics!Compiler instrumentationFlags of interest here:1)-finstrument-functions-finstrument-functions-exclude-file-list=file,file,-finstrument-functions-exclude-function-list=sym,sym,2)-fpatchable-function-entry=N,M-fno-optimize-sibling-callsCompiler instrumentation-finst