forked from len0rd/rockbox
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:
parent
e492b51d83
commit
719d48afc4
7 changed files with 75 additions and 43 deletions
|
@ -991,8 +991,7 @@ unsigned buflib_pin_count(struct buflib_context *ctx, int handle)
|
|||
return data[idx_PIN].pincount;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
#ifdef BUFLIB_DEBUG_GET_DATA
|
||||
void *buflib_get_data(struct buflib_context *ctx, int handle)
|
||||
{
|
||||
if (handle <= 0)
|
||||
|
@ -1000,7 +999,9 @@ void *buflib_get_data(struct buflib_context *ctx, int handle)
|
|||
|
||||
return (void*)(ctx->handle_table[-handle].alloc);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef BUFLIB_DEBUG_CHECK_VALID
|
||||
void buflib_check_valid(struct buflib_context *ctx)
|
||||
{
|
||||
for(union buflib_data *block = ctx->buf_start;
|
||||
|
@ -1016,10 +1017,11 @@ void buflib_check_valid(struct buflib_context *ctx)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef BUFLIB_DEBUG_BLOCK_SINGLE
|
||||
#ifdef BUFLIB_DEBUG_PRINT
|
||||
int buflib_get_num_blocks(struct buflib_context *ctx)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for(union buflib_data *block = ctx->buf_start;
|
||||
block < ctx->alloc_end;
|
||||
block += abs(block->val))
|
||||
|
@ -1027,11 +1029,12 @@ int buflib_get_num_blocks(struct buflib_context *ctx)
|
|||
check_block_length(ctx, block);
|
||||
++i;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
void buflib_print_block_at(struct buflib_context *ctx, int block_num,
|
||||
char* buf, size_t bufsize)
|
||||
bool buflib_print_block_at(struct buflib_context *ctx, int block_num,
|
||||
char *buf, size_t bufsize)
|
||||
{
|
||||
for(union buflib_data *block = ctx->buf_start;
|
||||
block < ctx->alloc_end;
|
||||
|
@ -1044,8 +1047,13 @@ void buflib_print_block_at(struct buflib_context *ctx, int block_num,
|
|||
snprintf(buf, bufsize, "%8p: val: %4ld (%sallocated)",
|
||||
block, (long)block->val,
|
||||
block->val > 0 ? "" : "un");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (bufsize > 0)
|
||||
*buf = '\0';
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue