[asan] some renaming before we move StackTrace into sanitizer_common

llvm-svn: 162747
This commit is contained in:
Kostya Serebryany 2012-08-28 11:54:30 +00:00
parent bb6f165952
commit 6b0d775229
13 changed files with 83 additions and 87 deletions

View File

@ -566,7 +566,7 @@ class MallocInfo {
pg->size_of_chunk = size;
pg->last_chunk = (uptr)(mem + size * (n_chunks - 1));
int idx = atomic_fetch_add(&n_page_groups_, 1, memory_order_relaxed);
CHECK(idx < (int)ASAN_ARRAY_SIZE(page_groups_));
CHECK(idx < (int)ARRAY_SIZE(page_groups_));
page_groups_[idx] = pg;
return res;
}
@ -593,8 +593,8 @@ void DescribeHeapAddress(uptr addr, uptr access_size) {
CHECK(m->alloc_tid >= 0);
AsanThreadSummary *alloc_thread =
asanThreadRegistry().FindByTid(m->alloc_tid);
AsanStackTrace alloc_stack;
AsanStackTrace::UncompressStack(&alloc_stack, m->compressed_alloc_stack(),
StackTrace alloc_stack;
StackTrace::UncompressStack(&alloc_stack, m->compressed_alloc_stack(),
m->compressed_alloc_stack_size());
AsanThread *t = asanThreadRegistry().GetCurrent();
CHECK(t);
@ -602,8 +602,8 @@ void DescribeHeapAddress(uptr addr, uptr access_size) {
AsanThreadSummary *free_thread =
asanThreadRegistry().FindByTid(m->free_tid);
Printf("freed by thread T%d here:\n", free_thread->tid());
AsanStackTrace free_stack;
AsanStackTrace::UncompressStack(&free_stack, m->compressed_free_stack(),
StackTrace free_stack;
StackTrace::UncompressStack(&free_stack, m->compressed_free_stack(),
m->compressed_free_stack_size());
free_stack.PrintStack();
Printf("previously allocated by thread T%d here:\n",
@ -621,7 +621,7 @@ void DescribeHeapAddress(uptr addr, uptr access_size) {
}
}
static u8 *Allocate(uptr alignment, uptr size, AsanStackTrace *stack) {
static u8 *Allocate(uptr alignment, uptr size, StackTrace *stack) {
__asan_init();
CHECK(stack);
if (size == 0) {
@ -699,7 +699,7 @@ static u8 *Allocate(uptr alignment, uptr size, AsanStackTrace *stack) {
CHECK(m->Beg() == addr);
m->alloc_tid = t ? t->tid() : 0;
m->free_tid = kInvalidTid;
AsanStackTrace::CompressStack(stack, m->compressed_alloc_stack(),
StackTrace::CompressStack(stack, m->compressed_alloc_stack(),
m->compressed_alloc_stack_size());
PoisonShadow(addr, rounded_size, 0);
if (size < rounded_size) {
@ -712,7 +712,7 @@ static u8 *Allocate(uptr alignment, uptr size, AsanStackTrace *stack) {
return (u8*)addr;
}
static void Deallocate(u8 *ptr, AsanStackTrace *stack) {
static void Deallocate(u8 *ptr, StackTrace *stack) {
if (!ptr) return;
CHECK(stack);
@ -739,7 +739,7 @@ static void Deallocate(u8 *ptr, AsanStackTrace *stack) {
CHECK(m->alloc_tid >= 0);
AsanThread *t = asanThreadRegistry().GetCurrent();
m->free_tid = t ? t->tid() : 0;
AsanStackTrace::CompressStack(stack, m->compressed_free_stack(),
StackTrace::CompressStack(stack, m->compressed_free_stack(),
m->compressed_free_stack_size());
uptr rounded_size = RoundUpTo(m->used_size, REDZONE);
PoisonShadow((uptr)ptr, rounded_size, kAsanHeapFreeMagic);
@ -765,7 +765,7 @@ static void Deallocate(u8 *ptr, AsanStackTrace *stack) {
}
static u8 *Reallocate(u8 *old_ptr, uptr new_size,
AsanStackTrace *stack) {
StackTrace *stack) {
CHECK(old_ptr && new_size);
// Statistics.
@ -804,26 +804,26 @@ void __asan_free_hook(void *ptr) {
namespace __asan {
SANITIZER_INTERFACE_ATTRIBUTE
void *asan_memalign(uptr alignment, uptr size, AsanStackTrace *stack) {
void *asan_memalign(uptr alignment, uptr size, StackTrace *stack) {
void *ptr = (void*)Allocate(alignment, size, stack);
__asan_malloc_hook(ptr, size);
return ptr;
}
SANITIZER_INTERFACE_ATTRIBUTE
void asan_free(void *ptr, AsanStackTrace *stack) {
void asan_free(void *ptr, StackTrace *stack) {
__asan_free_hook(ptr);
Deallocate((u8*)ptr, stack);
}
SANITIZER_INTERFACE_ATTRIBUTE
void *asan_malloc(uptr size, AsanStackTrace *stack) {
void *asan_malloc(uptr size, StackTrace *stack) {
void *ptr = (void*)Allocate(0, size, stack);
__asan_malloc_hook(ptr, size);
return ptr;
}
void *asan_calloc(uptr nmemb, uptr size, AsanStackTrace *stack) {
void *asan_calloc(uptr nmemb, uptr size, StackTrace *stack) {
void *ptr = (void*)Allocate(0, nmemb * size, stack);
if (ptr)
REAL(memset)(ptr, 0, nmemb * size);
@ -831,7 +831,7 @@ void *asan_calloc(uptr nmemb, uptr size, AsanStackTrace *stack) {
return ptr;
}
void *asan_realloc(void *p, uptr size, AsanStackTrace *stack) {
void *asan_realloc(void *p, uptr size, StackTrace *stack) {
if (p == 0) {
void *ptr = (void*)Allocate(0, size, stack);
__asan_malloc_hook(ptr, size);
@ -844,13 +844,13 @@ void *asan_realloc(void *p, uptr size, AsanStackTrace *stack) {
return Reallocate((u8*)p, size, stack);
}
void *asan_valloc(uptr size, AsanStackTrace *stack) {
void *asan_valloc(uptr size, StackTrace *stack) {
void *ptr = (void*)Allocate(kPageSize, size, stack);
__asan_malloc_hook(ptr, size);
return ptr;
}
void *asan_pvalloc(uptr size, AsanStackTrace *stack) {
void *asan_pvalloc(uptr size, StackTrace *stack) {
size = RoundUpTo(size, kPageSize);
if (size == 0) {
// pvalloc(0) should allocate one page.
@ -862,7 +862,7 @@ void *asan_pvalloc(uptr size, AsanStackTrace *stack) {
}
int asan_posix_memalign(void **memptr, uptr alignment, uptr size,
AsanStackTrace *stack) {
StackTrace *stack) {
void *ptr = Allocate(alignment, size, stack);
CHECK(IsAligned((uptr)ptr, alignment));
__asan_malloc_hook(ptr, size);
@ -870,7 +870,7 @@ int asan_posix_memalign(void **memptr, uptr alignment, uptr size,
return 0;
}
uptr asan_malloc_usable_size(void *ptr, AsanStackTrace *stack) {
uptr asan_malloc_usable_size(void *ptr, StackTrace *stack) {
CHECK(stack);
if (ptr == 0) return 0;
uptr usable_size = malloc_info.AllocationSize((uptr)ptr);

View File

@ -137,18 +137,18 @@ class FakeStack {
FakeFrameLifo call_stack_;
};
void *asan_memalign(uptr alignment, uptr size, AsanStackTrace *stack);
void asan_free(void *ptr, AsanStackTrace *stack);
void *asan_memalign(uptr alignment, uptr size, StackTrace *stack);
void asan_free(void *ptr, StackTrace *stack);
void *asan_malloc(uptr size, AsanStackTrace *stack);
void *asan_calloc(uptr nmemb, uptr size, AsanStackTrace *stack);
void *asan_realloc(void *p, uptr size, AsanStackTrace *stack);
void *asan_valloc(uptr size, AsanStackTrace *stack);
void *asan_pvalloc(uptr size, AsanStackTrace *stack);
void *asan_malloc(uptr size, StackTrace *stack);
void *asan_calloc(uptr nmemb, uptr size, StackTrace *stack);
void *asan_realloc(void *p, uptr size, StackTrace *stack);
void *asan_valloc(uptr size, StackTrace *stack);
void *asan_pvalloc(uptr size, StackTrace *stack);
int asan_posix_memalign(void **memptr, uptr alignment, uptr size,
AsanStackTrace *stack);
uptr asan_malloc_usable_size(void *ptr, AsanStackTrace *stack);
StackTrace *stack);
uptr asan_malloc_usable_size(void *ptr, StackTrace *stack);
uptr asan_mz_size(const void *ptr);
void asan_mz_force_lock();

View File

@ -93,7 +93,7 @@ extern "C" void* _ReturnAddress(void);
namespace __asan {
class AsanThread;
struct AsanStackTrace;
struct StackTrace;
// asan_rtl.cc
void NORETURN ShowStatsAndAbort();
@ -145,8 +145,6 @@ extern int asan_inited;
extern bool asan_init_is_running;
extern void (*death_callback)(void);
#define ASAN_ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
#if !defined(_WIN32) || defined(__clang__)
# define GET_CALLER_PC() (uptr)__builtin_return_address(0)
# define GET_CURRENT_FRAME() (uptr)__builtin_frame_address(0)

View File

@ -123,7 +123,7 @@ uptr Unwind_GetIP(struct _Unwind_Context *ctx) {
_Unwind_Reason_Code Unwind_Trace(struct _Unwind_Context *ctx,
void *param) {
AsanStackTrace *b = (AsanStackTrace*)param;
StackTrace *b = (StackTrace*)param;
CHECK(b->size < b->max_size);
uptr pc = Unwind_GetIP(ctx);
b->trace[b->size++] = pc;
@ -131,7 +131,7 @@ _Unwind_Reason_Code Unwind_Trace(struct _Unwind_Context *ctx,
return UNWIND_CONTINUE;
}
void AsanStackTrace::GetStackTrace(uptr max_s, uptr pc, uptr bp) {
void StackTrace::GetStackTrace(uptr max_s, uptr pc, uptr bp) {
size = 0;
trace[0] = pc;
if ((max_s) > 1) {

View File

@ -152,7 +152,7 @@ void AsanLock::Unlock() {
OSSpinLockUnlock((OSSpinLock*)&opaque_storage_);
}
void AsanStackTrace::GetStackTrace(uptr max_s, uptr pc, uptr bp) {
void StackTrace::GetStackTrace(uptr max_s, uptr pc, uptr bp) {
size = 0;
trace[0] = pc;
if ((max_s) > 1) {
@ -280,7 +280,7 @@ int pthread_workqueue_additem_np(pthread_workqueue_t workq,
} // extern "C"
static ALWAYS_INLINE
void asan_register_worker_thread(int parent_tid, AsanStackTrace *stack) {
void asan_register_worker_thread(int parent_tid, StackTrace *stack) {
AsanThread *t = asanThreadRegistry().GetCurrent();
if (!t) {
t = AsanThread::Create(parent_tid, 0, 0, stack);
@ -315,7 +315,7 @@ using namespace __asan; // NOLINT
// The caller retains control of the allocated context.
extern "C"
asan_block_context_t *alloc_asan_context(void *ctxt, dispatch_function_t func,
AsanStackTrace *stack) {
StackTrace *stack) {
asan_block_context_t *asan_ctxt =
(asan_block_context_t*) asan_malloc(sizeof(asan_block_context_t), stack);
asan_ctxt->block = ctxt;

View File

@ -261,14 +261,14 @@ void ReportSIGSEGV(uptr pc, uptr sp, uptr bp, uptr addr) {
stack.PrintStack();
}
void ReportDoubleFree(uptr addr, AsanStackTrace *stack) {
void ReportDoubleFree(uptr addr, StackTrace *stack) {
ScopedInErrorReport in_report;
Report("ERROR: AddressSanitizer attempting double-free on %p:\n", addr);
stack->PrintStack();
DescribeHeapAddress(addr, 1);
}
void ReportFreeNotMalloced(uptr addr, AsanStackTrace *stack) {
void ReportFreeNotMalloced(uptr addr, StackTrace *stack) {
ScopedInErrorReport in_report;
Report("ERROR: AddressSanitizer attempting free on address "
"which was not malloc()-ed: %p\n", addr);
@ -276,7 +276,7 @@ void ReportFreeNotMalloced(uptr addr, AsanStackTrace *stack) {
DescribeHeapAddress(addr, 1);
}
void ReportMallocUsableSizeNotOwned(uptr addr, AsanStackTrace *stack) {
void ReportMallocUsableSizeNotOwned(uptr addr, StackTrace *stack) {
ScopedInErrorReport in_report;
Report("ERROR: AddressSanitizer attempting to call "
"malloc_usable_size() for pointer which is "
@ -285,7 +285,7 @@ void ReportMallocUsableSizeNotOwned(uptr addr, AsanStackTrace *stack) {
DescribeHeapAddress(addr, 1);
}
void ReportAsanGetAllocatedSizeNotOwned(uptr addr, AsanStackTrace *stack) {
void ReportAsanGetAllocatedSizeNotOwned(uptr addr, StackTrace *stack) {
ScopedInErrorReport in_report;
Report("ERROR: AddressSanitizer attempting to call "
"__asan_get_allocated_size() for pointer which is "
@ -296,7 +296,7 @@ void ReportAsanGetAllocatedSizeNotOwned(uptr addr, AsanStackTrace *stack) {
void ReportStringFunctionMemoryRangesOverlap(
const char *function, const char *offset1, uptr length1,
const char *offset2, uptr length2, AsanStackTrace *stack) {
const char *offset2, uptr length2, StackTrace *stack) {
ScopedInErrorReport in_report;
Report("ERROR: AddressSanitizer %s-param-overlap: "
"memory ranges [%p,%p) and [%p, %p) overlap\n", \
@ -309,7 +309,7 @@ void ReportStringFunctionMemoryRangesOverlap(
// ----------------------- Mac-specific reports ----------------- {{{1
void WarnMacFreeUnallocated(
uptr addr, uptr zone_ptr, const char *zone_name, AsanStackTrace *stack) {
uptr addr, uptr zone_ptr, const char *zone_name, StackTrace *stack) {
// Just print a warning here.
Printf("free_common(%p) -- attempting to free unallocated memory.\n"
"AddressSanitizer is ignoring this error on Mac OS now.\n",
@ -320,7 +320,7 @@ void WarnMacFreeUnallocated(
}
void ReportMacMzReallocUnknown(
uptr addr, uptr zone_ptr, const char *zone_name, AsanStackTrace *stack) {
uptr addr, uptr zone_ptr, const char *zone_name, StackTrace *stack) {
ScopedInErrorReport in_report;
Printf("mz_realloc(%p) -- attempting to realloc unallocated memory.\n"
"This is an unrecoverable problem, exiting now.\n",
@ -331,7 +331,7 @@ void ReportMacMzReallocUnknown(
}
void ReportMacCfReallocUnknown(
uptr addr, uptr zone_ptr, const char *zone_name, AsanStackTrace *stack) {
uptr addr, uptr zone_ptr, const char *zone_name, StackTrace *stack) {
ScopedInErrorReport in_report;
Printf("cf_realloc(%p) -- attempting to realloc unallocated memory.\n"
"This is an unrecoverable problem, exiting now.\n",

View File

@ -29,22 +29,22 @@ void DescribeAddress(uptr addr, uptr access_size);
// Different kinds of error reports.
void NORETURN ReportSIGSEGV(uptr pc, uptr sp, uptr bp, uptr addr);
void NORETURN ReportDoubleFree(uptr addr, AsanStackTrace *stack);
void NORETURN ReportFreeNotMalloced(uptr addr, AsanStackTrace *stack);
void NORETURN ReportDoubleFree(uptr addr, StackTrace *stack);
void NORETURN ReportFreeNotMalloced(uptr addr, StackTrace *stack);
void NORETURN ReportMallocUsableSizeNotOwned(uptr addr,
AsanStackTrace *stack);
StackTrace *stack);
void NORETURN ReportAsanGetAllocatedSizeNotOwned(uptr addr,
AsanStackTrace *stack);
StackTrace *stack);
void NORETURN ReportStringFunctionMemoryRangesOverlap(
const char *function, const char *offset1, uptr length1,
const char *offset2, uptr length2, AsanStackTrace *stack);
const char *offset2, uptr length2, StackTrace *stack);
// Mac-specific errors and warnings.
void WarnMacFreeUnallocated(
uptr addr, uptr zone_ptr, const char *zone_name, AsanStackTrace *stack);
uptr addr, uptr zone_ptr, const char *zone_name, StackTrace *stack);
void NORETURN ReportMacMzReallocUnknown(
uptr addr, uptr zone_ptr, const char *zone_name, AsanStackTrace *stack);
uptr addr, uptr zone_ptr, const char *zone_name, StackTrace *stack);
void NORETURN ReportMacCfReallocUnknown(
uptr addr, uptr zone_ptr, const char *zone_name, AsanStackTrace *stack);
uptr addr, uptr zone_ptr, const char *zone_name, StackTrace *stack);
} // namespace __asan

View File

@ -31,7 +31,7 @@ static const char *StripPathPrefix(const char *filepath) {
return filepath;
}
// ----------------------- AsanStackTrace ----------------------------- {{{1
// ----------------------- StackTrace ----------------------------- {{{1
// PCs in stack traces are actually the return addresses, that is,
// addresses of the next instructions after the call. That's why we
// decrement them.
@ -43,7 +43,7 @@ static uptr patch_pc(uptr pc) {
return pc - 1;
}
void AsanStackTrace::PrintStack(uptr *addr, uptr size) {
void StackTrace::PrintStack(uptr *addr, uptr size) {
MemoryMappingLayout proc_maps;
uptr frame_num = 0;
for (uptr i = 0; i < size && addr[i]; i++) {
@ -61,8 +61,7 @@ void AsanStackTrace::PrintStack(uptr *addr, uptr size) {
AddressInfo addr_frames[64];
uptr addr_frames_num = 0;
if (flags()->symbolize) {
addr_frames_num = SymbolizeCode(pc, addr_frames,
ASAN_ARRAY_SIZE(addr_frames));
addr_frames_num = SymbolizeCode(pc, addr_frames, ARRAY_SIZE(addr_frames));
}
if (addr_frames_num > 0) {
for (uptr j = 0; j < addr_frames_num; j++) {
@ -97,11 +96,11 @@ void AsanStackTrace::PrintStack(uptr *addr, uptr size) {
}
}
uptr AsanStackTrace::GetCurrentPc() {
uptr StackTrace::GetCurrentPc() {
return GET_CALLER_PC();
}
void AsanStackTrace::FastUnwindStack(uptr pc, uptr bp) {
void StackTrace::FastUnwindStack(uptr pc, uptr bp) {
CHECK(size == 0 && trace[0] == pc);
size = 1;
if (!asan_inited) return;
@ -128,8 +127,7 @@ void AsanStackTrace::FastUnwindStack(uptr pc, uptr bp) {
// On 64-bits we compress stack traces: if a given pc differes slightly from
// the previous one, we record a 31-bit offset instead of the full pc.
SANITIZER_INTERFACE_ATTRIBUTE
uptr AsanStackTrace::CompressStack(AsanStackTrace *stack,
u32 *compressed, uptr size) {
uptr StackTrace::CompressStack(StackTrace *stack, u32 *compressed, uptr size) {
#if __WORDSIZE == 32
// Don't compress, just copy.
uptr res = 0;
@ -175,7 +173,7 @@ uptr AsanStackTrace::CompressStack(AsanStackTrace *stack,
// debug-only code
#if 0
AsanStackTrace check_stack;
StackTrace check_stack;
UncompressStack(&check_stack, compressed, size);
if (res < check_stack.size) {
Printf("res %zu check_stack.size %zu; c_size %zu\n", res,
@ -192,8 +190,8 @@ uptr AsanStackTrace::CompressStack(AsanStackTrace *stack,
}
SANITIZER_INTERFACE_ATTRIBUTE
void AsanStackTrace::UncompressStack(AsanStackTrace *stack,
u32 *compressed, uptr size) {
void StackTrace::UncompressStack(StackTrace *stack,
u32 *compressed, uptr size) {
#if __WORDSIZE == 32
// Don't uncompress, just copy.
stack->size = 0;

View File

@ -20,7 +20,7 @@ namespace __asan {
static const uptr kStackTraceMax = 64;
struct AsanStackTrace {
struct StackTrace {
uptr size;
uptr max_size;
uptr trace[kStackTraceMax];
@ -49,9 +49,9 @@ struct AsanStackTrace {
static uptr GetCurrentPc();
static uptr CompressStack(AsanStackTrace *stack,
static uptr CompressStack(StackTrace *stack,
u32 *compressed, uptr size);
static void UncompressStack(AsanStackTrace *stack,
static void UncompressStack(StackTrace *stack,
u32 *compressed, uptr size);
};
@ -69,7 +69,7 @@ struct AsanStackTrace {
// function in the top frame.
#define GET_CURRENT_PC_BP_SP \
uptr bp = GET_CURRENT_FRAME(); \
uptr pc = AsanStackTrace::GetCurrentPc(); \
uptr pc = StackTrace::GetCurrentPc(); \
uptr local_stack; \
uptr sp = (uptr)&local_stack
@ -78,7 +78,7 @@ struct AsanStackTrace {
// The bp may refer to the current frame or to the caller's frame.
// fast_unwind is currently unused.
#define GET_STACK_TRACE_WITH_PC_AND_BP(max_s, pc, bp) \
AsanStackTrace stack; \
StackTrace stack; \
stack.GetStackTrace(max_s, pc, bp)
// NOTE: A Rule of thumb is to retrieve stack trace in the interceptors
@ -87,7 +87,7 @@ struct AsanStackTrace {
#define GET_STACK_TRACE_HERE(max_size) \
GET_STACK_TRACE_WITH_PC_AND_BP(max_size, \
AsanStackTrace::GetCurrentPc(), GET_CURRENT_FRAME())
StackTrace::GetCurrentPc(), GET_CURRENT_FRAME())
#define GET_STACK_TRACE_HERE_FOR_MALLOC \
GET_STACK_TRACE_HERE(flags()->malloc_context_size)

View File

@ -30,7 +30,7 @@ static AsanLock mu_for_thread_summary(LINKER_INITIALIZED);
static LowLevelAllocator allocator_for_thread_summary;
AsanThread *AsanThread::Create(u32 parent_tid, thread_callback_t start_routine,
void *arg, AsanStackTrace *stack) {
void *arg, StackTrace *stack) {
uptr size = RoundUpTo(sizeof(AsanThread), kPageSize);
AsanThread *thread = (AsanThread*)MmapOrDie(size, __FUNCTION__);
thread->start_routine_ = start_routine;

View File

@ -31,7 +31,7 @@ class AsanThread;
class AsanThreadSummary {
public:
explicit AsanThreadSummary(LinkerInitialized) { } // for T0.
void Init(u32 parent_tid, AsanStackTrace *stack) {
void Init(u32 parent_tid, StackTrace *stack) {
parent_tid_ = parent_tid;
announced_ = false;
tid_ = kInvalidTid;
@ -58,7 +58,7 @@ class AsanThreadSummary {
u32 tid_;
u32 parent_tid_;
bool announced_;
AsanStackTrace stack_;
StackTrace stack_;
AsanThread *thread_;
};
@ -67,7 +67,7 @@ class AsanThread {
public:
explicit AsanThread(LinkerInitialized); // for T0.
static AsanThread *Create(u32 parent_tid, thread_callback_t start_routine,
void *arg, AsanStackTrace *stack);
void *arg, StackTrace *stack);
void Destroy();
void Init(); // Should be called from the thread itself.

View File

@ -32,7 +32,7 @@ static AsanLock dbghelp_lock(LINKER_INITIALIZED);
static bool dbghelp_initialized = false;
#pragma comment(lib, "dbghelp.lib")
void AsanStackTrace::GetStackTrace(uptr max_s, uptr pc, uptr bp) {
void StackTrace::GetStackTrace(uptr max_s, uptr pc, uptr bp) {
max_size = max_s;
void *tmp[kStackTraceMax];

View File

@ -42,17 +42,17 @@ TEST(AddressSanitizer, InternalSimpleDeathTest) {
static void MallocStress(size_t n) {
u32 seed = my_rand(&global_seed);
__asan::AsanStackTrace stack1;
__asan::StackTrace stack1;
stack1.trace[0] = 0xa123;
stack1.trace[1] = 0xa456;
stack1.size = 2;
__asan::AsanStackTrace stack2;
__asan::StackTrace stack2;
stack2.trace[0] = 0xb123;
stack2.trace[1] = 0xb456;
stack2.size = 2;
__asan::AsanStackTrace stack3;
__asan::StackTrace stack3;
stack3.trace[0] = 0xc123;
stack3.trace[1] = 0xc456;
stack3.size = 2;
@ -210,21 +210,21 @@ static uptr pc_array[] = {
void CompressStackTraceTest(size_t n_iter) {
u32 seed = my_rand(&global_seed);
const size_t kNumPcs = ASAN_ARRAY_SIZE(pc_array);
const size_t kNumPcs = ARRAY_SIZE(pc_array);
u32 compressed[2 * kNumPcs];
for (size_t iter = 0; iter < n_iter; iter++) {
std::random_shuffle(pc_array, pc_array + kNumPcs);
__asan::AsanStackTrace stack0, stack1;
__asan::StackTrace stack0, stack1;
stack0.CopyFrom(pc_array, kNumPcs);
stack0.size = std::max((size_t)1, (size_t)(my_rand(&seed) % stack0.size));
size_t compress_size =
std::max((size_t)2, (size_t)my_rand(&seed) % (2 * kNumPcs));
size_t n_frames =
__asan::AsanStackTrace::CompressStack(&stack0, compressed, compress_size);
__asan::StackTrace::CompressStack(&stack0, compressed, compress_size);
Ident(n_frames);
assert(n_frames <= stack0.size);
__asan::AsanStackTrace::UncompressStack(&stack1, compressed, compress_size);
__asan::StackTrace::UncompressStack(&stack1, compressed, compress_size);
assert(stack1.size == n_frames);
for (size_t i = 0; i < stack1.size; i++) {
assert(stack0.trace[i] == stack1.trace[i]);
@ -237,17 +237,17 @@ TEST(AddressSanitizer, CompressStackTraceTest) {
}
void CompressStackTraceBenchmark(size_t n_iter) {
const size_t kNumPcs = ASAN_ARRAY_SIZE(pc_array);
const size_t kNumPcs = ARRAY_SIZE(pc_array);
u32 compressed[2 * kNumPcs];
std::random_shuffle(pc_array, pc_array + kNumPcs);
__asan::AsanStackTrace stack0;
__asan::StackTrace stack0;
stack0.CopyFrom(pc_array, kNumPcs);
stack0.size = kNumPcs;
for (size_t iter = 0; iter < n_iter; iter++) {
size_t compress_size = kNumPcs;
size_t n_frames =
__asan::AsanStackTrace::CompressStack(&stack0, compressed, compress_size);
__asan::StackTrace::CompressStack(&stack0, compressed, compress_size);
Ident(n_frames);
}
}
@ -257,7 +257,7 @@ TEST(AddressSanitizer, CompressStackTraceBenchmark) {
}
TEST(AddressSanitizer, QuarantineTest) {
__asan::AsanStackTrace stack;
__asan::StackTrace stack;
stack.trace[0] = 0x890;
stack.size = 1;
@ -279,7 +279,7 @@ TEST(AddressSanitizer, QuarantineTest) {
void *ThreadedQuarantineTestWorker(void *unused) {
(void)unused;
u32 seed = my_rand(&global_seed);
__asan::AsanStackTrace stack;
__asan::StackTrace stack;
stack.trace[0] = 0x890;
stack.size = 1;
@ -306,7 +306,7 @@ TEST(AddressSanitizer, ThreadedQuarantineTest) {
void *ThreadedOneSizeMallocStress(void *unused) {
(void)unused;
__asan::AsanStackTrace stack;
__asan::StackTrace stack;
stack.trace[0] = 0x890;
stack.size = 1;
const size_t kNumMallocs = 1000;