24 #ifndef PXR_BASE_TF_REF_PTR_TRACKER_H
25 #define PXR_BASE_TF_REF_PTR_TRACKER_H
190 void _RemoveTraces(
const void* owner);
193 typedef std::mutex _Mutex;
194 typedef std::lock_guard<std::mutex> _Lock;
195 mutable _Mutex _mutex;
236 #define TF_DECLARE_REFPTR_TRACK(T) \
237 inline void Tf_RefPtrTracker_FirstRef(const void*, T* obj); \
238 inline void Tf_RefPtrTracker_LastRef(const void*, T* obj); \
239 inline void Tf_RefPtrTracker_New(const void* owner, T* obj); \
240 inline void Tf_RefPtrTracker_Delete(const void* owner, T* obj); \
241 inline void Tf_RefPtrTracker_Assign(const void* owner, T* obj, T* oldObj);
243 #define TF_DEFINE_REFPTR_TRACK(T, COND) \
244 inline void Tf_RefPtrTracker_FirstRef(const void*, T* obj) { \
245 if (obj && COND(obj)) Tf_RefPtrTrackerUtil::Watch(obj); \
247 inline void Tf_RefPtrTracker_LastRef(const void*, T* obj) { \
248 Tf_RefPtrTrackerUtil::Unwatch(obj); \
250 inline void Tf_RefPtrTracker_New(const void* owner, T* obj) { \
251 Tf_RefPtrTrackerUtil::AddTrace(owner, obj); \
253 inline void Tf_RefPtrTracker_Delete(const void* owner, T* obj) { \
254 Tf_RefPtrTrackerUtil::RemoveTraces(owner); \
256 inline void Tf_RefPtrTracker_Assign(const void* owner, T* obj, T* oldObj) { \
257 if (oldObj != obj) { \
258 Tf_RefPtrTrackerUtil::AddTrace(owner, obj, TfRefPtrTracker::Assign);\
TF_API void ReportTracesForWatched(std::ostream &stream, const TfRefBase *watched) const
Writes traces for all owners of watched.
static bool WatchNone(const void *)
static void AddTrace(const void *owner, const TfRefBase *obj, TfRefPtrTracker::TraceType type=TfRefPtrTracker::Add)
TfHashMap< const TfRefBase *, size_t, TfHash > WatchedCounts
TF_API_TEMPLATE_CLASS(TfSingleton< TfRefPtrTracker >)
static bool WatchAll(const void *)
TF_API void ReportAllTraces(std::ostream &stream) const
Writes all traces to stream.
TfHashMap< const void *, Trace, TfHash > OwnerTraces
Maps a TfRefPtr address to the most recent trace for it.
TraceType type
Whether the TfRefPtr was created or assigned to.
static void Unwatch(const TfRefBase *obj)
Stop watching obj. Existing traces for obj are kept.
TF_API WatchedCounts GetWatchedCounts() const
static void Watch(const TfRefBase *obj)
Start watching obj. Only watched objects are traced.
TF_API OwnerTraces GetAllTraces() const
Returns traces for all owners. Returns a copy for thread safety.
std::vector< uintptr_t > trace
The stack trace when the TfRefPtr was created or assigned to.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
const TfRefBase * obj
The object being pointed to.
static TF_API TfRefPtrTracker & GetInstance()
TF_API void ReportAllWatchedCounts(std::ostream &stream) const
static void RemoveTraces(const void *owner)
Remove traces for owner owner.
#define PXR_NAMESPACE_CLOSE_SCOPE
TF_API void SetStackTraceMaxDepth(size_t)
Sets the maximum stack trace depth.
TF_API size_t GetStackTraceMaxDepth() const
Returns the maximum stack trace depth.