2 * Defines the functions only necessary while debugging is active
\r
15 #include "command.h"
\r
17 FILE *dbg_logfile = stdout;
\r
18 char *dbg_logname = 0;
\r
19 unsigned firstMem = 0;
\r
21 void dbg_print(const char * const fmt, ...)
\r
25 vfprintf(dbg_logfile, fmt, ap);
\r
27 fflush(dbg_logfile);
\r
30 void dbg_outc(int ch)
\r
31 { putc(ch, dbg_logfile);
\r
33 void dbg_outs(const char * const s)
\r
34 { if(s) fputs(s, dbg_logfile);
\r
35 fflush(dbg_logfile);
\r
37 void dbg_outsn(const char * const s)
\r
38 { if(s) fputs(s, dbg_logfile);
\r
39 putc('\n', dbg_logfile);
\r
40 fflush(dbg_logfile);
\r
44 void dbg_printmem(void)
\r
45 { static unsigned nearLast = 0;
\r
46 static unsigned long farLast = 0;
\r
49 unsigned long farThis;
\r
51 switch(heapcheck()) {
\r
53 cputs("HEAP CORRUPTED. Cannot proceed!\r\n");
\r
56 cputs("NO HEAP. Cannot proceed!\r\n");
\r
59 cputs("Unknown heapcheck() error. Cannot proceed!\r\n");
\r
65 nearThis = coreleft();
\r
66 farThis = farcoreleft();
\r
68 dprintf(("[free memory: near=%6u far=%13lu]\n", nearThis, farThis));
\r
70 dprintf(("[changed : near=%6d far=%13ld]\n"
\r
71 , nearThis - nearLast , farThis - farLast));
\r
73 nearLast = nearThis;
\r
77 #endif /* defined(DEBUG) */
\r