From 97168378e889e68c2079728ebfddc09031881fe4 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Fri, 19 Dec 2014 12:19:28 +0100 Subject: [PATCH] Rename _DEBUG to I2_DEBUG fixes #7767 --- CMakeLists.txt | 6 ++---- icinga-app/icinga.cpp | 4 ++-- lib/base/application.cpp | 10 +++++----- lib/base/debug.hpp | 6 +++--- lib/base/dynamicobject.cpp | 4 ++-- lib/base/object.cpp | 8 ++++---- lib/base/object.hpp | 14 +++++++------- lib/base/objectlock.hpp | 8 ++++---- lib/base/threadpool.cpp | 8 ++++---- lib/cli/daemoncommand.cpp | 4 ++-- lib/cli/pkiutility.cpp | 4 ++-- lib/config/configitem.cpp | 12 ++++++------ lib/config/expression.cpp | 4 ++-- lib/icinga/checkable-comment.cpp | 4 ++-- lib/icinga/checkable-downtime.cpp | 4 ++-- lib/icinga/legacytimeperiod.cpp | 12 ++++++------ 16 files changed, 55 insertions(+), 57 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e8745758..31636cfe0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -149,10 +149,8 @@ if(NOT HAVE_COUNTER_MACRO AND ICINGA2_UNITY_BUILD) set(ICINGA2_UNITY_BUILD FALSE) endif() -if(NOT MSVC) - set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG") - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG") -endif() +set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DI2_DEBUG") +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DI2_DEBUG") check_function_exists(vfork HAVE_VFORK) check_function_exists(backtrace_symbols HAVE_BACKTRACE_SYMBOLS) diff --git a/icinga-app/icinga.cpp b/icinga-app/icinga.cpp index 1c360f52d..b58a6552c 100644 --- a/icinga-app/icinga.cpp +++ b/icinga-app/icinga.cpp @@ -277,9 +277,9 @@ int Main(void) std::cout << appName << " " << "- The Icinga 2 network monitoring daemon (version: " << ConsoleColorTag(vm.count("version") ? Console_ForegroundRed : Console_Normal) << Application::GetVersion() -#ifdef _DEBUG +#ifdef I2_DEBUG << "; debug" -#endif /* _DEBUG */ +#endif /* I2_DEBUG */ << ConsoleColorTag(Console_Normal) << ")" << std::endl << std::endl; diff --git a/lib/base/application.cpp b/lib/base/application.cpp index f8ddc33bd..b55f65d20 100644 --- a/lib/base/application.cpp +++ b/lib/base/application.cpp @@ -110,11 +110,11 @@ void Application::Exit(int rc) UninitializeBase(); -#ifdef _DEBUG +#ifdef I2_DEBUG exit(rc); -#else /* _DEBUG */ +#else /* I2_DEBUG */ _exit(rc); // Yay, our static destructors are pretty much beyond repair at this point. -#endif /* _DEBUG */ +#endif /* I2_DEBUG */ } void Application::InitializeBase(void) @@ -128,10 +128,10 @@ void Application::InitializeBase(void) maxfds = 65536; for (rlim_t i = 3; i < maxfds; i++) { -#ifdef _DEBUG +#ifdef I2_DEBUG if (close(i) >= 0) std::cerr << "Closed FD " << i << " which we inherited from our parent process." << std::endl; -#endif /* _DEBUG */ +#endif /* I2_DEBUG */ } } #endif /* _WIN32 */ diff --git a/lib/base/debug.hpp b/lib/base/debug.hpp index 82bfae40c..3b976b61d 100644 --- a/lib/base/debug.hpp +++ b/lib/base/debug.hpp @@ -22,11 +22,11 @@ #include "i2-base.hpp" -#ifndef _DEBUG +#ifndef I2_DEBUG # define ASSERT(expr) ((void)0) -#else /* _DEBUG */ +#else /* I2_DEBUG */ # define ASSERT(expr) ((expr) ? 0 : icinga_assert_fail(#expr, __FILE__, __LINE__)) -#endif /* _DEBUG */ +#endif /* I2_DEBUG */ #define VERIFY(expr) ((expr) ? 0 : icinga_assert_fail(#expr, __FILE__, __LINE__)) diff --git a/lib/base/dynamicobject.cpp b/lib/base/dynamicobject.cpp index 552b7e915..55438ee91 100644 --- a/lib/base/dynamicobject.cpp +++ b/lib/base/dynamicobject.cpp @@ -289,10 +289,10 @@ void DynamicObject::RestoreObject(const String& message, int attributeTypes) return; ASSERT(!object->IsActive()); -#ifdef _DEBUG +#ifdef I2_DEBUG Log(LogDebug, "DynamicObject") << "Restoring object '" << name << "' of type '" << type << "'."; -#endif /* _DEBUG */ +#endif /* I2_DEBUG */ Dictionary::Ptr update = persistentObject->Get("update"); Deserialize(object, update, false, attributeTypes); object->OnStateLoaded(); diff --git a/lib/base/object.cpp b/lib/base/object.cpp index 0da33c96e..f616b2e48 100644 --- a/lib/base/object.cpp +++ b/lib/base/object.cpp @@ -32,9 +32,9 @@ REGISTER_PRIMITIVE_TYPE(Object, Object::GetPrototype()); */ Object::Object(void) : m_References(0) -#ifdef _DEBUG +#ifdef I2_DEBUG , m_LockOwner(0) -#endif /* _DEBUG */ +#endif /* I2_DEBUG */ { } /** @@ -51,7 +51,7 @@ String Object::ToString(void) const return "Object of type '" + Utility::GetTypeName(typeid(*this)) + "'"; } -#ifdef _DEBUG +#ifdef I2_DEBUG /** * Checks if the calling thread owns the lock on this object. * @@ -69,7 +69,7 @@ bool Object::OwnsLock(void) const return (tid == pthread_self()); #endif /* _WIN32 */ } -#endif /* _DEBUG */ +#endif /* I2_DEBUG */ void Object::InflateMutex(void) { diff --git a/lib/base/object.hpp b/lib/base/object.hpp index d21907b22..f6a87d541 100644 --- a/lib/base/object.hpp +++ b/lib/base/object.hpp @@ -25,11 +25,11 @@ #include "base/thinmutex.hpp" #include -#ifndef _DEBUG +#ifndef I2_DEBUG #include -#else /* _DEBUG */ +#else /* I2_DEBUG */ #include -#endif /* _DEBUG */ +#endif /* I2_DEBUG */ #include @@ -98,9 +98,9 @@ public: virtual void SetField(int id, const Value& value); virtual Value GetField(int id) const; -#ifdef _DEBUG +#ifdef I2_DEBUG bool OwnsLock(void) const; -#endif /* _DEBUG */ +#endif /* I2_DEBUG */ void InflateMutex(void); @@ -113,13 +113,13 @@ private: uintptr_t m_References; mutable ThinMutex m_Mutex; -#ifdef _DEBUG +#ifdef I2_DEBUG # ifndef _WIN32 mutable pthread_t m_LockOwner; # else /* _WIN32 */ mutable DWORD m_LockOwner; # endif /* _WIN32 */ -#endif /* _DEBUG */ +#endif /* I2_DEBUG */ friend struct ObjectLock; diff --git a/lib/base/objectlock.hpp b/lib/base/objectlock.hpp index a98cfee15..36d7dac0c 100644 --- a/lib/base/objectlock.hpp +++ b/lib/base/objectlock.hpp @@ -61,18 +61,18 @@ public: m_Object->m_Mutex.Lock(); m_Locked = true; -#ifdef _DEBUG +#ifdef I2_DEBUG # ifdef _WIN32 InterlockedExchange(&m_Object->m_LockOwner, GetCurrentThreadId()); # else /* _WIN32 */ __sync_lock_test_and_set(&m_Object->m_LockOwner, pthread_self()); # endif /* _WIN32 */ -#endif /* _DEBUG */ +#endif /* I2_DEBUG */ } inline void Unlock(void) { -#ifdef _DEBUG +#ifdef I2_DEBUG if (m_Locked) { # ifdef _WIN32 InterlockedExchange(&m_Object->m_LockOwner, 0); @@ -80,7 +80,7 @@ public: __sync_lock_release(&m_Object->m_LockOwner); # endif /* _WIN32 */ } -#endif /* _DEBUG */ +#endif /* I2_DEBUG */ if (m_Locked) { m_Object->m_Mutex.Unlock(); diff --git a/lib/base/threadpool.cpp b/lib/base/threadpool.cpp index 941551c23..9dfff9bbe 100644 --- a/lib/base/threadpool.cpp +++ b/lib/base/threadpool.cpp @@ -117,13 +117,13 @@ void ThreadPool::WorkerThread::ThreadProc(Queue& queue) double st = Utility::GetTime();; -#ifdef _DEBUG +#ifdef I2_DEBUG # ifdef RUSAGE_THREAD struct rusage usage_start, usage_end; (void) getrusage(RUSAGE_THREAD, &usage_start); # endif /* RUSAGE_THREAD */ -#endif /* _DEBUG */ +#endif /* I2_DEBUG */ try { if (wi.Callback) @@ -147,7 +147,7 @@ void ThreadPool::WorkerThread::ThreadProc(Queue& queue) queue.TaskCount++; } -#ifdef _DEBUG +#ifdef I2_DEBUG # ifdef RUSAGE_THREAD (void) getrusage(RUSAGE_THREAD, &usage_end); @@ -173,7 +173,7 @@ void ThreadPool::WorkerThread::ThreadProc(Queue& queue) << "Event call took " << (et - st) << "s"; # endif /* RUSAGE_THREAD */ } -#endif /* _DEBUG */ +#endif /* I2_DEBUG */ } boost::mutex::scoped_lock lock(queue.Mutex); diff --git a/lib/cli/daemoncommand.cpp b/lib/cli/daemoncommand.cpp index 1ef46a639..e8be7ea72 100644 --- a/lib/cli/daemoncommand.cpp +++ b/lib/cli/daemoncommand.cpp @@ -319,9 +319,9 @@ int DaemonCommand::Run(const po::variables_map& vm, const std::vectorContains("error")) { Log(LogCritical, "cli", "Could not fetch valid response. Please check the master log (notice or debug)."); -#ifdef _DEBUG +#ifdef I2_DEBUG /* we shouldn't expose master errors to the user in production environments */ Log(LogCritical, "cli", response->Get("error")); -#endif /* _DEBUG */ +#endif /* I2_DEBUG */ return 1; } diff --git a/lib/config/configitem.cpp b/lib/config/configitem.cpp index 6e6352977..81f699ecc 100644 --- a/lib/config/configitem.cpp +++ b/lib/config/configitem.cpp @@ -142,10 +142,10 @@ DynamicObject::Ptr ConfigItem::Commit(bool discard) { ASSERT(!OwnsLock()); -#ifdef _DEBUG +#ifdef I2_DEBUG Log(LogDebug, "ConfigItem") << "Commit called for ConfigItem Type=" << GetType() << ", Name=" << GetName(); -#endif /* _DEBUG */ +#endif /* I2_DEBUG */ /* Make sure the type is valid. */ Type::Ptr type = Type::GetByName(GetType()); @@ -369,23 +369,23 @@ bool ConfigItem::ActivateItems(void) if (object->IsActive()) continue; -#ifdef _DEBUG +#ifdef I2_DEBUG Log(LogDebug, "ConfigItem") << "Activating object '" << object->GetName() << "' of type '" << object->GetType()->GetName() << "'"; -#endif /* _DEBUG */ +#endif /* I2_DEBUG */ upq.Enqueue(boost::bind(&DynamicObject::Activate, object)); } } upq.Join(); -#ifdef _DEBUG +#ifdef I2_DEBUG BOOST_FOREACH(const DynamicType::Ptr& type, DynamicType::GetTypes()) { BOOST_FOREACH(const DynamicObject::Ptr& object, type->GetObjects()) { ASSERT(object->IsActive()); } } -#endif /* _DEBUG */ +#endif /* I2_DEBUG */ Log(LogInformation, "ConfigItem", "Activated all objects."); diff --git a/lib/config/expression.cpp b/lib/config/expression.cpp index 1ff32298c..ce3bc2f2b 100644 --- a/lib/config/expression.cpp +++ b/lib/config/expression.cpp @@ -38,12 +38,12 @@ Expression::~Expression(void) Value Expression::Evaluate(ScriptFrame& frame, DebugHint *dhint) const { try { -#ifdef _DEBUG +#ifdef I2_DEBUG /* std::ostringstream msgbuf; ShowCodeFragment(msgbuf, GetDebugInfo(), false); Log(LogDebug, "Expression") << "Executing:\n" << msgbuf.str();*/ -#endif /* _DEBUG */ +#endif /* I2_DEBUG */ return DoEvaluate(frame, dhint); } catch (const InterruptExecutionError&) { diff --git a/lib/icinga/checkable-comment.cpp b/lib/icinga/checkable-comment.cpp index 7a94a6a42..37c837fce 100644 --- a/lib/icinga/checkable-comment.cpp +++ b/lib/icinga/checkable-comment.cpp @@ -165,9 +165,9 @@ Comment::Ptr Checkable::GetCommentByID(const String& id) void Checkable::AddCommentsToCache(void) { -#ifdef _DEBUG +#ifdef I2_DEBUG Log(LogDebug, "Checkable", "Updating Checkable comments cache."); -#endif /* _DEBUG */ +#endif /* I2_DEBUG */ Dictionary::Ptr comments = GetComments(); diff --git a/lib/icinga/checkable-downtime.cpp b/lib/icinga/checkable-downtime.cpp index 782c251db..a43118579 100644 --- a/lib/icinga/checkable-downtime.cpp +++ b/lib/icinga/checkable-downtime.cpp @@ -251,9 +251,9 @@ void Checkable::StartDowntimesExpiredTimer(void) void Checkable::AddDowntimesToCache(void) { -#ifdef _DEBUG +#ifdef I2_DEBUG Log(LogDebug, "Checkable", "Updating Checkable downtimes cache."); -#endif /* _DEBUG */ +#endif /* I2_DEBUG */ Dictionary::Ptr downtimes = GetDowntimes(); diff --git a/lib/icinga/legacytimeperiod.cpp b/lib/icinga/legacytimeperiod.cpp index d8a6f0f56..fa58c100f 100644 --- a/lib/icinga/legacytimeperiod.cpp +++ b/lib/icinga/legacytimeperiod.cpp @@ -452,25 +452,25 @@ Array::Ptr LegacyTimePeriod::ScriptFunc(const TimePeriod::Ptr& tp, double begin, time_t refts = begin + i * 24 * 60 * 60; tm reference = Utility::LocalTime(refts); -#ifdef _DEBUG +#ifdef I2_DEBUG Log(LogDebug, "LegacyTimePeriod") << "Checking reference time " << refts; -#endif /* _DEBUG */ +#endif /* I2_DEBUG */ ObjectLock olock(ranges); BOOST_FOREACH(const Dictionary::Pair& kv, ranges) { if (!IsInDayDefinition(kv.first, &reference)) { -#ifdef _DEBUG +#ifdef I2_DEBUG Log(LogDebug, "LegacyTimePeriod") << "Not in day definition '" << kv.first << "'."; -#endif /* _DEBUG */ +#endif /* I2_DEBUG */ continue; } -#ifdef _DEBUG +#ifdef I2_DEBUG Log(LogDebug, "LegacyTimePeriod") << "In day definition '" << kv.first << "'."; -#endif /* _DEBUG */ +#endif /* I2_DEBUG */ ProcessTimeRanges(kv.second, &reference, segments); } -- 2.40.0