Retro68/gcc/libsanitizer/sanitizer_common/sanitizer_stackdepot.h

70 lines
2.0 KiB
C
Raw Normal View History

2014-09-21 17:33:12 +00:00
//===-- sanitizer_stackdepot.h ----------------------------------*- C++ -*-===//
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file is shared between AddressSanitizer and ThreadSanitizer
// run-time libraries.
//===----------------------------------------------------------------------===//
#ifndef SANITIZER_STACKDEPOT_H
#define SANITIZER_STACKDEPOT_H
#include "sanitizer_common.h"
#include "sanitizer_internal_defs.h"
2015-08-28 15:33:40 +00:00
#include "sanitizer_stacktrace.h"
2014-09-21 17:33:12 +00:00
namespace __sanitizer {
// StackDepot efficiently stores huge amounts of stack traces.
2015-08-28 15:33:40 +00:00
struct StackDepotNode;
struct StackDepotHandle {
StackDepotNode *node_;
StackDepotHandle() : node_(0) {}
explicit StackDepotHandle(StackDepotNode *node) : node_(node) {}
bool valid() { return node_; }
u32 id();
int use_count();
void inc_use_count_unsafe();
2014-09-21 17:33:12 +00:00
};
2015-08-28 15:33:40 +00:00
const int kStackDepotMaxUseCount = 1U << 20;
2014-09-21 17:33:12 +00:00
StackDepotStats *StackDepotGetStats();
2015-08-28 15:33:40 +00:00
u32 StackDepotPut(StackTrace stack);
StackDepotHandle StackDepotPut_WithHandle(StackTrace stack);
// Retrieves a stored stack trace by the id.
StackTrace StackDepotGet(u32 id);
2014-09-21 17:33:12 +00:00
2015-08-28 15:33:40 +00:00
void StackDepotLockAll();
void StackDepotUnlockAll();
2014-09-21 17:33:12 +00:00
// Instantiating this class creates a snapshot of StackDepot which can be
// efficiently queried with StackDepotGet(). You can use it concurrently with
// StackDepot, but the snapshot is only guaranteed to contain those stack traces
// which were stored before it was instantiated.
class StackDepotReverseMap {
public:
StackDepotReverseMap();
2015-08-28 15:33:40 +00:00
StackTrace Get(u32 id);
2014-09-21 17:33:12 +00:00
private:
struct IdDescPair {
u32 id;
2015-08-28 15:33:40 +00:00
StackDepotNode *desc;
2014-09-21 17:33:12 +00:00
static bool IdComparator(const IdDescPair &a, const IdDescPair &b);
};
InternalMmapVector<IdDescPair> map_;
// Disallow evil constructors.
StackDepotReverseMap(const StackDepotReverseMap&);
void operator=(const StackDepotReverseMap&);
};
2015-08-28 15:33:40 +00:00
2014-09-21 17:33:12 +00:00
} // namespace __sanitizer
#endif // SANITIZER_STACKDEPOT_H