summaryrefslogtreecommitdiff
path: root/lib/asan/asan_errors.h
diff options
context:
space:
mode:
authorFilipe Cabecinhas <me@filcab.net>2016-09-12 17:10:44 +0000
committerFilipe Cabecinhas <me@filcab.net>2016-09-12 17:10:44 +0000
commit208c0261c7ad9eaf3ab1d8df866e8bc0193a39e3 (patch)
tree4f767cc552818a317796d75d55905a0534ffbeff /lib/asan/asan_errors.h
parent011080a2f3177a2302251b97dbdb3cf2e4c382db (diff)
[asan] Cleanup: Move tid into ErrorBase, add const to BufferedStackTrace, be consistent in constructor arguments and member order.
Summary: As mentioned in D24394, I'm moving tid to ErrorBase, since basically all errors need it. Also mentioned in the same review are other cleanups like adding const to BufferedStackTrace and make sure constructor orders are consistent. Reviewers: vitalybuka, kcc, eugenis Subscribers: llvm-commits, kubabrecka Differential Revision: https://reviews.llvm.org/D24455 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@281236 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/asan/asan_errors.h')
-rw-r--r--lib/asan/asan_errors.h41
1 files changed, 20 insertions, 21 deletions
diff --git a/lib/asan/asan_errors.h b/lib/asan/asan_errors.h
index 3ac4d95fd..afa96de4e 100644
--- a/lib/asan/asan_errors.h
+++ b/lib/asan/asan_errors.h
@@ -21,19 +21,21 @@
namespace __asan {
struct ErrorBase {
+ ErrorBase() = default;
+ explicit ErrorBase(u32 tid_) : tid(tid_) {}
ScarinessScoreBase scariness;
+ u32 tid;
};
struct ErrorStackOverflow : ErrorBase {
- u32 tid;
uptr addr, pc, bp, sp;
// ErrorStackOverflow never owns the context.
void *context;
// VS2013 doesn't implement unrestricted unions, so we need a trivial default
// constructor
ErrorStackOverflow() = default;
- ErrorStackOverflow(const SignalContext &sig, u32 tid_)
- : tid(tid_),
+ ErrorStackOverflow(u32 tid, const SignalContext &sig)
+ : ErrorBase(tid),
addr(sig.addr),
pc(sig.pc),
bp(sig.bp),
@@ -46,26 +48,25 @@ struct ErrorStackOverflow : ErrorBase {
};
struct ErrorDeadlySignal : ErrorBase {
- u32 tid;
uptr addr, pc, bp, sp;
+ // ErrorDeadlySignal never owns the context.
+ void *context;
int signo;
SignalContext::WriteFlag write_flag;
bool is_memory_access;
- // ErrorDeadlySignal never owns the context.
- void *context;
// VS2013 doesn't implement unrestricted unions, so we need a trivial default
// constructor
ErrorDeadlySignal() = default;
- ErrorDeadlySignal(int signo_, const SignalContext &sig, u32 tid_)
- : tid(tid_),
+ ErrorDeadlySignal(u32 tid, const SignalContext &sig, int signo_)
+ : ErrorBase(tid),
addr(sig.addr),
pc(sig.pc),
bp(sig.bp),
sp(sig.sp),
+ context(sig.context),
signo(signo_),
write_flag(sig.write_flag),
- is_memory_access(sig.is_memory_access),
- context(sig.context) {
+ is_memory_access(sig.is_memory_access) {
scariness.Clear();
if (is_memory_access) {
if (addr < GetPageSizeCached()) {
@@ -87,15 +88,14 @@ struct ErrorDeadlySignal : ErrorBase {
};
struct ErrorDoubleFree : ErrorBase {
- u32 tid;
- HeapAddressDescription addr_description;
// ErrorDoubleFree doesn't own the stack trace.
- BufferedStackTrace *second_free_stack;
+ const BufferedStackTrace *second_free_stack;
+ HeapAddressDescription addr_description;
// VS2013 doesn't implement unrestricted unions, so we need a trivial default
// constructor
ErrorDoubleFree() = default;
- ErrorDoubleFree(uptr addr, u32 tid_, BufferedStackTrace *stack)
- : tid(tid_), second_free_stack(stack) {
+ ErrorDoubleFree(u32 tid, BufferedStackTrace *stack, uptr addr)
+ : ErrorBase(tid), second_free_stack(stack) {
CHECK_GT(second_free_stack->size, 0);
GetHeapAddressInformation(addr, 1, &addr_description);
scariness.Clear();
@@ -105,17 +105,16 @@ struct ErrorDoubleFree : ErrorBase {
};
struct ErrorNewDeleteSizeMismatch : ErrorBase {
- u32 tid;
+ // ErrorNewDeleteSizeMismatch doesn't own the stack trace.
+ const BufferedStackTrace *free_stack;
HeapAddressDescription addr_description;
uptr delete_size;
- // ErrorNewDeleteSizeMismatch doesn't own the stack trace.
- BufferedStackTrace *free_stack;
// VS2013 doesn't implement unrestricted unions, so we need a trivial default
// constructor
ErrorNewDeleteSizeMismatch() = default;
- ErrorNewDeleteSizeMismatch(uptr addr, u32 tid_, uptr delete_size_,
- BufferedStackTrace *stack)
- : tid(tid_), delete_size(delete_size_), free_stack(stack) {
+ ErrorNewDeleteSizeMismatch(u32 tid, BufferedStackTrace *stack, uptr addr,
+ uptr delete_size_)
+ : ErrorBase(tid), free_stack(stack), delete_size(delete_size_) {
GetHeapAddressInformation(addr, 1, &addr_description);
scariness.Clear();
scariness.Scare(10, "new-delete-type-mismatch");