diff options
author | Cyrill Gorcunov <gorcunov@gmail.com> | 2010-11-11 15:06:12 +0300 |
---|---|---|
committer | Cyrill Gorcunov <gorcunov@gmail.com> | 2010-11-11 22:44:35 +0300 |
commit | 49e8f698fcdd121a5646a2d54da27fb15785756f (patch) | |
tree | 6575c73f65686937cee3a5254f70f901ec32f3a0 /preproc.c | |
parent | 574fbf1972935e1d3199cf5ea7efe796fae5d29c (diff) | |
download | nasm-49e8f698fcdd121a5646a2d54da27fb15785756f.tar.gz nasm-49e8f698fcdd121a5646a2d54da27fb15785756f.tar.bz2 nasm-49e8f698fcdd121a5646a2d54da27fb15785756f.zip |
preproc: Add dump_token helper
While being debugging some nifty problem I found
that it might be useful to produce a full dump of
tokens, in particular text of tokens.
For this reason dump_token is here just to not loose
it. It doesn't affect normal build procedure since it
requires a special -DNASM_TRACE to be passed to the
compiler. Which of course we don't in a regular
compilations.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Diffstat (limited to 'preproc.c')
-rw-r--r-- | preproc.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -483,6 +483,24 @@ static ExpInv *new_ExpInv(int exp_type, ExpDef *ed); #define tok_is_(x,v) (tok_type_((x), TOK_OTHER) && !strcmp((x)->text,(v))) #define tok_isnt_(x,v) ((x) && ((x)->type!=TOK_OTHER || strcmp((x)->text,(v)))) +#ifdef NASM_TRACE + +#define dump_token(t) raw_dump_token(t, __FILE__, __LINE__, __func__); +static void raw_dump_token(Token *token, const char *file, int line, const char *func) +{ + printf("---[%s (%s:%d): %p]---\n", func, file, line, (void *)token); + if (token) { + Token *t; + list_for_each(t, token) { + if (t->text) + printf("'%s' ", t->text); + } + printf("\n"); + } +} + +#endif + /* * nasm_unquote with error if the string contains NUL characters. * If the string contains NUL characters, issue an error and return |