]> git.ipfire.org Git - thirdparty/gcc.git/blob - libsanitizer/sanitizer_common/sanitizer_stackdepot.h
Remove support for alternative Solaris 11.4 ld -V output
[thirdparty/gcc.git] / libsanitizer / sanitizer_common / sanitizer_stackdepot.h
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
12 #ifndef SANITIZER_STACKDEPOT_H
13 #define SANITIZER_STACKDEPOT_H
14
15 #include "sanitizer_common.h"
16 #include "sanitizer_internal_defs.h"
17 #include "sanitizer_stacktrace.h"
18
19 namespace __sanitizer {
20
21 // StackDepot efficiently stores huge amounts of stack traces.
22 struct StackDepotNode;
23 struct StackDepotHandle {
24 StackDepotNode *node_;
25 StackDepotHandle() : node_(nullptr) {}
26 explicit StackDepotHandle(StackDepotNode *node) : node_(node) {}
27 bool valid() { return node_; }
28 u32 id();
29 int use_count();
30 void inc_use_count_unsafe();
31 };
32
33 const int kStackDepotMaxUseCount = 1U << 20;
34
35 StackDepotStats *StackDepotGetStats();
36 u32 StackDepotPut(StackTrace stack);
37 StackDepotHandle StackDepotPut_WithHandle(StackTrace stack);
38 // Retrieves a stored stack trace by the id.
39 StackTrace StackDepotGet(u32 id);
40
41 void StackDepotLockAll();
42 void StackDepotUnlockAll();
43
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 StackTrace Get(u32 id);
52
53 private:
54 struct IdDescPair {
55 u32 id;
56 StackDepotNode *desc;
57
58 static bool IdComparator(const IdDescPair &a, const IdDescPair &b);
59 };
60
61 InternalMmapVector<IdDescPair> map_;
62
63 // Disallow evil constructors.
64 StackDepotReverseMap(const StackDepotReverseMap&);
65 void operator=(const StackDepotReverseMap&);
66 };
67
68 } // namespace __sanitizer
69
70 #endif // SANITIZER_STACKDEPOT_H