Merge remote-tracking branch 'origin/swift-4.1-branch' into stable
diff --git a/lib/asan/asan_descriptions.cc b/lib/asan/asan_descriptions.cc
index 5662e6b..822a6a6 100644
--- a/lib/asan/asan_descriptions.cc
+++ b/lib/asan/asan_descriptions.cc
@@ -150,7 +150,7 @@
str.append(" %zu-byte region [%p,%p)\n", descr.chunk_size,
(void *)descr.chunk_begin,
(void *)(descr.chunk_begin + descr.chunk_size));
- str.append("%s", d.Default());
+ str.append("%s", d.EndLocation());
Printf("%s", str.data());
}
@@ -260,7 +260,7 @@
// FIXME: we may want to also print the size of the access here,
// but in case of accesses generated by memset it may be confusing.
str.append("%s <== Memory access at offset %zd %s this variable%s\n",
- d.Location(), addr, pos_descr, d.Default());
+ d.Location(), addr, pos_descr, d.EndLocation());
} else {
str.append("\n");
}
@@ -295,7 +295,7 @@
MaybeDemangleGlobalName(g.name));
PrintGlobalLocation(&str, g);
str.append("' (0x%zx) of size %zu\n", g.beg, g.size);
- str.append("%s", d.Default());
+ str.append("%s", d.EndLocation());
PrintGlobalNameIfASCII(&str, g);
Printf("%s", str.data());
}
@@ -343,10 +343,10 @@
ThreadNameWithParenthesis(tid, tname, sizeof(tname)));
if (!frame_descr) {
- Printf("%s\n", d.Default());
+ Printf("%s\n", d.EndLocation());
return;
}
- Printf(" at offset %zu in frame%s\n", offset, d.Default());
+ Printf(" at offset %zu in frame%s\n", offset, d.EndLocation());
// Now we print the frame where the alloca has happened.
// We print this frame as a stack trace with one element.
@@ -355,7 +355,7 @@
// previously. That's unfortunate, but I have no better solution,
// especially given that the alloca may be from entirely different place
// (e.g. use-after-scope, or different thread's stack).
- Printf("%s", d.Default());
+ Printf("%s", d.EndLocation());
StackTrace alloca_stack(&frame_pc, 1);
alloca_stack.Print();
@@ -405,18 +405,18 @@
Printf("%sfreed by thread T%d%s here:%s\n", d.Allocation(),
free_thread->tid,
ThreadNameWithParenthesis(free_thread, tname, sizeof(tname)),
- d.Default());
+ d.EndAllocation());
StackTrace free_stack = GetStackTraceFromId(free_stack_id);
free_stack.Print();
Printf("%spreviously allocated by thread T%d%s here:%s\n", d.Allocation(),
alloc_thread->tid,
ThreadNameWithParenthesis(alloc_thread, tname, sizeof(tname)),
- d.Default());
+ d.EndAllocation());
} else {
Printf("%sallocated by thread T%d%s here:%s\n", d.Allocation(),
alloc_thread->tid,
ThreadNameWithParenthesis(alloc_thread, tname, sizeof(tname)),
- d.Default());
+ d.EndAllocation());
}
alloc_stack.Print();
DescribeThread(GetCurrentThread());
diff --git a/lib/asan/asan_descriptions.h b/lib/asan/asan_descriptions.h
index 5161715..0ee677e 100644
--- a/lib/asan/asan_descriptions.h
+++ b/lib/asan/asan_descriptions.h
@@ -34,8 +34,11 @@
public:
Decorator() : SanitizerCommonDecorator() {}
const char *Access() { return Blue(); }
+ const char *EndAccess() { return Default(); }
const char *Location() { return Green(); }
+ const char *EndLocation() { return Default(); }
const char *Allocation() { return Magenta(); }
+ const char *EndAllocation() { return Default(); }
const char *ShadowByte(u8 byte) {
switch (byte) {
@@ -69,7 +72,9 @@
return Default();
}
}
+ const char *EndShadowByte() { return Default(); }
const char *MemoryByte() { return Magenta(); }
+ const char *EndMemoryByte() { return Default(); }
};
enum ShadowKind : u8 {
diff --git a/lib/asan/asan_errors.cc b/lib/asan/asan_errors.cc
index 63aaab1..b7a38eb 100644
--- a/lib/asan/asan_errors.cc
+++ b/lib/asan/asan_errors.cc
@@ -29,7 +29,7 @@
"ERROR: AddressSanitizer: %s on address %p"
" (pc %p bp %p sp %p T%d)\n", scariness.GetDescription(),
(void *)addr, (void *)pc, (void *)bp, (void *)sp, tid);
- Printf("%s", d.Default());
+ Printf("%s", d.EndWarning());
scariness.Print();
BufferedStackTrace stack;
GetStackTraceWithPcBpAndContext(&stack, kStackTraceMax, pc, bp, context,
@@ -77,7 +77,7 @@
"ERROR: AddressSanitizer: %s on unknown address %p (pc %p bp %p sp %p "
"T%d)\n",
description, (void *)addr, (void *)pc, (void *)bp, (void *)sp, tid);
- Printf("%s", d.Default());
+ Printf("%s", d.EndWarning());
if (pc < GetPageSizeCached()) Report("Hint: pc points to the zero page.\n");
if (is_memory_access) {
const char *access_type =
@@ -109,7 +109,7 @@
"thread T%d%s:\n",
scariness.GetDescription(), addr_description.addr, tid,
ThreadNameWithParenthesis(tid, tname, sizeof(tname)));
- Printf("%s", d.Default());
+ Printf("%s", d.EndWarning());
scariness.Print();
GET_STACK_TRACE_FATAL(second_free_stack->trace[0],
second_free_stack->top_frame_bp);
@@ -127,7 +127,7 @@
"T%d%s:\n",
scariness.GetDescription(), addr_description.addr, tid,
ThreadNameWithParenthesis(tid, tname, sizeof(tname)));
- Printf("%s object passed to delete has wrong type:\n", d.Default());
+ Printf("%s object passed to delete has wrong type:\n", d.EndWarning());
Printf(
" size of the allocated type: %zd bytes;\n"
" size of the deallocated type: %zd bytes.\n",
@@ -152,7 +152,7 @@
"which was not malloc()-ed: %p in thread T%d%s\n",
addr_description.Address(), tid,
ThreadNameWithParenthesis(tid, tname, sizeof(tname)));
- Printf("%s", d.Default());
+ Printf("%s", d.EndWarning());
CHECK_GT(free_stack->size, 0);
scariness.Print();
GET_STACK_TRACE_FATAL(free_stack->trace[0], free_stack->top_frame_bp);
@@ -173,7 +173,7 @@
scariness.GetDescription(),
alloc_names[alloc_type], dealloc_names[dealloc_type],
addr_description.addr);
- Printf("%s", d.Default());
+ Printf("%s", d.EndWarning());
CHECK_GT(dealloc_stack->size, 0);
scariness.Print();
GET_STACK_TRACE_FATAL(dealloc_stack->trace[0], dealloc_stack->top_frame_bp);
@@ -192,7 +192,7 @@
"ERROR: AddressSanitizer: attempting to call malloc_usable_size() for "
"pointer which is not owned: %p\n",
addr_description.Address());
- Printf("%s", d.Default());
+ Printf("%s", d.EndWarning());
stack->Print();
addr_description.Print();
ReportErrorSummary(scariness.GetDescription(), stack);
@@ -205,7 +205,7 @@
"ERROR: AddressSanitizer: attempting to call "
"__sanitizer_get_allocated_size() for pointer which is not owned: %p\n",
addr_description.Address());
- Printf("%s", d.Default());
+ Printf("%s", d.EndWarning());
stack->Print();
addr_description.Print();
ReportErrorSummary(scariness.GetDescription(), stack);
@@ -222,7 +222,7 @@
bug_type, addr1_description.Address(),
addr1_description.Address() + length1, addr2_description.Address(),
addr2_description.Address() + length2);
- Printf("%s", d.Default());
+ Printf("%s", d.EndWarning());
scariness.Print();
stack->Print();
addr1_description.Print();
@@ -235,7 +235,7 @@
Printf("%s", d.Warning());
Report("ERROR: AddressSanitizer: %s: (size=%zd)\n",
scariness.GetDescription(), size);
- Printf("%s", d.Default());
+ Printf("%s", d.EndWarning());
scariness.Print();
stack->Print();
addr_description.Print();
@@ -263,7 +263,7 @@
Printf("%s", d.Warning());
Report("ERROR: AddressSanitizer: %s (%p):\n", scariness.GetDescription(),
global1.beg);
- Printf("%s", d.Default());
+ Printf("%s", d.EndWarning());
InternalScopedString g1_loc(256), g2_loc(256);
PrintGlobalLocation(&g1_loc, global1);
PrintGlobalLocation(&g2_loc, global2);
@@ -292,7 +292,7 @@
Printf("%s", d.Warning());
Report("ERROR: AddressSanitizer: %s: %p %p\n", scariness.GetDescription(),
addr1_description.Address(), addr2_description.Address());
- Printf("%s", d.Default());
+ Printf("%s", d.EndWarning());
GET_STACK_TRACE_FATAL(pc, bp);
stack.Print();
addr1_description.Print();
@@ -491,13 +491,13 @@
uptr addr = addr_description.Address();
Report("ERROR: AddressSanitizer: %s on address %p at pc %p bp %p sp %p\n",
bug_descr, (void *)addr, pc, bp, sp);
- Printf("%s", d.Default());
+ Printf("%s", d.EndWarning());
char tname[128];
Printf("%s%s of size %zu at %p thread T%d%s%s\n", d.Access(),
access_size ? (is_write ? "WRITE" : "READ") : "ACCESS", access_size,
(void *)addr, tid,
- ThreadNameWithParenthesis(tid, tname, sizeof(tname)), d.Default());
+ ThreadNameWithParenthesis(tid, tname, sizeof(tname)), d.EndAccess());
scariness.Print();
GET_STACK_TRACE_FATAL(pc, bp);
diff --git a/lib/asan/asan_report.cc b/lib/asan/asan_report.cc
index cd8a4f0..2e477f2 100644
--- a/lib/asan/asan_report.cc
+++ b/lib/asan/asan_report.cc
@@ -60,8 +60,9 @@
bool in_shadow, const char *after) {
Decorator d;
str->append("%s%s%x%x%s%s", before,
- in_shadow ? d.ShadowByte(byte) : d.MemoryByte(), byte >> 4,
- byte & 15, d.Default(), after);
+ in_shadow ? d.ShadowByte(byte) : d.MemoryByte(),
+ byte >> 4, byte & 15,
+ in_shadow ? d.EndShadowByte() : d.EndMemoryByte(), after);
}
static void PrintZoneForPointer(uptr ptr, uptr zone_ptr,
diff --git a/lib/lsan/lsan_common.cc b/lib/lsan/lsan_common.cc
index a792768..c121e6a 100644
--- a/lib/lsan/lsan_common.cc
+++ b/lib/lsan/lsan_common.cc
@@ -122,6 +122,7 @@
Decorator() : SanitizerCommonDecorator() { }
const char *Error() { return Red(); }
const char *Leak() { return Blue(); }
+ const char *End() { return Default(); }
};
static inline bool CanBeAHeapPointer(uptr p) {
@@ -563,7 +564,7 @@
"\n");
Printf("%s", d.Error());
Report("ERROR: LeakSanitizer: detected memory leaks\n");
- Printf("%s", d.Default());
+ Printf("%s", d.End());
param.leak_report.ReportTopLeaks(flags()->max_leaks);
}
if (common_flags()->print_suppressions)
@@ -697,7 +698,7 @@
Printf("%s leak of %zu byte(s) in %zu object(s) allocated from:\n",
leaks_[index].is_directly_leaked ? "Direct" : "Indirect",
leaks_[index].total_size, leaks_[index].hit_count);
- Printf("%s", d.Default());
+ Printf("%s", d.End());
PrintStackTraceById(leaks_[index].stack_trace_id);
diff --git a/lib/msan/msan_report.cc b/lib/msan/msan_report.cc
index cddad01..9a35c9c 100644
--- a/lib/msan/msan_report.cc
+++ b/lib/msan/msan_report.cc
@@ -30,8 +30,10 @@
class Decorator: public __sanitizer::SanitizerCommonDecorator {
public:
Decorator() : SanitizerCommonDecorator() { }
+ const char *Warning() { return Red(); }
const char *Origin() { return Magenta(); }
const char *Name() { return Green(); }
+ const char *End() { return Default(); }
};
static void DescribeStackOrigin(const char *so, uptr pc) {
@@ -45,7 +47,7 @@
" %sUninitialized value was created by an allocation of '%s%s%s'"
" in the stack frame of function '%s%s%s'%s\n",
d.Origin(), d.Name(), s, d.Origin(), d.Name(), sep + 1, d.Origin(),
- d.Default());
+ d.End());
InternalFree(s);
if (pc) {
@@ -64,7 +66,7 @@
StackTrace stack;
o = o.getNextChainedOrigin(&stack);
Printf(" %sUninitialized value was stored to memory at%s\n", d.Origin(),
- d.Default());
+ d.End());
stack.Print();
}
if (o.isStackOrigin()) {
@@ -76,19 +78,18 @@
switch (stack.tag) {
case StackTrace::TAG_ALLOC:
Printf(" %sUninitialized value was created by a heap allocation%s\n",
- d.Origin(), d.Default());
+ d.Origin(), d.End());
break;
case StackTrace::TAG_DEALLOC:
Printf(" %sUninitialized value was created by a heap deallocation%s\n",
- d.Origin(), d.Default());
+ d.Origin(), d.End());
break;
case STACK_TRACE_TAG_POISON:
Printf(" %sMemory was marked as uninitialized%s\n", d.Origin(),
- d.Default());
+ d.End());
break;
default:
- Printf(" %sUninitialized value was created%s\n", d.Origin(),
- d.Default());
+ Printf(" %sUninitialized value was created%s\n", d.Origin(), d.End());
break;
}
stack.Print();
@@ -103,7 +104,7 @@
Decorator d;
Printf("%s", d.Warning());
Report("WARNING: MemorySanitizer: use-of-uninitialized-value\n");
- Printf("%s", d.Default());
+ Printf("%s", d.End());
stack->Print();
if (origin) {
DescribeOrigin(origin);
@@ -143,7 +144,7 @@
Decorator d;
Printf("%s", d.Warning());
Printf("MemorySanitizer: %d warnings reported.\n", msan_report_count);
- Printf("%s", d.Default());
+ Printf("%s", d.End());
}
}
@@ -202,7 +203,7 @@
Decorator d;
Printf("%s", d.Warning());
Printf("Shadow map of [%p, %p), %zu bytes:\n", start, end, end - start);
- Printf("%s", d.Default());
+ Printf("%s", d.End());
while (s < e) {
// Line start.
if (pos % 16 == 0) {
@@ -264,7 +265,7 @@
Printf("%s", d.Warning());
Printf("%sUninitialized bytes in %s%s%s at offset %zu inside [%p, %zu)%s\n",
d.Warning(), d.Name(), what, d.Warning(), offset, start, size,
- d.Default());
+ d.End());
if (__sanitizer::Verbosity())
DescribeMemoryRange(start, size);
}
diff --git a/lib/sanitizer_common/sanitizer_report_decorator.h b/lib/sanitizer_common/sanitizer_report_decorator.h
index daa7f00..86536aa 100644
--- a/lib/sanitizer_common/sanitizer_report_decorator.h
+++ b/lib/sanitizer_common/sanitizer_report_decorator.h
@@ -27,8 +27,8 @@
SanitizerCommonDecorator() : ansi_(ColorizeReports()) {}
const char *Bold() const { return ansi_ ? "\033[1m" : ""; }
const char *Default() const { return ansi_ ? "\033[1m\033[0m" : ""; }
- const char *Warning() const { return Red(); }
-
+ const char *Warning() { return Red(); }
+ const char *EndWarning() { return Default(); }
protected:
const char *Black() const { return ansi_ ? "\033[1m\033[30m" : ""; }
const char *Red() const { return ansi_ ? "\033[1m\033[31m" : ""; }
diff --git a/lib/tsan/rtl/tsan_report.cc b/lib/tsan/rtl/tsan_report.cc
index 3b11797..32cc332 100644
--- a/lib/tsan/rtl/tsan_report.cc
+++ b/lib/tsan/rtl/tsan_report.cc
@@ -38,11 +38,18 @@
class Decorator: public __sanitizer::SanitizerCommonDecorator {
public:
Decorator() : SanitizerCommonDecorator() { }
+ const char *Warning() { return Red(); }
+ const char *EndWarning() { return Default(); }
const char *Access() { return Blue(); }
+ const char *EndAccess() { return Default(); }
const char *ThreadDescription() { return Cyan(); }
+ const char *EndThreadDescription() { return Default(); }
const char *Location() { return Green(); }
+ const char *EndLocation() { return Default(); }
const char *Sleep() { return Yellow(); }
+ const char *EndSleep() { return Default(); }
const char *Mutex() { return Magenta(); }
+ const char *EndMutex() { return Default(); }
};
ReportDesc::ReportDesc()
@@ -173,7 +180,7 @@
}
PrintMutexSet(mop->mset);
Printf(":\n");
- Printf("%s", d.Default());
+ Printf("%s", d.EndAccess());
PrintStack(mop->stack);
}
@@ -214,20 +221,20 @@
loc->fd, thread_name(thrbuf, loc->tid));
print_stack = true;
}
- Printf("%s", d.Default());
+ Printf("%s", d.EndLocation());
if (print_stack)
PrintStack(loc->stack);
}
static void PrintMutexShort(const ReportMutex *rm, const char *after) {
Decorator d;
- Printf("%sM%zd%s%s", d.Mutex(), rm->id, d.Default(), after);
+ Printf("%sM%zd%s%s", d.Mutex(), rm->id, d.EndMutex(), after);
}
static void PrintMutexShortWithAddress(const ReportMutex *rm,
const char *after) {
Decorator d;
- Printf("%sM%zd (%p)%s%s", d.Mutex(), rm->id, rm->addr, d.Default(), after);
+ Printf("%sM%zd (%p)%s%s", d.Mutex(), rm->id, rm->addr, d.EndMutex(), after);
}
static void PrintMutex(const ReportMutex *rm) {
@@ -235,11 +242,11 @@
if (rm->destroyed) {
Printf("%s", d.Mutex());
Printf(" Mutex M%llu is already destroyed.\n\n", rm->id);
- Printf("%s", d.Default());
+ Printf("%s", d.EndMutex());
} else {
Printf("%s", d.Mutex());
Printf(" Mutex M%llu (%p) created at:\n", rm->id, rm->addr);
- Printf("%s", d.Default());
+ Printf("%s", d.EndMutex());
PrintStack(rm->stack);
}
}
@@ -257,7 +264,7 @@
if (rt->workerthread) {
Printf(" (tid=%zu, %s) is a GCD worker thread\n", rt->os_id, thread_status);
Printf("\n");
- Printf("%s", d.Default());
+ Printf("%s", d.EndThreadDescription());
return;
}
Printf(" (tid=%zu, %s) created by %s", rt->os_id, thread_status,
@@ -265,7 +272,7 @@
if (rt->stack)
Printf(" at:");
Printf("\n");
- Printf("%s", d.Default());
+ Printf("%s", d.EndThreadDescription());
PrintStack(rt->stack);
}
@@ -273,7 +280,7 @@
Decorator d;
Printf("%s", d.Sleep());
Printf(" As if synchronized via sleep:\n");
- Printf("%s", d.Default());
+ Printf("%s", d.EndSleep());
PrintStack(s);
}
@@ -317,7 +324,7 @@
Printf("%s", d.Warning());
Printf("WARNING: ThreadSanitizer: %s (pid=%d)\n", rep_typ_str,
(int)internal_getpid());
- Printf("%s", d.Default());
+ Printf("%s", d.EndWarning());
if (rep->typ == ReportTypeDeadlock) {
char thrbuf[kThreadBufSize];
@@ -335,7 +342,7 @@
PrintMutexShort(rep->mutexes[i], " in ");
Printf("%s", d.ThreadDescription());
Printf("%s:\n", thread_name(thrbuf, rep->unique_tids[i]));
- Printf("%s", d.Default());
+ Printf("%s", d.EndThreadDescription());
if (flags()->second_deadlock_stack) {
PrintStack(rep->stacks[2*i]);
Printf(" Mutex ");
diff --git a/lib/ubsan/ubsan_diag.cc b/lib/ubsan/ubsan_diag.cc
index f039a31..742802b 100644
--- a/lib/ubsan/ubsan_diag.cc
+++ b/lib/ubsan/ubsan_diag.cc
@@ -97,7 +97,9 @@
public:
Decorator() : SanitizerCommonDecorator() {}
const char *Highlight() const { return Green(); }
+ const char *EndHighlight() const { return Default(); }
const char *Note() const { return Black(); }
+ const char *EndNote() const { return Default(); }
};
}
@@ -293,7 +295,7 @@
Buffer.append("%c", P == Loc ? '^' : Byte);
Buffer.append("%c", Byte);
}
- Buffer.append("%s\n", Decor.Default());
+ Buffer.append("%s\n", Decor.EndHighlight());
// Go over the line again, and print names for the ranges.
InRange = 0;
@@ -343,12 +345,12 @@
switch (Level) {
case DL_Error:
- Buffer.append("%s runtime error: %s%s", Decor.Warning(), Decor.Default(),
+ Buffer.append("%s runtime error: %s%s", Decor.Warning(), Decor.EndWarning(),
Decor.Bold());
break;
case DL_Note:
- Buffer.append("%s note: %s", Decor.Note(), Decor.Default());
+ Buffer.append("%s note: %s", Decor.Note(), Decor.EndNote());
break;
}
diff --git a/lib/ubsan/ubsan_diag_standalone.cc b/lib/ubsan/ubsan_diag_standalone.cc
index 1f4a5bd..df8ed5f 100644
--- a/lib/ubsan/ubsan_diag_standalone.cc
+++ b/lib/ubsan/ubsan_diag_standalone.cc
@@ -26,10 +26,9 @@
if (request_fast_unwind)
__sanitizer::GetThreadStackTopAndBottom(false, &top, &bottom);
- GET_CURRENT_PC_BP_SP;
- (void)sp;
+ GET_REPORT_OPTIONS(false);
BufferedStackTrace stack;
- stack.Unwind(kStackTraceMax, pc, bp, nullptr, top, bottom,
+ stack.Unwind(kStackTraceMax, Opts.pc, Opts.bp, nullptr, top, bottom,
request_fast_unwind);
stack.Print();
}
diff --git a/lib/ubsan/ubsan_init.cc b/lib/ubsan/ubsan_init.cc
index d7433a5..307bca3 100644
--- a/lib/ubsan/ubsan_init.cc
+++ b/lib/ubsan/ubsan_init.cc
@@ -40,8 +40,8 @@
static void CommonStandaloneInit() {
SanitizerToolName = GetSanititizerToolName();
- CacheBinaryName();
InitializeFlags();
+ CacheBinaryName();
__sanitizer_set_report_path(common_flags()->log_path);
AndroidLogInit();
InitializeCoverage(common_flags()->coverage, common_flags()->coverage_dir);