C preprocessor: Difference between revisions

m
no edit summary
[unchecked revision][unchecked revision]
No edit summary
mNo edit summary
Line 17:
testif( isChecksumCorrect( kernel_heap.first_free_list ) );
testif( timersAreOn );
 
Capturing debugging information like values of variables at different moments of execution
void alert(const char *msg);
void alert(uint32 u);
void alert_dec(uint32 u);
#define complain(msg) do {\
alert_decimal(__FILE__); \
alert(": "); \
alert_decimal(__LINE__); \
alert(": "); \
alert(msg); \
alert("\n"); \
} while(0)
 
 
void * malloc(size_t s) {
complain((uint32)kernel_heap.first_free->addr);
do_something();
complain((uint32)kernel_heap.first_free->addr);
if (do_something2()) y = malloc(sizeof(struct book_keeping_struct));
complain((uint32)kernel_heap.first_free->addr);
do_something3();
}
with an output of
src/memory/malloc.c: 271: 0xd0010000 //entering malloc
src/memory/malloc.c: 273: 0xd0010000 //having done_something
src/memory/malloc.c: 271: 0xd0010000 //do_something2 makes malloc to recursive call
src/memory/malloc.c: 273: 0xd0010000 //done_something
src/memory/malloc.c: 275: 0x0e1bc30a //aha! an error after do_something2() (which returns 0) in nested malloc call
...
 
 
 
==== Deleted Code ====
Anonymous user