2011-11-30 09:07:02 +08:00
|
|
|
//===-- asan_stats.h --------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file is a part of AddressSanitizer, an address sanity checker.
|
|
|
|
//
|
|
|
|
// ASan-private header for statistics.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef ASAN_STATS_H
|
|
|
|
#define ASAN_STATS_H
|
|
|
|
|
|
|
|
#include "asan_allocator.h"
|
|
|
|
#include "asan_internal.h"
|
|
|
|
|
|
|
|
namespace __asan {
|
|
|
|
|
|
|
|
// AsanStats struct is NOT thread-safe.
|
|
|
|
// Each AsanThread has its own AsanStats, which are sometimes flushed
|
|
|
|
// to the accumulated AsanStats.
|
|
|
|
struct AsanStats {
|
2012-05-31 22:35:53 +08:00
|
|
|
// AsanStats must be a struct consisting of uptr fields only.
|
|
|
|
// When merging two AsanStats structs, we treat them as arrays of uptr.
|
|
|
|
uptr mallocs;
|
|
|
|
uptr malloced;
|
|
|
|
uptr malloced_redzones;
|
|
|
|
uptr frees;
|
|
|
|
uptr freed;
|
|
|
|
uptr real_frees;
|
|
|
|
uptr really_freed;
|
|
|
|
uptr reallocs;
|
|
|
|
uptr realloced;
|
|
|
|
uptr mmaps;
|
|
|
|
uptr mmaped;
|
2012-12-19 22:56:38 +08:00
|
|
|
uptr munmaps;
|
|
|
|
uptr munmaped;
|
2012-05-31 22:35:53 +08:00
|
|
|
uptr malloc_large;
|
2015-06-27 03:18:02 +08:00
|
|
|
uptr malloced_by_size[kNumberOfSizeClasses];
|
2011-11-30 09:07:02 +08:00
|
|
|
|
2013-11-27 21:22:21 +08:00
|
|
|
// Ctor for global AsanStats (accumulated stats for dead threads).
|
2011-11-30 09:07:02 +08:00
|
|
|
explicit AsanStats(LinkerInitialized) { }
|
2013-11-27 21:22:21 +08:00
|
|
|
// Creates empty stats.
|
2011-11-30 09:07:02 +08:00
|
|
|
AsanStats();
|
|
|
|
|
2013-09-02 16:39:07 +08:00
|
|
|
void Print(); // Prints formatted stats to stderr.
|
|
|
|
void Clear();
|
|
|
|
void MergeFrom(const AsanStats *stats);
|
2011-11-30 09:07:02 +08:00
|
|
|
};
|
|
|
|
|
2013-03-20 18:11:24 +08:00
|
|
|
// Returns stats for GetCurrentThread(), or stats for fake "unknown thread"
|
|
|
|
// if GetCurrentThread() returns 0.
|
|
|
|
AsanStats &GetCurrentThreadStats();
|
2013-09-02 16:39:07 +08:00
|
|
|
// Flushes a given stats into accumulated stats of dead threads.
|
|
|
|
void FlushToDeadThreadStats(AsanStats *stats);
|
2013-03-20 18:11:24 +08:00
|
|
|
|
2012-09-12 23:29:50 +08:00
|
|
|
// A cross-platform equivalent of malloc_statistics_t on Mac OS.
|
|
|
|
struct AsanMallocStats {
|
|
|
|
uptr blocks_in_use;
|
|
|
|
uptr size_in_use;
|
|
|
|
uptr max_size_in_use;
|
|
|
|
uptr size_allocated;
|
|
|
|
};
|
|
|
|
|
2013-03-20 18:11:24 +08:00
|
|
|
void FillMallocStatistics(AsanMallocStats *malloc_stats);
|
|
|
|
|
2011-11-30 09:07:02 +08:00
|
|
|
} // namespace __asan
|
|
|
|
|
|
|
|
#endif // ASAN_STATS_H
|