blob: 0a3710bc2c657aec586abcb75140297fc8c38d06 [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
David 'Digit' Turner5c734642010-01-20 12:36:51 -080034/* set LINKER_DEBUG_TO_LOG to 1 to send the logs to logcat,
35 * or 0 to use stdout instead.
36 */
37#define LINKER_DEBUG_TO_LOG 1
38#define TRACE_DEBUG 1
39#define DO_TRACE_LOOKUP 1
40#define DO_TRACE_RELO 1
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080041#define TIMING 0
42#define STATS 0
43#define COUNT_PAGES 0
44
45/*********************************************************************
46 * You shouldn't need to modify anything below unless you are adding
47 * more debugging information.
48 *
49 * To enable/disable specific debug options, change the defines above
50 *********************************************************************/
51
52
53/*********************************************************************/
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080054
David 'Digit' Turner5c734642010-01-20 12:36:51 -080055#include "linker_format.h"
Nick Kralevich3697b522012-08-24 13:40:25 -070056
David 'Digit' Turner5c734642010-01-20 12:36:51 -080057#if LINKER_DEBUG_TO_LOG
Elliott Hughes61a9ccb2012-11-02 12:37:13 -070058extern int format_log(int, const char*, const char*, ...) __attribute__((__format__(printf, 3, 4)));
Elliott Hughesbedfe382012-08-14 14:07:59 -070059#define _PRINTVF(v,x...) \
David 'Digit' Turner5c734642010-01-20 12:36:51 -080060 do { \
61 if (debug_verbosity > (v)) format_log(5-(v),"linker",x); \
Dima Zavin2e855792009-05-20 18:28:09 -070062 } while (0)
David 'Digit' Turner5c734642010-01-20 12:36:51 -080063#else /* !LINKER_DEBUG_TO_LOG */
Elliott Hughes61a9ccb2012-11-02 12:37:13 -070064extern int format_fd(int, const char *, ...) __attribute__((__format__(printf, 2, 3)));
Elliott Hughesbedfe382012-08-14 14:07:59 -070065#define _PRINTVF(v,x...) \
David 'Digit' Turner5c734642010-01-20 12:36:51 -080066 do { \
67 if (debug_verbosity > (v)) format_fd(1, x); \
68 } while (0)
69#endif /* !LINKER_DEBUG_TO_LOG */
Nick Kralevich3697b522012-08-24 13:40:25 -070070
Elliott Hughesbedfe382012-08-14 14:07:59 -070071#define PRINT(x...) _PRINTVF(-1, x)
72#define INFO(x...) _PRINTVF(0, x)
73#define TRACE(x...) _PRINTVF(1, x)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080074
75#if TRACE_DEBUG
Elliott Hughesbedfe382012-08-14 14:07:59 -070076#define DEBUG(x...) _PRINTVF(2, "DEBUG: " x)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080077#else /* !TRACE_DEBUG */
78#define DEBUG(x...) do {} while (0)
79#endif /* TRACE_DEBUG */
80
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080081#define TRACE_TYPE(t,x...) do { if (DO_TRACE_##t) { TRACE(x); } } while (0)
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080082
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080083#endif /* _LINKER_DEBUG_H_ */