blob: 7d2485342c11af1e05ed49743c3c705e4aff0436 [file] [log] [blame]
The Android Open Source Project1dc9e472009-03-03 19:28:35 -08001/*
David 'Digit' Turner5c734642010-01-20 12:36:51 -08002 * Copyright (C) 2008-2010 The Android Open Source Project
The Android Open Source Project1dc9e472009-03-03 19:28:35 -08003 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _LINKER_DEBUG_H_
30#define _LINKER_DEBUG_H_
31
32#include <stdio.h>
33
Elliott Hughes0493a6f2013-03-07 11:48:58 -080034// You can increase the verbosity of debug traces by defining the LD_DEBUG
35// environment variable to a numeric value from 0 to 2 (corresponding to
36// INFO, TRACE, and DEBUG calls in the source). This will only
37// affect new processes being launched.
38
39// By default, traces are sent to logcat, with the "linker" tag. You can
40// change this to go to stdout instead by setting the definition of
41// LINKER_DEBUG_TO_LOG to 0.
David 'Digit' Turner5c734642010-01-20 12:36:51 -080042#define LINKER_DEBUG_TO_LOG 1
Elliott Hughes0493a6f2013-03-07 11:48:58 -080043
David 'Digit' Turner5c734642010-01-20 12:36:51 -080044#define TRACE_DEBUG 1
45#define DO_TRACE_LOOKUP 1
46#define DO_TRACE_RELO 1
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080047#define TIMING 0
48#define STATS 0
49#define COUNT_PAGES 0
50
51/*********************************************************************
52 * You shouldn't need to modify anything below unless you are adding
53 * more debugging information.
54 *
55 * To enable/disable specific debug options, change the defines above
56 *********************************************************************/
57
58
59/*********************************************************************/
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080060
Elliott Hughes8f2a5a02013-03-15 15:30:25 -070061#include "private/libc_logging.h"
Nick Kralevich3697b522012-08-24 13:40:25 -070062
Elliott Hughes650be4e2013-03-05 18:47:58 -080063__LIBC_HIDDEN__ extern int gLdDebugVerbosity;
64
David 'Digit' Turner5c734642010-01-20 12:36:51 -080065#if LINKER_DEBUG_TO_LOG
Elliott Hughesca0c11b2013-03-12 10:40:45 -070066#define _PRINTVF(v,x...) \
67 do { \
68 if (gLdDebugVerbosity > (v)) __libc_format_log(5-(v),"linker",x); \
Dima Zavin2e855792009-05-20 18:28:09 -070069 } while (0)
David 'Digit' Turner5c734642010-01-20 12:36:51 -080070#else /* !LINKER_DEBUG_TO_LOG */
Elliott Hughesca0c11b2013-03-12 10:40:45 -070071#define _PRINTVF(v,x...) \
72 do { \
73 if (gLdDebugVerbosity > (v)) { __libc_format_fd(1, x); write(1, "\n", 1); } \
David 'Digit' Turner5c734642010-01-20 12:36:51 -080074 } while (0)
75#endif /* !LINKER_DEBUG_TO_LOG */
Nick Kralevich3697b522012-08-24 13:40:25 -070076
Elliott Hughesbedfe382012-08-14 14:07:59 -070077#define PRINT(x...) _PRINTVF(-1, x)
78#define INFO(x...) _PRINTVF(0, x)
79#define TRACE(x...) _PRINTVF(1, x)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080080
81#if TRACE_DEBUG
Elliott Hughesbedfe382012-08-14 14:07:59 -070082#define DEBUG(x...) _PRINTVF(2, "DEBUG: " x)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080083#else /* !TRACE_DEBUG */
84#define DEBUG(x...) do {} while (0)
85#endif /* TRACE_DEBUG */
86
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080087#define TRACE_TYPE(t,x...) do { if (DO_TRACE_##t) { TRACE(x); } } while (0)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080088
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080089#endif /* _LINKER_DEBUG_H_ */