# Instrumenting with Omnitrace ```eval_rst .. toctree:: :glob: :maxdepth: 4 ``` ## omnitrace Executable Instrumentation is performed with the `omnitrace` executable. View the help menu with the `-h` / `--help` option: ```shell $ omnitrace --help [omnitrace] Usage: omnitrace [ --help (count: 0, dtype: bool) --debug (max: 1, dtype: bool) --verbose (max: 1, dtype: bool) --error (max: 1, dtype: boolean) --simulate (max: 1, dtype: bool) --print-format (min: 1, dtype: string) --print-dir (count: 1, dtype: string) --print-available (count: 1) --print-instrumented (count: 1) --print-excluded (count: 1) --print-overlapping (count: 1) --output (count: 1) --pid (count: 1, dtype: int) --mode (count: 1) --command (count: 1) --prefer (count: 1) --library (count: unlimited) --main-function (count: 1) --driver (max: 1, dtype: boolean) --load (count: unlimited, dtype: string) --load-instr (count: unlimited, dtype: filepath) --init-functions (count: unlimited, dtype: string) --fini-functions (count: unlimited, dtype: string) --function-include (count: unlimited) --function-exclude (count: unlimited) --module-include (count: unlimited) --module-exclude (count: unlimited) --label (count: unlimited, dtype: string) --default-components (count: unlimited, dtype: string) --env (count: unlimited) --mpi (max: 1, dtype: bool) --instrument-loops (max: 1, dtype: boolean) --min-address-range (count: 1, dtype: int) --min-address-range-loop (count: 1, dtype: int) --dynamic-callsites (max: 1, dtype: boolean) --traps (max: 1, dtype: bool) --loop-traps (max: 1, dtype: bool) --allow-overlapping (count: 0, dtype: bool) --batch-size (count: 1, dtype: int) --dyninst-options (count: unlimited) ] -- Options: -h, -?, --help Shows this page [DEBUG OPTIONS] --debug Debug output -v, --verbose Verbose output -e, --error All warnings produce runtime errors --simulate Exit after outputting diagnostic {available,instrumented,excluded,overlapping} module function lists, e.g. available-instr.txt --print-format [ json | txt | xml ] Output format for diagnostic {available,instrumented,excluded,overlapping} module function lists, e.g. {print-dir}/available-instr.txt --print-dir Output directory for diagnostic {available,instrumented,excluded,overlapping} module function lists, e.g. {print-dir}/available-instr.txt --print-available [ functions | functions+ | modules | pair | pair+ ] Print the available entities for instrumentation (functions, modules, or module-function pair) to stdout applying regular expressions and exit --print-instrumented [ functions | functions+ | modules | pair | pair+ ] Print the instrumented entities (functions, modules, or module-function pair) to stdout after applying regular expressions and exit --print-excluded [ functions | functions+ | modules | pair | pair+ ] Print the entities for instrumentation (functions, modules, or module-function pair) which are excluded from the instrumentation to stdout after applying regular expressions and exit --print-overlapping [ functions | functions+ | modules | pair | pair+ ] Print the entities for instrumentation (functions, modules, or module-function pair) which overlap other function calls or have multiple entry points to stdout applying regular expressions and exit [MODE OPTIONS] -o, --output Enable generation of a new executable (binary-rewrite) -p, --pid Connect to running process -M, --mode [ sampling | trace ] Instrumentation mode. 'trace' mode instruments the selected functions, 'sampling' mode only instruments the main function to start and stop the sampler. -c, --command Input executable and arguments (if '-- ' not provided) [LIBRARY OPTIONS] --prefer [ shared | static ] Prefer this library types when available -L, --library Libraries with instrumentation routines (default: "libomnitrace") -m, --main-function The primary function to instrument around, e.g. 'main' --driver Force main or _init/_fini instrumentation --load Supplemental instrumentation library names w/o extension (e.g. 'libinstr' for 'libinstr.so' or 'libinstr.a') --load-instr Load {available,instrumented,excluded,overlapping}-instr JSON or XML file(s) and override what is read from the binary --init-functions Initialization function(s) for supplemental instrumentation libraries (see '--load' option) --fini-functions Finalization function(s) for supplemental instrumentation libraries (see '--load' option) [SYMBOL SELECTION OPTIONS] -I, -R, --function-include Regex for selecting functions -E, --function-exclude Regex for excluding functions -MI, -MR, --module-include Regex for selecting modules/files/libraries -ME, --module-exclude Regex for excluding modules/files/libraries [RUNTIME OPTIONS] --label [ args | file | line | return ] Labeling info for functions. By default, just the function name is recorded. Use these options to gain more information about the function signature or location of the functions -d, --default-components Default components to instrument (only useful when timemory is enabled in omnitrace library) --env Environment variables to add to the runtime in form VARIABLE=VALUE. E.g. use '--env OMNITRACE_USE_TIMEMORY=ON' to default to using timemory instead of perfetto --mpi Enable MPI support (requires omnitrace built w/ MPI and GOTCHA support). NOTE: this will automatically be activated if MPI_Init/MPI_Init_thread and MPI_Finalize are found in the symbol table of target [GRANULARITY OPTIONS] -l, --instrument-loops Instrument at the loop level -r, --min-address-range If the address range of a function is less than this value, exclude it from instrumentation --min-address-range-loop If the address range of a function containing a loop is less than this value, exclude it from instrumentation --dynamic-callsites Force instrumentation if a function has dynamic callsites (e.g. function pointers) --traps Instrument points which require using a trap. On the x86 architecture, because instructions are of variable size, the instruction at a point may be too small for Dyninst to replace it with the normal code sequence used to call instrumentation. Also, when instrumentation is placed at points other than subroutine entry, exit, or call points, traps may be used to ensure the instrumentation fits. In this case, Dyninst replaces the instruction with a single-byte instruction that generates a trap. --loop-traps Instrument points within a loop which require using a trap (only relevant when --instrument-loops is enabled). --allow-overlapping Allow dyninst to instrument either multiple functions which overlap (share part of same function body) or single functions with multiple entry points. For more info, see Section 2 of the DyninstAPI documentation. [DYNINST OPTIONS] -b, --batch-size Dyninst supports batch insertion of multiple points during runtime instrumentation. If one large batch insertion fails, this value will be used to create smaller batches. Larger batches generally decrease the instrumentation time --dyninst-options [ BaseTrampDeletion | DebugParsing | DelayedParsing | InstrStackFrames | MergeTramp | SaveFPR | TrampRecursive | TypeChecking ] Advanced dyninst options: BPatch::set