forked from OSchip/llvm-project
[ASan] Make printf arguments match format strings better.
llvm-svn: 158059
This commit is contained in:
parent
ac4c290d02
commit
461820ad67
|
@ -217,7 +217,7 @@ struct AsanChunk: public ChunkBase {
|
|||
|
||||
void DescribeAddress(uptr addr, uptr access_size) {
|
||||
uptr offset;
|
||||
Printf("%p is located ", addr);
|
||||
Printf("%p is located ", (void*)addr);
|
||||
if (AddrIsInside(addr, access_size, &offset)) {
|
||||
Printf("%zu bytes inside of", offset);
|
||||
} else if (AddrIsAtLeft(addr, access_size, &offset)) {
|
||||
|
@ -228,7 +228,7 @@ struct AsanChunk: public ChunkBase {
|
|||
Printf(" somewhere around (this is AddressSanitizer bug!)");
|
||||
}
|
||||
Printf(" %zu-byte region [%p,%p)\n",
|
||||
used_size, beg(), beg() + used_size);
|
||||
used_size, (void*)beg(), (void*)(beg() + used_size));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -622,7 +622,8 @@ static u8 *Allocate(uptr alignment, uptr size, AsanStackTrace *stack) {
|
|||
}
|
||||
CHECK(IsAligned(needed_size, REDZONE));
|
||||
if (size > kMaxAllowedMallocSize || needed_size > kMaxAllowedMallocSize) {
|
||||
Report("WARNING: AddressSanitizer failed to allocate %p bytes\n", size);
|
||||
Report("WARNING: AddressSanitizer failed to allocate %p bytes\n",
|
||||
(void*)size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -66,13 +66,13 @@ void PrintIfASCII(const Global &g) {
|
|||
if (!isascii(*(char*)p)) return;
|
||||
}
|
||||
if (*(char*)(g.beg + g.size - 1) != 0) return;
|
||||
Printf(" '%s' is ascii string '%s'\n", g.name, g.beg);
|
||||
Printf(" '%s' is ascii string '%s'\n", g.name, (char*)g.beg);
|
||||
}
|
||||
|
||||
bool DescribeAddrIfMyRedZone(const Global &g, uptr addr) {
|
||||
if (addr < g.beg - kGlobalAndStackRedzone) return false;
|
||||
if (addr >= g.beg + g.size_with_redzone) return false;
|
||||
Printf("%p is located ", addr);
|
||||
Printf("%p is located ", (void*)addr);
|
||||
if (addr < g.beg) {
|
||||
Printf("%zd bytes to the left", g.beg - addr);
|
||||
} else if (addr >= g.beg + g.size) {
|
||||
|
@ -95,7 +95,7 @@ bool DescribeAddrIfGlobal(uptr addr) {
|
|||
const Global &g = *l->g;
|
||||
if (FLAG_report_globals >= 2)
|
||||
Printf("Search Global: beg=%p size=%zu name=%s\n",
|
||||
g.beg, g.size, g.name);
|
||||
(void*)g.beg, g.size, (char*)g.name);
|
||||
res |= DescribeAddrIfMyRedZone(g, addr);
|
||||
}
|
||||
return res;
|
||||
|
@ -118,7 +118,7 @@ static void RegisterGlobal(const Global *g) {
|
|||
list_of_globals = l;
|
||||
if (FLAG_report_globals >= 2)
|
||||
Report("Added Global: beg=%p size=%zu name=%s\n",
|
||||
g->beg, g->size, g->name);
|
||||
(void*)g->beg, g->size, g->name);
|
||||
}
|
||||
|
||||
static void UnregisterGlobal(const Global *g) {
|
||||
|
|
|
@ -79,7 +79,8 @@ void __asan_poison_memory_region(void const volatile *addr, uptr size) {
|
|||
uptr beg_addr = (uptr)addr;
|
||||
uptr end_addr = beg_addr + size;
|
||||
if (FLAG_v >= 1) {
|
||||
Printf("Trying to poison memory region [%p, %p)\n", beg_addr, end_addr);
|
||||
Printf("Trying to poison memory region [%p, %p)\n",
|
||||
(void*)beg_addr, (void*)end_addr);
|
||||
}
|
||||
ShadowSegmentEndpoint beg(beg_addr);
|
||||
ShadowSegmentEndpoint end(end_addr);
|
||||
|
@ -120,7 +121,8 @@ void __asan_unpoison_memory_region(void const volatile *addr, uptr size) {
|
|||
uptr beg_addr = (uptr)addr;
|
||||
uptr end_addr = beg_addr + size;
|
||||
if (FLAG_v >= 1) {
|
||||
Printf("Trying to unpoison memory region [%p, %p)\n", beg_addr, end_addr);
|
||||
Printf("Trying to unpoison memory region [%p, %p)\n",
|
||||
(void*)beg_addr, (void*)end_addr);
|
||||
}
|
||||
ShadowSegmentEndpoint beg(beg_addr);
|
||||
ShadowSegmentEndpoint end(end_addr);
|
||||
|
|
|
@ -88,7 +88,7 @@ static void ASAN_OnSIGSEGV(int, siginfo_t *siginfo, void *context) {
|
|||
GetPcSpBp(context, &pc, &sp, &bp);
|
||||
Report("ERROR: AddressSanitizer crashed on unknown address %p"
|
||||
" (pc %p sp %p bp %p T%d)\n",
|
||||
addr, pc, sp, bp,
|
||||
(void*)addr, (void*)pc, (void*)sp, (void*)bp,
|
||||
asanThreadRegistry().GetCurrentTidOrMinusOne());
|
||||
Printf("AddressSanitizer can not provide additional info. ABORTING\n");
|
||||
GET_STACK_TRACE_WITH_PC_AND_BP(kStackTraceMax, pc, bp);
|
||||
|
|
|
@ -33,7 +33,7 @@ void Die() {
|
|||
while (1) { }
|
||||
}
|
||||
if (FLAG_sleep_before_dying) {
|
||||
Report("Sleeping for %d second(s)\n", FLAG_sleep_before_dying);
|
||||
Report("Sleeping for %zd second(s)\n", FLAG_sleep_before_dying);
|
||||
SleepForSeconds(FLAG_sleep_before_dying);
|
||||
}
|
||||
if (FLAG_unmap_shadow_on_exit)
|
||||
|
@ -189,7 +189,7 @@ static bool DescribeStackAddress(uptr addr, uptr access_size) {
|
|||
static_cast<sptr>(name_end - frame_descr)));
|
||||
Printf("Address %p is located at offset %zu "
|
||||
"in frame <%s> of T%d's stack:\n",
|
||||
addr, offset, buf, t->tid());
|
||||
(void*)addr, offset, buf, t->tid());
|
||||
// Report the number of stack objects.
|
||||
char *p;
|
||||
uptr n_objects = internal_simple_strtoll(name_end, &p, 10);
|
||||
|
@ -419,11 +419,11 @@ void __asan_report_error(uptr pc, uptr bp, uptr sp,
|
|||
|
||||
Report("ERROR: AddressSanitizer %s on address "
|
||||
"%p at pc 0x%zx bp 0x%zx sp 0x%zx\n",
|
||||
bug_descr, addr, pc, bp, sp);
|
||||
bug_descr, (void*)addr, pc, bp, sp);
|
||||
|
||||
Printf("%s of size %zu at %p thread T%d\n",
|
||||
access_size ? (is_write ? "WRITE" : "READ") : "ACCESS",
|
||||
access_size, addr, curr_tid);
|
||||
access_size, (void*)addr, curr_tid);
|
||||
|
||||
if (FLAG_debug) {
|
||||
PrintBytes("PC: ", (uptr*)pc);
|
||||
|
@ -440,7 +440,7 @@ void __asan_report_error(uptr pc, uptr bp, uptr sp,
|
|||
Report("ABORTING\n");
|
||||
__asan_print_accumulated_stats();
|
||||
Printf("Shadow byte and word:\n");
|
||||
Printf(" %p: %x\n", shadow_addr, *(unsigned char*)shadow_addr);
|
||||
Printf(" %p: %x\n", (void*)shadow_addr, *(unsigned char*)shadow_addr);
|
||||
uptr aligned_shadow = shadow_addr & ~(kWordSize - 1);
|
||||
PrintBytes(" ", (uptr*)(aligned_shadow));
|
||||
Printf("More shadow bytes:\n");
|
||||
|
@ -536,14 +536,14 @@ void __asan_init() {
|
|||
ReplaceOperatorsNewAndDelete();
|
||||
|
||||
if (FLAG_v) {
|
||||
Printf("|| `[%p, %p]` || HighMem ||\n", kHighMemBeg, kHighMemEnd);
|
||||
Printf("|| `[%p, %p]` || HighShadow ||\n",
|
||||
Printf("|| `[%zx, %zx]` || HighMem ||\n", kHighMemBeg, kHighMemEnd);
|
||||
Printf("|| `[%zx, %zx]` || HighShadow ||\n",
|
||||
kHighShadowBeg, kHighShadowEnd);
|
||||
Printf("|| `[%p, %p]` || ShadowGap ||\n",
|
||||
Printf("|| `[%zx, %zx]` || ShadowGap ||\n",
|
||||
kShadowGapBeg, kShadowGapEnd);
|
||||
Printf("|| `[%p, %p]` || LowShadow ||\n",
|
||||
Printf("|| `[%zx, %zx]` || LowShadow ||\n",
|
||||
kLowShadowBeg, kLowShadowEnd);
|
||||
Printf("|| `[%p, %p]` || LowMem ||\n", kLowMemBeg, kLowMemEnd);
|
||||
Printf("|| `[%zx, %zx]` || LowMem ||\n", kLowMemBeg, kLowMemEnd);
|
||||
Printf("MemToShadow(shadow): %p %p %p %p\n",
|
||||
MEM_TO_SHADOW(kLowShadowBeg),
|
||||
MEM_TO_SHADOW(kLowShadowEnd),
|
||||
|
|
|
@ -74,7 +74,7 @@ void AsanThread::Init() {
|
|||
if (FLAG_v >= 1) {
|
||||
int local = 0;
|
||||
Report("T%d: stack [%p,%p) size 0x%zx; local=%p\n",
|
||||
tid(), stack_bottom_, stack_top_,
|
||||
tid(), (void*)stack_bottom_, (void*)stack_top_,
|
||||
stack_top_ - stack_bottom_, &local);
|
||||
}
|
||||
fake_stack_.Init(stack_size());
|
||||
|
|
|
@ -88,7 +88,8 @@ AsanThread *AsanThreadRegistry::GetCurrent() {
|
|||
void AsanThreadRegistry::SetCurrent(AsanThread *t) {
|
||||
CHECK(t->summary());
|
||||
if (FLAG_v >= 2) {
|
||||
Report("SetCurrent: %p for thread %p\n", t->summary(), GetThreadSelf());
|
||||
Report("SetCurrent: %p for thread %p\n",
|
||||
t->summary(), (void*)GetThreadSelf());
|
||||
}
|
||||
// Make sure we do not reset the current AsanThread.
|
||||
CHECK(AsanTSDGet() == 0);
|
||||
|
|
Loading…
Reference in New Issue