Path: blob/main/contrib/llvm-project/compiler-rt/lib/memprof/memprof_stats.h
35236 views
//===-- memprof_stats.h ----------------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file is a part of MemProfiler, a memory profiler.9//10// MemProf-private header for statistics.11//===----------------------------------------------------------------------===//12#ifndef MEMPROF_STATS_H13#define MEMPROF_STATS_H1415#include "memprof_allocator.h"16#include "memprof_internal.h"1718namespace __memprof {1920// MemprofStats struct is NOT thread-safe.21// Each MemprofThread has its own MemprofStats, which are sometimes flushed22// to the accumulated MemprofStats.23struct MemprofStats {24// MemprofStats must be a struct consisting of uptr fields only.25// When merging two MemprofStats structs, we treat them as arrays of uptr.26uptr mallocs;27uptr malloced;28uptr malloced_overhead;29uptr frees;30uptr freed;31uptr real_frees;32uptr really_freed;33uptr reallocs;34uptr realloced;35uptr mmaps;36uptr mmaped;37uptr munmaps;38uptr munmaped;39uptr malloc_large;40uptr malloced_by_size[kNumberOfSizeClasses];4142// Ctor for global MemprofStats (accumulated stats for dead threads).43explicit MemprofStats(LinkerInitialized) {}44// Creates empty stats.45MemprofStats();4647void Print(); // Prints formatted stats to stderr.48void Clear();49void MergeFrom(const MemprofStats *stats);50};5152// Returns stats for GetCurrentThread(), or stats for fake "unknown thread"53// if GetCurrentThread() returns 0.54MemprofStats &GetCurrentThreadStats();55// Flushes a given stats into accumulated stats of dead threads.56void FlushToDeadThreadStats(MemprofStats *stats);5758} // namespace __memprof5960#endif // MEMPROF_STATS_H616263