Skip to content

Commit 9f2a20f

Browse files
MirkoBonadeiWebRTC LUCI CQ
authored andcommitted
Add WebRTC specific dcheck_always_on.
Inspired by V8 CL: crrev.com/c/3038528. This makes the WebRTC's dcheck control independent of Chromium's and prepares switching Chromium's default behavior without affecting WebRTC developers or builders. Preparation for: https://crrev.com/c/2893204 Bug: chromium:1225701, webrtc:12988 Change-Id: Ia0d21f9fb8e9d7704fd1beca16504c301a263b3b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226465 Commit-Queue: Mirko Bonadei <[email protected]> Reviewed-by: Markus Handell <[email protected]> Reviewed-by: Dirk Pranke <[email protected]> Cr-Commit-Position: refs/heads/master@{#34512}
1 parent 3b35fbc commit 9f2a20f

File tree

9 files changed

+32
-20
lines changed

9 files changed

+32
-20
lines changed

BUILD.gn

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,10 @@ config("common_config") {
252252
cflags_objc = []
253253
defines = []
254254

255+
if (rtc_dcheck_always_on) {
256+
defines += [ "RTC_DCHECK_ALWAYS_ON" ]
257+
}
258+
255259
if (rtc_enable_protobuf) {
256260
defines += [ "WEBRTC_ENABLE_PROTOBUF=1" ]
257261
} else {

rtc_base/checks.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// If you for some reson need to know if DCHECKs are on, test the value of
1515
// RTC_DCHECK_IS_ON. (Test its value, not if it's defined; it'll always be
1616
// defined, to either a true or a false value.)
17-
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
17+
#if !defined(NDEBUG) || defined(RTC_DCHECK_ALWAYS_ON)
1818
#define RTC_DCHECK_IS_ON 1
1919
#else
2020
#define RTC_DCHECK_IS_ON 0

rtc_base/thread.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,7 @@ void Thread::QueuedTaskHandler::OnMessage(Message* msg) {
10441044
}
10451045

10461046
void Thread::AllowInvokesToThread(Thread* thread) {
1047-
#if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
1047+
#if (!defined(NDEBUG) || defined(RTC_DCHECK_ALWAYS_ON))
10481048
if (!IsCurrent()) {
10491049
PostTask(webrtc::ToQueuedTask(
10501050
[thread, this]() { AllowInvokesToThread(thread); }));
@@ -1057,7 +1057,7 @@ void Thread::AllowInvokesToThread(Thread* thread) {
10571057
}
10581058

10591059
void Thread::DisallowAllInvokes() {
1060-
#if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
1060+
#if (!defined(NDEBUG) || defined(RTC_DCHECK_ALWAYS_ON))
10611061
if (!IsCurrent()) {
10621062
PostTask(webrtc::ToQueuedTask([this]() { DisallowAllInvokes(); }));
10631063
return;
@@ -1082,7 +1082,7 @@ uint32_t Thread::GetCouldBeBlockingCallCount() const {
10821082
// Returns true if no policies added or if there is at least one policy
10831083
// that permits invocation to |target| thread.
10841084
bool Thread::IsInvokeToThreadAllowed(rtc::Thread* target) {
1085-
#if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
1085+
#if (!defined(NDEBUG) || defined(RTC_DCHECK_ALWAYS_ON))
10861086
RTC_DCHECK_RUN_ON(this);
10871087
if (!invoke_policy_enabled_) {
10881088
return true;

rtc_base/thread.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,15 +400,17 @@ class RTC_LOCKABLE RTC_EXPORT Thread : public webrtc::TaskQueueBase {
400400

401401
// Allows invoke to specified |thread|. Thread never will be dereferenced and
402402
// will be used only for reference-based comparison, so instance can be safely
403-
// deleted. If NDEBUG is defined and DCHECK_ALWAYS_ON is undefined do nothing.
403+
// deleted. If NDEBUG is defined and RTC_DCHECK_ALWAYS_ON is undefined do
404+
// nothing.
404405
void AllowInvokesToThread(Thread* thread);
405406

406-
// If NDEBUG is defined and DCHECK_ALWAYS_ON is undefined do nothing.
407+
// If NDEBUG is defined and RTC_DCHECK_ALWAYS_ON is undefined do nothing.
407408
void DisallowAllInvokes();
408409
// Returns true if |target| was allowed by AllowInvokesToThread() or if no
409410
// calls were made to AllowInvokesToThread and DisallowAllInvokes. Otherwise
410411
// returns false.
411-
// If NDEBUG is defined and DCHECK_ALWAYS_ON is undefined always returns true.
412+
// If NDEBUG is defined and RTC_DCHECK_ALWAYS_ON is undefined always returns
413+
// true.
412414
bool IsInvokeToThreadAllowed(rtc::Thread* target);
413415

414416
// Posts a task to invoke the functor on |this| thread asynchronously, i.e.

rtc_base/thread_unittest.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ TEST(ThreadTest, Wrap) {
366366
ThreadManager::Instance()->SetCurrentThread(current_thread);
367367
}
368368

369-
#if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
369+
#if (!defined(NDEBUG) || defined(RTC_DCHECK_ALWAYS_ON))
370370
TEST(ThreadTest, InvokeToThreadAllowedReturnsTrueWithoutPolicies) {
371371
// Create and start the thread.
372372
auto thread1 = Thread::CreateWithSocketServer();
@@ -410,7 +410,7 @@ TEST(ThreadTest, InvokesDisallowedWhenDisallowAllInvokes) {
410410
Thread* th_main = Thread::Current();
411411
th_main->ProcessMessages(100);
412412
}
413-
#endif // (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
413+
#endif // (!defined(NDEBUG) || defined(RTC_DCHECK_ALWAYS_ON))
414414

415415
TEST(ThreadTest, InvokesAllowedByDefault) {
416416
// Create and start the thread.

tools_webrtc/coverage/generate_ios_coverage_command.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def GetGNArgs(is_simulator):
8989
target_cpu = 'x64' if is_simulator else 'arm64'
9090
return ([] + ['target_os="ios"'] + ['target_cpu="%s"' % target_cpu] +
9191
['use_clang_coverage=true'] + ['is_component_build=false'] +
92-
['dcheck_always_on=true'])
92+
['rtc_dcheck_always_on=true'])
9393

9494

9595
def GenerateIOSSimulatorCommand():
@@ -103,7 +103,7 @@ def GenerateIOSSimulatorCommand():
103103
[FormatIossimTest(t, is_xctest=True) for t in XC_TESTS] +
104104
[FormatIossimTest(t, is_xctest=False) for t in TESTS])
105105

106-
print 'To get code coverage using iOS simulator just run following commands:'
106+
print 'To get code coverage using iOS sim just run following commands:'
107107
print ''
108108
print ' '.join(gn_cmd)
109109
print ''

tools_webrtc/mb/docs/user_guide.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ For example, if you had:
248248
}
249249
'mixins': {
250250
'bot': {
251-
'gyp_defines': 'use_goma=1 dcheck_always_on=0',
252-
'gn_args': 'use_goma=true dcheck_always_on=false',
251+
'gyp_defines': 'use_goma=1 rtc_dcheck_always_on=0',
252+
'gn_args': 'use_goma=true rtc_dcheck_always_on=false',
253253
},
254254
'debug': {
255255
'gn_args': 'is_debug=true',
@@ -267,16 +267,16 @@ For example, if you had:
267267
'gyp_defines': 'component=shared_library',
268268
},
269269
'trybot': {
270-
'gyp_defines': 'dcheck_always_on=1',
271-
'gn_args': 'dcheck_always_on=true',
270+
'gyp_defines': 'rtc_dcheck_always_on=1',
271+
'gn_args': 'rtc_dcheck_always_on=true',
272272
}
273273
}
274274
}
275275
```
276276

277277
and you ran `mb gen -c linux_release_trybot //out/Release`, it would
278278
translate into a call to `gyp_chromium -G Release` with `GYP_DEFINES` set to
279-
`"use_goma=true dcheck_always_on=false dcheck_always_on=true"`.
279+
`"use_goma=true rtc_dcheck_always_on=false rtc_dcheck_always_on=true"`.
280280

281281
(From that you can see that mb is intentionally dumb and does not
282282
attempt to de-dup the flags, it lets gyp do that).

tools_webrtc/mb/mb_config.pyl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,8 @@
459459
'gn_args': 'is_clang=true',
460460
},
461461

462-
'dcheck_always_on': {
463-
'gn_args': 'dcheck_always_on=true',
462+
'rtc_dcheck_always_on': {
463+
'gn_args': 'rtc_dcheck_always_on=true',
464464
},
465465

466466
'debug': {
@@ -548,11 +548,11 @@
548548
},
549549

550550
'release_bot': {
551-
'mixins': ['pure_release_bot', 'dcheck_always_on'],
551+
'mixins': ['pure_release_bot', 'rtc_dcheck_always_on'],
552552
},
553553

554554
'release_bot_no_goma': {
555-
'mixins': ['release', 'no_goma', 'dcheck_always_on'],
555+
'mixins': ['release', 'no_goma', 'rtc_dcheck_always_on'],
556556
},
557557

558558
'tsan': {

webrtc.gni

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# in the file PATENTS. All contributing project authors may
77
# be found in the AUTHORS file in the root of the source tree.
88
import("//build/config/arm.gni")
9+
import("//build/config/dcheck_always_on.gni")
910
import("//build/config/features.gni")
1011
import("//build/config/mips.gni")
1112
import("//build/config/sanitizers/sanitizers.gni")
@@ -36,6 +37,11 @@ if (is_mac) {
3637
}
3738

3839
declare_args() {
40+
# Separate control for dchecks in V8. Defaults to Chromium's behavior if
41+
# built with Chromium.
42+
# When set to true, it will enable RTC_DCHECK() also in Release builds.
43+
rtc_dcheck_always_on = build_with_chromium && dcheck_always_on
44+
3945
# Setting this to true will make RTC_EXPORT (see rtc_base/system/rtc_export.h)
4046
# expand to code that will manage symbols visibility.
4147
rtc_enable_symbol_export = false

0 commit comments

Comments
 (0)