A tool to annotate functions with c++ TRACE_EVENT. This tool serves two workflows:
The goal of this tool is to transfer a function:
int foo(int bar, int baz) { return 42; }
into:
int foo(int bar, int baz) { TRACE_EVENT0("test", "foo"); return 42; }
In future also argument tracing is to be supported.
This document is based on //docs/clang_tool_refactoring.md
The following might take approx. 2 hours depending on your computer.
shell cr build all To make sure all files have been generated.shell cp -R third_party/llvm-build ~--without-fuchsia --extra-tools trace_annotator``` * TODO how to build with plugin 'find-bad-constructs'?
shell cd third_party/llvm-build/Release+Assertsshell ninja trace_annotatorBeware that running shell gclient sync might overwrite the build and another full build might be necessary. A backup of the binary from //third_party/llvm-build/Release+Asserts/bin/trace_annotator might be useful.
shell tools/clang/scripts/test_tool.py --apply-edits trace_annotatorChrome plugins are not supported yet, run: shell gn args out/Debug/ and add: clang_use_chrome_plugins = false option.
Make sure you have up to date compilation database:
shell tools/clang/scripts/generate_compdb.py -p out/Debug/ > out/Debug/compile_commands.jsongit checkout $DIR && tools/clang/scripts/run_tool.py --tool trace_annotator -p out/Debug/ $DIR \ | tools/clang/scripts/extract_edits.py \ | tools/clang/scripts/apply_edits.py -p out/Debug $DIR \ && git cl format $DIR```
Consult documentation of //tools/clang/scripts/run_tool.py for more options.
Do not run the tool on //base or anything that has to do with tracing or synchronization. Or at least do not submit the resulting patch.
shell git add . ; git commitshell git add . ; git commitshell git add . ; git commitshell git rebase -i and follow the help.c++ #ifdef OS_WIN will not be annotated.shell gclient sync).