Properly regenerate gcc/configure.
[official-gcc.git] / libsanitizer / sanitizer_common / sanitizer_stackdepot.h
blob2b1da4ee14f8a8d48e77ad002a00c3f62305a6ac
1 //===-- sanitizer_stackdepot.h ----------------------------------*- C++ -*-===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // This file is shared between AddressSanitizer and ThreadSanitizer
9 // run-time libraries.
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.
20 struct StackDepotNode;
21 struct StackDepotHandle {
22 StackDepotNode *node_;
23 StackDepotHandle() : node_(0) {}
24 explicit StackDepotHandle(StackDepotNode *node) : node_(node) {}
25 bool valid() { return node_; }
26 u32 id();
27 int use_count();
28 void inc_use_count_unsafe();
29 uptr size();
30 uptr *stack();
33 const int kStackDepotMaxUseCount = 1U << 20;
35 StackDepotStats *StackDepotGetStats();
36 u32 StackDepotPut(const uptr *stack, uptr size);
37 StackDepotHandle StackDepotPut_WithHandle(const uptr *stack, uptr size);
38 // Retrieves a stored stack trace by the id.
39 const uptr *StackDepotGet(u32 id, uptr *size);
41 void StackDepotLockAll();
42 void StackDepotUnlockAll();
44 // Instantiating this class creates a snapshot of StackDepot which can be
45 // efficiently queried with StackDepotGet(). You can use it concurrently with
46 // StackDepot, but the snapshot is only guaranteed to contain those stack traces
47 // which were stored before it was instantiated.
48 class StackDepotReverseMap {
49 public:
50 StackDepotReverseMap();
51 const uptr *Get(u32 id, uptr *size);
53 private:
54 struct IdDescPair {
55 u32 id;
56 StackDepotNode *desc;
58 static bool IdComparator(const IdDescPair &a, const IdDescPair &b);
61 InternalMmapVector<IdDescPair> map_;
63 // Disallow evil constructors.
64 StackDepotReverseMap(const StackDepotReverseMap&);
65 void operator=(const StackDepotReverseMap&);
68 } // namespace __sanitizer
70 #endif // SANITIZER_STACKDEPOT_H