Revert of Test RTC_DCHECK_IS_ON instead of checking DCHECK_ALWAYS_ON everywhere (patchset #2 id:20001 of https://codereview.webrtc.org/2384693002/ )

Reason for revert:
This CL breaks FYI bots with a compile error.

Sample error:
jingle/glue/thread_wrapper.cc -o obj/jingle/jingle_glue/thread_wrapper.o
In file included from ../../jingle/glue/thread_wrapper.cc:5:
In file included from ../../jingle/glue/thread_wrapper.h:16:
In file included from ../../base/message_loop/message_loop.h:17:
In file included from ../../base/memory/ref_counted.h:19:
../../base/logging.h:598:1: error: call to 'MakeCheckOpString' is ambiguous
DEFINE_CHECK_OP_IMPL(EQ, ==)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../base/logging.h:592:17: note: expanded from macro 'DEFINE_CHECK_OP_IMPL'
    else return MakeCheckOpString(v1, v2, names); \
                ^~~~~~~~~~~~~~~~~
../../jingle/glue/thread_wrapper.cc:46:3: note: in instantiation of function template specialization 'logging::CheckEQImpl<rtc::Thread *, jingle_glue::JingleThreadWrapper *>' requested here
  DCHECK_EQ(rtc::Thread::Current(), current());
  ^
../../base/logging.h:748:31: note: expanded from macro 'DCHECK_EQ'
#define DCHECK_EQ(val1, val2) DCHECK_OP(EQ, ==, val1, val2)
                              ^
../../base/logging.h:721:18: note: expanded from macro 'DCHECK_OP'
      ::logging::Check##name##Impl((val1), (val2),                     \
                 ^
<scratch space>:102:1: note: expanded from here
CheckEQImpl
^
../../base/logging.h:555:14: note: candidate function [with t1 = rtc::Thread *, t2 = jingle_glue::JingleThreadWrapper *]
std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) {
             ^
../../third_party/webrtc/base/checks.h:122:14: note: candidate function [with t1 = rtc::Thread *, t2 = jingle_glue::JingleThreadWrapper *]
std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) {
             ^
In file included from ../../jingle/glue/thread_wrapper.cc:5:
In file included from ../../jingle/glue/thread_wrapper.h:16:
In file included from ../../base/message_loop/message_loop.h:17:
In file included from ../../base/memory/ref_counted.h:19:
../../base/logging.h:598:1: error: call to 'MakeCheckOpString' is ambiguous
DEFINE_CHECK_OP_IMPL(EQ, ==)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../base/logging.h:592:17: note: expanded from macro 'DEFINE_CHECK_OP_IMPL'
    else return MakeCheckOpString(v1, v2, names); \
                ^~~~~~~~~~~~~~~~~
../../jingle/glue/thread_wrapper.cc:81:3: note: in instantiation of function template specialization 'logging::CheckEQImpl<jingle_glue::JingleThreadWrapper *, jingle_glue::JingleThreadWrapper *>' requested here
  DCHECK_EQ(this, JingleThreadWrapper::current());
  ^
../../base/logging.h:748:31: note: expanded from macro 'DCHECK_EQ'
#define DCHECK_EQ(val1, val2) DCHECK_OP(EQ, ==, val1, val2)
                              ^
../../base/logging.h:721:18: note: expanded from macro 'DCHECK_OP'
      ::logging::Check##name##Impl((val1), (val2),                     \
                 ^
<scratch space>:5:1: note: expanded from here
CheckEQImpl
^
../../base/logging.h:555:14: note: candidate function [with t1 = jingle_glue::JingleThreadWrapper *, t2 = jingle_glue::JingleThreadWrapper *]
std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) {
             ^
../../third_party/webrtc/base/checks.h:122:14: note: candidate function [with t1 = jingle_glue::JingleThreadWrapper *, t2 = jingle_glue::JingleThreadWrapper *]
std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) {
             ^
In file included from ../../jingle/glue/thread_wrapper.cc:5:
In file included from ../../jingle/glue/thread_wrapper.h:16:
In file included from ../../base/message_loop/message_loop.h:17:
In file included from ../../base/memory/ref_counted.h:19:
../../base/logging.h:598:1: error: call to 'MakeCheckOpString' is ambiguous
DEFINE_CHECK_OP_IMPL(EQ, ==)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../base/logging.h:592:17: note: expanded from macro 'DEFINE_CHECK_OP_IMPL'
    else return MakeCheckOpString(v1, v2, names); \
                ^~~~~~~~~~~~~~~~~
../../jingle/glue/thread_wrapper.cc:82:3: note: in instantiation of function template specialization 'logging::CheckEQImpl<jingle_glue::JingleThreadWrapper *, rtc::Thread *>' requested here
  DCHECK_EQ(this, rtc::Thread::Current());
  ^
../../base/logging.h:748:31: note: expanded from macro 'DCHECK_EQ'
#define DCHECK_EQ(val1, val2) DCHECK_OP(EQ, ==, val1, val2)
                              ^
../../base/logging.h:721:18: note: expanded from macro 'DCHECK_OP'
      ::logging::Check##name##Impl((val1), (val2),                     \
                 ^
<scratch space>:12:1: note: expanded from here
CheckEQImpl
^
../../base/logging.h:555:14: note: candidate function [with t1 = jingle_glue::JingleThreadWrapper *, t2 = rtc::Thread *]
std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) {
             ^
../../third_party/webrtc/base/checks.h:122:14: note: candidate function [with t1 = jingle_glue::JingleThreadWrapper *, t2 = rtc::Thread *]
std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) {
             ^
3 errors generated.

Original issue's description:
> Test RTC_DCHECK_IS_ON instead of checking DCHECK_ALWAYS_ON everywhere
>
> The former is always defined (by webrtc/base/checks.h) to either 0 or
> 1, whereas the latter isn't necessarily defined.
>
> NOTRY=true
> BUG=webrtc:6451
>
> Committed: https://crrev.com/ab0b929321d37669165d5795268fa10a8c97ec5b
> Cr-Commit-Position: refs/heads/master@{#14474}

TBR=ossu@webrtc.org,kwiberg@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:6451

Review-Url: https://codereview.webrtc.org/2384083004
Cr-Commit-Position: refs/heads/master@{#14480}
This commit is contained in:
guidou
2016-10-03 08:32:31 -07:00
committed by Commit bot
parent 65b42c251f
commit 8f9010631c
15 changed files with 54 additions and 31 deletions

View File

@ -398,7 +398,7 @@ void StatsCollector::AddLocalAudioTrack(AudioTrackInterface* audio_track,
uint32_t ssrc) { uint32_t ssrc) {
RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent()); RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
RTC_DCHECK(audio_track != NULL); RTC_DCHECK(audio_track != NULL);
#if RTC_DCHECK_IS_ON #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
for (const auto& track : local_audio_tracks_) for (const auto& track : local_audio_tracks_)
RTC_DCHECK(track.first != audio_track || track.second != ssrc); RTC_DCHECK(track.first != audio_track || track.second != ssrc);
#endif #endif

View File

@ -276,7 +276,7 @@ bool StatsReport::Value::Equals(const Value& other) const {
case kFloat: case kFloat:
return value_.float_ == other.value_.float_; return value_.float_ == other.value_.float_;
case kStaticString: { case kStaticString: {
#if RTC_DCHECK_IS_ON #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
if (value_.static_string_ != other.value_.static_string_) { if (value_.static_string_ != other.value_.static_string_) {
RTC_DCHECK(strcmp(value_.static_string_, other.value_.static_string_) != RTC_DCHECK(strcmp(value_.static_string_, other.value_.static_string_) !=
0) 0)
@ -306,7 +306,7 @@ bool StatsReport::Value::operator==(const char* value) const {
return value_.string_->compare(value) == 0; return value_.string_->compare(value) == 0;
if (type_ != kStaticString) if (type_ != kStaticString)
return false; return false;
#if RTC_DCHECK_IS_ON #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
if (value_.static_string_ != value) if (value_.static_string_ != value)
RTC_DCHECK(strcmp(value_.static_string_, value) != 0) RTC_DCHECK(strcmp(value_.static_string_, value) != 0)
<< "Duplicate global?"; << "Duplicate global?";

View File

@ -349,7 +349,7 @@ class BufferT {
// Called when *this has been moved from. Conceptually it's a no-op, but we // Called when *this has been moved from. Conceptually it's a no-op, but we
// can mutate the state slightly to help subsequent sanity checks catch bugs. // can mutate the state slightly to help subsequent sanity checks catch bugs.
void OnMovedFrom() { void OnMovedFrom() {
#if RTC_DCHECK_IS_ON #ifdef NDEBUG
// Make *this consistent and empty. Shouldn't be necessary, but better safe // Make *this consistent and empty. Shouldn't be necessary, but better safe
// than sorry. // than sorry.
size_ = 0; size_ = 0;

View File

@ -13,10 +13,7 @@
#include "webrtc/typedefs.h" #include "webrtc/typedefs.h"
// If you for some reson need to know if DCHECKs are on, test the value of #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
// RTC_DCHECK_IS_ON. (Test its value, not if it's defined; it'll always be
// defined, to either a true or a false value.)
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
#define RTC_DCHECK_IS_ON 1 #define RTC_DCHECK_IS_ON 1
#else #else
#define RTC_DCHECK_IS_ON 0 #define RTC_DCHECK_IS_ON 0
@ -93,9 +90,9 @@ namespace rtc {
? static_cast<void>(0) \ ? static_cast<void>(0) \
: rtc::FatalMessageVoidify() & rtc::FatalMessage("", 0).stream() : rtc::FatalMessageVoidify() & rtc::FatalMessage("", 0).stream()
// RTC_CHECK dies with a fatal error if condition is not true. It is *not* // RTC_CHECK dies with a fatal error if condition is not true. It is *not*
// controlled by NDEBUG or anything else, so the check will be executed // controlled by NDEBUG, so the check will be executed regardless of
// regardless of compilation mode. // compilation mode.
// //
// We make sure RTC_CHECK et al. always evaluates their arguments, as // We make sure RTC_CHECK et al. always evaluates their arguments, as
// doing RTC_CHECK(FunctionWithSideEffect()) is a common idiom. // doing RTC_CHECK(FunctionWithSideEffect()) is a common idiom.

View File

@ -12,7 +12,6 @@
#define WEBRTC_BASE_CRITICALSECTION_H_ #define WEBRTC_BASE_CRITICALSECTION_H_
#include "webrtc/base/atomicops.h" #include "webrtc/base/atomicops.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/constructormagic.h" #include "webrtc/base/constructormagic.h"
#include "webrtc/base/thread_annotations.h" #include "webrtc/base/thread_annotations.h"
#include "webrtc/base/platform_thread_types.h" #include "webrtc/base/platform_thread_types.h"
@ -38,7 +37,11 @@
#include <dispatch/dispatch.h> #include <dispatch/dispatch.h>
#endif #endif
#define CS_DEBUG_CHECKS RTC_DCHECK_IS_ON #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
#define CS_DEBUG_CHECKS 1
#else
#define CS_DEBUG_CHECKS 0
#endif
#if CS_DEBUG_CHECKS #if CS_DEBUG_CHECKS
#define CS_DEBUG_CODE(x) x #define CS_DEBUG_CODE(x) x

View File

@ -12,9 +12,18 @@
#define WEBRTC_BASE_SEQUENCED_TASK_CHECKER_H_ #define WEBRTC_BASE_SEQUENCED_TASK_CHECKER_H_
// Apart from debug builds, we also enable the sequence checker in // Apart from debug builds, we also enable the sequence checker in
// builds with RTC_DCHECK_IS_ON so that trybots and waterfall bots // builds with DCHECK_ALWAYS_ON so that trybots and waterfall bots
// with this define will get the same level of checking as debug bots. // with this define will get the same level of checking as debug bots.
#define ENABLE_SEQUENCED_TASK_CHECKER RTC_DCHECK_IS_ON //
// Note that this does not perfectly match situations where RTC_DCHECK is
// enabled. For example a non-official release build may have
// DCHECK_ALWAYS_ON undefined (and therefore SequencedTaskChecker would be
// disabled) but have RTC_DCHECKs enabled at runtime.
#if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
#define ENABLE_SEQUENCED_TASK_CHECKER 1
#else
#define ENABLE_SEQUENCED_TASK_CHECKER 0
#endif
#include "webrtc/base/checks.h" #include "webrtc/base/checks.h"
#include "webrtc/base/constructormagic.h" #include "webrtc/base/constructormagic.h"

View File

@ -198,7 +198,7 @@ TEST(SequencedTaskCheckerTest, DetachFromTaskQueueAndUseOnThread) {
EXPECT_TRUE(done_event.Wait(1000)); EXPECT_TRUE(done_event.Wait(1000));
} }
#if RTC_DCHECK_IS_ON #if !defined(NDEBUG) || DCHECK_ALWAYS_ON
TEST(SequencedTaskCheckerTest, MethodNotAllowedOnDifferentThreadInDebug) { TEST(SequencedTaskCheckerTest, MethodNotAllowedOnDifferentThreadInDebug) {
RunMethodOnDifferentThread(false); RunMethodOnDifferentThread(false);
} }
@ -208,7 +208,7 @@ TEST(SequencedTaskCheckerTest, MethodAllowedOnDifferentThreadInRelease) {
} }
#endif #endif
#if RTC_DCHECK_IS_ON #if !defined(NDEBUG) || DCHECK_ALWAYS_ON
TEST(SequencedTaskCheckerTest, MethodNotAllowedOnDifferentTaskQueueInDebug) { TEST(SequencedTaskCheckerTest, MethodNotAllowedOnDifferentTaskQueueInDebug) {
RunMethodOnDifferentTaskQueue(false); RunMethodOnDifferentTaskQueue(false);
} }
@ -218,7 +218,7 @@ TEST(SequencedTaskCheckerTest, MethodAllowedOnDifferentTaskQueueInRelease) {
} }
#endif #endif
#if RTC_DCHECK_IS_ON #if !defined(NDEBUG) || DCHECK_ALWAYS_ON
TEST(SequencedTaskCheckerTest, DetachFromTaskQueueInDebug) { TEST(SequencedTaskCheckerTest, DetachFromTaskQueueInDebug) {
DetachThenCallFromDifferentTaskQueue(false); DetachThenCallFromDifferentTaskQueue(false);
} }

View File

@ -77,7 +77,7 @@ size_t asccpyn(wchar_t* buffer, size_t buflen,
} else if (srclen >= buflen) { } else if (srclen >= buflen) {
srclen = buflen - 1; srclen = buflen - 1;
} }
#if RTC_DCHECK_IS_ON #if !defined(NDEBUG)
// Double check that characters are not UTF-8 // Double check that characters are not UTF-8
for (size_t pos = 0; pos < srclen; ++pos) for (size_t pos = 0; pos < srclen; ++pos)
RTC_DCHECK_LT(static_cast<unsigned char>(source[pos]), 128); RTC_DCHECK_LT(static_cast<unsigned char>(source[pos]), 128);

View File

@ -14,10 +14,19 @@
#define WEBRTC_BASE_THREAD_CHECKER_H_ #define WEBRTC_BASE_THREAD_CHECKER_H_
// Apart from debug builds, we also enable the thread checker in // Apart from debug builds, we also enable the thread checker in
// builds with RTC_DCHECK_IS_ON so that trybots and waterfall bots // builds with DCHECK_ALWAYS_ON so that trybots and waterfall bots
// with this define will get the same level of thread checking as // with this define will get the same level of thread checking as
// debug bots. // debug bots.
#define ENABLE_THREAD_CHECKER RTC_DCHECK_IS_ON //
// Note that this does not perfectly match situations where RTC_DCHECK is
// enabled. For example a non-official release build may have
// DCHECK_ALWAYS_ON undefined (and therefore ThreadChecker would be
// disabled) but have RTC_DCHECKs enabled at runtime.
#if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
#define ENABLE_THREAD_CHECKER 1
#else
#define ENABLE_THREAD_CHECKER 0
#endif
#include "webrtc/base/checks.h" #include "webrtc/base/checks.h"
#include "webrtc/base/constructormagic.h" #include "webrtc/base/constructormagic.h"

View File

@ -21,7 +21,11 @@
// Duplicated from base/threading/thread_checker.h so that we can be // Duplicated from base/threading/thread_checker.h so that we can be
// good citizens there and undef the macro. // good citizens there and undef the macro.
#define ENABLE_THREAD_CHECKER RTC_DCHECK_IS_ON #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
#define ENABLE_THREAD_CHECKER 1
#else
#define ENABLE_THREAD_CHECKER 0
#endif
namespace rtc { namespace rtc {

View File

@ -29,7 +29,7 @@ void CheckValidInitParams(int src_sample_rate_hz, int dst_sample_rate_hz,
size_t num_channels) { size_t num_channels) {
// The below checks are temporarily disabled on WEBRTC_WIN due to problems // The below checks are temporarily disabled on WEBRTC_WIN due to problems
// with clang debug builds. // with clang debug builds.
#if !defined(WEBRTC_WIN) && defined(__clang__) #if !defined(WEBRTC_WIN) && defined(__clang__) && !defined(NDEBUG)
RTC_DCHECK_GT(src_sample_rate_hz, 0); RTC_DCHECK_GT(src_sample_rate_hz, 0);
RTC_DCHECK_GT(dst_sample_rate_hz, 0); RTC_DCHECK_GT(dst_sample_rate_hz, 0);
RTC_DCHECK_GT(num_channels, 0u); RTC_DCHECK_GT(num_channels, 0u);
@ -46,11 +46,11 @@ void CheckExpectedBufferSizes(size_t src_length,
// with clang debug builds. // with clang debug builds.
// TODO(tommi): Re-enable when we've figured out what the problem is. // TODO(tommi): Re-enable when we've figured out what the problem is.
// http://crbug.com/615050 // http://crbug.com/615050
#if !defined(WEBRTC_WIN) && defined(__clang__) #if !defined(WEBRTC_WIN) && defined(__clang__) && !defined(NDEBUG)
const size_t src_size_10ms = src_sample_rate * num_channels / 100; const size_t src_size_10ms = src_sample_rate * num_channels / 100;
const size_t dst_size_10ms = dst_sample_rate * num_channels / 100; const size_t dst_size_10ms = dst_sample_rate * num_channels / 100;
RTC_DCHECK_EQ(src_length, src_size_10ms); RTC_CHECK_EQ(src_length, src_size_10ms);
RTC_DCHECK_GE(dst_capacity, dst_size_10ms); RTC_CHECK_GE(dst_capacity, dst_size_10ms);
#endif #endif
} }
} }

View File

@ -118,7 +118,7 @@ enum {
// Helper for logging SCTP messages. // Helper for logging SCTP messages.
void DebugSctpPrintf(const char* format, ...) { void DebugSctpPrintf(const char* format, ...) {
#if RTC_DCHECK_IS_ON #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
char s[255]; char s[255];
va_list ap; va_list ap;
va_start(ap, format); va_start(ap, format);

View File

@ -317,8 +317,8 @@ TEST_F(AudioCodingModuleTestOldApi, VerifyOutputFrame) {
// with clang debug builds. // with clang debug builds.
// TODO(tommi): Re-enable when we've figured out what the problem is. // TODO(tommi): Re-enable when we've figured out what the problem is.
// http://crbug.com/615050 // http://crbug.com/615050
#if !defined(WEBRTC_WIN) && defined(__clang__) && RTC_DCHECK_IS_ON && \ #if !defined(WEBRTC_WIN) && defined(__clang__) && !defined(NDEBUG)
GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
TEST_F(AudioCodingModuleTestOldApi, FailOnZeroDesiredFrequency) { TEST_F(AudioCodingModuleTestOldApi, FailOnZeroDesiredFrequency) {
AudioFrame audio_frame; AudioFrame audio_frame;
bool muted; bool muted;
@ -326,6 +326,7 @@ TEST_F(AudioCodingModuleTestOldApi, FailOnZeroDesiredFrequency) {
"dst_sample_rate_hz"); "dst_sample_rate_hz");
} }
#endif #endif
#endif
// Checks that the transport callback is invoked once for each speech packet. // Checks that the transport callback is invoked once for each speech packet.
// Also checks that the frame type is kAudioFrameSpeech. // Also checks that the frame type is kAudioFrameSpeech.

View File

@ -141,7 +141,7 @@ int OpenSLESPlayer::StopPlayout() {
RETURN_ON_ERROR((*player_)->SetPlayState(player_, SL_PLAYSTATE_STOPPED), -1); RETURN_ON_ERROR((*player_)->SetPlayState(player_, SL_PLAYSTATE_STOPPED), -1);
// Clear the buffer queue to flush out any remaining data. // Clear the buffer queue to flush out any remaining data.
RETURN_ON_ERROR((*simple_buffer_queue_)->Clear(simple_buffer_queue_), -1); RETURN_ON_ERROR((*simple_buffer_queue_)->Clear(simple_buffer_queue_), -1);
#if RTC_DCHECK_IS_ON #ifndef NDEBUG
// Verify that the buffer queue is in fact cleared as it should. // Verify that the buffer queue is in fact cleared as it should.
SLAndroidSimpleBufferQueueState buffer_queue_state; SLAndroidSimpleBufferQueueState buffer_queue_state;
(*simple_buffer_queue_)->GetState(simple_buffer_queue_, &buffer_queue_state); (*simple_buffer_queue_)->GetState(simple_buffer_queue_, &buffer_queue_state);

View File

@ -133,7 +133,7 @@ void ProcessThreadImpl::RegisterModule(Module* module) {
RTC_DCHECK(thread_checker_.CalledOnValidThread()); RTC_DCHECK(thread_checker_.CalledOnValidThread());
RTC_DCHECK(module); RTC_DCHECK(module);
#if RTC_DCHECK_IS_ON #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
{ {
// Catch programmer error. // Catch programmer error.
rtc::CritScope lock(&lock_); rtc::CritScope lock(&lock_);