summaryrefslogtreecommitdiff
path: root/contrib/llvm/lib/Support/Windows/Signals.inc
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/lib/Support/Windows/Signals.inc')
-rw-r--r--contrib/llvm/lib/Support/Windows/Signals.inc49
1 files changed, 28 insertions, 21 deletions
diff --git a/contrib/llvm/lib/Support/Windows/Signals.inc b/contrib/llvm/lib/Support/Windows/Signals.inc
index 21dd2dd13754..41eb5e593aa5 100644
--- a/contrib/llvm/lib/Support/Windows/Signals.inc
+++ b/contrib/llvm/lib/Support/Windows/Signals.inc
@@ -10,6 +10,7 @@
// This file provides the Win32 specific implementation of the Signals class.
//
//===----------------------------------------------------------------------===//
+#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Process.h"
@@ -36,9 +37,6 @@
#ifdef _MSC_VER
#pragma comment(lib, "psapi.lib")
#elif __MINGW32__
- #if (HAVE_LIBPSAPI != 1)
- #error "libpsapi.a should be present"
- #endif
// The version of g++ that comes with MinGW does *not* properly understand
// the ll format specifier for printf. However, MinGW passes the format
// specifiers on to the MSVCRT entirely, and the CRT understands the ll
@@ -193,7 +191,7 @@ using namespace llvm;
static LONG WINAPI LLVMUnhandledExceptionFilter(LPEXCEPTION_POINTERS ep);
static BOOL WINAPI LLVMConsoleCtrlHandler(DWORD dwCtrlType);
-// InterruptFunction - The function to call if ctrl-c is pressed.
+// The function to call if ctrl-c is pressed.
static void (*InterruptFunction)() = 0;
static std::vector<std::string> *FilesToRemove = NULL;
@@ -390,9 +388,9 @@ namespace llvm {
//===----------------------------------------------------------------------===//
#ifdef _MSC_VER
-/// AvoidMessageBoxHook - Emulates hitting "retry" from an "abort, retry,
-/// ignore" CRT debug report dialog. "retry" raises an exception which
-/// ultimately triggers our stack dumper.
+/// Emulates hitting "retry" from an "abort, retry, ignore" CRT debug report
+/// dialog. "retry" raises an exception which ultimately triggers our stack
+/// dumper.
static LLVM_ATTRIBUTE_UNUSED int
AvoidMessageBoxHook(int ReportType, char *Message, int *Return) {
// Set *Return to the retry code for the return value of _CrtDbgReport:
@@ -450,7 +448,7 @@ static void RegisterHandler() {
// else multi-threading problems will ensue.
}
-// RemoveFileOnSignal - The public API
+// The public API
bool sys::RemoveFileOnSignal(StringRef Filename, std::string* ErrMsg) {
RegisterHandler();
@@ -469,7 +467,7 @@ bool sys::RemoveFileOnSignal(StringRef Filename, std::string* ErrMsg) {
return false;
}
-// DontRemoveFileOnSignal - The public API
+// The public API
void sys::DontRemoveFileOnSignal(StringRef Filename) {
if (FilesToRemove == NULL)
return;
@@ -503,8 +501,8 @@ void sys::DisableSystemDialogsOnCrash() {
_set_error_mode(_OUT_TO_STDERR);
}
-/// PrintStackTraceOnErrorSignal - When an error signal (such as SIBABRT or
-/// SIGSEGV) is delivered to the process, print a stack trace and then exit.
+/// When an error signal (such as SIGABRT or SIGSEGV) is delivered to the
+/// process, print a stack trace and then exit.
void sys::PrintStackTraceOnErrorSignal(StringRef Argv0,
bool DisableCrashReporting) {
::Argv0 = Argv0;
@@ -536,10 +534,14 @@ void llvm::sys::PrintStackTrace(raw_ostream &OS) {
StackFrame.AddrPC.Offset = Context.Eip;
StackFrame.AddrStack.Offset = Context.Esp;
StackFrame.AddrFrame.Offset = Context.Ebp;
-#elif defined(_M_ARM64) || defined(_M_ARM)
+#elif defined(_M_ARM64)
StackFrame.AddrPC.Offset = Context.Pc;
StackFrame.AddrStack.Offset = Context.Sp;
StackFrame.AddrFrame.Offset = Context.Fp;
+#elif defined(_M_ARM)
+ StackFrame.AddrPC.Offset = Context.Pc;
+ StackFrame.AddrStack.Offset = Context.Sp;
+ StackFrame.AddrFrame.Offset = Context.R11;
#endif
StackFrame.AddrPC.Mode = AddrModeFlat;
StackFrame.AddrStack.Mode = AddrModeFlat;
@@ -556,11 +558,12 @@ void llvm::sys::SetInterruptFunction(void (*IF)()) {
}
-/// AddSignalHandler - Add a function to be called when a signal is delivered
-/// to the process. The handler can have a cookie passed to it to identify
-/// what instance of the handler it is.
-void llvm::sys::AddSignalHandler(void (*FnPtr)(void *), void *Cookie) {
- CallBacksToRun->push_back(std::make_pair(FnPtr, Cookie));
+/// Add a function to be called when a signal is delivered to the process. The
+/// handler can have a cookie passed to it to identify what instance of the
+/// handler it is.
+void llvm::sys::AddSignalHandler(sys::SignalHandlerCallback FnPtr,
+ void *Cookie) {
+ insertSignalHandler(FnPtr, Cookie);
RegisterHandler();
LeaveCriticalSection(&CriticalSection);
}
@@ -594,7 +597,7 @@ void llvm::sys::RunInterruptHandlers() {
Cleanup();
}
-/// \brief Find the Windows Registry Key for a given location.
+/// Find the Windows Registry Key for a given location.
///
/// \returns a valid HKEY if the location exists, else NULL.
static HKEY FindWERKey(const llvm::Twine &RegistryLocation) {
@@ -607,7 +610,7 @@ static HKEY FindWERKey(const llvm::Twine &RegistryLocation) {
return Key;
}
-/// \brief Populate ResultDirectory with the value for "DumpFolder" for a given
+/// Populate ResultDirectory with the value for "DumpFolder" for a given
/// Windows Registry key.
///
/// \returns true if a valid value for DumpFolder exists, false otherwise.
@@ -648,7 +651,7 @@ static bool GetDumpFolder(HKEY Key,
return true;
}
-/// \brief Populate ResultType with a valid MINIDUMP_TYPE based on the value of
+/// Populate ResultType with a valid MINIDUMP_TYPE based on the value of
/// "DumpType" for a given Windows Registry key.
///
/// According to
@@ -695,7 +698,7 @@ static bool GetDumpType(HKEY Key, MINIDUMP_TYPE &ResultType) {
return true;
}
-/// \brief Write a Windows dump file containing process information that can be
+/// Write a Windows dump file containing process information that can be
/// used for post-mortem debugging.
///
/// \returns zero error code if a mini dump created, actual error code
@@ -819,7 +822,11 @@ static LONG WINAPI LLVMUnhandledExceptionFilter(LPEXCEPTION_POINTERS ep) {
StackFrame.AddrPC.Mode = AddrModeFlat;
StackFrame.AddrStack.Offset = ep->ContextRecord->Sp;
StackFrame.AddrStack.Mode = AddrModeFlat;
+#if defined(_M_ARM64)
StackFrame.AddrFrame.Offset = ep->ContextRecord->Fp;
+#else
+ StackFrame.AddrFrame.Offset = ep->ContextRecord->R11;
+#endif
StackFrame.AddrFrame.Mode = AddrModeFlat;
#endif