crazy_linker_debug.h revision f8ee788a64d60abd8f2d742a5fdedde054ecd910
1f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved.
2f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
3f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)// found in the LICENSE file.
4f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)
5f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#ifndef CRAZY_LINKER_DEBUG_H
6f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#define CRAZY_LINKER_DEBUG_H
7f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)
8f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)// Set CRAZY_DEBUG on the command-line to 1 to enable debugging support.
9f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)// This really means adding traces that will be sent to both stderr
10f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)// and the logcat during execution.
11f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#ifndef CRAZY_DEBUG
12f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#define CRAZY_DEBUG 0
13f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#endif
14f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)
15f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)namespace crazy {
16f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)
17f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#if CRAZY_DEBUG
18f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)
19f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)void Log(const char* fmt, ...);
20f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)void LogErrno(const char* fmt, ...);
21f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)
22f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#define LOG(...) ::crazy::Log(__VA_ARGS__)
23f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#define LOG_ERRNO(...) ::crazy::LogErrno(__VA_ARGS__)
24f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)
25f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#else
26f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)
27f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#define LOG(...) ((void)0)
28f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#define LOG_ERRNO(...) ((void)0)
29f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)
30f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#endif
31f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)
32f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)// Conditional logging.
33f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#define LOG_IF(cond, ...) \
34f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  do {                    \
35f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)    if ((cond))           \
36f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)      LOG(__VA_ARGS__);   \
37f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  } while (0)
38f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)
39f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#define LOG_ERRNO_IF(cond, ...) \
40f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  do {                          \
41f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)    if ((cond))                 \
42f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)      LOG_ERRNO(__VA_ARGS__);   \
43f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  } while (0)
44f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)
45f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)}  // namespace crazy
46f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)
47f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)#endif  // CRAZY_LINKER_DEBUG_H
48