1//===-- sanitizer_stackdepot.h ----------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file is shared between AddressSanitizer and ThreadSanitizer
10// run-time libraries.
11//===----------------------------------------------------------------------===//
12
13#ifndef SANITIZER_STACKDEPOT_H
14#define SANITIZER_STACKDEPOT_H
15
16#include "sanitizer_common.h"
17#include "sanitizer_internal_defs.h"
18#include "sanitizer_stacktrace.h"
19
20namespace __sanitizer {
21
22// StackDepot efficiently stores huge amounts of stack traces.
23struct StackDepotNode;
24struct StackDepotHandle {
25 StackDepotNode *node_ = nullptr;
26 u32 id_ = 0;
27 StackDepotHandle(StackDepotNode *node, u32 id) : node_(node), id_(id) {}
28 bool valid() const { return node_; }
29 u32 id() const { return id_; }
30 int use_count() const;
31 void inc_use_count_unsafe();
32};
33
34const int kStackDepotMaxUseCount = 1U << (SANITIZER_ANDROID ? 16 : 20);
35
36StackDepotStats StackDepotGetStats();
37u32 StackDepotPut(StackTrace stack);
38StackDepotHandle StackDepotPut_WithHandle(StackTrace stack);
39// Retrieves a stored stack trace by the id.
40StackTrace StackDepotGet(u32 id);
41
42void StackDepotLockBeforeFork();
43void StackDepotUnlockAfterFork(bool fork_child);
44void StackDepotPrintAll();
45void StackDepotStopBackgroundThread();
46
47void StackDepotTestOnlyUnmap();
48
49} // namespace __sanitizer
50
51#endif // SANITIZER_STACKDEPOT_H
52

source code of compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.h