llvm/compiler-rt/lib/hwasan/hwasan_report.cpp

//===-- hwasan_report.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file is a part of HWAddressSanitizer.
//
// Error reporting.
//===----------------------------------------------------------------------===//

#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 *);

// If there is an active ScopedReport, append to its error message.
void AppendToErrorMessageBuffer(const char *buffer) {}

static StackTrace GetStackTraceFromId(u32 id) {}

static void MaybePrintAndroidHelpUrl() {}

namespace {
// A RAII object that holds a copy of the current thread stack ring buffer.
// The actual stack buffer may change while we are iterating over it (for
// example, Printf may call syslog() which can itself be built with hwasan).
class SavedStackAllocations {};

class Decorator: public __sanitizer::SanitizerCommonDecorator {};
}  // namespace

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) {}

// Returns true if tag == *tag_ptr, reading tags from short granules if
// necessary. This may return a false positive if tags 1-15 are used as a
// regular tag rather than a short granule marker.
static bool TagsEqual(tag_t tag, tag_t *tag_ptr) {}

// HWASan globals store the size of the global in the descriptor. In cases where
// we don't have a binary with symbols, we can't grab the size of the global
// from the debug info - but we might be able to retrieve it from the
// descriptor. Returns zero if the lookup failed.
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() {}
}  // namespace

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) {}

// See the frame breakdown defined in __hwasan_tag_mismatch (from
// hwasan_tag_mismatch_{aarch64,riscv64}.S).
void ReportRegisters(const uptr *frame, uptr pc) {}

}  // namespace __hwasan

void __hwasan_set_error_report_callback(void (*callback)(const char *)) {}