2012-11-12 16:53:47 +01:00
|
|
|
//===-- asan_stats.h --------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// 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 {
|
|
|
|
// 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;
|
2013-01-10 13:44:08 +01:00
|
|
|
uptr munmaps;
|
|
|
|
uptr munmaped;
|
2012-11-12 16:53:47 +01:00
|
|
|
uptr malloc_large;
|
2015-10-21 09:32:45 +02:00
|
|
|
uptr malloced_by_size[kNumberOfSizeClasses];
|
2012-11-12 16:53:47 +01:00
|
|
|
|
2013-12-05 10:18:38 +01:00
|
|
|
// Ctor for global AsanStats (accumulated stats for dead threads).
|
2012-11-12 16:53:47 +01:00
|
|
|
explicit AsanStats(LinkerInitialized) { }
|
2013-12-05 10:18:38 +01:00
|
|
|
// Creates empty stats.
|
2012-11-12 16:53:47 +01:00
|
|
|
AsanStats();
|
|
|
|
|
2013-11-04 22:33:31 +01:00
|
|
|
void Print(); // Prints formatted stats to stderr.
|
|
|
|
void Clear();
|
|
|
|
void MergeFrom(const AsanStats *stats);
|
2012-11-12 16:53:47 +01:00
|
|
|
};
|
|
|
|
|
2013-11-04 22:33:31 +01:00
|
|
|
// Returns stats for GetCurrentThread(), or stats for fake "unknown thread"
|
|
|
|
// if GetCurrentThread() returns 0.
|
|
|
|
AsanStats &GetCurrentThreadStats();
|
|
|
|
// Flushes a given stats into accumulated stats of dead threads.
|
|
|
|
void FlushToDeadThreadStats(AsanStats *stats);
|
|
|
|
|
2012-11-12 16:53:47 +01: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-11-04 22:33:31 +01:00
|
|
|
void FillMallocStatistics(AsanMallocStats *malloc_stats);
|
|
|
|
|
2012-11-12 16:53:47 +01:00
|
|
|
} // namespace __asan
|
|
|
|
|
|
|
|
#endif // ASAN_STATS_H
|