Remove the checks.h dependence on logging.h in a standalone build.
logging.h apparently drags in a lot of undesirable dependencies. It was only required for the trivial LogMessageVoidify; simply add an identical FatalMessageVoidify instead. Keep the include in a Chromium build to still have the override mechanism use Chromium's macros. Bonus: Add the missing DCHECK_GT (noticed by bercic). R=kwiberg@webrtc.org Review URL: https://webrtc-codereview.appspot.com/17259004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7031 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
8e24d87778
commit
34a6764981
@ -13,22 +13,19 @@
|
||||
|
||||
// Use the C++ version to provide __GLIBCXX__.
|
||||
#include <cstdio>
|
||||
#include <cstdarg>
|
||||
|
||||
#if defined(__GLIBCXX__) && !defined(__UCLIBC__)
|
||||
#include <cxxabi.h>
|
||||
#include <execinfo.h>
|
||||
#endif
|
||||
|
||||
#if defined(ANDROID)
|
||||
#if defined(WEBRTC_ANDROID)
|
||||
#define LOG_TAG "rtc"
|
||||
#include <android/log.h> // NOLINT
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/common.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
// Warning C4722: destructor never returns, potential memory leak.
|
||||
@ -59,7 +56,7 @@ void PrintError(const char* format, ...) {
|
||||
void DumpBacktrace() {
|
||||
#if defined(__GLIBCXX__) && !defined(__UCLIBC__)
|
||||
void* trace[100];
|
||||
int size = backtrace(trace, ARRAY_SIZE(trace));
|
||||
int size = backtrace(trace, sizeof(trace) / sizeof(*trace));
|
||||
char** symbols = backtrace_symbols(trace, size);
|
||||
PrintError("\n==== C stack trace ===============================\n\n");
|
||||
if (size == 0) {
|
||||
|
@ -11,12 +11,16 @@
|
||||
#ifndef WEBRTC_BASE_CHECKS_H_
|
||||
#define WEBRTC_BASE_CHECKS_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#ifdef WEBRTC_CHROMIUM_BUILD
|
||||
// Include logging.h in a Chromium build to enable the overrides mechanism for
|
||||
// using Chromium's macros. Otherwise, don't depend on logging.h.
|
||||
// TODO(ajm): Ideally, checks.h would be combined with logging.h, but
|
||||
// consolidation with system_wrappers/logging.h should happen first.
|
||||
#include "webrtc/base/logging.h"
|
||||
#endif
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
// The macros here print a message to stderr and abort under various
|
||||
@ -47,8 +51,6 @@
|
||||
// doesn't hold. Prefer them to raw CHECK and DCHECK.
|
||||
//
|
||||
// - FATAL() aborts unconditionally.
|
||||
//
|
||||
// TODO(ajm): Ideally, this would be combined with webrtc/base/logging.h.
|
||||
|
||||
namespace rtc {
|
||||
|
||||
@ -59,12 +61,13 @@ namespace rtc {
|
||||
|
||||
// Helper macro which avoids evaluating the arguments to a stream if
|
||||
// the condition doesn't hold.
|
||||
#define LAZY_STREAM(stream, condition) \
|
||||
!(condition) ? (void) 0 : rtc::LogMessageVoidify() & (stream)
|
||||
#define LAZY_STREAM(stream, condition) \
|
||||
!(condition) ? static_cast<void>(0) : rtc::FatalMessageVoidify() & (stream)
|
||||
|
||||
// The actual stream used isn't important.
|
||||
#define EAT_STREAM_PARAMETERS \
|
||||
true ? (void) 0 : rtc::LogMessageVoidify() & rtc::FatalMessage("", 0).stream()
|
||||
#define EAT_STREAM_PARAMETERS \
|
||||
true ? static_cast<void>(0) \
|
||||
: rtc::FatalMessageVoidify() & rtc::FatalMessage("", 0).stream()
|
||||
|
||||
// CHECK dies with a fatal error if condition is not true. It is *not*
|
||||
// controlled by NDEBUG, so the check will be executed regardless of
|
||||
@ -155,18 +158,29 @@ DEFINE_CHECK_OP_IMPL(GT, > )
|
||||
#define DCHECK(condition) CHECK(condition)
|
||||
#define DCHECK_EQ(v1, v2) CHECK_EQ(v1, v2)
|
||||
#define DCHECK_NE(v1, v2) CHECK_NE(v1, v2)
|
||||
#define DCHECK_GE(v1, v2) CHECK_GE(v1, v2)
|
||||
#define DCHECK_LT(v1, v2) CHECK_LT(v1, v2)
|
||||
#define DCHECK_LE(v1, v2) CHECK_LE(v1, v2)
|
||||
#define DCHECK_LT(v1, v2) CHECK_LT(v1, v2)
|
||||
#define DCHECK_GE(v1, v2) CHECK_GE(v1, v2)
|
||||
#define DCHECK_GT(v1, v2) CHECK_GT(v1, v2)
|
||||
#else
|
||||
#define DCHECK(condition) EAT_STREAM_PARAMETERS
|
||||
#define DCHECK_EQ(v1, v2) EAT_STREAM_PARAMETERS
|
||||
#define DCHECK_NE(v1, v2) EAT_STREAM_PARAMETERS
|
||||
#define DCHECK_GE(v1, v2) EAT_STREAM_PARAMETERS
|
||||
#define DCHECK_LT(v1, v2) EAT_STREAM_PARAMETERS
|
||||
#define DCHECK_LE(v1, v2) EAT_STREAM_PARAMETERS
|
||||
#define DCHECK_LT(v1, v2) EAT_STREAM_PARAMETERS
|
||||
#define DCHECK_GE(v1, v2) EAT_STREAM_PARAMETERS
|
||||
#define DCHECK_GT(v1, v2) EAT_STREAM_PARAMETERS
|
||||
#endif
|
||||
|
||||
// This is identical to LogMessageVoidify but in name.
|
||||
class FatalMessageVoidify {
|
||||
public:
|
||||
FatalMessageVoidify() { }
|
||||
// This has to be an operator with a precedence lower than << but
|
||||
// higher than ?:
|
||||
void operator&(std::ostream&) { }
|
||||
};
|
||||
|
||||
#endif // WEBRTC_CHROMIUM_BUILD
|
||||
|
||||
#define FATAL() rtc::FatalMessage(__FILE__, __LINE__).stream()
|
||||
|
Loading…
x
Reference in New Issue
Block a user