Add debug print function.

This commit is contained in:
uebayasi 2014-10-09 06:45:31 +00:00
parent 9acfc293f2
commit 99af41ba8d
3 changed files with 37 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: defs.h,v 1.46 2014/08/24 20:22:18 joerg Exp $ */
/* $NetBSD: defs.h,v 1.47 2014/10/09 06:45:31 uebayasi Exp $ */
/*
* Copyright (c) 1992, 1993
@ -622,6 +622,13 @@ int onlist(struct nvlist *, void *);
void prefix_push(const char *);
void prefix_pop(void);
char *sourcepath(const char *);
#ifndef MAKE_BOOTSTRAP
extern int dflag;
#define CFGDBG(n, ...) \
do { if ((dflag) >= (n)) cfgdbg(__VA_ARGS__); } while (0)
void cfgdbg(const char *, ...) /* debug info */
__printflike(1, 2);
#endif
void cfgwarn(const char *, ...) /* immediate warns */
__printflike(1, 2);
void cfgxwarn(const char *, int, const char *, ...) /* delayed warns */

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.54 2014/08/09 12:40:14 bad Exp $ */
/* $NetBSD: main.c,v 1.55 2014/10/09 06:45:31 uebayasi Exp $ */
/*
* Copyright (c) 1992, 1993
@ -92,6 +92,7 @@ int yyparse(void);
#ifndef MAKE_BOOTSTRAP
extern int yydebug;
int dflag;
#endif
static struct dlhash *obsopttab;
@ -166,6 +167,7 @@ main(int argc, char **argv)
#ifndef MAKE_BOOTSTRAP
case 'd':
yydebug = 1;
dflag++;
break;
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: util.c,v 1.16 2013/11/01 21:39:13 christos Exp $ */
/* $NetBSD: util.c,v 1.17 2014/10/09 06:45:31 uebayasi Exp $ */
/*
* Copyright (c) 1992, 1993
@ -57,6 +57,10 @@
static void cfgvxerror(const char *, int, const char *, va_list)
__printflike(3, 0);
#ifndef MAKE_BOOTSTRAP
static void cfgvxdbg(const char *, int, const char *, va_list)
__printflike(3, 0);
#endif
static void cfgvxwarn(const char *, int, const char *, va_list)
__printflike(3, 0);
static void cfgvxmsg(const char *, int, const char *, const char *, va_list)
@ -413,6 +417,19 @@ condexpr_destroy(struct condexpr *expr)
* Diagnostic messages
*/
#ifndef MAKE_BOOTSTRAP
void
cfgdbg(const char *fmt, ...)
{
va_list ap;
extern const char *yyfile;
va_start(ap, fmt);
cfgvxdbg(yyfile, currentline(), fmt, ap);
va_end(ap);
}
#endif
void
cfgwarn(const char *fmt, ...)
{
@ -434,6 +451,14 @@ cfgxwarn(const char *file, int line, const char *fmt, ...)
va_end(ap);
}
#ifndef MAKE_BOOTSTRAP
static void
cfgvxdbg(const char *file, int line, const char *fmt, va_list ap)
{
cfgvxmsg(file, line, "debug: ", fmt, ap);
}
#endif
static void
cfgvxwarn(const char *file, int line, const char *fmt, va_list ap)
{