mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-28 02:11:43 +00:00
[build] Prepare for Windows arm64 builds (#5390)
Builds aren't actually enabled yet due to a bug in Gradle.
This commit is contained in:
@@ -23,13 +23,7 @@ class StackTraceWalker : public StackWalker {
|
||||
} // namespace
|
||||
|
||||
void StackTraceWalker::OnOutput(LPCTSTR szText) {
|
||||
#ifdef _UNICODE
|
||||
wpi::SmallString<128> utf8;
|
||||
wpi::sys::windows::UTF16ToUTF8(szText, wcslen(szText), utf8);
|
||||
m_output.append(utf8.data(), utf8.size());
|
||||
#else
|
||||
m_output.append(szText);
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace wpi {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -43,14 +43,27 @@
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#if _MSC_VER >= 1900
|
||||
#pragma warning(disable : 4091)
|
||||
// special defines for VC5/6 (if no actual PSDK is installed):
|
||||
#if _MSC_VER < 1300
|
||||
typedef unsigned __int64 DWORD64, *PDWORD64;
|
||||
#if defined(_WIN64)
|
||||
typedef unsigned __int64 SIZE_T, *PSIZE_T;
|
||||
#else
|
||||
typedef unsigned long SIZE_T, *PSIZE_T;
|
||||
#endif
|
||||
#endif // _MSC_VER < 1300
|
||||
|
||||
class StackWalkerInternal; // forward
|
||||
class StackWalker
|
||||
{
|
||||
public:
|
||||
typedef enum ExceptType
|
||||
{
|
||||
NonExcept = 0, // RtlCaptureContext
|
||||
AfterExcept = 1,
|
||||
AfterCatch = 2, // get_current_exception_context
|
||||
} ExceptType;
|
||||
|
||||
typedef enum StackWalkOptions
|
||||
{
|
||||
// No addition info will be retrieved
|
||||
@@ -85,13 +98,28 @@ public:
|
||||
OptionsAll = 0x3F
|
||||
} StackWalkOptions;
|
||||
|
||||
StackWalker(ExceptType extype, int options = OptionsAll, PEXCEPTION_POINTERS exp = NULL);
|
||||
|
||||
StackWalker(int options = OptionsAll, // 'int' is by design, to combine the enum-flags
|
||||
LPCTSTR szSymPath = NULL,
|
||||
LPCSTR szSymPath = NULL,
|
||||
DWORD dwProcessId = GetCurrentProcessId(),
|
||||
HANDLE hProcess = GetCurrentProcess());
|
||||
|
||||
StackWalker(DWORD dwProcessId, HANDLE hProcess);
|
||||
|
||||
virtual ~StackWalker();
|
||||
|
||||
bool SetSymPath(LPCSTR szSymPath);
|
||||
|
||||
bool SetTargetProcess(DWORD dwProcessId, HANDLE hProcess);
|
||||
|
||||
PCONTEXT GetCurrentExceptionContext();
|
||||
|
||||
private:
|
||||
bool Init(ExceptType extype, int options, LPCSTR szSymPath, DWORD dwProcessId,
|
||||
HANDLE hProcess, PEXCEPTION_POINTERS exp = NULL);
|
||||
|
||||
public:
|
||||
typedef BOOL(__stdcall* PReadProcessMemoryRoutine)(
|
||||
HANDLE hProcess,
|
||||
DWORD64 qwBaseAddress,
|
||||
@@ -127,18 +155,18 @@ protected:
|
||||
typedef struct CallstackEntry
|
||||
{
|
||||
DWORD64 offset; // if 0, we have no valid entry
|
||||
TCHAR name[STACKWALK_MAX_NAMELEN];
|
||||
TCHAR undName[STACKWALK_MAX_NAMELEN];
|
||||
TCHAR undFullName[STACKWALK_MAX_NAMELEN];
|
||||
CHAR name[STACKWALK_MAX_NAMELEN];
|
||||
CHAR undName[STACKWALK_MAX_NAMELEN];
|
||||
CHAR undFullName[STACKWALK_MAX_NAMELEN];
|
||||
DWORD64 offsetFromSmybol;
|
||||
DWORD offsetFromLine;
|
||||
DWORD lineNumber;
|
||||
TCHAR lineFileName[STACKWALK_MAX_NAMELEN];
|
||||
CHAR lineFileName[STACKWALK_MAX_NAMELEN];
|
||||
DWORD symType;
|
||||
LPCSTR symTypeString;
|
||||
TCHAR moduleName[STACKWALK_MAX_NAMELEN];
|
||||
CHAR moduleName[STACKWALK_MAX_NAMELEN];
|
||||
DWORD64 baseOfImage;
|
||||
TCHAR loadedImageName[STACKWALK_MAX_NAMELEN];
|
||||
CHAR loadedImageName[STACKWALK_MAX_NAMELEN];
|
||||
} CallstackEntry;
|
||||
|
||||
typedef enum CallstackEntryType
|
||||
@@ -148,24 +176,24 @@ protected:
|
||||
lastEntry
|
||||
} CallstackEntryType;
|
||||
|
||||
virtual void OnSymInit(LPCTSTR szSearchPath, DWORD symOptions, LPCTSTR szUserName);
|
||||
virtual void OnLoadModule(LPCTSTR img,
|
||||
LPCTSTR mod,
|
||||
virtual void OnSymInit(LPCSTR szSearchPath, DWORD symOptions, LPCSTR szUserName);
|
||||
virtual void OnLoadModule(LPCSTR img,
|
||||
LPCSTR mod,
|
||||
DWORD64 baseAddr,
|
||||
DWORD size,
|
||||
DWORD result,
|
||||
LPCTSTR symType,
|
||||
LPCTSTR pdbName,
|
||||
LPCSTR symType,
|
||||
LPCSTR pdbName,
|
||||
ULONGLONG fileVersion);
|
||||
virtual void OnCallstackEntry(CallstackEntryType eType, CallstackEntry& entry);
|
||||
virtual void OnDbgHelpErr(LPCTSTR szFuncName, DWORD gle, DWORD64 addr);
|
||||
virtual void OnOutput(LPCTSTR szText);
|
||||
virtual void OnDbgHelpErr(LPCSTR szFuncName, DWORD gle, DWORD64 addr);
|
||||
virtual void OnOutput(LPCSTR szText);
|
||||
|
||||
StackWalkerInternal* m_sw;
|
||||
HANDLE m_hProcess;
|
||||
DWORD m_dwProcessId;
|
||||
BOOL m_modulesLoaded;
|
||||
LPTSTR m_szSymPath;
|
||||
LPSTR m_szSymPath;
|
||||
|
||||
int m_options;
|
||||
int m_MaxRecursionCount;
|
||||
@@ -179,6 +207,57 @@ protected:
|
||||
friend StackWalkerInternal;
|
||||
}; // class StackWalker
|
||||
|
||||
// The "ugly" assembler-implementation is needed for systems before XP
|
||||
// If you have a new PSDK and you only compile for XP and later, then you can use
|
||||
// the "RtlCaptureContext"
|
||||
// Currently there is no define which determines the PSDK-Version...
|
||||
// So we just use the compiler-version (and assumes that the PSDK is
|
||||
// the one which was installed by the VS-IDE)
|
||||
|
||||
// INFO: If you want, you can use the RtlCaptureContext if you only target XP and later...
|
||||
// But I currently use it in x64/IA64 environments...
|
||||
//#if defined(_M_IX86) && (_WIN32_WINNT <= 0x0500) && (_MSC_VER < 1400)
|
||||
|
||||
#if defined(_M_IX86)
|
||||
#ifdef CURRENT_THREAD_VIA_EXCEPTION
|
||||
// TODO: The following is not a "good" implementation,
|
||||
// because the callstack is only valid in the "__except" block...
|
||||
#define GET_CURRENT_CONTEXT_STACKWALKER_CODEPLEX(c, contextFlags) \
|
||||
do \
|
||||
{ \
|
||||
memset(&c, 0, sizeof(CONTEXT)); \
|
||||
EXCEPTION_POINTERS* pExp = NULL; \
|
||||
__try \
|
||||
{ \
|
||||
throw 0; \
|
||||
} \
|
||||
__except (((pExp = GetExceptionInformation()) ? EXCEPTION_EXECUTE_HANDLER \
|
||||
: EXCEPTION_EXECUTE_HANDLER)) \
|
||||
{ \
|
||||
} \
|
||||
if (pExp != NULL) \
|
||||
memcpy(&c, pExp->ContextRecord, sizeof(CONTEXT)); \
|
||||
c.ContextFlags = contextFlags; \
|
||||
} while (0);
|
||||
#else
|
||||
// clang-format off
|
||||
// The following should be enough for walking the callstack...
|
||||
#define GET_CURRENT_CONTEXT_STACKWALKER_CODEPLEX(c, contextFlags) \
|
||||
do \
|
||||
{ \
|
||||
memset(&c, 0, sizeof(CONTEXT)); \
|
||||
c.ContextFlags = contextFlags; \
|
||||
__asm call x \
|
||||
__asm x: pop eax \
|
||||
__asm mov c.Eip, eax \
|
||||
__asm mov c.Ebp, ebp \
|
||||
__asm mov c.Esp, esp \
|
||||
} while (0)
|
||||
// clang-format on
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
// The following is defined for x86 (XP and higher), x64 and IA64:
|
||||
#define GET_CURRENT_CONTEXT_STACKWALKER_CODEPLEX(c, contextFlags) \
|
||||
do \
|
||||
@@ -187,6 +266,7 @@ protected:
|
||||
c.ContextFlags = contextFlags; \
|
||||
RtlCaptureContext(&c); \
|
||||
} while (0);
|
||||
#endif
|
||||
|
||||
#endif //defined(_MSC_VER)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user