xref: /freebsd-13.1/libexec/rtld-elf/debug.c (revision 3124c3e0)
1*3124c3e0SJohn Polstra /*-
2*3124c3e0SJohn Polstra  * Copyright 1996-1998 John D. Polstra.
3*3124c3e0SJohn Polstra  * All rights reserved.
4*3124c3e0SJohn Polstra  *
5*3124c3e0SJohn Polstra  * Redistribution and use in source and binary forms, with or without
6*3124c3e0SJohn Polstra  * modification, are permitted provided that the following conditions
7*3124c3e0SJohn Polstra  * are met:
8*3124c3e0SJohn Polstra  * 1. Redistributions of source code must retain the above copyright
9*3124c3e0SJohn Polstra  *    notice, this list of conditions and the following disclaimer.
10*3124c3e0SJohn Polstra  * 2. Redistributions in binary form must reproduce the above copyright
11*3124c3e0SJohn Polstra  *    notice, this list of conditions and the following disclaimer in the
12*3124c3e0SJohn Polstra  *    documentation and/or other materials provided with the distribution.
13*3124c3e0SJohn Polstra  *
14*3124c3e0SJohn Polstra  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15*3124c3e0SJohn Polstra  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16*3124c3e0SJohn Polstra  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17*3124c3e0SJohn Polstra  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18*3124c3e0SJohn Polstra  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19*3124c3e0SJohn Polstra  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20*3124c3e0SJohn Polstra  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21*3124c3e0SJohn Polstra  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22*3124c3e0SJohn Polstra  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23*3124c3e0SJohn Polstra  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24*3124c3e0SJohn Polstra  *
25*3124c3e0SJohn Polstra  *      $Id: debug.c,v 1.1 1998/03/05 21:05:48 jdp Exp $
26*3124c3e0SJohn Polstra  */
27*3124c3e0SJohn Polstra 
28*3124c3e0SJohn Polstra /*
29*3124c3e0SJohn Polstra  * Support for printing debugging messages.
30*3124c3e0SJohn Polstra  */
31*3124c3e0SJohn Polstra 
32*3124c3e0SJohn Polstra #include <stdarg.h>
33*3124c3e0SJohn Polstra #include <stdio.h>
34*3124c3e0SJohn Polstra 
35*3124c3e0SJohn Polstra #include "debug.h"
36*3124c3e0SJohn Polstra 
37*3124c3e0SJohn Polstra int debug = 0;
38*3124c3e0SJohn Polstra 
39*3124c3e0SJohn Polstra void
40*3124c3e0SJohn Polstra debug_printf(const char *format, ...)
41*3124c3e0SJohn Polstra {
42*3124c3e0SJohn Polstra     if (debug) {
43*3124c3e0SJohn Polstra 	va_list ap;
44*3124c3e0SJohn Polstra 	va_start(ap, format);
45*3124c3e0SJohn Polstra 
46*3124c3e0SJohn Polstra 	fflush(stdout);
47*3124c3e0SJohn Polstra 	vfprintf(stderr, format, ap);
48*3124c3e0SJohn Polstra 	putc('\n', stderr);
49*3124c3e0SJohn Polstra 
50*3124c3e0SJohn Polstra 	va_end(ap);
51*3124c3e0SJohn Polstra     }
52*3124c3e0SJohn Polstra }
53