Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

[x86/Linux] Fix WIN64EXCEPTIONS build error #8629

Merged
merged 62 commits into from
Jan 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
c814180
Use WIN64EXCEPTIONS instead of _TARGET_X86_
parjong Dec 14, 2016
6677089
Revise FaultingExceptionFrame
parjong Dec 14, 2016
c2bad85
Move GetUnwindInfo and GetNumberOfUnwindInfos into the real code header
parjong Nov 29, 2016
c8d8738
Add RUNTIME_FUNCTION__EndAddress as NYI
parjong Dec 14, 2016
27cdda4
Revise regdisp.h
parjong Dec 15, 2016
df7c9db
Revise eetwain.h
parjong Dec 15, 2016
9a59ac6
Comment out exinfo.cpp if WIN64EXCEPTIONS is defined
parjong Dec 15, 2016
9d391d6
Revises excep.cpp
parjong Dec 15, 2016
8fa9fa5
Fix mistmatch in ThrowControlForThread defintion
parjong Dec 15, 2016
b5fc9fd
Revises cgenx86.cpp
parjong Dec 15, 2016
50875b7
Disable SEH-based exception handlers when WIN64EXCEPTIONS is defined
parjong Dec 15, 2016
0b3d7c0
Revise stackwalk.cpp
parjong Dec 15, 2016
d4471e4
Revise jitinterface.cpp
parjong Dec 15, 2016
fcae39e
Revise readytorun.h
parjong Dec 15, 2016
f733395
Revise dbgipcevents.h
parjong Dec 15, 2016
cf6be8c
Revise zapcode.cpp
parjong Dec 15, 2016
67eb702
Revise clrnt.h
parjong Dec 15, 2016
c280c94
Fix Windows build error
parjong Dec 15, 2016
4935445
Mark FaultingExceptionFrame::UpdateRegDisplay as NYI
parjong Dec 15, 2016
8936dff
Revise per feedback
parjong Dec 15, 2016
51990b4
Revert #if defined(..) as #ifdef
parjong Dec 15, 2016
acf7d0a
Fix style changes
parjong Dec 15, 2016
dc42954
Fix style changes
parjong Dec 15, 2016
abd974e
Remove #undef _TARGET_X86_
parjong Dec 16, 2016
b22d9e2
2nd attempt to fix Windows build error
parjong Dec 16, 2016
53d121b
Revise per feedback
parjong Dec 20, 2016
e991914
Revert the chagnes in clrdefinitions.cmake and add BIT32 in CMakeList…
parjong Dec 20, 2016
e9bccea
Use !BIT64 instead of BIT32
parjong Dec 20, 2016
fcbdf54
Include exceptionhandling.cpp and gcinfodecoder.cpp in build
parjong Dec 22, 2016
8768e45
Fix COMPlus_EndCatch undefined reference
parjong Dec 22, 2016
66d86af
Fix build error
parjong Dec 22, 2016
3e4c917
Fix GcInfoDecoder-related undefined references
parjong Dec 22, 2016
2d534a2
Fix AdjustContextForVirtualStub undefined reference
parjong Dec 22, 2016
0b43f76
Fix GetCallerSP undefined reference
parjong Dec 22, 2016
92eb6f2
Fix ResetThreadAbortState undefined reference
parjong Dec 22, 2016
b0061b6
Attempt to fix Windows build error
parjong Dec 22, 2016
3c5f643
Fix CLRNoCatchHandler undefined reference
parjong Dec 22, 2016
56f69ef
Another attemp to fix Windows build error
parjong Dec 22, 2016
0b6f553
Fix GetXXXFromRedirectedStubStackFrame undefined references
parjong Dec 22, 2016
0977740
Fix Windows Build Error
parjong Dec 22, 2016
9bfae60
Add RtlpGetFunctionEndAddress and RtlVirtualUnwind as NYI
parjong Dec 22, 2016
feb6956
Fix undefined references on JIT helpers
parjong Dec 22, 2016
1feba59
Enable Dummy Application Run with WIN64EXCEPTIONS
parjong Jan 3, 2017
024af9b
Revert "Move GetUnwindInfo and GetNumberOfUnwindInfos into the real c…
parjong Jan 3, 2017
ec97590
Use indirect code header when WIN64EXCEPTIONS is enabled
parjong Jan 3, 2017
301c261
Port 'SyncRegDisplayToCurrentContext' and 'FillRegDisplay'
parjong Jan 3, 2017
33fdeab
Revise style 'RUNTIME_FUNCTION__SetUnwindInfoAddress'
parjong Jan 5, 2017
cf6b3b1
Extract out HandlerData from #ifdef region
parjong Jan 5, 2017
b95967a
Add UNIXTODO
parjong Jan 5, 2017
285ef04
Add UNIXTODO
parjong Jan 5, 2017
055abfd
Port 'GetRegdisplayReturnValue'
parjong Jan 5, 2017
1fd427c
Fix incorrect comment
parjong Jan 5, 2017
a92ba63
Remove messages that mentions WIN32EXCEPTIONS
parjong Jan 5, 2017
2a7d295
Revise AdjustContextForWriteBarrier
parjong Jan 5, 2017
e21fcd1
Port 'FaultingExceptionFrame::UpdateRegDisplay'
parjong Jan 5, 2017
671923f
Extract out 'AdjustContextForVirtualStub' and 'CLRNoCatchHandler' fro…
parjong Jan 6, 2017
8f38336
Merge two #ifdef regions
parjong Jan 6, 2017
442d763
Set WIN64EXCEPTIONS as a default for x86/Linux
parjong Dec 12, 2016
1c30ee4
Remove unnecessary #ifdef from ThrowControlForThread
parjong Jan 6, 2017
bf6ec0d
Remove unnecessary stubs
parjong Jan 6, 2017
6019340
Add Dependency Check between Compile Flags
parjong Jan 8, 2017
248dc87
Revise per feedback
parjong Jan 10, 2017
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
1 change: 1 addition & 0 deletions src/ToolBox/SOS/Strike/disasmARM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
namespace ARMGCDump
{
#undef _TARGET_X86_
#define WIN64EXCEPTIONS
#undef LIMITED_METHOD_CONTRACT
#define LIMITED_METHOD_DAC_CONTRACT
#define SUPPORTS_DAC
Expand Down
4 changes: 2 additions & 2 deletions src/debug/daccess/enummem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ HRESULT ClrDataAccess::EnumMemWalkStackHelper(CLRDataEnumMemoryFlags flags,
// Pulls in sequence points and local variable info
DebugInfoManager::EnumMemoryRegionsForMethodDebugInfo(flags, pMethodDesc);

#ifdef WIN64EXCEPTIONS
#if defined(WIN64EXCEPTIONS) && defined(USE_GC_INFO_DECODER)

if (addr != NULL)
{
Expand All @@ -988,7 +988,7 @@ HRESULT ClrDataAccess::EnumMemWalkStackHelper(CLRDataEnumMemoryFlags flags,
DacEnumMemoryRegion(dac_cast<TADDR>(pGCInfo), gcDecoder.GetNumBytesRead(), true);
}
}
#endif // WIN64EXCEPTIONS
#endif // WIN64EXCEPTIONS && USE_GC_INFO_DECODER
}
pMethodDefinition.Clear();
}
Expand Down
4 changes: 2 additions & 2 deletions src/debug/di/rspriv.h
Original file line number Diff line number Diff line change
Expand Up @@ -6929,11 +6929,11 @@ struct CordbMiscFrame
// new-style constructor
CordbMiscFrame(DebuggerIPCE_JITFuncData * pJITFuncData);

#if defined(DBG_TARGET_WIN64) || defined(DBG_TARGET_ARM)
#ifdef WIN64EXCEPTIONS
SIZE_T parentIP;
FramePointer fpParentOrSelf;
bool fIsFilterFunclet;
#endif // DBG_TARGET_WIN64 || DBG_TARGET_ARM
#endif // WIN64EXCEPTIONS
};


Expand Down
4 changes: 2 additions & 2 deletions src/debug/di/rsthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5849,11 +5849,11 @@ CordbMiscFrame::CordbMiscFrame()
// the real constructor which stores the funclet-related information in the CordbMiscFrame
CordbMiscFrame::CordbMiscFrame(DebuggerIPCE_JITFuncData * pJITFuncData)
{
#if defined(DBG_TARGET_WIN64) || defined(DBG_TARGET_ARM)
#ifdef WIN64EXCEPTIONS
this->parentIP = pJITFuncData->parentNativeOffset;
this->fpParentOrSelf = pJITFuncData->fpParentOrSelf;
this->fIsFilterFunclet = (pJITFuncData->fIsFilterFrame == TRUE);
#endif // DBG_TARGET_WIN64 || DBG_TARGET_ARM
#endif // WIN64EXCEPTIONS
}

/* ------------------------------------------------------------------------- *
Expand Down
4 changes: 2 additions & 2 deletions src/debug/inc/dbgipcevents.h
Original file line number Diff line number Diff line change
Expand Up @@ -1355,11 +1355,11 @@ struct MSLAYOUT DebuggerIPCE_JITFuncData
LSPTR_DJI nativeCodeJITInfoToken;
VMPTR_MethodDesc vmNativeCodeMethodDescToken;

#if defined(DBG_TARGET_WIN64) || defined(DBG_TARGET_ARM)
#ifdef WIN64EXCEPTIONS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change also the same condition at src\debug\di\rsthread.cpp:5852

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@janvorli Revised.

BOOL fIsFilterFrame;
SIZE_T parentNativeOffset;
FramePointer fpParentOrSelf;
#endif // DBG_TARGET_WIN64 || DBG_TARGET_ARM
#endif // WIN64EXCEPTIONS

// indicates if the MethodDesc is a generic function or a method inside a generic class (or
// both!).
Expand Down
44 changes: 44 additions & 0 deletions src/inc/clrnt.h
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,13 @@ RtlVirtualUnwind_Unsafe(

#ifdef _TARGET_X86_
#ifndef FEATURE_PAL
//
// x86 ABI does not define RUNTIME_FUNCTION. Define our own to allow unification between x86 and other platforms.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@parjong I am not sure I understand how could the Windows build get broken. Things that you change for the WIN64EXCEPTIONS should be done in a way that doesn't influence windows x86 stuff.

Copy link
Author

@parjong parjong Dec 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I am trying not to affect windows x86 stuff via submitting small commits frequently (I have no mean to check windows build issue).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turns out that windows build uses PORTABILITY_ASSERT that raises compile error (instead of runtime error).

//
typedef struct _RUNTIME_FUNCTION {
DWORD BeginAddress;
DWORD UnwindData;
} RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;

typedef struct _DISPATCHER_CONTEXT {
_EXCEPTION_REGISTRATION_RECORD* RegistrationPointer;
Expand All @@ -845,6 +852,43 @@ typedef struct _DISPATCHER_CONTEXT {
#endif // !FEATURE_PAL

#define RUNTIME_FUNCTION__BeginAddress(prf) (prf)->BeginAddress
#define RUNTIME_FUNCTION__SetBeginAddress(prf,addr) ((prf)->BeginAddress = (addr))

#ifdef WIN64EXCEPTIONS
EXTERN_C ULONG
RtlpGetFunctionEndAddress (
__in PT_RUNTIME_FUNCTION FunctionEntry,
__in ULONG ImageBase
);

#define RUNTIME_FUNCTION__EndAddress(prf, ImageBase) RtlpGetFunctionEndAddress(prf, ImageBase)

#define RUNTIME_FUNCTION__GetUnwindInfoAddress(prf) (prf)->UnwindData
#define RUNTIME_FUNCTION__SetUnwindInfoAddress(prf, addr) do { (prf)->UnwindData = (addr); } while(0)

#define UNW_FLAG_NHANDLER 0x0 /* any handler */
#define UNW_FLAG_EHANDLER 0x1 /* filter handler */
#define UNW_FLAG_UHANDLER 0x2 /* unwind handler */

typedef struct _UNWIND_INFO {
// dummy
} UNWIND_INFO, *PUNWIND_INFO;

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
);
#endif // WIN64EXCEPTIONS

#endif // _TARGET_X86_

Expand Down
14 changes: 2 additions & 12 deletions src/inc/corcompile.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
#error FEATURE_PREJIT is required for this file
#endif // FEATURE_PREJIT

#if !defined(_TARGET_X86_)
#if !defined(_TARGET_X86_) || defined(FEATURE_PAL)
#ifndef WIN64EXCEPTIONS
#define WIN64EXCEPTIONS
#endif
#endif // !_TARGET_X86_
#endif // !_TARGET_X86_ || FEATURE_PAL

#include <cor.h>
#include <corhdr.h>
Expand Down Expand Up @@ -72,16 +72,6 @@ typedef DPTR(struct CORCOMPILE_IMPORT_SECTION)
PTR_CORCOMPILE_IMPORT_SECTION;

#ifdef _TARGET_X86_
#ifndef FEATURE_PAL
//
// x86 ABI does not define RUNTIME_FUNCTION. Define our own to allow unification between x86 and other platforms.
//
typedef struct _RUNTIME_FUNCTION {
DWORD BeginAddress;
DWORD UnwindData;
} RUNTIME_FUNCTION, *PRUNTIME_FUNCTION;

#endif // !FEATURE_PAL

typedef DPTR(RUNTIME_FUNCTION) PTR_RUNTIME_FUNCTION;

Expand Down
2 changes: 1 addition & 1 deletion src/inc/eetwain.h
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ HRESULT FixContextForEnC(PCONTEXT pCtx,

#endif // #ifndef DACCESS_COMPILE

#ifndef _TARGET_X86_
#ifdef WIN64EXCEPTIONS
static void EnsureCallerContextIsValid( PREGDISPLAY pRD, StackwalkCacheEntry* pCacheEntry, EECodeInfo * pCodeInfo = NULL );
static size_t GetCallerSp( PREGDISPLAY pRD );
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/inc/gcinfodecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ class GcSlotDecoder
GcSlotDesc* m_pLastSlot;
};

#ifdef USE_GC_INFO_DECODER
class GcInfoDecoder
{
public:
Expand Down Expand Up @@ -678,6 +679,7 @@ class GcInfoDecoder
}
}
};
#endif // USE_GC_INFO_DECODER


#endif // _GC_INFO_DECODER_
Expand Down
3 changes: 2 additions & 1 deletion src/inc/jithelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@
JITHELPER(CORINFO_HELP_FIELD_ACCESS_EXCEPTION,JIT_ThrowFieldAccessException, CORINFO_HELP_SIG_REG_ONLY)
JITHELPER(CORINFO_HELP_CLASS_ACCESS_EXCEPTION,JIT_ThrowClassAccessException, CORINFO_HELP_SIG_REG_ONLY)

#ifdef WIN64EXCEPTIONS
// UNIXTODO: Disable JIT_EndCatch after revising the jitter not to use this (for x86/Linux)
#ifndef _TARGET_X86_
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this change needed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@janvorli It is a simple workaround. As JIT is not revised yet, JIT attempts to use JIT_EndCatch even when WIN64EXCEPTIONS is enabled while running simple 'Hello, World' example. This causes assert failure.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks for the explanation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add UNIXTODO here to revert this change once the JIT is revised?

JITHELPER(CORINFO_HELP_ENDCATCH, NULL, CORINFO_HELP_SIG_CANNOT_USE_ALIGN_STUB)
#else
JITHELPER(CORINFO_HELP_ENDCATCH, JIT_EndCatch, CORINFO_HELP_SIG_CANNOT_USE_ALIGN_STUB)
Expand Down
2 changes: 1 addition & 1 deletion src/inc/readytorun.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ enum ReadyToRunHelper
READYTORUN_HELPER_DblRound = 0xE2,
READYTORUN_HELPER_FltRound = 0xE3,

#ifndef _TARGET_X86_
#ifdef WIN64EXCEPTIONS
// Personality rountines
READYTORUN_HELPER_PersonalityRoutine = 0xF0,
READYTORUN_HELPER_PersonalityRoutineFilterFunclet = 0xF1,
Expand Down
Loading