1//===-- sanitizer_chained_origin_depot.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// A storage for chained origins. 10//===----------------------------------------------------------------------===// 11 12#ifndef SANITIZER_CHAINED_ORIGIN_DEPOT_H 13#define SANITIZER_CHAINED_ORIGIN_DEPOT_H 14 15#include "sanitizer_common.h" 16 17namespace __sanitizer { 18 19class ChainedOriginDepot { 20 public: 21 ChainedOriginDepot(); 22 23 // Gets the statistic of the origin chain storage. 24 StackDepotStats GetStats() const; 25 26 // Stores a chain with StackDepot ID here_id and previous chain ID prev_id. 27 // If successful, returns true and the new chain id new_id. 28 // If the same element already exists, returns false and sets new_id to the 29 // existing ID. 30 bool Put(u32 here_id, u32 prev_id, u32 *new_id); 31 32 // Retrieves the stored StackDepot ID for the given origin ID. 33 u32 Get(u32 id, u32 *other); 34 35 void LockBeforeFork(); 36 void UnlockAfterFork(bool fork_child); 37 void TestOnlyUnmap(); 38 39 private: 40 ChainedOriginDepot(const ChainedOriginDepot &) = delete; 41 void operator=(const ChainedOriginDepot &) = delete; 42}; 43 44} // namespace __sanitizer 45 46#endif // SANITIZER_CHAINED_ORIGIN_DEPOT_H 47