Skip to content

Commit

Permalink
PAL_VirtualUnwindOutOfProc for MacOS (dotnet#39213)
Browse files Browse the repository at this point in the history
PAL_VirtualUnwindOutOfProc for MacOS

Add MacOS compact unwind section parsing (__unwind_info) and stepping: SearchCompactEncodingSection, SearchDwarfSection, GetProcInfo, StepWithCompactEncoding*.

Add back some (from a previous commit) of the dwarf unwind info parsing functions to use for the dwarf unwind info (__eh_frame section): ReadValue*, ReadULEB128, ReadSLEB128, ReadEncodedPointer, ParseCie, ExtractFde, ExtractProcInfoFromFde. These functions were used and fairly well tested in 3.x.

Build libunwind8 source on MacOS for those dwarf unwind info cases.

The methoddesc's enum memory region code needed add more of the code version manager's data to the coredump.
  • Loading branch information
mikem8361 authored Jul 15, 2020
1 parent a4065df commit 60ccaa8
Show file tree
Hide file tree
Showing 17 changed files with 3,393 additions and 26 deletions.
7 changes: 5 additions & 2 deletions src/coreclr/src/debug/daccess/dacfn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ DacVirtualUnwind(ULONG32 threadId, PT_CONTEXT context, PT_KNONVOLATILE_CONTEXT_P
memset(contextPointers, 0, sizeof(T_KNONVOLATILE_CONTEXT_POINTERS));
}

HRESULT hr = S_OK;
HRESULT hr = E_NOINTERFACE;

#ifdef FEATURE_DATATARGET4
ReleaseHolder<ICorDebugDataTarget4> dt;
Expand All @@ -277,9 +277,12 @@ DacVirtualUnwind(ULONG32 threadId, PT_CONTEXT context, PT_KNONVOLATILE_CONTEXT_P
{
hr = dt->VirtualUnwind(threadId, sizeof(CONTEXT), (BYTE*)context);
}
else
#endif

if (hr == E_NOINTERFACE || hr == E_NOTIMPL)
{
hr = S_OK;

SIZE_T baseAddress = DacGlobalBase();
if (baseAddress == 0 || !PAL_VirtualUnwindOutOfProc(context, contextPointers, baseAddress, DacReadAllAdapter))
{
Expand Down
6 changes: 6 additions & 0 deletions src/coreclr/src/dlls/mscordac/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ if(CLR_CMAKE_HOST_WIN32 AND CLR_CMAKE_TARGET_UNIX)
)
endif(CLR_CMAKE_HOST_WIN32 AND CLR_CMAKE_TARGET_UNIX)

if(CLR_CMAKE_HOST_OSX)
list(APPEND COREDAC_LIBRARIES
coreclrpal_dac
)
endif(CLR_CMAKE_HOST_OSX)

target_link_libraries(mscordaccore PRIVATE ${COREDAC_LIBRARIES})

# Create the DAC module index header file containing the DAC build id
Expand Down
33 changes: 31 additions & 2 deletions src/coreclr/src/pal/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ if(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND)
add_subdirectory(libunwind)
elseif(NOT CLR_CMAKE_TARGET_OSX)
find_unwind_libs(UNWIND_LIBS)
else()
add_subdirectory(libunwind)
endif(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND)

include(configure.cmake)
Expand Down Expand Up @@ -131,7 +133,6 @@ set(SOURCES
debug/debug.cpp
exception/seh.cpp
exception/signal.cpp
exception/remote-unwind.cpp
file/directory.cpp
file/file.cpp
file/filetime.cpp
Expand Down Expand Up @@ -214,6 +215,12 @@ set(SOURCES
thread/threadsusp.cpp
)

if(NOT CLR_CMAKE_TARGET_OSX)
list(APPEND SOURCES
exception/remote-unwind.cpp
)
endif(NOT CLR_CMAKE_TARGET_OSX)

if(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND)
set(LIBUNWIND_OBJECTS $<TARGET_OBJECTS:libunwind>)
endif(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND)
Expand All @@ -226,6 +233,29 @@ add_library(coreclrpal
${LIBUNWIND_OBJECTS}
)

# Build separate pal library for DAC (addition to regular pal library)
if(CLR_CMAKE_TARGET_OSX)
set(LIBUNWIND_DAC_OBJECTS $<TARGET_OBJECTS:libunwind_dac>)

add_library(coreclrpal_dac STATIC
exception/remote-unwind.cpp
${LIBUNWIND_DAC_OBJECTS}
)

target_compile_definitions(coreclrpal_dac PUBLIC
"-D_XOPEN_SOURCE"
"-DUNW_REMOTE_ONLY"
)

target_include_directories(coreclrpal_dac PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/libunwind/include
${CMAKE_CURRENT_SOURCE_DIR}/libunwind/include/tdep
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/libunwind/include
${CMAKE_CURRENT_BINARY_DIR}/libunwind/include/tdep
)
endif(CLR_CMAKE_TARGET_OSX)

# There is only one function exported in 'tracepointprovider.cpp' namely 'PAL_InitializeTracing',
# which is guarded with '#if defined(__linux__)'. On macOS, Xcode issues the following warning:
#
Expand Down Expand Up @@ -309,6 +339,5 @@ if(FEATURE_EVENT_TRACE)
add_subdirectory(eventprovider)
endif(FEATURE_EVENT_TRACE)


# Install the static PAL library for VS
_install (TARGETS coreclrpal DESTINATION lib)
Loading

0 comments on commit 60ccaa8

Please sign in to comment.