summaryrefslogtreecommitdiffstats
path: root/mozglue/linker/Logging.h
blob: ec0a2b32b4468362bbaed310c2bfb0ac3f3886e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef Logging_h
#define Logging_h

#include "mozilla/Likely.h"

class Logging
{
public:
  static bool isVerbose()
  {
    return Singleton.verbose;
  }

private:
  bool verbose;

public:
  static void Init()
  {
    const char *env = getenv("MOZ_DEBUG_LINKER");
    if (env && *env == '1')
      Singleton.verbose = true;
  }

private:
  static Logging Singleton;
};

#define DEBUG_LOG(...)   \
  do {                   \
    if (MOZ_UNLIKELY(Logging::isVerbose())) {  \
      LOG(__VA_ARGS__);  \
    }                    \
  } while(0)

#if defined(__LP64__)
#  define PRIxAddr "lx"
#  define PRIxSize "lx"
#  define PRIdSize "ld"
#  define PRIuSize "lu"
#else
#  define PRIxAddr "x"
#  define PRIxSize "x"
#  define PRIdSize "d"
#  define PRIuSize "u"
#endif

#endif /* Logging_h */