Skip to content

Commit 0a6c9cf

Browse files
committed
Aligning usage of DBUG_OFF and DBUG_ASSERT with Server.
Server Change: - Commit: 008c81cb8a19328744ce5f2f87d956440ac8600c - Summary: Replace DBUG_OFF with NDEBUG, and DBUG_ASSERT() with assert(). - Reason: Bug #32216281: REMOVE DBUG_OFF AND DBUG_ASSERT 008c81cb8a19328744ce5f2f87d956440ac8600c Change-Id: I3d90c0b00f0a74869c88fca969b4900cd25c6a5a
1 parent f9a6e94 commit 0a6c9cf

File tree

10 files changed

+28
-28
lines changed

10 files changed

+28
-28
lines changed

CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -577,10 +577,10 @@ IF(WIN32)
577577
ENDIF()
578578
ENDIF()
579579

580-
# Set DBUG_OFF for non-debug project types.
580+
# Set NDEBUG for non-debug project types.
581581
FOREACH(BUILD_TYPE RELEASE RELWITHDEBINFO MINSIZEREL)
582582
FOREACH(LANG C CXX)
583-
SET(CMAKE_${LANG}_FLAGS_${BUILD_TYPE} "${CMAKE_${LANG}_FLAGS_${BUILD_TYPE}} -DDBUG_OFF ")
583+
SET(CMAKE_${LANG}_FLAGS_${BUILD_TYPE} "${CMAKE_${LANG}_FLAGS_${BUILD_TYPE}} -DNDEBUG ")
584584
ENDFOREACH()
585585
ENDFOREACH()
586586

@@ -589,8 +589,8 @@ IF(NOT CMAKE_BUILD_TYPE
589589
AND NOT CMAKE_GENERATOR MATCHES "Xcode")
590590
# This is the case of no CMAKE_BUILD_TYPE choosen, typical for VS and Xcode
591591
# or if custom C flags are set. In VS and Xcode for non-Debug configurations
592-
# DBUG_OFF is already correctly set.
593-
ADD_DEFINITIONS(-DDBUG_OFF)
592+
# NDEBUG is already correctly set.
593+
ADD_DEFINITIONS(-DNDEBUG)
594594
ENDIF()
595595

596596
# Includes common to the whole project

cmake/FindMySQL.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- indent-tabs-mode:nil; -*-
22
# vim: set expandtab:
33
#
4-
# Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
4+
# Copyright (c) 2008, 2020, Oracle and/or its affiliates.
55
#
66
# This program is free software; you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License, version 2.0,
@@ -180,7 +180,7 @@ if(CMAKE_BUILD_TYPE STREQUAL Debug)
180180
else()
181181
set(_lib_suffix_dist opt)
182182
set(_lib_suffix_build Release)
183-
add_definitions(-DDBUG_OFF) # FIXME what?!
183+
add_definitions(-DNDEBUG) # FIXME what?!
184184
endif()
185185

186186
set(_exe_fallback_path

modules/adminapi/common/instance_pool.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ std::shared_ptr<Instance> Instance_pool::connect_unchecked(
631631

632632
const Cluster_metadata *cluster =
633633
m_mdcache->try_get_cluster(node->cluster_id);
634-
DBUG_ASSERT(cluster);
634+
assert(cluster);
635635
if (!cluster) {
636636
throw shcore::Exception::logic_error("Invalid node " + node->label);
637637
}
@@ -714,7 +714,7 @@ std::shared_ptr<Instance> Instance_pool::connect_primary(
714714

715715
const Cluster_metadata *cluster =
716716
m_mdcache->try_get_cluster(node->cluster_id);
717-
DBUG_ASSERT(cluster);
717+
assert(cluster);
718718
if (!cluster) {
719719
throw shcore::Exception::logic_error("Invalid cluster " + node->label);
720720
}

modules/adminapi/common/star_global_topology_manager.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#include "modules/adminapi/common/star_global_topology_manager.h"
3232

33+
#include <assert.h>
3334
#include <list>
3435
#include <numeric>
3536
#include <string>
@@ -40,7 +41,6 @@
4041
#include "modules/adminapi/common/global_topology_check.h"
4142
#include "modules/adminapi/common/instance_pool.h"
4243
#include "modules/adminapi/common/validations.h"
43-
#include "my_dbug.h"
4444
#include "mysqlshdk/include/scripting/types.h"
4545
#include "mysqlshdk/include/shellcore/console.h"
4646
#include "mysqlshdk/libs/mysql/async_replication.h"
@@ -555,7 +555,7 @@ void Star_global_topology_manager::validate_active_unavailable() {
555555
// Find the primary master cluster according to the MD
556556
primary_master = m_topology->get_primary_master_node();
557557

558-
DBUG_ASSERT(primary_master);
558+
assert(primary_master);
559559

560560
log_info("Status of PRIMARY node %s is %s", primary_master->label.c_str(),
561561
to_string(primary_master->status()).c_str());

mysqlshdk/libs/utils/debug.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2020, Oracle and/or its affiliates.
33
*
44
* This program is free software; you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License, version 2.0,
@@ -196,7 +196,7 @@ bool debug_object_dump_report(bool verbose);
196196

197197
// Right now, this is in mysql-trunk only, remove once DBUG_TRACE hits
198198
// our target branch
199-
#if !defined(DBUG_PRETTY_FUNCTION) && !defined(DBUG_OFF)
199+
#if !defined(DBUG_PRETTY_FUNCTION) && !defined(NDEBUG)
200200

201201
#if defined(__GNUC__)
202202
// GCC, Clang, and compatible compilers.
@@ -260,7 +260,7 @@ class AutoDebugTrace {
260260

261261
#endif
262262

263-
#if !defined(DBUG_OFF)
263+
#if !defined(NDEBUG)
264264

265265
// workaround for BUG30071277
266266

@@ -276,6 +276,6 @@ class AutoDebugTrace {
276276
} \
277277
} while (0)
278278

279-
#endif // !DBUG_OFF
279+
#endif // !NDEBUG
280280

281281
#endif // MYSQLSHDK_LIBS_UTILS_DEBUG_H_

mysqlshdk/libs/utils/fault_injection.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ void FI::trigger_trap(Type_id type, const Trap_options &input) {
248248

249249
void FI::set_trap(const std::string &type, const Conditions &conds,
250250
const Trap_options &options) {
251-
#ifdef DBUG_OFF
251+
#ifdef NDEBUG
252252
throw std::logic_error("FI not enabled in this build");
253253
#endif
254254
bool flag = false;

mysqlshdk/libs/utils/fault_injection.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ namespace utils {
5252
*
5353
* An injector is a custom routine that executes a custom action, like throwing
5454
* an exception or calling abort(). That can be done with the FI_DEFINE()
55-
* macro, which is only enabled if DBUG_OFF is NOT defined.
55+
* macro, which is only enabled if NDEBUG is NOT defined.
5656
*
5757
* These injectors must then be invoked by the code to be tested (e.g. right
5858
* before SQL is executed, to simulate client or server DB errors) by using
@@ -194,7 +194,7 @@ class FI {
194194
* context, which should be used to trigger faults.
195195
*
196196
* Use the FI_DEFINE() macro instead of calling directly, which becomes
197-
* a no-op in DBUG_OFF builds.
197+
* a no-op in NDEBUG builds.
198198
*/
199199
static Type_id add_injector(const std::string &type,
200200
const std::function<void(const Args &)> &handler);
@@ -205,7 +205,7 @@ class FI {
205205
* This function may not return.
206206
*
207207
* Use the FI_TRIGGER_TRAP() macro instead of calling directly, which becomes
208-
* a no-op in DBUG_OFF builds.
208+
* a no-op in NDEBUG builds.
209209
*/
210210
static void trigger_trap(Type_id type, const Trigger_options &input);
211211

@@ -229,7 +229,7 @@ class FI {
229229
static void reset_traps(const std::string &type = "");
230230
};
231231

232-
#ifdef DBUG_OFF
232+
#ifdef NDEBUG
233233

234234
#define FI_DEFINE(type, injector) struct dummy_fi_##type
235235

mysqlshdk/shellcore/shell_options.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2020, Oracle and/or its affiliates.
33
*
44
* This program is free software; you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License, version 2.0,
@@ -566,7 +566,7 @@ Shell_options::Shell_options(int argc, char **argv,
566566
})
567567
(cmdline("--debug=<control>"),
568568
[this](const std::string &, const char* value) {
569-
#ifdef DBUG_OFF
569+
#ifdef NDEBUG
570570
// If DBUG is disabled, we just print a warning saying the option won't
571571
// do anything. This is to keep options compatible between build types
572572
std::cout << "WARNING: This build of mysqlsh has the DBUG feature "

unittest/shell_script_tester.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1661,7 +1661,7 @@ void Shell_script_tester::set_defaults() {
16611661
def_var("__with_oci", "0");
16621662
#endif
16631663

1664-
#ifdef DBUG_OFF
1664+
#ifdef NDEBUG
16651665
// TODO(.) - remove __dbug_off and replace all uses with __dbug
16661666
def_var("__dbug_off", "1");
16671667
// dbug tests should only run in direct mode, so that traces aren't affected

unittest/test_utils/mod_testutils.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -373,11 +373,11 @@ void Testutils::bp(bool flag) {
373373
void Testutils::set_trap(const std::string &type,
374374
const shcore::Array_t &conditions,
375375
const shcore::Dictionary_t &options) {
376-
#ifdef DBUG_OFF
376+
#ifdef NDEBUG
377377
(void)type;
378378
(void)conditions;
379379
(void)options;
380-
throw std::logic_error("set_trap() not available in DBUG_OFF builds");
380+
throw std::logic_error("set_trap() not available in NDEBUG builds");
381381
#else
382382
mysqlshdk::utils::FI::Conditions conds;
383383

@@ -399,18 +399,18 @@ void Testutils::set_trap(const std::string &type,
399399
}
400400

401401
void Testutils::clear_traps(const std::string &type) {
402-
#ifdef DBUG_OFF
402+
#ifdef NDEBUG
403403
(void)type;
404-
throw std::logic_error("clear_traps() not available in DBUG_OFF builds");
404+
throw std::logic_error("clear_traps() not available in NDEBUG builds");
405405
#else
406406
mysqlshdk::utils::FI::clear_traps(type);
407407
#endif
408408
}
409409

410410
void Testutils::reset_traps(const std::string &type) {
411-
#ifdef DBUG_OFF
411+
#ifdef NDEBUG
412412
(void)type;
413-
throw std::logic_error("reset_traps() not available in DBUG_OFF builds");
413+
throw std::logic_error("reset_traps() not available in NDEBUG builds");
414414
#else
415415
mysqlshdk::utils::FI::reset_traps(type);
416416
#endif

0 commit comments

Comments
 (0)