Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,13 @@ class SizeClassAllocator64 {
Printf(
"%s %02zd (%6zd): mapped: %6zdK allocs: %7zd frees: %7zd inuse: %6zd "
"num_freed_chunks %7zd avail: %6zd rss: %6zdK releases: %6zd "
"last released: %6lldK region: 0x%zx\n",
"last released: %6lldK region: %p\n",
region->exhausted ? "F" : " ", class_id, ClassIdToSize(class_id),
region->mapped_user >> 10, region->stats.n_allocated,
region->stats.n_freed, in_use, region->num_freed_chunks, avail_chunks,
rss >> 10, region->rtoi.num_releases,
region->rtoi.last_released_bytes >> 10,
SpaceBeg() + kRegionSize * class_id);
(void *)(SpaceBeg() + kRegionSize * class_id));
}

void PrintStats() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ static void SanitizerDumpCoverage(const uptr* unsorted_pcs, uptr len) {
if (!pc) continue;

if (!GetModuleAndOffsetForPc(pc, nullptr, 0, &pcs[i])) {
Printf("ERROR: unknown pc 0x%zx (may happen if dlclose is used)\n", pc);
Printf("ERROR: unknown pc %p (may happen if dlclose is used)\n",
(void*)pc);
continue;
}
uptr module_base = pc - pcs[i];
Expand Down
4 changes: 2 additions & 2 deletions compiler-rt/lib/sanitizer_common/sanitizer_libignore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ void LibIgnore::OnLibraryLoaded(const char *name) {
continue;
if (IsPcInstrumented(range.beg) && IsPcInstrumented(range.end - 1))
continue;
VReport(1, "Adding instrumented range 0x%zx-0x%zx from library '%s'\n",
range.beg, range.end, mod.full_name());
VReport(1, "Adding instrumented range %p-%p from library '%s'\n",
(void *)range.beg, (void *)range.end, mod.full_name());
const uptr idx =
atomic_load(&instrumented_ranges_count_, memory_order_relaxed);
CHECK_LT(idx, ARRAY_SIZE(instrumented_code_ranges_));
Expand Down
4 changes: 2 additions & 2 deletions compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1372,8 +1372,8 @@ void DumpProcessMap() {
for (uptr i = 0; i < modules.size(); ++i) {
char uuid_str[128];
FormatUUID(uuid_str, sizeof(uuid_str), modules[i].uuid());
Printf("0x%zx-0x%zx %s (%s) %s\n", modules[i].base_address(),
modules[i].max_address(), modules[i].full_name(),
Printf("%p-%p %s (%s) %s\n", (void *)modules[i].base_address(),
(void *)modules[i].max_address(), modules[i].full_name(),
ModuleArchToString(modules[i].arch()), uuid_str);
}
Printf("End of module map.\n");
Expand Down
4 changes: 2 additions & 2 deletions compiler-rt/lib/sanitizer_common/sanitizer_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ static void *MmapFixedImpl(uptr fixed_addr, uptr size, bool tolerate_enomem,
if (tolerate_enomem && reserrno == ENOMEM)
return nullptr;
char mem_type[40];
internal_snprintf(mem_type, sizeof(mem_type), "memory at address 0x%zx",
fixed_addr);
internal_snprintf(mem_type, sizeof(mem_type), "memory at address %p",
(void *)fixed_addr);
ReportMmapFailureAndDie(size, mem_type, "allocate", reserrno);
}
IncreaseTotalMmap(size);
Expand Down
7 changes: 4 additions & 3 deletions compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,10 @@ static bool MmapFixed(uptr fixed_addr, uptr size, int additional_flags,
MAP_PRIVATE | MAP_FIXED | additional_flags | MAP_ANON, name);
int reserrno;
if (internal_iserror(p, &reserrno)) {
Report("ERROR: %s failed to "
"allocate 0x%zx (%zd) bytes at address %zx (errno: %d)\n",
SanitizerToolName, size, size, fixed_addr, reserrno);
Report(
"ERROR: %s failed to "
"allocate 0x%zx (%zd) bytes at address %p (errno: %d)\n",
SanitizerToolName, size, size, (void *)fixed_addr, reserrno);
return false;
}
IncreaseTotalMmap(size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ void FormattedStackTracePrinter::RenderFrame(InternalScopedString *buffer,
buffer->AppendF("%u", frame_no);
break;
case 'p':
buffer->AppendF("0x%zx", address);
buffer->AppendF("%p", (void *)address);
break;
case 'm':
buffer->AppendF("%s", StripPathPrefix(info->module, strip_path_prefix));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ static void TracerThreadDieCallback() {
static void TracerThreadSignalHandler(int signum, __sanitizer_siginfo *siginfo,
void *uctx) {
SignalContext ctx(siginfo, uctx);
Printf("Tracer caught signal %d: addr=0x%zx pc=0x%zx sp=0x%zx\n", signum,
ctx.addr, ctx.pc, ctx.sp);
Printf("Tracer caught signal %d: addr=%p pc=%p sp=%p\n", signum,
(void *)ctx.addr, (void *)ctx.pc, (void *)ctx.sp);
ThreadSuspender *inst = thread_suspender_instance;
if (inst) {
if (signum == SIGABRT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ static void TracerThreadDieCallback() {
static void TracerThreadSignalHandler(int signum, __sanitizer_siginfo *siginfo,
void *uctx) {
SignalContext ctx(siginfo, uctx);
Printf("Tracer caught signal %d: addr=0x%zx pc=0x%zx sp=0x%zx\n", signum,
ctx.addr, ctx.pc, ctx.sp);
Printf("Tracer caught signal %d: addr=%p pc=%p sp=%p\n", signum,
(void *)ctx.addr, (void *)ctx.pc, (void *)ctx.sp);
ThreadSuspender *inst = thread_suspender_instance;
if (inst) {
if (signum == SIGABRT)
Expand Down
14 changes: 7 additions & 7 deletions compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,25 +121,25 @@ DTLS::DTV *DTLS_on_tls_get_addr(void *arg_void, void *res,
uptr tls_size = 0;
uptr tls_beg = reinterpret_cast<uptr>(res) - arg->offset - kDtvOffset;
VReport(2,
"__tls_get_addr: %p {0x%zx,0x%zx} => %p; tls_beg: 0x%zx; sp: %p "
"__tls_get_addr: %p {0x%zx,0x%zx} => %p; tls_beg: %p; sp: %p "
"num_live_dtls %zd\n",
(void *)arg, arg->dso_id, arg->offset, res, tls_beg, (void *)&tls_beg,
(void *)arg, arg->dso_id, arg->offset, res, (void *)tls_beg, &tls_beg,
atomic_load(&number_of_live_dtls, memory_order_relaxed));
if (dtls.last_memalign_ptr == tls_beg) {
tls_size = dtls.last_memalign_size;
VReport(2, "__tls_get_addr: glibc <=2.24 suspected; tls={0x%zx,0x%zx}\n",
tls_beg, tls_size);
VReport(2, "__tls_get_addr: glibc <=2.24 suspected; tls={%p,0x%zx}\n",
(void *)tls_beg, tls_size);
} else if (tls_beg >= static_tls_begin && tls_beg < static_tls_end) {
// This is the static TLS block which was initialized / unpoisoned at thread
// creation.
VReport(2, "__tls_get_addr: static tls: 0x%zx\n", tls_beg);
VReport(2, "__tls_get_addr: static tls: %p\n", (void *)tls_beg);
tls_size = 0;
} else if (const void *start =
__sanitizer_get_allocated_begin((void *)tls_beg)) {
tls_beg = (uptr)start;
tls_size = __sanitizer_get_allocated_size(start);
VReport(2, "__tls_get_addr: glibc >=2.25 suspected; tls={0x%zx,0x%zx}\n",
tls_beg, tls_size);
VReport(2, "__tls_get_addr: glibc >=2.25 suspected; tls={%p,0x%zx}\n",
(void *)tls_beg, tls_size);
} else {
VReport(2, "__tls_get_addr: Can't guess glibc version\n");
// This may happen inside the DTOR of main thread, so just ignore it.
Expand Down
8 changes: 4 additions & 4 deletions compiler-rt/lib/sanitizer_common/sanitizer_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ void *MmapFixedOrDie(uptr fixed_addr, uptr size, const char *name) {
MEM_COMMIT, PAGE_READWRITE);
if (p == 0) {
char mem_type[30];
internal_snprintf(mem_type, sizeof(mem_type), "memory at address 0x%zx",
fixed_addr);
internal_snprintf(mem_type, sizeof(mem_type), "memory at address %p",
(void *)fixed_addr);
ReportMmapFailureAndDie(size, mem_type, "allocate", GetLastError());
}
return p;
Expand Down Expand Up @@ -308,8 +308,8 @@ void *MmapFixedOrDieOnFatalError(uptr fixed_addr, uptr size, const char *name) {
MEM_COMMIT, PAGE_READWRITE);
if (p == 0) {
char mem_type[30];
internal_snprintf(mem_type, sizeof(mem_type), "memory at address 0x%zx",
fixed_addr);
internal_snprintf(mem_type, sizeof(mem_type), "memory at address %p",
(void *)fixed_addr);
return ReturnNullptrOnOOMOrDie(size, mem_type, "allocate");
}
return p;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ TEST_F(StackDepotTest, Print) {
return s;
return std::regex_replace(s, std::regex("\\.\\*"), ".*\\n.*");
};
EXPECT_EXIT(
(StackDepotPrintAll(), exit(0)), ::testing::ExitedWithCode(0),
fix_regex("Stack for id .*#0 0x1.*#1 0x2.*#2 0x3.*#3 0x4.*#4 0x7.*"));
EXPECT_EXIT(
(StackDepotPrintAll(), exit(0)), ::testing::ExitedWithCode(0),
fix_regex(
"Stack for id .*#0 0x1.*#1 0x2.*#2 0x3.*#3 0x4.*#4 0x8.*#5 0x9.*"));
"Stack for id .*#0 0x0*1.*#1 0x0*2.*#2 0x0*3.*#3 0x0*4.*#4 0x0*7.*"));
EXPECT_EXIT((StackDepotPrintAll(), exit(0)), ::testing::ExitedWithCode(0),
fix_regex("Stack for id .*#0 0x0*1.*#1 0x0*2.*#2 0x0*3.*#3 "
"0x0*4.*#4 0x0*8.*#5 0x0*9.*"));
}

TEST_F(StackDepotTest, PrintNoLock) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
//===----------------------------------------------------------------------===//
#include "sanitizer_common/sanitizer_stacktrace_printer.h"

#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "interception/interception.h"

using testing::MatchesRegex;

namespace __sanitizer {

class TestFormattedStackTracePrinter final : public FormattedStackTracePrinter {
Expand Down Expand Up @@ -96,10 +99,12 @@ TEST(FormattedStackTracePrinter, RenderFrame) {
"Function:%f FunctionOffset:%q Source:%s Line:%l "
"Column:%c",
frame_no, info.address, &info, false, "/path/to/");
EXPECT_STREQ("% Frame:42 PC:0x400000 Module:my/module ModuleOffset:0x200 "
"Function:foo FunctionOffset:0x100 Source:my/source Line:10 "
"Column:5",
str.data());
EXPECT_THAT(
str.data(),
MatchesRegex(
"% Frame:42 PC:0x0*400000 Module:my/module ModuleOffset:0x200 "
"Function:foo FunctionOffset:0x100 Source:my/source Line:10 "
"Column:5"));

str.clear();
// Check that RenderFrame() strips interceptor prefixes.
Expand All @@ -109,10 +114,12 @@ TEST(FormattedStackTracePrinter, RenderFrame) {
"Function:%f FunctionOffset:%q Source:%s Line:%l "
"Column:%c",
frame_no, info.address, &info, false, "/path/to/");
EXPECT_STREQ("% Frame:42 PC:0x400000 Module:my/module ModuleOffset:0x200 "
"Function:bar FunctionOffset:0x100 Source:my/source Line:10 "
"Column:5",
str.data());
EXPECT_THAT(
str.data(),
MatchesRegex(
"% Frame:42 PC:0x0*400000 Module:my/module ModuleOffset:0x200 "
"Function:bar FunctionOffset:0x100 Source:my/source Line:10 "
"Column:5"));
info.Clear();
str.clear();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ TEST(GetCurrentPc, Basic) {
StackTrace::GetCurrentPc(),
};
for (uptr i = 0; i < ARRAY_SIZE(pcs); i++)
Printf("pc%zu: 0x%zx\n", i, pcs[i]);
Printf("pc%zu: %p\n", i, (void *)(pcs[i]));
for (uptr i = 1; i < ARRAY_SIZE(pcs); i++) {
EXPECT_GT(pcs[i], pcs[0]);
EXPECT_LT(pcs[i], pcs[0] + 1000);
Expand Down