Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/coreclr/debug/daccess/cdac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,7 @@ namespace
path.Truncate(iter);
path.Append(CDAC_LIB_NAME);

#ifdef HOST_WINDOWS
// LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR tells the native windows loader to load dependencies
// from the same directory as cdacreader.dll. Once the native portions of the cDAC
// are statically linked, this won't be required.
*phCDAC = CLRLoadLibraryEx(path.GetUnicode(), NULL, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR);
#else // !HOST_WINDOWS
*phCDAC = CLRLoadLibrary(path.GetUnicode());
#endif // HOST_WINDOWS
if (*phCDAC == NULL)
return false;

Expand Down
66 changes: 53 additions & 13 deletions src/coreclr/unwinder/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,33 @@ add_dependencies(unwinder_dac eventing_headers)
set_target_properties(unwinder_dac PROPERTIES DAC_COMPONENT TRUE)
target_compile_definitions(unwinder_dac PRIVATE FEATURE_NO_HOST)

### cDAC Unwinders ####

set(BASE_UNWINDER_SOURCES baseunwinder.cpp)
convert_to_absolute_path(BASE_UNWINDER_SOURCES ${BASE_UNWINDER_SOURCES})
add_library_clr(unwinder_cdac_base STATIC ${BASE_UNWINDER_SOURCES})

target_include_directories(unwinder_cdac_base BEFORE PUBLIC ${VM_DIR})
target_include_directories(unwinder_cdac_base BEFORE PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(unwinder_cdac_base BEFORE PUBLIC ${CLR_DIR}/unwinder)
target_include_directories(unwinder_cdac_base PUBLIC ${CLR_DIR}/debug/ee)
target_include_directories(unwinder_cdac_base PUBLIC ${CLR_DIR}/gc)
target_include_directories(unwinder_cdac_base PUBLIC ${CLR_DIR}/gcdump)
target_include_directories(unwinder_cdac_base PUBLIC ${CLR_DIR}/debug/daccess)
target_compile_definitions(unwinder_cdac_base PUBLIC FEATURE_NO_HOST FEATURE_CDAC_UNWINDER)

if (CLR_CMAKE_TARGET_WIN32)
# cDAC unwinders are statically linked into the NativeAOT runtime which is built with
# release version of the statically linked CRT. Therefore we do the same here.
set_property(TARGET unwinder_cdac_base PROPERTY MSVC_RUNTIME_LIBRARY MultiThreaded)

# _DEBUG is always passed as a parameter if the build is a debug build.
# This causes the debug CRT on MSVC to be used so we need to undefine it.
target_compile_options(unwinder_cdac_base PRIVATE -U_DEBUG)
endif()

install_clr(TARGETS unwinder_cdac_base DESTINATIONS cdaclibs COMPONENT debug)

# Helper function for platform specific cDAC uwninder builds.
function(create_platform_unwinder)
set(oneValueArgs TARGET ARCH)
Expand All @@ -48,21 +75,23 @@ function(create_platform_unwinder)
clr_unknown_arch()
endif()

set(UNWINDER_SOURCES
baseunwinder.cpp
${ARCH_SOURCES_DIR}/unwinder.cpp
)

set(UNWINDER_SOURCES ${ARCH_SOURCES_DIR}/unwinder.cpp)
convert_to_absolute_path(UNWINDER_SOURCES ${UNWINDER_SOURCES})
add_library_clr(${TARGETDETAILS_TARGET} STATIC ${UNWINDER_SOURCES})

add_library_clr(${TARGETDETAILS_TARGET}
SHARED
${UNWINDER_SOURCES}
)
target_include_directories(${TARGETDETAILS_TARGET} BEFORE PRIVATE ${VM_DIR}/${ARCH_SOURCES_DIR})
target_include_directories(${TARGETDETAILS_TARGET} PRIVATE ${ARCH_SOURCES_DIR})

add_unwinder_include_directories(${TARGETDETAILS_TARGET})
target_link_libraries(${TARGETDETAILS_TARGET} PRIVATE unwinder_cdac_base)
if (CLR_CMAKE_TARGET_WIN32)
# cDAC unwinders are statically linked into the NativeAOT runtime which is built with
# release version of the statically linked CRT. Therefore we do the same here.
set_property(TARGET ${TARGETDETAILS_TARGET} PROPERTY MSVC_RUNTIME_LIBRARY MultiThreaded)

target_link_libraries(${TARGETDETAILS_TARGET} PRIVATE ${STATIC_MT_CRT_LIB} ${STATIC_MT_VCRT_LIB})
# _DEBUG is always passed as a parameter if the build is a debug build.
# This causes the debug CRT on MSVC to be used so we need to undefine it.
target_compile_options(${TARGETDETAILS_TARGET} PRIVATE -U_DEBUG)
endif()

# add the install targets
install_clr(TARGETS ${TARGETDETAILS_TARGET} DESTINATIONS ${TARGETDETAILS_DESTINATIONS} COMPONENT debug INSTALL_ALL_ARTIFACTS)
Expand All @@ -73,9 +102,20 @@ function(create_platform_unwinder)
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE FEATURE_NO_HOST FEATURE_CDAC_UNWINDER)
endfunction()

# TODO: Support building cDAC unwinders on other platforms
# https://github.com/dotnet/runtime/issues/112272#issue-2838611496
if(CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_TARGET_ARCH_AMD64)
create_platform_unwinder(TARGET unwinder_cdac_amd64 ARCH x64 DESTINATIONS cdaclibs)
create_platform_unwinder(TARGET unwinder_cdac_arm64 ARCH arm64 DESTINATIONS cdaclibs)
endif(CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_TARGET_ARCH_AMD64)

if(CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_TARGET_ARCH_ARM64)
create_platform_unwinder(TARGET unwinder_cdac_arm64 ARCH arm64 DESTINATIONS cdaclibs)
endif(CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_TARGET_ARCH_ARM64)

if(NOT CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_TARGET_ARCH_AMD64)
create_platform_unwinder(TARGET unwinder_cdac_amd64 ARCH x64 DESTINATIONS cdaclibs)
endif(CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_TARGET_ARCH_AMD64)

if(NOT CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_TARGET_ARCH_ARM64)
create_platform_unwinder(TARGET unwinder_cdac_arm64 ARCH arm64 DESTINATIONS cdaclibs)
endif(CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_TARGET_ARCH_ARM64)

12 changes: 6 additions & 6 deletions src/coreclr/unwinder/amd64/unwinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
#include "baseunwinder.h"

#ifdef FEATURE_CDAC_UNWINDER
EXTERN_C __declspec(dllexport) BOOL amd64Unwind(void* pContext,
ReadFromTarget readFromTarget,
GetAllocatedBuffer getAllocatedBuffer,
GetStackWalkInfo getStackWalkInfo,
UnwinderFail unwinderFail,
void* callbackContext);
EXTERN_C BOOL amd64Unwind(void* pContext,
ReadFromTarget readFromTarget,
GetAllocatedBuffer getAllocatedBuffer,
GetStackWalkInfo getStackWalkInfo,
UnwinderFail unwinderFail,
void* callbackContext);
#endif // FEATURE_CDAC_UNWINDER

//---------------------------------------------------------------------------------------
Expand Down
10 changes: 5 additions & 5 deletions src/coreclr/unwinder/arm64/unwinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
#include "baseunwinder.h"

#ifdef FEATURE_CDAC_UNWINDER
EXTERN_C __declspec(dllexport) BOOL arm64Unwind(void* pContext, ReadFromTarget readFromTarget,
GetAllocatedBuffer getAllocatedBuffer,
GetStackWalkInfo getStackWalkInfo,
UnwinderFail unwinderFail,
void* callbackContext);
EXTERN_C BOOL arm64Unwind(void* pContext, ReadFromTarget readFromTarget,
GetAllocatedBuffer getAllocatedBuffer,
GetStackWalkInfo getStackWalkInfo,
UnwinderFail unwinderFail,
void* callbackContext);
#endif // FEATURE_CDAC_UNWINDER

//---------------------------------------------------------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions src/coreclr/unwinder/baseunwinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ HRESULT OOPStackUnwinder::GetFunctionEntry( DWORD64 addres
_Out_writes_(cbBuffer) PVOID pBuffer,
DWORD cbBuffer)
{
if (cbBuffer < sizeof(T_RUNTIME_FUNCTION))
{
return E_INVALIDARG;
}
// if (cbBuffer < sizeof(T_RUNTIME_FUNCTION))
// {
// return E_INVALIDARG;
// }

PVOID pFuncEntry = NULL;
#ifndef FEATURE_CDAC_UNWINDER
Expand Down
18 changes: 13 additions & 5 deletions src/native/managed/cdacreader/src/cdacreader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,20 @@
</ItemGroup>

<ItemGroup>
<!-- TODO: Link libraries on non-windows platforms. -->
<!-- https://github.com/dotnet/runtime/issues/112416 -->
<DirectPInvoke Include="unwinder_cdac_amd64" Condition="'$(TargetsWindows)' == 'true' and '$(TargetArchitecture)' == 'x64'"/>
<DirectPInvoke Include="unwinder_cdac_amd64" />
<DirectPInvoke Include="unwinder_cdac_arm64" />

<!-- unwinder_cdac_base is supported on all platforms -->
<NativeLibrary Include="$(CoreCLRArtifactsPath)cdaclibs\unwinder_cdac_base.lib" Condition="'$(TargetsWindows)' == 'true'"/>
<NativeLibrary Include="$(CoreCLRArtifactsPath)cdaclibs\libunwinder_cdac_base.a" Condition="'$(TargetsWindows)' != 'true'" />

<!-- amd64 and arm64 are supported on windows x64, or on their native platform -->
<NativeLibrary Include="$(CoreCLRArtifactsPath)cdaclibs\unwinder_cdac_amd64.lib" Condition="'$(TargetsWindows)' == 'true' and '$(TargetArchitecture)' == 'x64'" />
<DirectPInvoke Include="unwinder_cdac_arm64" Condition="'$(TargetsWindows)' == 'true' and '$(TargetArchitecture)' == 'x64'"/>
<NativeLibrary Include="$(CoreCLRArtifactsPath)cdaclibs\unwinder_cdac_arm64.lib" Condition="'$(TargetsWindows)' == 'true' and '$(TargetArchitecture)' == 'x64'" />
<NativeLibrary Include="$(CoreCLRArtifactsPath)cdaclibs\unwinder_cdac_arm64.lib" Condition="'$(TargetsWindows)' == 'true' and ('$(TargetArchitecture)' == 'x64' or '$(TargetArchitecture)' == 'arm64')" />

<!-- non-windows, load only the platform native unwinders -->
<NativeLibrary Include="$(CoreCLRArtifactsPath)cdaclibs\libunwinder_cdac_amd64.a" Condition="'$(TargetsWindows)' != 'true' and '$(TargetArchitecture)' == 'x64'" />
<NativeLibrary Include="$(CoreCLRArtifactsPath)cdaclibs\libunwinder_cdac_arm64.a" Condition="'$(TargetsWindows)' != 'true' and '$(TargetArchitecture)' == 'arm64'" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading