I am trying to debug a flow and for which I am trying to make use of -finstrument-functions compiler option. I have successfully written up below method and created trace.o object file:
void __cyg_profile_func_enter(void* this_fn, void* call_site)
__attribute__((no_instrument_function));
void __cyg_profile_func_exit(void* this_fn, void* call_site)
__attribute__((no_instrument_function));
It works well with sample code and I get function address logged in file from where I can extract file:function name.
In our project code there around 1500 files so I have added the below code in my CMakeLists.txt file:
SET(GCC_COVERAGE_COMPILE_FLAGS "-finstrument-functions")
add_definitions(${GCC_COVERAGE_COMPILE_FLAGS})
The above config ensures that all my source code files are compiled with -finstrument-functions compiler flag.
To ensure that I link trace.o file I am trying the below method:
SET(OBJS
/c/work/trace.o #path to trace.o in my system
)
SET_SOURCE_FILES_PROPERTIES(
${OBJS}
PROPERTIES
EXTERNAL_OBJECT true
GENERATED true
)
But during compilation of my project code I get below error:
Test.cpp.obj: In function `cc::cppx::cMethod(int, int*, int&)':
Test.cpp:16: undefined reference to `__cyg_profile_func_enter'
Test.cpp:17: undefined reference to `__cyg_profile_func_exit'
Test.cpp.obj: In function `__gthread_active_p':
C:/tools/mingw64/x86_64-w64-mingw32/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:304: undefined reference to `__cyg_profile_func_enter'
C:/tools/mingw64/x86_64-w64-mingw32/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:304: undefined reference to `__cyg_profile_func_exit'
Test.cpp.obj: In function `__exchange_and_add_single':
C:/tools/mingw64/x86_64-w64-mingw32/include/c++/ext/atomicity.h:66: undefined reference to `__cyg_profile_func_enter'
C:/tools/mingw64/x86_64-w64-mingw32/include/c++/ext/atomicity.h:68: undefined reference to `__cyg_profile_func_exit'
Test.cpp.obj: In function `forward<cc::cppx::TestInvoke_lambda_with_args_byvalue_ptr_ref_Test::TestBody()::<lambda(int, int*, int&)>&>':
C:/tools/mingw64/x86_64-w64-mingw32/include/c++/bits/move.h:76: undefined reference to `__cyg_profile_func_enter'
C:/tools/mingw64/x86_64-w64-mingw32/include/c++/bits/move.h:76: undefined reference to `__cyg_profile_func_exit'
Test.cpp.obj: In function `operator()':
Test.cpp:54: undefined reference to `__cyg_profile_func_enter'
Test.cpp:56: undefined reference to `__cyg_profile_func_exit'
Test.cpp.obj: In function `__exchange_and_add':
C:/tools/mingw64/x86_64-w64-mingw32/include/c++/ext/atomicity.h:49: undefined reference to `__cyg_profile_func_enter'
C:/tools/mingw64/x86_64-w64-mingw32/include/c++/ext/atomicity.h:49: undefined reference to `__cyg_profile_func_exit'
Test.cpp.obj: In function `__tcf_0':
I am trying hard to find ways how to achieve my objective but it is not sorting the issue - is there a way the same can be setup?