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>
This commit is contained in:
1 parent
654beef6ab
commit
1b8f09aa2d
8 files changed
+115
-1
No files matched your search
@@ -45,3 +45,4 @@ add_subdirectory(mpi)
|
||||
add_subdirectory(python)
|
||||
add_subdirectory(lulesh)
|
||||
add_subdirectory(rccl)
|
||||
add_subdirectory(rewrite-caller)
|
||||
@@ -0,0 +1,24 @@
|
||||
cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
|
||||
|
||||
project(omnitrace-rewrite-caller-example LANGUAGES CXX)
|
||||
|
||||
if(OMNITRACE_DISABLE_EXAMPLES)
|
||||
get_filename_component(_DIR ${CMAKE_CURRENT_LIST_DIR} NAME)
|
||||
|
||||
if(${PROJECT_NAME} IN_LIST OMNITRACE_DISABLE_EXAMPLES OR ${_DIR} IN_LIST
|
||||
OMNITRACE_DISABLE_EXAMPLES)
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(CMAKE_BUILD_TYPE "Debug")
|
||||
|
||||
add_executable(rewrite-caller rewrite-caller.cpp)
|
||||
target_compile_options(rewrite-caller PRIVATE ${_FLAGS})
|
||||
|
||||
if(OMNITRACE_INSTALL_EXAMPLES)
|
||||
install(
|
||||
TARGETS rewrite-caller
|
||||
DESTINATION bin
|
||||
COMPONENT omnitrace-examples)
|
||||
endif()
|
||||
@@ -0,0 +1,37 @@
|
||||
#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);
|
||||
}
|
||||
Reference in new issue
Block a user