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