mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-05 14:29:56 +02:00
Implement thread debugging with tsan
This is enabled with the VIRCADIA_THREAD_DEBUGGING environment variable. It's incompatible with VIRCADIA_MEMORY_DEBUGGING, so only one of those can be enabled for a build.
This commit is contained in:
parent
f8574a99c9
commit
43f6fd82f4
28 changed files with 67 additions and 2 deletions
|
@ -8,6 +8,7 @@ if (APPLE)
|
|||
endif ()
|
||||
|
||||
setup_memory_debugger()
|
||||
setup_thread_debugger()
|
||||
|
||||
# link in the shared libraries
|
||||
link_hifi_libraries(
|
||||
|
|
|
@ -26,5 +26,6 @@ function(LINK_HIFI_LIBRARIES)
|
|||
endforeach()
|
||||
|
||||
setup_memory_debugger()
|
||||
setup_thread_debugger()
|
||||
|
||||
endfunction()
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
|
||||
macro(SETUP_MEMORY_DEBUGGER)
|
||||
if ("$ENV{VIRCADIA_MEMORY_DEBUGGING}")
|
||||
if (DEFINED VIRCADIA_THREAD_DEBUGGING )
|
||||
message(FATAL_ERROR "Thread debugging and memory debugging can't be enabled at the same time." )
|
||||
endif()
|
||||
|
||||
SET( VIRCADIA_MEMORY_DEBUGGING true )
|
||||
endif ()
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@ macro(SETUP_HIFI_LIBRARY)
|
|||
endforeach()
|
||||
|
||||
setup_memory_debugger()
|
||||
setup_thread_debugger()
|
||||
|
||||
# create a library and set the property so it can be referenced later
|
||||
if (${${TARGET_NAME}_SHARED})
|
||||
|
|
36
cmake/macros/ThreadDebugger.cmake
Normal file
36
cmake/macros/ThreadDebugger.cmake
Normal file
|
@ -0,0 +1,36 @@
|
|||
#
|
||||
# MemoryDebugger.cmake
|
||||
#
|
||||
# Copyright 2021 Vircadia Contributors
|
||||
#
|
||||
# Distributed under the Apache License, Version 2.0.
|
||||
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
#
|
||||
|
||||
macro(SETUP_THREAD_DEBUGGER)
|
||||
if ("$ENV{VIRCADIA_THREAD_DEBUGGING}")
|
||||
if (DEFINED VIRCADIA_MEMORY_DEBUGGING )
|
||||
message(FATAL_ERROR "Thread debugging and memory debugging can't be enabled at the same time." )
|
||||
endif ()
|
||||
|
||||
SET( VIRCADIA_THREAD_DEBUGGING true )
|
||||
endif ()
|
||||
|
||||
if (VIRCADIA_THREAD_DEBUGGING)
|
||||
if (UNIX)
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
# for clang on Linux
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread -fno-omit-frame-pointer" )
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "-fsanitize=thread ${CMAKE_EXE_LINKER_FLAGS}")
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS "-fsanitize=thread ${CMAKE_EXE_LINKER_FLAGS}")
|
||||
else ()
|
||||
# for gcc on Linux
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread -fno-omit-frame-pointer")
|
||||
SET(CMAKE_EXE_LINKER_FLAGS " -fsanitize=thread ${CMAKE_EXE_LINKER_FLAGS}")
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS "-fsanitize=thread ${CMAKE_EXE_LINKER_FLAGS}")
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "Thread debugging is not supported on this platform." )
|
||||
endif (UNIX)
|
||||
endif ()
|
||||
endmacro(SETUP_THREAD_DEBUGGER)
|
|
@ -15,6 +15,7 @@ if (APPLE)
|
|||
endif ()
|
||||
|
||||
setup_memory_debugger()
|
||||
setup_thread_debugger()
|
||||
|
||||
# TODO: find a solution that will handle web file changes in resources on windows without a re-build.
|
||||
# Currently the resources are only copied on post-build. If one is changed but the domain-server is not, they will
|
||||
|
|
|
@ -19,6 +19,7 @@ endif ()
|
|||
include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}")
|
||||
|
||||
setup_memory_debugger()
|
||||
setup_thread_debugger()
|
||||
|
||||
# append OpenSSL to our list of libraries to link
|
||||
target_link_libraries(${TARGET_NAME} ${OPENSSL_LIBRARIES})
|
||||
|
|
|
@ -47,6 +47,7 @@ add_custom_target(resources ALL DEPENDS ${GENERATE_QRC_DEPENDS})
|
|||
set(OPTIONAL_EXTERNALS "LeapMotion")
|
||||
|
||||
setup_memory_debugger()
|
||||
setup_thread_debugger()
|
||||
|
||||
foreach(EXTERNAL ${OPTIONAL_EXTERNALS})
|
||||
string(TOUPPER ${EXTERNAL} ${EXTERNAL}_UPPERCASE)
|
||||
|
@ -299,7 +300,7 @@ target_link_libraries(
|
|||
${PLATFORM_QT_LIBRARIES}
|
||||
)
|
||||
|
||||
if (UNIX AND NOT ANDROID)
|
||||
if (UNIX AND NOT ANDROID AND NOT VIRCADIA_THREAD_DEBUGGING)
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
# Linux
|
||||
target_link_libraries(${TARGET_NAME} pthread atomic)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
set(TARGET_NAME gpu-gl)
|
||||
setup_hifi_library(Concurrent)
|
||||
link_hifi_libraries(shared gl gpu gpu-gl-common shaders)
|
||||
if (UNIX)
|
||||
if (UNIX AND NOT VIRCADIA_THREAD_DEBUGGING)
|
||||
target_link_libraries(${TARGET_NAME} pthread)
|
||||
endif(UNIX)
|
||||
GroupSources("src")
|
||||
|
|
|
@ -7,6 +7,7 @@ setup_hifi_project(Script Qml)
|
|||
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/")
|
||||
|
||||
setup_memory_debugger()
|
||||
setup_thread_debugger()
|
||||
|
||||
# link in the shared libraries
|
||||
link_hifi_libraries(shared gl script-engine plugins render-utils ui-plugins input-plugins display-plugins controllers)
|
||||
|
|
|
@ -4,6 +4,7 @@ set(TARGET_NAME "entities-test")
|
|||
# This is not a testcase -- just set it up as a regular hifi project
|
||||
setup_hifi_project(Network Script)
|
||||
setup_memory_debugger()
|
||||
setup_thread_debugger()
|
||||
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/")
|
||||
|
||||
# link in the shared libraries
|
||||
|
|
|
@ -2,6 +2,7 @@ set(TARGET_NAME gl-test)
|
|||
# This is not a testcase -- just set it up as a regular hifi project
|
||||
setup_hifi_project(Quick Gui OpenGL)
|
||||
setup_memory_debugger()
|
||||
setup_thread_debugger()
|
||||
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/")
|
||||
link_hifi_libraries(shared gl)
|
||||
package_libraries_for_deployment()
|
||||
|
|
|
@ -2,6 +2,7 @@ set(TARGET_NAME gpu-textures-tests)
|
|||
# This is not a testcase -- just set it up as a regular hifi project
|
||||
setup_hifi_project(Quick Gui Script)
|
||||
setup_memory_debugger()
|
||||
setup_thread_debugger()
|
||||
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/")
|
||||
link_hifi_libraries(
|
||||
shared shaders task networking gl
|
||||
|
|
|
@ -2,6 +2,7 @@ set(TARGET_NAME gpu-test)
|
|||
# This is not a testcase -- just set it up as a regular hifi project
|
||||
setup_hifi_project(Quick Gui Script)
|
||||
setup_memory_debugger()
|
||||
setup_thread_debugger()
|
||||
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/")
|
||||
link_hifi_libraries(
|
||||
shared task networking gl
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
set(TARGET_NAME qml-test)
|
||||
setup_hifi_project(Quick Qml Gui OpenGL)
|
||||
setup_memory_debugger()
|
||||
setup_thread_debugger()
|
||||
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/")
|
||||
link_hifi_libraries(shared networking gl qml)
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ if (WIN32)
|
|||
endif()
|
||||
|
||||
setup_memory_debugger()
|
||||
setup_thread_debugger()
|
||||
|
||||
# This is not a testcase -- just set it up as a regular hifi project
|
||||
setup_hifi_project(Quick Gui)
|
||||
|
|
|
@ -6,6 +6,7 @@ if (WIN32)
|
|||
endif()
|
||||
|
||||
setup_memory_debugger()
|
||||
setup_thread_debugger()
|
||||
|
||||
# This is not a testcase -- just set it up as a regular hifi project
|
||||
setup_hifi_project(Quick Gui)
|
||||
|
|
|
@ -6,6 +6,7 @@ setup_hifi_project(Quick Gui)
|
|||
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/")
|
||||
|
||||
setup_memory_debugger()
|
||||
setup_thread_debugger()
|
||||
|
||||
# link in the shared libraries
|
||||
link_hifi_libraries(render-utils shaders gl gpu shared ${PLATFORM_GL_BACKEND})
|
||||
|
|
|
@ -3,6 +3,7 @@ set(TARGET_NAME recording-test)
|
|||
setup_hifi_project(Test)
|
||||
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/")
|
||||
setup_memory_debugger()
|
||||
setup_thread_debugger()
|
||||
link_hifi_libraries(shared recording)
|
||||
if (WIN32)
|
||||
target_link_libraries(${TARGET_NAME} Winmm.lib)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
set(TARGET_NAME ac-client)
|
||||
setup_hifi_project(Core)
|
||||
setup_memory_debugger()
|
||||
setup_thread_debugger()
|
||||
link_hifi_libraries(shared networking)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
set(TARGET_NAME atp-client)
|
||||
setup_hifi_project(Core)
|
||||
setup_memory_debugger()
|
||||
setup_thread_debugger()
|
||||
link_hifi_libraries(shared networking)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
set(TARGET_NAME gpu-frame-player)
|
||||
|
||||
setup_memory_debugger()
|
||||
setup_thread_debugger()
|
||||
|
||||
if (APPLE)
|
||||
set(CMAKE_MACOSX_BUNDLE TRUE)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
set(TARGET_NAME ice-client)
|
||||
setup_hifi_project(Core)
|
||||
setup_memory_debugger()
|
||||
setup_thread_debugger()
|
||||
link_hifi_libraries(shared networking)
|
||||
|
|
|
@ -7,6 +7,7 @@ link_hifi_libraries(shared networking image gl shaders gpu ktx)
|
|||
target_gli()
|
||||
|
||||
setup_memory_debugger()
|
||||
setup_thread_debugger()
|
||||
|
||||
if (WIN32)
|
||||
package_libraries_for_deployment()
|
||||
|
|
|
@ -31,6 +31,7 @@ source_group("UI Files" FILES ${QT_UI_FILES})
|
|||
qt5_wrap_ui(QT_UI_HEADERS "${QT_UI_FILES}")
|
||||
|
||||
setup_memory_debugger()
|
||||
setup_thread_debugger()
|
||||
|
||||
# add them to the nitpick source files
|
||||
set(NITPICK_SRCS ${NITPICK_SRCS} "${QT_UI_HEADERS}" "${QT_RESOURCES}")
|
||||
|
|
|
@ -5,6 +5,7 @@ setup_hifi_project(Widgets Gui Concurrent)
|
|||
link_hifi_libraries(shared shaders image gpu ktx fbx hfm baking graphics networking procedural material-networking model-baker task)
|
||||
|
||||
setup_memory_debugger()
|
||||
setup_thread_debugger()
|
||||
|
||||
if (WIN32)
|
||||
package_libraries_for_deployment()
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
set(TARGET_NAME skeleton-dump)
|
||||
setup_hifi_project(Core)
|
||||
setup_memory_debugger()
|
||||
setup_thread_debugger()
|
||||
link_hifi_libraries(shared fbx hfm graphics gpu gl animation)
|
||||
|
||||
include_hifi_library_headers(image)
|
||||
|
|
|
@ -7,6 +7,7 @@ include_hifi_library_headers(image)
|
|||
target_vhacd()
|
||||
|
||||
setup_memory_debugger()
|
||||
setup_thread_debugger()
|
||||
|
||||
if (WIN32)
|
||||
package_libraries_for_deployment()
|
||||
|
|
Loading…
Reference in a new issue