diff --git a/asm/preproc.c b/asm/preproc.c index 7724b12a..203664b5 100644 --- a/asm/preproc.c +++ b/asm/preproc.c @@ -1717,6 +1717,19 @@ static Token *tokenize(const char *line) return list; } +static FILE * logfile = NULL; +static unsigned long logamount = 0; +static unsigned long logtotal = 0; +static unsigned long logmodulo = 0; + +static void openlogfile(void); +static void openlogfile(void) { + if (logfile) return; + logfile = fopen("nasmtoka.log", "wb"); + if (!logfile) nasm_panic("unable to open log file"); + return; +} + /* * Tokens are allocated in blocks to improve speed. Set the blocksize * to 0 to use regular nasm_malloc(); this is useful for debugging. @@ -1733,6 +1746,13 @@ static Token *tokenblocks = NULL; static Token *alloc_Token(void) { Token *t = freeTokens; + openlogfile(); + logamount++; + logtotal++; + if ((logmodulo++ & 8191) == 0) { + fprintf(logfile, "[%12lu] (%12lu) allocate\n", logamount, logtotal); + fflush(logfile); + } if (unlikely(!t)) { Token *block; @@ -1770,6 +1790,12 @@ static Token *alloc_Token(void) static Token *delete_Token(Token *t) { Token *next; + openlogfile(); + logamount--; + if ((logmodulo++ & 8191) == 0) { + fprintf(logfile, "[%12lu] (%12lu) delete\n", logamount, logtotal); + fflush(logfile); + } nasm_assert(t && t->type != TOKEN_FREE);