xref: /minix3/libexec/ld.elf_so/debug.c (revision e83f7ba2c93894ce4409c1a9136af3d6d8ad48cf)
1*e83f7ba2SBen Gras /*	$NetBSD: debug.c,v 1.6 2004/10/22 05:39:56 skrll Exp $	*/
2*e83f7ba2SBen Gras 
3*e83f7ba2SBen Gras /*
4*e83f7ba2SBen Gras  * Copyright 1996 John D. Polstra.
5*e83f7ba2SBen Gras  * Copyright 1996 Matt Thomas <matt@3am-software.com>
6*e83f7ba2SBen Gras  * All rights reserved.
7*e83f7ba2SBen Gras  *
8*e83f7ba2SBen Gras  * Redistribution and use in source and binary forms, with or without
9*e83f7ba2SBen Gras  * modification, are permitted provided that the following conditions
10*e83f7ba2SBen Gras  * are met:
11*e83f7ba2SBen Gras  * 1. Redistributions of source code must retain the above copyright
12*e83f7ba2SBen Gras  *    notice, this list of conditions and the following disclaimer.
13*e83f7ba2SBen Gras  * 2. Redistributions in binary form must reproduce the above copyright
14*e83f7ba2SBen Gras  *    notice, this list of conditions and the following disclaimer in the
15*e83f7ba2SBen Gras  *    documentation and/or other materials provided with the distribution.
16*e83f7ba2SBen Gras  * 3. All advertising materials mentioning features or use of this software
17*e83f7ba2SBen Gras  *    must display the following acknowledgement:
18*e83f7ba2SBen Gras  *      This product includes software developed by John Polstra.
19*e83f7ba2SBen Gras  * 4. The name of the author may not be used to endorse or promote products
20*e83f7ba2SBen Gras  *    derived from this software without specific prior written permission.
21*e83f7ba2SBen Gras  *
22*e83f7ba2SBen Gras  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23*e83f7ba2SBen Gras  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24*e83f7ba2SBen Gras  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25*e83f7ba2SBen Gras  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26*e83f7ba2SBen Gras  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27*e83f7ba2SBen Gras  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28*e83f7ba2SBen Gras  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29*e83f7ba2SBen Gras  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30*e83f7ba2SBen Gras  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31*e83f7ba2SBen Gras  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32*e83f7ba2SBen Gras  */
33*e83f7ba2SBen Gras 
34*e83f7ba2SBen Gras /*
35*e83f7ba2SBen Gras  * Support for printing debugging messages.
36*e83f7ba2SBen Gras  */
37*e83f7ba2SBen Gras 
38*e83f7ba2SBen Gras #include <sys/cdefs.h>
39*e83f7ba2SBen Gras #ifndef lint
40*e83f7ba2SBen Gras __RCSID("$NetBSD: debug.c,v 1.6 2004/10/22 05:39:56 skrll Exp $");
41*e83f7ba2SBen Gras #endif /* not lint */
42*e83f7ba2SBen Gras 
43*e83f7ba2SBen Gras #include <stdarg.h>
44*e83f7ba2SBen Gras 
45*e83f7ba2SBen Gras #include "debug.h"
46*e83f7ba2SBen Gras #include "rtldenv.h"
47*e83f7ba2SBen Gras 
48*e83f7ba2SBen Gras #ifdef DEBUG
49*e83f7ba2SBen Gras int debug = 0;
50*e83f7ba2SBen Gras 
51*e83f7ba2SBen Gras void
debug_printf(const char * format,...)52*e83f7ba2SBen Gras debug_printf(const char *format, ...)
53*e83f7ba2SBen Gras {
54*e83f7ba2SBen Gras 
55*e83f7ba2SBen Gras 	if (debug) {
56*e83f7ba2SBen Gras 		va_list ap;
57*e83f7ba2SBen Gras 
58*e83f7ba2SBen Gras 		va_start(ap, format);
59*e83f7ba2SBen Gras 		xvprintf(format, ap);
60*e83f7ba2SBen Gras 		va_end(ap);
61*e83f7ba2SBen Gras 		xprintf("\n");
62*e83f7ba2SBen Gras 	}
63*e83f7ba2SBen Gras }
64*e83f7ba2SBen Gras #endif
65