mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-21 13:21:05 +00:00
test/auto-pts: compile-time selection of __gcov_dump vs. __gcov_flush
__gcov_flush is a private symbol in Clang 10 and cannot be resolved with dlsym
This commit is contained in:
parent
04dff67be0
commit
5ba066244f
@ -69,6 +69,23 @@ add_compile_options(--coverage)
|
||||
add_link_options( --coverage)
|
||||
add_definitions( -DCOVERAGE)
|
||||
|
||||
# figure out how to flush gcov data, clang 10 provides __gcov_flush, while clang 13 provides __gcov_dump
|
||||
message("Compiler: ${CMAKE_CXX_COMPILER_VERSION}")
|
||||
if ("${CMAKE_C_COMPILER_ID}" MATCHES ".*Clang.*")
|
||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 13)
|
||||
message("Using __gcov_dump")
|
||||
add_definitions( -DHAVE_GCOV_DUMP)
|
||||
else()
|
||||
message("Using __gcov_flush")
|
||||
add_definitions( -DHAVE_GCOV_FLUSH)
|
||||
endif()
|
||||
else()
|
||||
# assume GCC
|
||||
message("Using __gcov_flush")
|
||||
add_definitions( -DHAVE_GCOV_FLUSH)
|
||||
endif()
|
||||
|
||||
|
||||
# create static lib
|
||||
add_library(btstack STATIC ${SOURCES})
|
||||
|
||||
|
@ -125,28 +125,25 @@ static btstack_timer_source_t heartbeat;
|
||||
// static bd_addr_t pts_addr = { 0x00, 0x1b, 0xdc, 0x07, 0x32, 0xef};
|
||||
static bd_addr_t pts_addr = { 0x00, 0x1b, 0xdc, 0x08, 0xe2, 0x5c};
|
||||
|
||||
// GCOV Flush
|
||||
// flush gcov data
|
||||
#ifdef HAVE_GCOV_FLUSH
|
||||
void __gcov_flush(void);
|
||||
#endif
|
||||
#ifdef HAVE_GCOV_DUMP
|
||||
void __gcov_dump(void);
|
||||
void __gcov_reset(void);
|
||||
#endif
|
||||
|
||||
static void my_gcov_flush(void){
|
||||
#ifdef COVERAGE
|
||||
static void (*gcov_flush_fn)(void) = NULL;
|
||||
if (gcov_flush_fn == NULL){
|
||||
// look up __gov_flush
|
||||
gcov_flush_fn = dlsym(RTLD_DEFAULT, "__gcov_flush");
|
||||
if (gcov_flush_fn != NULL){
|
||||
printf("Using __gcov_flush %p\n", gcov_flush_fn);
|
||||
}
|
||||
}
|
||||
if (gcov_flush_fn == NULL){
|
||||
// lookup __gov_dump
|
||||
gcov_flush_fn = dlsym(RTLD_DEFAULT, "__gcov_dump");
|
||||
if (gcov_flush_fn != NULL){
|
||||
printf("Using __gcov_dump %p\n", gcov_flush_fn);
|
||||
}
|
||||
}
|
||||
if (gcov_flush_fn != NULL){
|
||||
// call either one
|
||||
(*gcov_flush_fn)();
|
||||
}
|
||||
#ifdef HAVE_GCOV_DUMP
|
||||
__gcov_dump();
|
||||
__gcov_reset();
|
||||
#elif defined(HAVE_GCOV_FLUSH)
|
||||
__gcov_flush();
|
||||
#else
|
||||
#error "COVERAGE defined, but neither HAVE_GCOV_DUMP nor HAVE_GCOV_FLUSH"
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user