2012-08-30 18:02:48 +08:00
|
|
|
//===-- sanitizer_stackdepot.h ----------------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2012-08-30 18:02:48 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file is shared between AddressSanitizer and ThreadSanitizer
|
|
|
|
// run-time libraries.
|
|
|
|
//===----------------------------------------------------------------------===//
|
2015-09-30 02:23:36 +08:00
|
|
|
|
2012-08-30 18:02:48 +08:00
|
|
|
#ifndef SANITIZER_STACKDEPOT_H
|
|
|
|
#define SANITIZER_STACKDEPOT_H
|
|
|
|
|
2013-08-26 21:24:43 +08:00
|
|
|
#include "sanitizer_common.h"
|
2013-01-30 21:12:08 +08:00
|
|
|
#include "sanitizer_internal_defs.h"
|
2014-10-26 11:35:14 +08:00
|
|
|
#include "sanitizer_stacktrace.h"
|
2012-08-30 18:02:48 +08:00
|
|
|
|
|
|
|
namespace __sanitizer {
|
|
|
|
|
|
|
|
// StackDepot efficiently stores huge amounts of stack traces.
|
2014-05-21 17:02:13 +08:00
|
|
|
struct StackDepotNode;
|
|
|
|
struct StackDepotHandle {
|
2021-10-12 10:44:09 +08:00
|
|
|
StackDepotNode *node_ = nullptr;
|
|
|
|
u32 id_ = 0;
|
|
|
|
StackDepotHandle(StackDepotNode *node, u32 id) : node_(node), id_(id) {}
|
2021-10-12 09:37:25 +08:00
|
|
|
bool valid() const { return node_; }
|
2021-10-12 10:44:09 +08:00
|
|
|
u32 id() const { return id_; }
|
2021-10-12 09:37:25 +08:00
|
|
|
int use_count() const;
|
2014-05-21 17:02:13 +08:00
|
|
|
void inc_use_count_unsafe();
|
|
|
|
};
|
|
|
|
|
2019-01-05 06:55:04 +08:00
|
|
|
const int kStackDepotMaxUseCount = 1U << (SANITIZER_ANDROID ? 16 : 20);
|
2012-08-30 18:02:48 +08:00
|
|
|
|
2021-09-29 02:20:18 +08:00
|
|
|
StackDepotStats StackDepotGetStats();
|
2014-10-26 14:23:07 +08:00
|
|
|
u32 StackDepotPut(StackTrace stack);
|
|
|
|
StackDepotHandle StackDepotPut_WithHandle(StackTrace stack);
|
2012-08-30 18:02:48 +08:00
|
|
|
// Retrieves a stored stack trace by the id.
|
2014-10-26 11:35:14 +08:00
|
|
|
StackTrace StackDepotGet(u32 id);
|
2012-08-30 18:02:48 +08:00
|
|
|
|
2014-09-04 18:36:14 +08:00
|
|
|
void StackDepotLockAll();
|
|
|
|
void StackDepotUnlockAll();
|
2020-09-17 04:47:16 +08:00
|
|
|
void StackDepotPrintAll();
|
2014-09-04 18:36:14 +08:00
|
|
|
|
2021-10-17 04:31:59 +08:00
|
|
|
void StackDepotTestOnlyUnmap();
|
|
|
|
|
2015-09-30 02:23:36 +08:00
|
|
|
} // namespace __sanitizer
|
2012-08-30 18:02:48 +08:00
|
|
|
|
2015-09-30 02:23:36 +08:00
|
|
|
#endif // SANITIZER_STACKDEPOT_H
|