buflib: Refactor various debugging features

Gate buflib_get_data() checking, debug printing, and buflib
integrity checks behind individual defines in buflib.h, and
turn them all off by default. If needed, they can be turned
on manually when compiling.

The buflib debug menu is only available if debug printing is
enabled, so after this commit it will no longer be included
in normal builds -- it isn't very useful to end users.

Change-Id: Iab25b7852bc7c5592ce04c9c45762046a87d5bc3
This commit is contained in:
Aidan MacDonald 2023-01-02 19:18:02 +00:00
parent e492b51d83
commit 719d48afc4
7 changed files with 75 additions and 43 deletions

View file

@ -21,21 +21,23 @@ unsigned core_pin_count(int handle);
int core_free(int handle);
size_t core_available(void);
size_t core_allocatable(void);
#ifdef DEBUG
#ifdef BUFLIB_DEBUG_CHECK_VALID
void core_check_valid(void);
#endif
/* DO NOT ADD wrappers for buflib_buffer_out/in. They do not call
* the move callbacks and are therefore unsafe in the core */
#ifdef BUFLIB_DEBUG_BLOCK_SINGLE
int core_get_num_blocks(void);
void core_print_block_at(int block_num, char* buf, size_t bufsize);
#endif
#ifdef BUFLIB_DEBUG_PRINT
int core_get_num_blocks(void);
bool core_print_block_at(int block_num, char* buf, size_t bufsize);
/* frees the debug test alloc created at initialization,
* since this is the first any further alloc should force a compaction run */
* since this is the first any further alloc should force a compaction run
* only used if debug print is active */
bool core_test_free(void);
#endif
static inline void* core_get_data(int handle)
{