Daily bump.
[official-gcc.git] / libsanitizer / sanitizer_common / sanitizer_stackdepot.h
blobaad9bfb8d358f5b1f8ce8b1924b5e2875d953823
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"
16 #include "sanitizer_stacktrace.h"
18 namespace __sanitizer {
20 // StackDepot efficiently stores huge amounts of stack traces.
21 struct StackDepotNode;
22 struct StackDepotHandle {
23 StackDepotNode *node_;
24 StackDepotHandle() : node_(0) {}
25 explicit StackDepotHandle(StackDepotNode *node) : node_(node) {}
26 bool valid() { return node_; }
27 u32 id();
28 int use_count();
29 void inc_use_count_unsafe();
32 const int kStackDepotMaxUseCount = 1U << 20;
34 StackDepotStats *StackDepotGetStats();
35 u32 StackDepotPut(StackTrace stack);
36 StackDepotHandle StackDepotPut_WithHandle(StackTrace stack);
37 // Retrieves a stored stack trace by the id.
38 StackTrace StackDepotGet(u32 id);
40 void StackDepotLockAll();
41 void StackDepotUnlockAll();
43 // Instantiating this class creates a snapshot of StackDepot which can be
44 // efficiently queried with StackDepotGet(). You can use it concurrently with
45 // StackDepot, but the snapshot is only guaranteed to contain those stack traces
46 // which were stored before it was instantiated.
47 class StackDepotReverseMap {
48 public:
49 StackDepotReverseMap();
50 StackTrace Get(u32 id);
52 private:
53 struct IdDescPair {
54 u32 id;
55 StackDepotNode *desc;
57 static bool IdComparator(const IdDescPair &a, const IdDescPair &b);
60 InternalMmapVector<IdDescPair> map_;
62 // Disallow evil constructors.
63 StackDepotReverseMap(const StackDepotReverseMap&);
64 void operator=(const StackDepotReverseMap&);
67 } // namespace __sanitizer
69 #endif // SANITIZER_STACKDEPOT_H