From: Mikhail Kurinnoi Date: Thu, 9 Sep 2021 16:06:34 +0000 (-0700) Subject: Fix build with CorecLR 6.0. X-Git-Tag: submit/tizen/20210909.063632~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=01ad175aa138b18b2e8b63f3c8e609af604566b1;p=sdk%2Ftools%2Fcoreprofiler.git Fix build with CorecLR 6.0. --- diff --git a/clr.cmake b/clr.cmake index 0294627..9d19cc0 100644 --- a/clr.cmake +++ b/clr.cmake @@ -119,19 +119,25 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--build-id=sha1") #----------------------------------- if (CLR_CMAKE_PLATFORM_ARCH_AMD64) add_definitions(-D_AMD64_) + add_definitions(-DHOST_AMD64) # https://github.com/dotnet/runtime/commit/fcd862e06413a000f9cafa9d2f359226c60b9b42 add_definitions(-D_WIN64) add_definitions(-DAMD64) add_definitions(-DBIT64=1) + add_definitions(-DHOST_64BIT=1) # https://github.com/dotnet/runtime/commit/fcd862e06413a000f9cafa9d2f359226c60b9b42 elseif (CLR_CMAKE_PLATFORM_ARCH_I386) add_definitions(-D_X86_) + add_definitions(-DHOST_X86) # https://github.com/dotnet/runtime/commit/fcd862e06413a000f9cafa9d2f359226c60b9b42 elseif (CLR_CMAKE_PLATFORM_ARCH_ARM) add_definitions(-D_ARM_) add_definitions(-DARM) + add_definitions(-DHOST_ARM) # https://github.com/dotnet/runtime/commit/fcd862e06413a000f9cafa9d2f359226c60b9b42 elseif (CLR_CMAKE_PLATFORM_ARCH_ARM64) add_definitions(-D_ARM64_) add_definitions(-DARM64) + add_definitions(-DHOST_ARM64) # https://github.com/dotnet/runtime/commit/fcd862e06413a000f9cafa9d2f359226c60b9b42 add_definitions(-D_WIN64) add_definitions(-DBIT64=1) + add_definitions(-DHOST_64BIT=1) # https://github.com/dotnet/runtime/commit/fcd862e06413a000f9cafa9d2f359226c60b9b42 else () clr_unknown_arch() endif () diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8d7e65e..e74b9b1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -49,7 +49,7 @@ set_property( ) target_link_libraries(coreprof - libcorguids + # libcorguids # utilcodestaticnohost # gcinfo # mscorrc_debug diff --git a/src/trace/commontrace.cpp b/src/trace/commontrace.cpp index 66e4e07..dee5a93 100644 --- a/src/trace/commontrace.cpp +++ b/src/trace/commontrace.cpp @@ -46,6 +46,7 @@ // NOTE: currently only one instance of the CommonTrace can exist at each // moment, so global variable can be used. static CommonTrace *g_pCommonTraceObject = nullptr; +static thread_local ThreadInfo *tlsThreadInfo = nullptr; static void SampleHandlerStub( int code, siginfo_t *siginfo, void *context) @@ -98,7 +99,6 @@ static struct timespec MsToTS(unsigned long ms) CommonTrace::CommonTrace(Profiler &profiler) : BaseTrace(profiler) - , m_tlsThreadInfoIndex(TLS_OUT_OF_INDEXES) , m_threadStorage() , m_classStorage() , m_pauseAction() @@ -117,17 +117,6 @@ CommonTrace::~CommonTrace() // NOTE: we are dealing with a partially destroyed m_profiler! this->Shutdown(); - if (m_tlsThreadInfoIndex != TLS_OUT_OF_INDEXES) - { - if (!TlsFree(m_tlsThreadInfoIndex)) - { - m_profiler.HandleHresult( - "CommonTrace::~CommonTrace(): TlsFree()", - HRESULT_FROM_WIN32(GetLastError()) - ); - } - } - _ASSERTE(g_pCommonTraceObject == this); g_pCommonTraceObject = nullptr; } @@ -170,19 +159,6 @@ void CommonTrace::ProcessConfig(ProfilerConfig &config) } #endif - // - // Initializing thread local storage. - // - - m_tlsThreadInfoIndex = TlsAlloc(); - if (m_tlsThreadInfoIndex == TLS_OUT_OF_INDEXES) - { - throw HresultException( - "CommonTrace::ProcessConfig(): TlsAlloc()", - HRESULT_FROM_WIN32(GetLastError()) - ); - } - // // Setup signal handlers. // @@ -684,20 +660,7 @@ ThreadInfo *CommonTrace::GetThreadInfo() noexcept // Try to get thread info from the local storage. // - ThreadInfo *threadInfo = reinterpret_cast( - TlsGetValue(m_tlsThreadInfoIndex)); - - if (threadInfo == nullptr) - { - DWORD lastError = GetLastError(); - if (lastError != ERROR_SUCCESS) - { - m_profiler.HandleHresult( - "CommonTrace::GetThreadInfo(): TlsGetValue()", - HRESULT_FROM_WIN32(lastError) - ); - } - } + ThreadInfo *threadInfo = tlsThreadInfo; HRESULT hr; @@ -748,13 +711,7 @@ ThreadInfo *CommonTrace::GetThreadInfo() noexcept // Save new thead info to the local storage. // - if (!TlsSetValue(m_tlsThreadInfoIndex, threadInfo)) - { - m_profiler.HandleHresult( - "CommonTrace::GetThreadInfo(): TlsSetValue()", - HRESULT_FROM_WIN32(GetLastError()) - ); - } + tlsThreadInfo = threadInfo; } return threadInfo; @@ -772,8 +729,7 @@ ThreadInfo *CommonTrace::GetThreadInfoR() const noexcept // Try to get thread info from the local storage. // - ThreadInfo *threadInfo = reinterpret_cast( - TlsGetValue(m_tlsThreadInfoIndex)); + ThreadInfo *threadInfo = tlsThreadInfo; #ifdef _TARGET_AMD64_ if (threadInfo == nullptr) diff --git a/src/trace/commontrace.h b/src/trace/commontrace.h index 2bcb0c1..e66caa5 100644 --- a/src/trace/commontrace.h +++ b/src/trace/commontrace.h @@ -149,8 +149,6 @@ public: HRESULT GarbageCollectionFinished() noexcept; private: - int m_tlsThreadInfoIndex; - SharedResource m_threadStorage; SharedResource m_classStorage;