namespace __hwasan {
-void EnterSymbolizer() {
- Thread *t = GetCurrentThread();
- CHECK(t);
- t->EnterSymbolizer();
-}
-void ExitSymbolizer() {
- Thread *t = GetCurrentThread();
- CHECK(t);
- t->LeaveSymbolizer();
-}
-bool IsInSymbolizer() {
- Thread *t = GetCurrentThread();
- return t && t->InSymbolizer();
-}
-
static Flags hwasan_flags;
Flags *flags() {
size = 0;
return;
}
- if (!StackTrace::WillUseFastUnwind(request_fast)) {
- // Block reports from our interceptors during _Unwind_Backtrace.
- SymbolizerScope sym_scope;
- return Unwind(max_depth, pc, bp, context, 0, 0, request_fast);
- }
- if (StackTrace::WillUseFastUnwind(request_fast))
- Unwind(max_depth, pc, bp, nullptr, t->stack_top(), t->stack_bottom(), true);
- else
- Unwind(max_depth, pc, 0, context, 0, 0, false);
+ Unwind(max_depth, pc, bp, context, t->stack_top(), t->stack_bottom(),
+ request_fast);
}
struct hwasan_global {
InstallDeadlySignalHandlers(HwasanOnDeadlySignal);
InstallAtExitHandler(); // Needs __cxa_atexit interceptor.
- Symbolizer::GetOrInit()->AddHooks(EnterSymbolizer, ExitSymbolizer);
-
InitializeCoverage(common_flags()->coverage, common_flags()->coverage_dir);
HwasanTSDInit();
extern bool hwasan_init_is_running;
extern int hwasan_report_count;
-bool ProtectRange(uptr beg, uptr end);
bool InitShadow();
void InitPrctl();
void InitThreads();
void MadviseShadow();
-char *GetProcSelfMaps();
void InitializeInterceptors();
void HwasanAllocatorInit();
-void HwasanAllocatorThreadFinish();
void *hwasan_malloc(uptr size, StackTrace *stack);
void *hwasan_calloc(uptr nmemb, uptr size, StackTrace *stack);
StackTrace *stack);
void hwasan_free(void *ptr, StackTrace *stack);
-void InstallTrapHandler();
void InstallAtExitHandler();
-void EnterSymbolizer();
-void ExitSymbolizer();
-bool IsInSymbolizer();
-
-struct SymbolizerScope {
- SymbolizerScope() { EnterSymbolizer(); }
- ~SymbolizerScope() { ExitSymbolizer(); }
-};
-
-// Returns a "chained" origin id, pointing to the given stack trace followed by
-// the previous origin id.
-u32 ChainOrigin(u32 id, StackTrace *stack);
-
-const int STACK_TRACE_TAG_POISON = StackTrace::TAG_CUSTOM + 1;
-
#define GET_MALLOC_STACK_TRACE \
BufferedStackTrace stack; \
if (hwasan_inited) \
stack.Print(); \
}
-class ScopedThreadLocalStateBackup {
- public:
- ScopedThreadLocalStateBackup() { Backup(); }
- ~ScopedThreadLocalStateBackup() { Restore(); }
- void Backup();
- void Restore();
- private:
- u64 va_arg_overflow_size_tls;
-};
-
void HwasanTSDInit();
void HwasanTSDThreadInit();
return addr >= stack_bottom_ && addr < stack_top_;
}
- bool InSignalHandler() { return in_signal_handler_; }
- void EnterSignalHandler() { in_signal_handler_++; }
- void LeaveSignalHandler() { in_signal_handler_--; }
-
- bool InSymbolizer() { return in_symbolizer_; }
- void EnterSymbolizer() { in_symbolizer_++; }
- void LeaveSymbolizer() { in_symbolizer_--; }
-
AllocatorCache *allocator_cache() { return &allocator_cache_; }
HeapAllocationsRingBuffer *heap_allocations() { return heap_allocations_; }
StackAllocationsRingBuffer *stack_allocations() { return stack_allocations_; }
void DisableTagging() { tagging_disabled_++; }
void EnableTagging() { tagging_disabled_--; }
- bool TaggingIsDisabled() const { return tagging_disabled_; }
u64 unique_id() const { return unique_id_; }
void Announce() {
uptr tls_begin_;
uptr tls_end_;
- unsigned in_signal_handler_;
- unsigned in_symbolizer_;
-
u32 random_state_;
u32 random_buffer_;
HeapAllocationsRingBuffer *heap_allocations_;
StackAllocationsRingBuffer *stack_allocations_;
- static void InsertIntoThreadList(Thread *t);
- static void RemoveFromThreadList(Thread *t);
Thread *next_; // All live threads form a linked list.
u64 unique_id_; // counting from zero.