@@ -93,6 +93,13 @@ FD_STATIC_ASSERT( FD_SPAD_ALLOC_ALIGN_DEFAULT >= FD_MSAN_ALIGN,
93
93
94
94
/* spad internals */
95
95
96
+ struct fd_spad_debug_state {
97
+ ulong frame_free ; /* number of frames free, in [0,FD_SPAD_FRAME_MAX] */
98
+ ulong mem_used ; /* number of spad memory bytes used, in [0,mem_max] */
99
+ fd_spad_t * spad ;
100
+ };
101
+ typedef struct fd_spad_debug_state fd_spad_debug_state_t ;
102
+
96
103
struct __attribute__((aligned (FD_SPAD_ALIGN ))) fd_spad_private {
97
104
98
105
/* This point is FD_SPAD_ALIGN aligned */
@@ -360,13 +367,29 @@ fd_spad_private_frame_end( fd_spad_t ** _spad ) { /* declared here to avoid a fd
360
367
fd_spad_pop ( * _spad );
361
368
}
362
369
370
+ void fd_spad_private_frame_end_debug ( fd_spad_debug_state_t * _spad_state );
371
+
372
+ #if defined(FD_SPAD_USE_HANDHOLDING )
373
+
374
+ #define FD_SPAD_FRAME_BEGIN (spad ) do { \
375
+ __attribute__((cleanup(fd_spad_private_frame_end_debug))) fd_spad_debug_state_t _spad_state; \
376
+ _spad_state = fd_spad_push_debug( spad ); \
377
+ do
378
+
379
+ #define FD_SPAD_FRAME_END while(0); } while(0)
380
+
381
+ #else
382
+
363
383
#define FD_SPAD_FRAME_BEGIN (spad ) do { \
364
384
fd_spad_t * _spad __attribute__((cleanup(fd_spad_private_frame_end))) = (spad); \
365
385
fd_spad_push( _spad ); \
366
386
do
367
387
368
388
#define FD_SPAD_FRAME_END while(0); } while(0)
369
389
390
+ #endif
391
+
392
+
370
393
/* fd_spad_alloc allocates sz bytes with alignment align from spad.
371
394
Returns a pointer in the caller's address space to the first byte of
372
395
the allocation (will be non-NULL with alignment align). Assumes spad
@@ -492,7 +515,7 @@ void * fd_spad_delete_debug ( void * shspad
492
515
ulong fd_spad_alloc_max_debug ( fd_spad_t const * spad , ulong align );
493
516
void * fd_spad_frame_lo_debug ( fd_spad_t * spad );
494
517
void * fd_spad_frame_hi_debug ( fd_spad_t * spad );
495
- void fd_spad_push_debug ( fd_spad_t * spad );
518
+ fd_spad_debug_state_t fd_spad_push_debug ( fd_spad_t * spad );
496
519
void fd_spad_pop_debug ( fd_spad_t * spad );
497
520
void * fd_spad_alloc_check ( fd_spad_t * spad , ulong align , ulong sz );
498
521
#define fd_spad_alloc_debug fd_spad_alloc_check
0 commit comments