* [x86/Linux][SOS] Add support for x86 in GetContextFromFrame
It's need for 'clrstack -f' command of SOS plugin on x86.
* [x86/Linux] Fix RtlpGetFunctionEndAddress function
We should use PTR_UNWIND_INFO instead of PUNWIND_INFO for pointer to
UNWIND_INFO structure because it's pointer from other process and
we need to use DAC to read data using it.
* [x86/Linux][SOS] Define DEBUG_STACK_CONTEXT for x86
It's needed for 'clrstack -f' command in libsosplugin.
* [x86/Linux] Fix undefined references in libmscordbi.so on x86
Asm block like following:
__asm fnsave currentFPUState
where currentFPUState is structure works with MSVC but leads to
undefined reference currentFPUState in the binary with other
compilers. So rewrite such asm blocks for them.
This patch fixes error "Unable to load 'libmscordbi.so'" during
execution of 'clrstack -f' command of SOS plugin on x86.
* [x86/Linux] Fix calling convention inconsistency
WINAPI and STDAPI are defined as __cdecl but in some cases functions
with these attributes are called using stdcall calling convention.
It leads to crashes during execution of 'clrstack -i' command of
SOS plugin on x86.
Commit migrated from https://github.com/dotnet/coreclr/commit/
de4daccc1ea52ddc1ae8ac9e48cde603c507b868
#define DEBUG_STACK_CONTEXT AMD64_CONTEXT
#elif defined(_TARGET_ARM_) // _TARGET_WIN64_
#define DEBUG_STACK_CONTEXT ARM_CONTEXT
-#endif // _TARGET_ARM_
+#elif defined(_TARGET_X86_) // _TARGET_ARM_
+#define DEBUG_STACK_CONTEXT X86_CONTEXT
+#endif // _TARGET_X86_
#ifdef DEBUG_STACK_CONTEXT
// I use a global set of frames for stack walking on win64 because the debugger's
dtcontext->R10 = GetRegister(frame, "r10");
dtcontext->R11 = GetRegister(frame, "r11");
dtcontext->R12 = GetRegister(frame, "r12");
+#elif DBG_TARGET_X86
+ dtcontext->Eip = frame.GetPC();
+ dtcontext->Esp = frame.GetSP();
+ dtcontext->Ebp = frame.GetFP();
+ dtcontext->EFlags = GetRegister(frame, "eflags");
+
+ dtcontext->Edi = GetRegister(frame, "edi");
+ dtcontext->Esi = GetRegister(frame, "esi");
+ dtcontext->Ebx = GetRegister(frame, "ebx");
+ dtcontext->Edx = GetRegister(frame, "edx");
+ dtcontext->Ecx = GetRegister(frame, "ecx");
+ dtcontext->Eax = GetRegister(frame, "eax");
+
+ dtcontext->SegCs = GetRegister(frame, "cs");
+ dtcontext->SegSs = GetRegister(frame, "ss");
+ dtcontext->SegDs = GetRegister(frame, "ds");
+ dtcontext->SegEs = GetRegister(frame, "es");
+ dtcontext->SegFs = GetRegister(frame, "fs");
+ dtcontext->SegGs = GetRegister(frame, "gs");
#endif
}
FLOATING_SAVE_AREA currentFPUState;
+#ifdef _MSC_VER
__asm fnsave currentFPUState // save the current FPU state.
+#else
+ __asm__ __volatile__
+ (
+ " fnsave %0\n" \
+ : "=m"(currentFPUState)
+ );
+#endif
floatarea.StatusWord &= 0xFF00; // remove any error codes.
floatarea.ControlWord |= 0x3F; // mask all exceptions.
// @dbgtodo Microsoft crossplat: the conversion from a series of bytes to a floating
// point value will need to be done with an explicit conversion routine to unpack
// the IEEE format and compute the real number value represented.
-
+
+#ifdef _MSC_VER
__asm
{
fninit
frstor floatarea ;; reload the threads FPU state.
}
+#else
+ __asm__
+ (
+ " fninit\n" \
+ " frstor %0\n" \
+ : /* no outputs */
+ : "m"(floatarea)
+ );
+#endif
unsigned int i;
m_floatValues[i] = td;
}
+#ifdef _MSC_VER
__asm
{
fninit
frstor currentFPUState ;; restore our saved FPU state.
}
+#else
+ __asm__
+ (
+ " fninit\n" \
+ " frstor %0\n" \
+ : /* no outputs */
+ : "m"(currentFPUState)
+ );
+#endif
m_fFloatStateValid = true;
m_floatStackTop = floatStackTop;
// restore our original state.
DT_FLOATING_SAVE_AREA currentFPUState;
+ #ifdef _MSC_VER
__asm fnsave currentFPUState // save the current FPU state.
+ #else
+ __asm__ __volatile__
+ (
+ " fnsave %0\n" \
+ : "=m"(currentFPUState)
+ );
+ #endif
// Copy the state out of the context.
DT_FLOATING_SAVE_AREA floatarea = pContext->FloatSave;
floatarea.StatusWord &= 0xFF00; // remove any error codes.
floatarea.ControlWord |= 0x3F; // mask all exceptions.
+ #ifdef _MSC_VER
__asm
{
fninit
frstor floatarea ;; reload the threads FPU state.
}
+ #else
+ __asm__
+ (
+ " fninit\n" \
+ " frstor %0\n" \
+ : /* no outputs */
+ : "m"(floatarea)
+ );
+ #endif
double td; // temp double
double popArea[DebuggerIPCE_FloatCount];
}
// Save out the modified float area.
+ #ifdef _MSC_VER
__asm fnsave floatarea
+ #else
+ __asm__ __volatile__
+ (
+ " fnsave %0\n" \
+ : "=m"(floatarea)
+ );
+ #endif
// Put it into the context.
pContext->FloatSave= floatarea;
// Restore our FPU state
+ #ifdef _MSC_VER
__asm
{
fninit
frstor currentFPUState ;; restore our saved FPU state.
}
+ #else
+ __asm__
+ (
+ " fninit\n" \
+ " frstor %0\n" \
+ : /* no outputs */
+ : "m"(currentFPUState)
+ );
+ #endif
#endif // DBG_TARGET_X86
// update the thread's floating point stack
// CLRDebuggingImpl implementation (ICLRDebugging)
//*****************************************************************************
-typedef HRESULT (__stdcall *OpenVirtualProcessImplFnPtr)(ULONG64 clrInstanceId,
+typedef HRESULT (STDAPICALLTYPE *OpenVirtualProcessImplFnPtr)(ULONG64 clrInstanceId,
IUnknown * pDataTarget,
HMODULE hDacDll,
CLR_DEBUGGING_VERSION * pMaxDebuggerSupportedVersion,
IUnknown ** ppInstance,
CLR_DEBUGGING_PROCESS_FLAGS * pdwFlags);
-typedef HRESULT (__stdcall *OpenVirtualProcess2FnPtr)(ULONG64 clrInstanceId,
+typedef HRESULT (STDAPICALLTYPE *OpenVirtualProcess2FnPtr)(ULONG64 clrInstanceId,
IUnknown * pDataTarget,
HMODULE hDacDll,
REFIID riid,
//*****************************************************************************
#include "stdafx.h"
-extern BOOL STDMETHODCALLTYPE DbgDllMain(HINSTANCE hInstance, DWORD dwReason,
+extern BOOL WINAPI DbgDllMain(HINSTANCE hInstance, DWORD dwReason,
LPVOID lpReserved);
//*****************************************************************************
__in TADDR ImageBase
)
{
- PUNWIND_INFO pUnwindInfo = (PUNWIND_INFO)(ImageBase + FunctionEntry->UnwindData);
+ PTR_UNWIND_INFO pUnwindInfo = (PTR_UNWIND_INFO)(ImageBase + FunctionEntry->UnwindData);
return FunctionEntry->BeginAddress + pUnwindInfo->FunctionLength;
}