annotate libsanitizer/sanitizer_common/sanitizer_stackdepot.h @ 118:fd00160c1b76

ifdef TARGET_64BIT
author mir3636
date Tue, 27 Feb 2018 15:01:35 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 //===-- sanitizer_stackdepot.h ----------------------------------*- C++ -*-===//
kono
parents:
diff changeset
2 //
kono
parents:
diff changeset
3 // This file is distributed under the University of Illinois Open Source
kono
parents:
diff changeset
4 // License. See LICENSE.TXT for details.
kono
parents:
diff changeset
5 //
kono
parents:
diff changeset
6 //===----------------------------------------------------------------------===//
kono
parents:
diff changeset
7 //
kono
parents:
diff changeset
8 // This file is shared between AddressSanitizer and ThreadSanitizer
kono
parents:
diff changeset
9 // run-time libraries.
kono
parents:
diff changeset
10 //===----------------------------------------------------------------------===//
kono
parents:
diff changeset
11
kono
parents:
diff changeset
12 #ifndef SANITIZER_STACKDEPOT_H
kono
parents:
diff changeset
13 #define SANITIZER_STACKDEPOT_H
kono
parents:
diff changeset
14
kono
parents:
diff changeset
15 #include "sanitizer_common.h"
kono
parents:
diff changeset
16 #include "sanitizer_internal_defs.h"
kono
parents:
diff changeset
17 #include "sanitizer_stacktrace.h"
kono
parents:
diff changeset
18
kono
parents:
diff changeset
19 namespace __sanitizer {
kono
parents:
diff changeset
20
kono
parents:
diff changeset
21 // StackDepot efficiently stores huge amounts of stack traces.
kono
parents:
diff changeset
22 struct StackDepotNode;
kono
parents:
diff changeset
23 struct StackDepotHandle {
kono
parents:
diff changeset
24 StackDepotNode *node_;
kono
parents:
diff changeset
25 StackDepotHandle() : node_(nullptr) {}
kono
parents:
diff changeset
26 explicit StackDepotHandle(StackDepotNode *node) : node_(node) {}
kono
parents:
diff changeset
27 bool valid() { return node_; }
kono
parents:
diff changeset
28 u32 id();
kono
parents:
diff changeset
29 int use_count();
kono
parents:
diff changeset
30 void inc_use_count_unsafe();
kono
parents:
diff changeset
31 };
kono
parents:
diff changeset
32
kono
parents:
diff changeset
33 const int kStackDepotMaxUseCount = 1U << 20;
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 StackDepotStats *StackDepotGetStats();
kono
parents:
diff changeset
36 u32 StackDepotPut(StackTrace stack);
kono
parents:
diff changeset
37 StackDepotHandle StackDepotPut_WithHandle(StackTrace stack);
kono
parents:
diff changeset
38 // Retrieves a stored stack trace by the id.
kono
parents:
diff changeset
39 StackTrace StackDepotGet(u32 id);
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 void StackDepotLockAll();
kono
parents:
diff changeset
42 void StackDepotUnlockAll();
kono
parents:
diff changeset
43
kono
parents:
diff changeset
44 // Instantiating this class creates a snapshot of StackDepot which can be
kono
parents:
diff changeset
45 // efficiently queried with StackDepotGet(). You can use it concurrently with
kono
parents:
diff changeset
46 // StackDepot, but the snapshot is only guaranteed to contain those stack traces
kono
parents:
diff changeset
47 // which were stored before it was instantiated.
kono
parents:
diff changeset
48 class StackDepotReverseMap {
kono
parents:
diff changeset
49 public:
kono
parents:
diff changeset
50 StackDepotReverseMap();
kono
parents:
diff changeset
51 StackTrace Get(u32 id);
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 private:
kono
parents:
diff changeset
54 struct IdDescPair {
kono
parents:
diff changeset
55 u32 id;
kono
parents:
diff changeset
56 StackDepotNode *desc;
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 static bool IdComparator(const IdDescPair &a, const IdDescPair &b);
kono
parents:
diff changeset
59 };
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 InternalMmapVector<IdDescPair> map_;
kono
parents:
diff changeset
62
kono
parents:
diff changeset
63 // Disallow evil constructors.
kono
parents:
diff changeset
64 StackDepotReverseMap(const StackDepotReverseMap&);
kono
parents:
diff changeset
65 void operator=(const StackDepotReverseMap&);
kono
parents:
diff changeset
66 };
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 } // namespace __sanitizer
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 #endif // SANITIZER_STACKDEPOT_H