Files
rocm-systems/examples/rewrite-caller/rewrite-caller.cpp
T
Mészáros Gergely 1b8f09aa2d instrumentation: include functions with specific calls (#202)
* instrumentation: include functions with specific calls

Add the option `--caller-include <regex>` or environment variable
`OMNITRACE_REGEX_CALLER_INCLUDE` to instrument functions which contain
call to a set of functions, E.g. `--caller-include foo` instruments any
function which calls `foo`.

* Serialize caller include information

* Add test for caller include

* Tweak to the caller include test

- tweak environment
- tweak pass regexes

* Set rewrite caller example to debug

, to avoid optimizing out the call expressions that it relies on.

Co-authored-by: Jonathan R. Madsen <jonathanrmadsen@gmail.com>
2022-11-11 02:32:57 -06:00

38 строки
588 B
C++

#include <cstdio>
#include <cstdlib>
#include <string>
#define NOINLINE __attribute__((noinline))
int num_calls;
void NOINLINE
inner()
{
++num_calls;
}
void NOINLINE
outer()
{
inner();
}
int
main(int argc, char** argv)
{
int ncalls = 10;
if(argc > 1) ncalls = atol(argv[1]);
std::string _name = argv[0];
auto _pos = _name.find_last_of('/');
if(_pos != std::string::npos) _name = _name.substr(_pos + 1);
for(int i = 0; i < ncalls; ++i)
{
outer();
}
printf("[%s] number of calls made = %d\n", _name.c_str(), num_calls);
}