File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,19 @@ void swift_endAccess(ValueBuffer *buffer);
58
58
SWIFT_RUNTIME_EXPORT
59
59
bool _swift_disableExclusivityChecking;
60
60
61
+ #ifndef NDEBUG
62
+
63
+ // / Dump all accesses currently tracked by the runtime.
64
+ // /
65
+ // / This is a debug routine that is intended to be used from the debugger and is
66
+ // / compiled out when asserts are disabled. The intention is that it allows one
67
+ // / to dump the access state to easily see if/when exclusivity violations will
68
+ // / happen. This eases debugging.
69
+ SWIFT_RUNTIME_EXPORT
70
+ void swift_dumpTrackedAccesses ();
71
+
72
+ #endif
73
+
61
74
} // end namespace swift
62
75
63
76
#endif
Original file line number Diff line number Diff line change @@ -260,6 +260,16 @@ class AccessSet {
260
260
261
261
swift_runtime_unreachable (" access not found in set" );
262
262
}
263
+
264
+ #ifndef NDEBUG
265
+ // / Only available with asserts. Intended to be used with
266
+ // / swift_dumpTrackedAccess().
267
+ void forEach (std::function<void (Access *)> action) {
268
+ for (auto *iter = Head; iter != nullptr ; iter = iter->getNext ()) {
269
+ action (iter);
270
+ }
271
+ }
272
+ #endif
263
273
};
264
274
265
275
} // end anonymous namespace
@@ -348,3 +358,17 @@ void swift::swift_endAccess(ValueBuffer *buffer) {
348
358
349
359
getAccessSet ().remove (access);
350
360
}
361
+
362
+ #ifndef NDEBUG
363
+
364
+ // Dump the accesses that are currently being tracked by the runtime.
365
+ //
366
+ // This is only intended to be used in the debugger.
367
+ void swift::swift_dumpTrackedAccesses () {
368
+ getAccessSet ().forEach ([](Access *a) {
369
+ fprintf (stderr, " Access. Pointer: %p. PC: %p. AccessAction: %s" ,
370
+ a->Pointer , a->PC , getAccessName (a->getAccessAction ()));
371
+ });
372
+ }
373
+
374
+ #endif
You can’t perform that action at this time.
0 commit comments