sanitizer_stackdepot.h revision c154820b43052cfc54ee20752a3232aa8e6c7843
1//===-- sanitizer_stackdepot.h ----------------------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file is shared between AddressSanitizer and ThreadSanitizer 11// run-time libraries. 12//===----------------------------------------------------------------------===// 13#ifndef SANITIZER_STACKDEPOT_H 14#define SANITIZER_STACKDEPOT_H 15 16#include "sanitizer_common.h" 17#include "sanitizer_internal_defs.h" 18 19namespace __sanitizer { 20 21// StackDepot efficiently stores huge amounts of stack traces. 22 23// Maps stack trace to an unique id. 24u32 StackDepotPut(const uptr *stack, uptr size); 25// Retrieves a stored stack trace by the id. 26const uptr *StackDepotGet(u32 id, uptr *size); 27 28struct StackDepotStats { 29 uptr n_uniq_ids; 30 uptr mapped; 31}; 32 33StackDepotStats *StackDepotGetStats(); 34 35struct StackDesc; 36 37// Instantiating this class creates a snapshot of StackDepot which can be 38// efficiently queried with StackDepotGet(). You can use it concurrently with 39// StackDepot, but the snapshot is only guaranteed to contain those stack traces 40// which were stored before it was instantiated. 41class StackDepotReverseMap { 42 public: 43 StackDepotReverseMap(); 44 const uptr *Get(u32 id, uptr *size); 45 46 private: 47 struct IdDescPair { 48 u32 id; 49 StackDesc *desc; 50 51 static bool IdComparator(const IdDescPair &a, const IdDescPair &b); 52 }; 53 54 InternalMmapVector<IdDescPair> map_; 55 56 // Disallow evil constructors. 57 StackDepotReverseMap(const StackDepotReverseMap&); 58 void operator=(const StackDepotReverseMap&); 59}; 60} // namespace __sanitizer 61 62#endif // SANITIZER_STACKDEPOT_H 63