sanitizer_stackdepot.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. #ifndef SANITIZER_STACKDEPOT_H
  13. #define SANITIZER_STACKDEPOT_H
  14. #include "sanitizer_common.h"
  15. #include "sanitizer_internal_defs.h"
  16. #include "sanitizer_stacktrace.h"
  17. namespace __sanitizer {
  18. // StackDepot efficiently stores huge amounts of stack traces.
  19. struct StackDepotNode;
  20. struct StackDepotHandle {
  21. StackDepotNode *node_ = nullptr;
  22. u32 id_ = 0;
  23. StackDepotHandle(StackDepotNode *node, u32 id) : node_(node), id_(id) {}
  24. bool valid() const { return node_; }
  25. u32 id() const { return id_; }
  26. int use_count() const;
  27. void inc_use_count_unsafe();
  28. };
  29. const int kStackDepotMaxUseCount = 1U << (SANITIZER_ANDROID ? 16 : 20);
  30. StackDepotStats StackDepotGetStats();
  31. u32 StackDepotPut(StackTrace stack);
  32. StackDepotHandle StackDepotPut_WithHandle(StackTrace stack);
  33. // Retrieves a stored stack trace by the id.
  34. StackTrace StackDepotGet(u32 id);
  35. void StackDepotLockAll();
  36. void StackDepotUnlockAll();
  37. void StackDepotPrintAll();
  38. void StackDepotTestOnlyUnmap();
  39. } // namespace __sanitizer
  40. #endif // SANITIZER_STACKDEPOT_H