2012-08-30 18:02:48 +08:00
|
|
|
//===-- sanitizer_stackdepot.h ----------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
|
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"
|
2012-08-30 18:02:48 +08:00
|
|
|
|
|
|
|
namespace __sanitizer {
|
|
|
|
|
|
|
|
// StackDepot efficiently stores huge amounts of stack traces.
|
|
|
|
|
|
|
|
// Maps stack trace to an unique id.
|
2012-08-30 21:02:30 +08:00
|
|
|
u32 StackDepotPut(const uptr *stack, uptr size);
|
2012-08-30 18:02:48 +08:00
|
|
|
// Retrieves a stored stack trace by the id.
|
2012-08-30 21:02:30 +08:00
|
|
|
const uptr *StackDepotGet(u32 id, uptr *size);
|
2012-08-30 18:02:48 +08:00
|
|
|
|
2012-12-26 14:30:02 +08:00
|
|
|
struct StackDepotStats {
|
|
|
|
uptr n_uniq_ids;
|
|
|
|
uptr mapped;
|
|
|
|
};
|
|
|
|
|
|
|
|
StackDepotStats *StackDepotGetStats();
|
|
|
|
|
2013-08-26 21:24:43 +08:00
|
|
|
struct StackDesc;
|
|
|
|
|
|
|
|
// 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();
|
|
|
|
const uptr *Get(u32 id, uptr *size);
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct IdDescPair {
|
2013-08-28 19:26:09 +08:00
|
|
|
u32 id;
|
|
|
|
StackDesc *desc;
|
2013-08-26 21:24:43 +08:00
|
|
|
|
2013-08-28 19:26:09 +08:00
|
|
|
static bool IdComparator(const IdDescPair &a, const IdDescPair &b);
|
2013-08-26 21:24:43 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
InternalMmapVector<IdDescPair> map_;
|
|
|
|
|
|
|
|
// Disallow evil constructors.
|
|
|
|
StackDepotReverseMap(const StackDepotReverseMap&);
|
|
|
|
void operator=(const StackDepotReverseMap&);
|
|
|
|
};
|
2012-08-30 18:02:48 +08:00
|
|
|
} // namespace __sanitizer
|
|
|
|
|
|
|
|
#endif // SANITIZER_STACKDEPOT_H
|