crazy_linker_debug.h revision f8ee788a64d60abd8f2d742a5fdedde054ecd910
18bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
58bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#ifndef CRAZY_LINKER_DEBUG_H
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define CRAZY_LINKER_DEBUG_H
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
89ab5563a3196760eb381d102cbb2bc0f7abc6a50Ben Murdoch// Set CRAZY_DEBUG on the command-line to 1 to enable debugging support.
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// This really means adding traces that will be sent to both stderr
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// and the logcat during execution.
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#ifndef CRAZY_DEBUG
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define CRAZY_DEBUG 0
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif
142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace crazy {
162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#if CRAZY_DEBUG
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void Log(const char* fmt, ...);
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void LogErrno(const char* fmt, ...);
218bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define LOG(...) ::crazy::Log(__VA_ARGS__)
232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define LOG_ERRNO(...) ::crazy::LogErrno(__VA_ARGS__)
248bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#else
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
278bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#define LOG(...) ((void)0)
28424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#define LOG_ERRNO(...) ((void)0)
29424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
308bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#endif
312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Conditional logging.
332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define LOG_IF(cond, ...) \
342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  do {                    \
358bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)    if ((cond))           \
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      LOG(__VA_ARGS__);   \
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  } while (0)
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define LOG_ERRNO_IF(cond, ...) \
408bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  do {                          \
412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    if ((cond))                 \
422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)      LOG_ERRNO(__VA_ARGS__);   \
432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  } while (0)
448bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace crazy
462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
47c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#endif  // CRAZY_LINKER_DEBUG_H
48c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)