xref: /netbsd/libexec/ld.elf_so/debug.c (revision 2728318e)
1*2728318eSskrll /*	$NetBSD: debug.c,v 1.6 2004/10/22 05:39:56 skrll Exp $	*/
241fe218bScgd 
341fe218bScgd /*
441fe218bScgd  * Copyright 1996 John D. Polstra.
541fe218bScgd  * Copyright 1996 Matt Thomas <matt@3am-software.com>
641fe218bScgd  * All rights reserved.
741fe218bScgd  *
841fe218bScgd  * Redistribution and use in source and binary forms, with or without
941fe218bScgd  * modification, are permitted provided that the following conditions
1041fe218bScgd  * are met:
1141fe218bScgd  * 1. Redistributions of source code must retain the above copyright
1241fe218bScgd  *    notice, this list of conditions and the following disclaimer.
1341fe218bScgd  * 2. Redistributions in binary form must reproduce the above copyright
1441fe218bScgd  *    notice, this list of conditions and the following disclaimer in the
1541fe218bScgd  *    documentation and/or other materials provided with the distribution.
1641fe218bScgd  * 3. All advertising materials mentioning features or use of this software
1741fe218bScgd  *    must display the following acknowledgement:
1841fe218bScgd  *      This product includes software developed by John Polstra.
1941fe218bScgd  * 4. The name of the author may not be used to endorse or promote products
2041fe218bScgd  *    derived from this software without specific prior written permission.
2141fe218bScgd  *
2241fe218bScgd  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
2341fe218bScgd  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2441fe218bScgd  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2541fe218bScgd  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2641fe218bScgd  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2741fe218bScgd  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2841fe218bScgd  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2941fe218bScgd  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3041fe218bScgd  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
3141fe218bScgd  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3241fe218bScgd  */
3341fe218bScgd 
3441fe218bScgd /*
3541fe218bScgd  * Support for printing debugging messages.
3641fe218bScgd  */
3741fe218bScgd 
3826475619Schristos #include <sys/cdefs.h>
39*2728318eSskrll #ifndef lint
40*2728318eSskrll __RCSID("$NetBSD: debug.c,v 1.6 2004/10/22 05:39:56 skrll Exp $");
41*2728318eSskrll #endif /* not lint */
42*2728318eSskrll 
4341fe218bScgd #include <stdarg.h>
4441fe218bScgd 
4541fe218bScgd #include "debug.h"
4641fe218bScgd #include "rtldenv.h"
4741fe218bScgd 
4841fe218bScgd #ifdef DEBUG
4941fe218bScgd int debug = 0;
5041fe218bScgd 
5141fe218bScgd void
debug_printf(const char * format,...)5241fe218bScgd debug_printf(const char *format, ...)
5341fe218bScgd {
54a9f5b3f8Ssimonb 
5541fe218bScgd 	if (debug) {
5641fe218bScgd 		va_list ap;
57bf840df2Swiz 
5841fe218bScgd 		va_start(ap, format);
5941fe218bScgd 		xvprintf(format, ap);
6041fe218bScgd 		va_end(ap);
6141fe218bScgd 		xprintf("\n");
6241fe218bScgd 	}
6341fe218bScgd }
6441fe218bScgd #endif
65