|
24 | 24 |
|
25 | 25 | #include <lib/support/CHIPMem.h>
|
26 | 26 | #include <lib/support/CodeUtils.h>
|
| 27 | +#include <lib/support/ObjectDump.h> |
27 | 28 | #include <system/SystemConfig.h>
|
28 | 29 |
|
29 | 30 | #include <lib/support/Iterators.h>
|
@@ -263,7 +264,7 @@ class BitMapObjectPool : public internal::StaticAllocatorBitmap
|
263 | 264 | {
|
264 | 265 | public:
|
265 | 266 | BitMapObjectPool() : StaticAllocatorBitmap(mData.mMemory, mUsage, N, sizeof(T)) {}
|
266 |
| - ~BitMapObjectPool() { VerifyOrDie(Allocated() == 0); } |
| 267 | + ~BitMapObjectPool() { VerifyOrDieWithObject(Allocated() == 0, this); } |
267 | 268 |
|
268 | 269 | BitmapActiveObjectIterator<T> begin() { return BitmapActiveObjectIterator<T>(this, FirstActiveIndex()); }
|
269 | 270 | BitmapActiveObjectIterator<T> end() { return BitmapActiveObjectIterator<T>(this, N); }
|
@@ -323,6 +324,18 @@ class BitMapObjectPool : public internal::StaticAllocatorBitmap
|
323 | 324 | return ForEachActiveObjectInner(&proxy, &internal::LambdaProxy<T, Function>::ConstCall);
|
324 | 325 | }
|
325 | 326 |
|
| 327 | + void DumpToLog() const |
| 328 | + { |
| 329 | + ChipLogError(Support, "BitMapObjectPool: %lu allocated", static_cast<unsigned long>(Allocated())); |
| 330 | + if constexpr (IsDumpable<T>::value) |
| 331 | + { |
| 332 | + ForEachActiveObject([](const T * object) { |
| 333 | + object->DumpToLog(); |
| 334 | + return Loop::Continue; |
| 335 | + }); |
| 336 | + } |
| 337 | + } |
| 338 | + |
326 | 339 | private:
|
327 | 340 | static Loop ReleaseObject(void * context, void * object)
|
328 | 341 | {
|
@@ -389,7 +402,7 @@ class HeapObjectPool : public internal::Statistics, public HeapObjectPoolExitHan
|
389 | 402 | if (!sIgnoringLeaksOnExit)
|
390 | 403 | {
|
391 | 404 | // Verify that no live objects remain, to prevent potential use-after-free.
|
392 |
| - VerifyOrDie(Allocated() == 0); |
| 405 | + VerifyOrDieWithObject(Allocated() == 0, this); |
393 | 406 | }
|
394 | 407 | #endif // __SANITIZE_ADDRESS__
|
395 | 408 | }
|
@@ -570,6 +583,18 @@ class HeapObjectPool : public internal::Statistics, public HeapObjectPoolExitHan
|
570 | 583 | return mObjects.ForEachNode(&proxy, &internal::LambdaProxy<const T, Function>::ConstCall);
|
571 | 584 | }
|
572 | 585 |
|
| 586 | + void DumpToLog() const |
| 587 | + { |
| 588 | + ChipLogError(Support, "HeapObjectPool: %lu allocated", static_cast<unsigned long>(Allocated())); |
| 589 | + if constexpr (IsDumpable<T>::value) |
| 590 | + { |
| 591 | + ForEachActiveObject([](const T * object) { |
| 592 | + object->DumpToLog(); |
| 593 | + return Loop::Continue; |
| 594 | + }); |
| 595 | + } |
| 596 | + } |
| 597 | + |
573 | 598 | private:
|
574 | 599 | static Loop ReleaseObject(void * context, void * object)
|
575 | 600 | {
|
|
0 commit comments