summaryrefslogtreecommitdiff
path: root/src/unwinder
diff options
context:
space:
mode:
Diffstat (limited to 'src/unwinder')
-rw-r--r--src/unwinder/CMakeLists.txt10
-rw-r--r--src/unwinder/dac/dirs.proj18
-rw-r--r--src/unwinder/dac/hostlocal/unwinder_dac.nativeproj13
-rw-r--r--src/unwinder/dac/hostwinamd64/unwinder_dac.nativeproj15
-rw-r--r--src/unwinder/dac/hostwinx86/unwinder_dac.nativeproj15
-rw-r--r--src/unwinder/dirs.proj19
-rw-r--r--src/unwinder/i386/unwinder_i386.cpp194
-rw-r--r--src/unwinder/i386/unwinder_i386.h33
-rw-r--r--src/unwinder/unwinder.targets60
9 files changed, 231 insertions, 146 deletions
diff --git a/src/unwinder/CMakeLists.txt b/src/unwinder/CMakeLists.txt
index bf1cfa2938..5cd7bae337 100644
--- a/src/unwinder/CMakeLists.txt
+++ b/src/unwinder/CMakeLists.txt
@@ -12,12 +12,10 @@ set(UNWINDER_SOURCES
)
# Include platform specific unwinder for applicable (native and cross-target) builds.
-if(NOT DEFINED CLR_CMAKE_TARGET_ARCH_I386)
- include_directories(${ARCH_SOURCES_DIR})
- list(APPEND UNWINDER_SOURCES
- ${ARCH_SOURCES_DIR}/unwinder_${ARCH_SOURCES_DIR}.cpp
- )
-endif()
+include_directories(${ARCH_SOURCES_DIR})
+list(APPEND UNWINDER_SOURCES
+ ${ARCH_SOURCES_DIR}/unwinder_${ARCH_SOURCES_DIR}.cpp
+)
convert_to_absolute_path(UNWINDER_SOURCES ${UNWINDER_SOURCES})
diff --git a/src/unwinder/dac/dirs.proj b/src/unwinder/dac/dirs.proj
deleted file mode 100644
index 77738732ed..0000000000
--- a/src/unwinder/dac/dirs.proj
+++ /dev/null
@@ -1,18 +0,0 @@
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <!--Import the settings-->
- <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\clr.props" />
-
- <PropertyGroup>
- <BuildInPhase1>true</BuildInPhase1>
- <BuildInPhaseDefault>false</BuildInPhaseDefault>
- <BuildCoreBinaries>true</BuildCoreBinaries>
- <BuildSysBinaries>true</BuildSysBinaries>
- </PropertyGroup>
-
- <!--The following projects will build during PHASE 1-->
- <ItemGroup Condition="'$(BuildExePhase)' == '1'">
- <ProjectFile Include="hostlocal\unwinder_dac.nativeproj" />
- </ItemGroup>
-
- <Import Project="$(_NTDRIVE)$(_NTROOT)\tools\Microsoft.DevDiv.Traversal.targets" />
-</Project>
diff --git a/src/unwinder/dac/hostlocal/unwinder_dac.nativeproj b/src/unwinder/dac/hostlocal/unwinder_dac.nativeproj
deleted file mode 100644
index 3b562e07f9..0000000000
--- a/src/unwinder/dac/hostlocal/unwinder_dac.nativeproj
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-
- <PropertyGroup>
- <BuildCoreBinaries>true</BuildCoreBinaries>
- <BuildSysBinaries>true</BuildSysBinaries>
- <OutputName>unwinder_dac</OutputName>
- </PropertyGroup>
-
- <!-- compile items -->
- <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\src\unwinder\unwinder.targets" />
-
-</Project>
diff --git a/src/unwinder/dac/hostwinamd64/unwinder_dac.nativeproj b/src/unwinder/dac/hostwinamd64/unwinder_dac.nativeproj
deleted file mode 100644
index e0dff469a4..0000000000
--- a/src/unwinder/dac/hostwinamd64/unwinder_dac.nativeproj
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-
- <!-- xplat Windows host, local target DAC build -->
- <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\xplat\SetTargetLocal.props" />
- <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\xplat\SetHostWinAMD64.props" />
- <PropertyGroup>
- <BuildSysBinaries>true</BuildSysBinaries>
- <OutputName>unwinder_dac_amd64</OutputName>
- </PropertyGroup>
-
- <!-- compile items -->
- <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\src\unwinder\unwinder.targets" />
-
-</Project>
diff --git a/src/unwinder/dac/hostwinx86/unwinder_dac.nativeproj b/src/unwinder/dac/hostwinx86/unwinder_dac.nativeproj
deleted file mode 100644
index a3538c3383..0000000000
--- a/src/unwinder/dac/hostwinx86/unwinder_dac.nativeproj
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-
- <!-- xplat win32 host, local target DAC build -->
- <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\xplat\SetTargetLocal.props" />
- <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\xplat\SetHostWinx86.props" />
- <PropertyGroup>
- <BuildSysBinaries>true</BuildSysBinaries>
- <OutputName>unwinder_dac_x86</OutputName>
- </PropertyGroup>
-
- <!-- compile items -->
- <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\src\unwinder\unwinder.targets" />
-
-</Project>
diff --git a/src/unwinder/dirs.proj b/src/unwinder/dirs.proj
deleted file mode 100644
index 8b511971e3..0000000000
--- a/src/unwinder/dirs.proj
+++ /dev/null
@@ -1,19 +0,0 @@
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <!--Import the settings-->
- <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\clr.props" />
-
- <PropertyGroup>
- <BuildInPhase1>true</BuildInPhase1>
- <BuildInPhaseDefault>false</BuildInPhaseDefault>
- <BuildCoreBinaries>true</BuildCoreBinaries>
- <BuildSysBinaries>true</BuildSysBinaries>
- </PropertyGroup>
-
- <!--The following projects will build during PHASE 1-->
- <ItemGroup Condition="'$(BuildExePhase)' == '1'">
- <ProjectFile Include="dac\dirs.proj" />
- </ItemGroup>
-
- <!--Import the targets-->
- <Import Project="$(_NTDRIVE)$(_NTROOT)\tools\Microsoft.DevDiv.Traversal.targets" />
-</Project>
diff --git a/src/unwinder/i386/unwinder_i386.cpp b/src/unwinder/i386/unwinder_i386.cpp
new file mode 100644
index 0000000000..ca9e28e44a
--- /dev/null
+++ b/src/unwinder/i386/unwinder_i386.cpp
@@ -0,0 +1,194 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+//
+
+#include "stdafx.h"
+#include "unwinder_i386.h"
+
+#ifdef WIN64EXCEPTIONS
+/*++
+
+Routine Description:
+
+ This function virtually unwinds the specified function by executing its
+ prologue code backward or its epilogue code forward.
+
+ If a context pointers record is specified, then the address where each
+ nonvolatile registers is restored from is recorded in the appropriate
+ element of the context pointers record.
+
+Arguments:
+
+ HandlerType - Supplies the handler type expected for the virtual unwind.
+ This may be either an exception or an unwind handler. A flag may
+ optionally be supplied to avoid epilogue detection if it is known
+ the specified control PC is not located inside a function epilogue.
+
+ ImageBase - Supplies the base address of the image that contains the
+ function being unwound.
+
+ ControlPc - Supplies the address where control left the specified
+ function.
+
+ FunctionEntry - Supplies the address of the function table entry for the
+ specified function.
+
+ ContextRecord - Supplies the address of a context record.
+
+
+ HandlerData - Supplies a pointer to a variable that receives a pointer
+ the the language handler data.
+
+ EstablisherFrame - Supplies a pointer to a variable that receives the
+ the establisher frame pointer value.
+
+ ContextPointers - Supplies an optional pointer to a context pointers
+ record.
+
+ HandlerRoutine - Supplies an optional pointer to a variable that receives
+ the handler routine address. If control did not leave the specified
+ function in either the prologue or an epilogue and a handler of the
+ proper type is associated with the function, then the address of the
+ language specific exception handler is returned. Otherwise, NULL is
+ returned.
+--*/
+HRESULT
+OOPStackUnwinderX86::VirtualUnwind(
+ __in DWORD HandlerType,
+ __in DWORD ImageBase,
+ __in DWORD ControlPc,
+ __in _PIMAGE_RUNTIME_FUNCTION_ENTRY FunctionEntry,
+ __inout PCONTEXT ContextRecord,
+ __out PVOID *HandlerData,
+ __out PDWORD EstablisherFrame,
+ __inout_opt PKNONVOLATILE_CONTEXT_POINTERS ContextPointers,
+ __deref_opt_out_opt PEXCEPTION_ROUTINE *HandlerRoutine
+ )
+{
+ if (HandlerRoutine != NULL)
+ {
+ *HandlerRoutine = NULL;
+ }
+
+ REGDISPLAY rd;
+
+ FillRegDisplay(&rd, ContextRecord);
+
+ rd.PCTAddr = (UINT_PTR)&(ContextRecord->Eip);
+
+ if (ContextPointers)
+ {
+ rd.pCurrentContextPointers = ContextPointers;
+ }
+
+ CodeManState codeManState;
+ codeManState.dwIsSet = 0;
+
+ EECodeInfo codeInfo;
+ codeInfo.Init((PCODE) ControlPc);
+
+ if (!UnwindStackFrame(&rd, &codeInfo, UpdateAllRegs, &codeManState, NULL))
+ {
+ return HRESULT_FROM_WIN32(ERROR_READ_FAULT);
+ }
+
+ ContextRecord->ContextFlags |= CONTEXT_UNWOUND_TO_CALL;
+
+#define ARGUMENT_AND_SCRATCH_REGISTER(reg) if (rd.pCurrentContextPointers->reg) ContextRecord->reg = *rd.pCurrentContextPointers->reg;
+ ENUM_ARGUMENT_AND_SCRATCH_REGISTERS();
+#undef ARGUMENT_AND_SCRATCH_REGISTER
+
+#define CALLEE_SAVED_REGISTER(reg) if (rd.pCurrentContextPointers->reg) ContextRecord->reg = *rd.pCurrentContextPointers->reg;
+ ENUM_CALLEE_SAVED_REGISTERS();
+#undef CALLEE_SAVED_REGISTER
+
+ ContextRecord->Esp = rd.SP;
+ ContextRecord->Eip = rd.ControlPC;
+
+ // For x86, the value of Establisher Frame Pointer is Caller SP
+ //
+ // (Please refers to CLR ABI for details)
+ *EstablisherFrame = ContextRecord->Esp;
+ return S_OK;
+}
+
+//---------------------------------------------------------------------------------------
+//
+// This function behaves like the RtlVirtualUnwind in Windows.
+// It virtually unwinds the specified function by executing its
+// prologue code backward or its epilogue code forward.
+//
+// If a context pointers record is specified, then the address where each
+// nonvolatile registers is restored from is recorded in the appropriate
+// element of the context pointers record.
+//
+// Arguments:
+//
+// HandlerType - Supplies the handler type expected for the virtual unwind.
+// This may be either an exception or an unwind handler. A flag may
+// optionally be supplied to avoid epilogue detection if it is known
+// the specified control PC is not located inside a function epilogue.
+//
+// ImageBase - Supplies the base address of the image that contains the
+// function being unwound.
+//
+// ControlPc - Supplies the address where control left the specified
+// function.
+//
+// FunctionEntry - Supplies the address of the function table entry for the
+// specified function.
+//
+// ContextRecord - Supplies the address of a context record.
+//
+// HandlerData - Supplies a pointer to a variable that receives a pointer
+// the the language handler data.
+//
+// EstablisherFrame - Supplies a pointer to a variable that receives the
+// the establisher frame pointer value.
+//
+// ContextPointers - Supplies an optional pointer to a context pointers
+// record.
+//
+// Return value:
+//
+// The handler routine address. If control did not leave the specified
+// function in either the prologue or an epilogue and a handler of the
+// proper type is associated with the function, then the address of the
+// language specific exception handler is returned. Otherwise, NULL is
+// returned.
+//
+EXTERN_C
+NTSYSAPI
+PEXCEPTION_ROUTINE
+NTAPI
+RtlVirtualUnwind (
+ __in DWORD HandlerType,
+ __in DWORD ImageBase,
+ __in DWORD ControlPc,
+ __in PRUNTIME_FUNCTION FunctionEntry,
+ __inout PT_CONTEXT ContextRecord,
+ __out PVOID *HandlerData,
+ __out PDWORD EstablisherFrame,
+ __inout_opt PT_KNONVOLATILE_CONTEXT_POINTERS ContextPointers
+ )
+{
+ PEXCEPTION_ROUTINE handlerRoutine;
+
+ HRESULT res = OOPStackUnwinderX86::VirtualUnwind(
+ HandlerType,
+ ImageBase,
+ ControlPc,
+ (_PIMAGE_RUNTIME_FUNCTION_ENTRY)FunctionEntry,
+ ContextRecord,
+ HandlerData,
+ EstablisherFrame,
+ ContextPointers,
+ &handlerRoutine);
+
+ _ASSERTE(SUCCEEDED(res));
+
+ return handlerRoutine;
+}
+#endif // WIN64EXCEPTIONS
diff --git a/src/unwinder/i386/unwinder_i386.h b/src/unwinder/i386/unwinder_i386.h
new file mode 100644
index 0000000000..bed30bf894
--- /dev/null
+++ b/src/unwinder/i386/unwinder_i386.h
@@ -0,0 +1,33 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+//
+
+#ifndef __unwinder_i386_h__
+#define __unwinder_i386_h__
+
+#include "unwinder.h"
+
+#ifdef WIN64EXCEPTIONS
+//---------------------------------------------------------------------------------------
+//
+// See the comment for the base class code:OOPStackUnwinder.
+//
+
+class OOPStackUnwinderX86 : public OOPStackUnwinder
+{
+public:
+ static HRESULT VirtualUnwind(__in DWORD HandlerType,
+ __in DWORD ImageBase,
+ __in DWORD ControlPc,
+ __in _PIMAGE_RUNTIME_FUNCTION_ENTRY FunctionEntry,
+ __inout PCONTEXT ContextRecord,
+ __out PVOID *HandlerData,
+ __out PDWORD EstablisherFrame,
+ __inout_opt PKNONVOLATILE_CONTEXT_POINTERS ContextPointers,
+ __deref_opt_out_opt PEXCEPTION_ROUTINE *HandlerRoutine);
+};
+#endif // WIN64EXCEPTIONS
+
+#endif // __unwinder_i386_h__
diff --git a/src/unwinder/unwinder.targets b/src/unwinder/unwinder.targets
deleted file mode 100644
index 18cd2bfa7c..0000000000
--- a/src/unwinder/unwinder.targets
+++ /dev/null
@@ -1,60 +0,0 @@
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-
- <!--Import the settings-->
- <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\clr.props" />
- <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\dac.props" />
- <Import Project="$(_NTDRIVE)$(_NTROOT)\ndp\clr\src\debug\SetDebugTargetLocal.props" />
- <!--Leaf project Properties-->
- <PropertyGroup>
- <UseStl Condition="'$(BuildForCoreSystem)' != 'true'">true</UseStl>
-
- <UserIncludes>
- $(UserIncludes);
- $(ClrSrcDirectory)\unwinder;
- $(ClrSrcDirectory)\debug\daccess;
- $(ClrSrcDirectory)\vm;
- $(ClrSrcDirectory)\vm\$(TargetCpu);
- $(ClrSrcDirectory)\debug\inc;
- $(ClrSrcDirectory)\debug\inc\$(TargetCpu);
- $(ClrSrcDirectory)\debug\inc\dump;
- $(ClrSrcDirectory)\debug\ee;
- $(ClrSrcDirectory)\inc;
- $(VCToolsIncPath);
- </UserIncludes>
-
- <CDefines>$(CDefines);UNICODE;_UNICODE;$(USER_SPECIFIC_C_DEFINES);FEATURE_NO_HOST</CDefines>
-
- <OutputName Condition="'$(OutputName)' == ''">unwinder_dac</OutputName>
- <OutputPath>$(ClrLibDest)</OutputPath>
- <TargetType>LIBRARY</TargetType>
- <PCHHeader>stdafx.h</PCHHeader>
- <EnableCxxPCHHeaders>true</EnableCxxPCHHeaders>
- <PCHCompile>$(ClrSrcDirectory)\unwinder\stdafx.cpp</PCHCompile>
-
- <UnwinderSourcesDir>$(ClrSrcDirectory)\unwinder</UnwinderSourcesDir>
- <Amd64SourcesDir>$(ClrSrcDirectory)\unwinder\amd64</Amd64SourcesDir>
- <ArmSourcesDir>$(ClrSrcDirectory)\unwinder\arm</ArmSourcesDir>
- <Arm64SourcesDir>$(ClrSrcDirectory)\unwinder\arm64</Arm64SourcesDir>
- </PropertyGroup>
-
- <ItemGroup>
- <CppCompile Include="$(UnwinderSourcesDir)\unwinder.cpp" />
- </ItemGroup>
-
- <!-- AMD64_SOURCES -->
- <ItemGroup Condition="'$(TargetArch)' == 'amd64'">
- <CppCompile Include="$(Amd64SourcesDir)\unwinder_amd64.cpp" />
- </ItemGroup>
- <!-- ARM_SOURCES -->
- <ItemGroup Condition="'$(TargetArch)' == 'arm'">
- <CppCompile Include="$(ArmSourcesDir)\unwinder_arm.cpp" />
- </ItemGroup>
- <!-- ARM64_SOURCES -->
- <ItemGroup Condition="'$(TargetArch)' == 'arm64'">
- <CppCompile Include="$(Arm64SourcesDir)\unwinder_arm64.cpp" />
- </ItemGroup>
-
- <Import Project="$(Clrbase)\clr.targets" />
-
-</Project>
-