summaryrefslogtreecommitdiff
path: root/lib/asan/asan_errors.h
diff options
context:
space:
mode:
authorFilipe Cabecinhas <me@filcab.net>2016-08-28 10:32:44 +0000
committerFilipe Cabecinhas <me@filcab.net>2016-08-28 10:32:44 +0000
commita0e3eb177a3f0aa9aa229546787457ef135302e6 (patch)
tree52bca606a28504a57e17b272cbfc0f1ead05b4d8 /lib/asan/asan_errors.h
parentb8abcb0e22dc9a9c78cecef63b4444fc873191b5 (diff)
downloadcompiler-rt-a0e3eb177a3f0aa9aa229546787457ef135302e6.tar.gz
Start reifying error descriptions. Second try: Try to appease Visual Studio.
Summary: This commit sets up the infrastructure to use reified error descriptions, and moves ReportStackOverflow to the new system. After we convert all the errors, we'll be able to simplify ScopedInErrorReport and remove the older debugging mechanism which had some errors partly reified in some way. We'll be able to maintain the external API. ScopedInErrorReport will be able to track one of the reified errors at a time. The purpose of this is so we have its destructor actually print the error and possibly interface with the debugger (will depend on the platform, of course). Reviewers: kcc, samsonov, timurrrr Subscribers: kubabrecka, llvm-commits Differential Revision: https://reviews.llvm.org/D23672 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@279931 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/asan/asan_errors.h')
-rw-r--r--lib/asan/asan_errors.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/lib/asan/asan_errors.h b/lib/asan/asan_errors.h
new file mode 100644
index 000000000..fdcf088fd
--- /dev/null
+++ b/lib/asan/asan_errors.h
@@ -0,0 +1,74 @@
+//===-- asan_errors.h -------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file is a part of AddressSanitizer, an address sanity checker.
+//
+// ASan-private header for error structures.
+//===----------------------------------------------------------------------===//
+#ifndef ASAN_ERRORS_H
+#define ASAN_ERRORS_H
+
+#include "asan_descriptions.h"
+#include "asan_scariness_score.h"
+
+namespace __asan {
+
+struct ErrorBase {
+ ScarinessScore scariness;
+};
+
+struct ErrorStackOverflow : ErrorBase {
+ u32 tid;
+ uptr addr, pc, bp, sp;
+ // ErrorStackOverflow never owns the context.
+ void *context;
+ ErrorStackOverflow() = default;
+ ErrorStackOverflow(const SignalContext &sig, u32 tid_)
+ : tid(tid_),
+ addr(sig.addr),
+ pc(sig.pc),
+ bp(sig.bp),
+ sp(sig.sp),
+ context(sig.context) {
+ scariness.Scare(10, "stack-overflow");
+ }
+ void Print();
+};
+
+enum ErrorKind {
+ kErrorKindInvalid = 0,
+ kErrorKindStackOverflow,
+};
+
+struct ErrorDescription {
+ ErrorKind kind;
+ union {
+ ErrorStackOverflow stack_overflow;
+ };
+ ErrorDescription() { internal_memset(this, 0, sizeof(*this)); }
+ ErrorDescription(const ErrorStackOverflow &e) // NOLINT
+ : kind(kErrorKindStackOverflow),
+ stack_overflow(e) {}
+
+ bool IsValid() { return kind != kErrorKindInvalid; }
+ void Print() {
+ switch (kind) {
+ case kErrorKindStackOverflow:
+ stack_overflow.Print();
+ return;
+ case kErrorKindInvalid:
+ CHECK(0);
+ }
+ CHECK(0);
+ }
+};
+
+} // namespace __asan
+
+#endif // ASAN_ERRORS_H