aboutsummaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_win.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sanitizer_common/sanitizer_win.cc')
-rw-r--r--lib/sanitizer_common/sanitizer_win.cc71
1 files changed, 50 insertions, 21 deletions
diff --git a/lib/sanitizer_common/sanitizer_win.cc b/lib/sanitizer_common/sanitizer_win.cc
index e76f1d1f7fa6..362c8c99a74c 100644
--- a/lib/sanitizer_common/sanitizer_win.cc
+++ b/lib/sanitizer_common/sanitizer_win.cc
@@ -40,6 +40,12 @@ uptr GetMmapGranularity() {
return 1U << 16; // FIXME: is this configurable?
}
+uptr GetMaxVirtualAddress() {
+ SYSTEM_INFO si;
+ GetSystemInfo(&si);
+ return (uptr)si.lpMaximumApplicationAddress;
+}
+
bool FileExists(const char *filename) {
UNIMPLEMENTED();
}
@@ -124,7 +130,7 @@ void *MapFileToMemory(const char *file_name, uptr *buff_size) {
}
static const int kMaxEnvNameLength = 128;
-static const int kMaxEnvValueLength = 32767;
+static const DWORD kMaxEnvValueLength = 32767;
namespace {
@@ -190,6 +196,11 @@ void SetStackSizeLimitInBytes(uptr limit) {
UNIMPLEMENTED();
}
+char *FindPathToBinary(const char *name) {
+ // Nothing here for now.
+ return 0;
+}
+
void SleepForSeconds(int seconds) {
Sleep(seconds * 1000);
}
@@ -198,11 +209,20 @@ void SleepForMillis(int millis) {
Sleep(millis);
}
+u64 NanoTime() {
+ return 0;
+}
+
void Abort() {
abort();
_exit(-1); // abort is not NORETURN on Windows.
}
+uptr GetListOfModules(LoadedModule *modules, uptr max_modules,
+ string_predicate_t filter) {
+ UNIMPLEMENTED();
+};
+
#ifndef SANITIZER_GO
int Atexit(void (*function)(void)) {
return atexit(function);
@@ -341,39 +361,48 @@ void InitTlsSize() {
void GetThreadStackAndTls(bool main, uptr *stk_addr, uptr *stk_size,
uptr *tls_addr, uptr *tls_size) {
+#ifdef SANITIZER_GO
+ *stk_addr = 0;
+ *stk_size = 0;
+ *tls_addr = 0;
+ *tls_size = 0;
+#else
uptr stack_top, stack_bottom;
GetThreadStackTopAndBottom(main, &stack_top, &stack_bottom);
*stk_addr = stack_bottom;
*stk_size = stack_top - stack_bottom;
*tls_addr = 0;
*tls_size = 0;
+#endif
}
-void GetStackTrace(StackTrace *stack, uptr max_s, uptr pc, uptr bp,
- uptr stack_top, uptr stack_bottom, bool fast) {
- (void)fast;
- (void)stack_top;
- (void)stack_bottom;
- stack->max_size = max_s;
- void *tmp[kStackTraceMax];
-
+void StackTrace::SlowUnwindStack(uptr pc, uptr max_depth) {
// FIXME: CaptureStackBackTrace might be too slow for us.
// FIXME: Compare with StackWalk64.
// FIXME: Look at LLVMUnhandledExceptionFilter in Signals.inc
- uptr cs_ret = CaptureStackBackTrace(1, stack->max_size, tmp, 0);
- uptr offset = 0;
+ size = CaptureStackBackTrace(2, Min(max_depth, kStackTraceMax),
+ (void**)trace, 0);
// Skip the RTL frames by searching for the PC in the stacktrace.
- // FIXME: this doesn't work well for the malloc/free stacks yet.
- for (uptr i = 0; i < cs_ret; i++) {
- if (pc != (uptr)tmp[i])
- continue;
- offset = i;
- break;
- }
+ uptr pc_location = LocatePcInTrace(pc);
+ PopStackFrames(pc_location);
+}
- stack->size = cs_ret - offset;
- for (uptr i = 0; i < stack->size; i++)
- stack->trace[i] = (uptr)tmp[i + offset];
+void MaybeOpenReportFile() {
+ // Windows doesn't have native fork, and we don't support Cygwin or other
+ // environments that try to fake it, so the initial report_fd will always be
+ // correct.
+}
+
+void RawWrite(const char *buffer) {
+ static const char *kRawWriteError =
+ "RawWrite can't output requested buffer!\n";
+ uptr length = (uptr)internal_strlen(buffer);
+ if (length != internal_write(report_fd, buffer, length)) {
+ // stderr may be closed, but we may be able to print to the debugger
+ // instead. This is the case when launching a program from Visual Studio,
+ // and the following routine should write to its console.
+ OutputDebugStringA(buffer);
+ }
}
} // namespace __sanitizer