1 /*
2 * Copyright (C) 2008-2010 The Android Open Source Project
3 * 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 */
29 #ifndef _LINKER_DEBUG_H_
30 #define _LINKER_DEBUG_H_
32 // You can increase the verbosity of debug traces by defining the LD_DEBUG
33 // environment variable to a numeric value from 0 to 2 (corresponding to
34 // INFO, TRACE, and DEBUG calls in the source). This will only
35 // affect new processes being launched.
37 // By default, traces are sent to logcat, with the "linker" tag. You can
38 // change this to go to stdout instead by setting the definition of
39 // LINKER_DEBUG_TO_LOG to 0.
40 #define LINKER_DEBUG_TO_LOG 1
42 #define TRACE_DEBUG 1
43 #define DO_TRACE_LOOKUP 1
44 #define DO_TRACE_RELO 1
45 #define TIMING 0
46 #define STATS 0
47 #define COUNT_PAGES 0
49 /*********************************************************************
50 * You shouldn't need to modify anything below unless you are adding
51 * more debugging information.
52 *
53 * To enable/disable specific debug options, change the defines above
54 *********************************************************************/
56 #include "private/libc_logging.h"
58 __LIBC_HIDDEN__ extern int gLdDebugVerbosity;
60 #if LINKER_DEBUG_TO_LOG
61 #define _PRINTVF(v, x...) \
62 do { \
63 if (gLdDebugVerbosity > (v)) __libc_format_log(5-(v), "linker", x); \
64 } while (0)
65 #else /* !LINKER_DEBUG_TO_LOG */
66 #define _PRINTVF(v, x...) \
67 do { \
68 if (gLdDebugVerbosity > (v)) { __libc_format_fd(1, x); write(1, "\n", 1); } \
69 } while (0)
70 #endif /* !LINKER_DEBUG_TO_LOG */
72 #define PRINT(x...) _PRINTVF(-1, x)
73 #define INFO(x...) _PRINTVF(0, x)
74 #define TRACE(x...) _PRINTVF(1, x)
76 #if TRACE_DEBUG
77 #define DEBUG(x...) _PRINTVF(2, "DEBUG: " x)
78 #else /* !TRACE_DEBUG */
79 #define DEBUG(x...) do {} while (0)
80 #endif /* TRACE_DEBUG */
82 #define TRACE_TYPE(t, x...) do { if (DO_TRACE_##t) { TRACE(x); } } while (0)
84 #endif /* _LINKER_DEBUG_H_ */