#include "hwasan_report.h"
#include <dlfcn.h>
#include "hwasan.h"
#include "hwasan_allocator.h"
#include "hwasan_globals.h"
#include "hwasan_mapping.h"
#include "hwasan_thread.h"
#include "hwasan_thread_list.h"
#include "sanitizer_common/sanitizer_allocator_internal.h"
#include "sanitizer_common/sanitizer_array_ref.h"
#include "sanitizer_common/sanitizer_common.h"
#include "sanitizer_common/sanitizer_flags.h"
#include "sanitizer_common/sanitizer_internal_defs.h"
#include "sanitizer_common/sanitizer_mutex.h"
#include "sanitizer_common/sanitizer_placement_new.h"
#include "sanitizer_common/sanitizer_report_decorator.h"
#include "sanitizer_common/sanitizer_stackdepot.h"
#include "sanitizer_common/sanitizer_stacktrace_printer.h"
#include "sanitizer_common/sanitizer_symbolizer.h"
usingnamespace__sanitizer;
namespace __hwasan {
class ScopedReport { … };
Mutex ScopedReport::error_message_lock_;
InternalScopedString *ScopedReport::error_message_ptr_;
void (*ScopedReport::error_report_callback_)(const char *);
void AppendToErrorMessageBuffer(const char *buffer) { … }
static StackTrace GetStackTraceFromId(u32 id) { … }
static void MaybePrintAndroidHelpUrl() { … }
namespace {
class SavedStackAllocations { … };
class Decorator: public __sanitizer::SanitizerCommonDecorator { … };
}
static bool FindHeapAllocation(HeapAllocationsRingBuffer *rb, uptr tagged_addr,
HeapAllocationRecord *har, uptr *ring_index,
uptr *num_matching_addrs,
uptr *num_matching_addrs_4b) { … }
static void PrintStackAllocations(const StackAllocationsRingBuffer *sa,
tag_t addr_tag, uptr untagged_addr) { … }
static bool TagsEqual(tag_t tag, tag_t *tag_ptr) { … }
static uptr GetGlobalSizeFromDescriptor(uptr ptr) { … }
void ReportStats() { … }
constexpr uptr kDumpWidth = …;
constexpr uptr kShadowLines = …;
constexpr uptr kShadowDumpSize = …;
constexpr uptr kShortLines = …;
constexpr uptr kShortDumpSize = …;
constexpr uptr kShortDumpOffset = …;
static uptr GetPrintTagStart(uptr addr) { … }
template <typename PrintTag>
static void PrintTagInfoAroundAddr(uptr addr, uptr num_rows,
InternalScopedString &s,
PrintTag print_tag) { … }
template <typename GetTag, typename GetShortTag>
static void PrintTagsAroundAddr(uptr addr, GetTag get_tag,
GetShortTag get_short_tag) { … }
static uptr GetTopPc(const StackTrace *stack) { … }
namespace {
class BaseReport { … };
sptr BaseReport::FindMismatchOffset() const { … }
BaseReport::Shadow BaseReport::CopyShadow() const { … }
tag_t BaseReport::GetTagCopy(uptr addr) const { … }
tag_t BaseReport::GetShortTagCopy(uptr addr) const { … }
BaseReport::HeapChunk BaseReport::CopyHeapChunk() const { … }
BaseReport::Allocations BaseReport::CopyAllocations() { … }
BaseReport::OverflowCandidate BaseReport::FindBufferOverflowCandidate() const { … }
void BaseReport::PrintHeapOrGlobalCandidate() const { … }
void BaseReport::PrintAddressDescription() const { … }
void BaseReport::PrintTags(uptr addr) const { … }
class InvalidFreeReport : public BaseReport { … };
InvalidFreeReport::~InvalidFreeReport() { … }
class TailOverwrittenReport : public BaseReport { … };
TailOverwrittenReport::~TailOverwrittenReport() { … }
class TagMismatchReport : public BaseReport { … };
TagMismatchReport::~TagMismatchReport() { … }
}
void ReportInvalidFree(StackTrace *stack, uptr tagged_addr) { … }
void ReportTailOverwritten(StackTrace *stack, uptr tagged_addr, uptr orig_size,
const u8 *expected) { … }
void ReportTagMismatch(StackTrace *stack, uptr tagged_addr, uptr access_size,
bool is_store, bool fatal, uptr *registers_frame) { … }
void ReportRegisters(const uptr *frame, uptr pc) { … }
}
void __hwasan_set_error_report_callback(void (*callback)(const char *)) { … }