1 //===-- sanitizer_stackdepot.h ----------------------------------*- C++ -*-===//
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
6 //===----------------------------------------------------------------------===//
8 // This file is shared between AddressSanitizer and ThreadSanitizer
10 //===----------------------------------------------------------------------===//
11 #ifndef SANITIZER_STACKDEPOT_H
12 #define SANITIZER_STACKDEPOT_H
14 #include "sanitizer_common.h"
15 #include "sanitizer_internal_defs.h"
17 namespace __sanitizer
{
19 // StackDepot efficiently stores huge amounts of stack traces.
21 // Maps stack trace to an unique id.
22 u32
StackDepotPut(const uptr
*stack
, uptr size
);
23 // Retrieves a stored stack trace by the id.
24 const uptr
*StackDepotGet(u32 id
, uptr
*size
);
26 struct StackDepotStats
{
31 StackDepotStats
*StackDepotGetStats();
35 // Instantiating this class creates a snapshot of StackDepot which can be
36 // efficiently queried with StackDepotGet(). You can use it concurrently with
37 // StackDepot, but the snapshot is only guaranteed to contain those stack traces
38 // which were stored before it was instantiated.
39 class StackDepotReverseMap
{
41 StackDepotReverseMap();
42 const uptr
*Get(u32 id
, uptr
*size
);
49 static bool IdComparator(const IdDescPair
&a
, const IdDescPair
&b
);
52 InternalMmapVector
<IdDescPair
> map_
;
54 // Disallow evil constructors.
55 StackDepotReverseMap(const StackDepotReverseMap
&);
56 void operator=(const StackDepotReverseMap
&);
58 } // namespace __sanitizer
60 #endif // SANITIZER_STACKDEPOT_H