Rename _DEBUG to I2_DEBUG

fixes #7767
This commit is contained in:
Gunnar Beutner 2014-12-19 12:19:28 +01:00
parent 28d7051aed
commit 97168378e8
16 changed files with 55 additions and 57 deletions

View File

@ -149,10 +149,8 @@ if(NOT HAVE_COUNTER_MACRO AND ICINGA2_UNITY_BUILD)
set(ICINGA2_UNITY_BUILD FALSE) set(ICINGA2_UNITY_BUILD FALSE)
endif() endif()
if(NOT MSVC) set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DI2_DEBUG")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DI2_DEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
endif()
check_function_exists(vfork HAVE_VFORK) check_function_exists(vfork HAVE_VFORK)
check_function_exists(backtrace_symbols HAVE_BACKTRACE_SYMBOLS) check_function_exists(backtrace_symbols HAVE_BACKTRACE_SYMBOLS)

View File

@ -277,9 +277,9 @@ int Main(void)
std::cout << appName << " " << "- The Icinga 2 network monitoring daemon (version: " std::cout << appName << " " << "- The Icinga 2 network monitoring daemon (version: "
<< ConsoleColorTag(vm.count("version") ? Console_ForegroundRed : Console_Normal) << ConsoleColorTag(vm.count("version") ? Console_ForegroundRed : Console_Normal)
<< Application::GetVersion() << Application::GetVersion()
#ifdef _DEBUG #ifdef I2_DEBUG
<< "; debug" << "; debug"
#endif /* _DEBUG */ #endif /* I2_DEBUG */
<< ConsoleColorTag(Console_Normal) << ConsoleColorTag(Console_Normal)
<< ")" << std::endl << std::endl; << ")" << std::endl << std::endl;

View File

@ -110,11 +110,11 @@ void Application::Exit(int rc)
UninitializeBase(); UninitializeBase();
#ifdef _DEBUG #ifdef I2_DEBUG
exit(rc); exit(rc);
#else /* _DEBUG */ #else /* I2_DEBUG */
_exit(rc); // Yay, our static destructors are pretty much beyond repair at this point. _exit(rc); // Yay, our static destructors are pretty much beyond repair at this point.
#endif /* _DEBUG */ #endif /* I2_DEBUG */
} }
void Application::InitializeBase(void) void Application::InitializeBase(void)
@ -128,10 +128,10 @@ void Application::InitializeBase(void)
maxfds = 65536; maxfds = 65536;
for (rlim_t i = 3; i < maxfds; i++) { for (rlim_t i = 3; i < maxfds; i++) {
#ifdef _DEBUG #ifdef I2_DEBUG
if (close(i) >= 0) if (close(i) >= 0)
std::cerr << "Closed FD " << i << " which we inherited from our parent process." << std::endl; std::cerr << "Closed FD " << i << " which we inherited from our parent process." << std::endl;
#endif /* _DEBUG */ #endif /* I2_DEBUG */
} }
} }
#endif /* _WIN32 */ #endif /* _WIN32 */

View File

@ -22,11 +22,11 @@
#include "i2-base.hpp" #include "i2-base.hpp"
#ifndef _DEBUG #ifndef I2_DEBUG
# define ASSERT(expr) ((void)0) # define ASSERT(expr) ((void)0)
#else /* _DEBUG */ #else /* I2_DEBUG */
# define ASSERT(expr) ((expr) ? 0 : icinga_assert_fail(#expr, __FILE__, __LINE__)) # 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__)) #define VERIFY(expr) ((expr) ? 0 : icinga_assert_fail(#expr, __FILE__, __LINE__))

View File

@ -289,10 +289,10 @@ void DynamicObject::RestoreObject(const String& message, int attributeTypes)
return; return;
ASSERT(!object->IsActive()); ASSERT(!object->IsActive());
#ifdef _DEBUG #ifdef I2_DEBUG
Log(LogDebug, "DynamicObject") Log(LogDebug, "DynamicObject")
<< "Restoring object '" << name << "' of type '" << type << "'."; << "Restoring object '" << name << "' of type '" << type << "'.";
#endif /* _DEBUG */ #endif /* I2_DEBUG */
Dictionary::Ptr update = persistentObject->Get("update"); Dictionary::Ptr update = persistentObject->Get("update");
Deserialize(object, update, false, attributeTypes); Deserialize(object, update, false, attributeTypes);
object->OnStateLoaded(); object->OnStateLoaded();

View File

@ -32,9 +32,9 @@ REGISTER_PRIMITIVE_TYPE(Object, Object::GetPrototype());
*/ */
Object::Object(void) Object::Object(void)
: m_References(0) : m_References(0)
#ifdef _DEBUG #ifdef I2_DEBUG
, m_LockOwner(0) , 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)) + "'"; return "Object of type '" + Utility::GetTypeName(typeid(*this)) + "'";
} }
#ifdef _DEBUG #ifdef I2_DEBUG
/** /**
* Checks if the calling thread owns the lock on this object. * Checks if the calling thread owns the lock on this object.
* *
@ -69,7 +69,7 @@ bool Object::OwnsLock(void) const
return (tid == pthread_self()); return (tid == pthread_self());
#endif /* _WIN32 */ #endif /* _WIN32 */
} }
#endif /* _DEBUG */ #endif /* I2_DEBUG */
void Object::InflateMutex(void) void Object::InflateMutex(void)
{ {

View File

@ -25,11 +25,11 @@
#include "base/thinmutex.hpp" #include "base/thinmutex.hpp"
#include <boost/thread/thread.hpp> #include <boost/thread/thread.hpp>
#ifndef _DEBUG #ifndef I2_DEBUG
#include <boost/thread/mutex.hpp> #include <boost/thread/mutex.hpp>
#else /* _DEBUG */ #else /* I2_DEBUG */
#include <boost/thread/recursive_mutex.hpp> #include <boost/thread/recursive_mutex.hpp>
#endif /* _DEBUG */ #endif /* I2_DEBUG */
#include <boost/smart_ptr/intrusive_ptr.hpp> #include <boost/smart_ptr/intrusive_ptr.hpp>
@ -98,9 +98,9 @@ public:
virtual void SetField(int id, const Value& value); virtual void SetField(int id, const Value& value);
virtual Value GetField(int id) const; virtual Value GetField(int id) const;
#ifdef _DEBUG #ifdef I2_DEBUG
bool OwnsLock(void) const; bool OwnsLock(void) const;
#endif /* _DEBUG */ #endif /* I2_DEBUG */
void InflateMutex(void); void InflateMutex(void);
@ -113,13 +113,13 @@ private:
uintptr_t m_References; uintptr_t m_References;
mutable ThinMutex m_Mutex; mutable ThinMutex m_Mutex;
#ifdef _DEBUG #ifdef I2_DEBUG
# ifndef _WIN32 # ifndef _WIN32
mutable pthread_t m_LockOwner; mutable pthread_t m_LockOwner;
# else /* _WIN32 */ # else /* _WIN32 */
mutable DWORD m_LockOwner; mutable DWORD m_LockOwner;
# endif /* _WIN32 */ # endif /* _WIN32 */
#endif /* _DEBUG */ #endif /* I2_DEBUG */
friend struct ObjectLock; friend struct ObjectLock;

View File

@ -61,18 +61,18 @@ public:
m_Object->m_Mutex.Lock(); m_Object->m_Mutex.Lock();
m_Locked = true; m_Locked = true;
#ifdef _DEBUG #ifdef I2_DEBUG
# ifdef _WIN32 # ifdef _WIN32
InterlockedExchange(&m_Object->m_LockOwner, GetCurrentThreadId()); InterlockedExchange(&m_Object->m_LockOwner, GetCurrentThreadId());
# else /* _WIN32 */ # else /* _WIN32 */
__sync_lock_test_and_set(&m_Object->m_LockOwner, pthread_self()); __sync_lock_test_and_set(&m_Object->m_LockOwner, pthread_self());
# endif /* _WIN32 */ # endif /* _WIN32 */
#endif /* _DEBUG */ #endif /* I2_DEBUG */
} }
inline void Unlock(void) inline void Unlock(void)
{ {
#ifdef _DEBUG #ifdef I2_DEBUG
if (m_Locked) { if (m_Locked) {
# ifdef _WIN32 # ifdef _WIN32
InterlockedExchange(&m_Object->m_LockOwner, 0); InterlockedExchange(&m_Object->m_LockOwner, 0);
@ -80,7 +80,7 @@ public:
__sync_lock_release(&m_Object->m_LockOwner); __sync_lock_release(&m_Object->m_LockOwner);
# endif /* _WIN32 */ # endif /* _WIN32 */
} }
#endif /* _DEBUG */ #endif /* I2_DEBUG */
if (m_Locked) { if (m_Locked) {
m_Object->m_Mutex.Unlock(); m_Object->m_Mutex.Unlock();

View File

@ -117,13 +117,13 @@ void ThreadPool::WorkerThread::ThreadProc(Queue& queue)
double st = Utility::GetTime();; double st = Utility::GetTime();;
#ifdef _DEBUG #ifdef I2_DEBUG
# ifdef RUSAGE_THREAD # ifdef RUSAGE_THREAD
struct rusage usage_start, usage_end; struct rusage usage_start, usage_end;
(void) getrusage(RUSAGE_THREAD, &usage_start); (void) getrusage(RUSAGE_THREAD, &usage_start);
# endif /* RUSAGE_THREAD */ # endif /* RUSAGE_THREAD */
#endif /* _DEBUG */ #endif /* I2_DEBUG */
try { try {
if (wi.Callback) if (wi.Callback)
@ -147,7 +147,7 @@ void ThreadPool::WorkerThread::ThreadProc(Queue& queue)
queue.TaskCount++; queue.TaskCount++;
} }
#ifdef _DEBUG #ifdef I2_DEBUG
# ifdef RUSAGE_THREAD # ifdef RUSAGE_THREAD
(void) getrusage(RUSAGE_THREAD, &usage_end); (void) getrusage(RUSAGE_THREAD, &usage_end);
@ -173,7 +173,7 @@ void ThreadPool::WorkerThread::ThreadProc(Queue& queue)
<< "Event call took " << (et - st) << "s"; << "Event call took " << (et - st) << "s";
# endif /* RUSAGE_THREAD */ # endif /* RUSAGE_THREAD */
} }
#endif /* _DEBUG */ #endif /* I2_DEBUG */
} }
boost::mutex::scoped_lock lock(queue.Mutex); boost::mutex::scoped_lock lock(queue.Mutex);

View File

@ -319,9 +319,9 @@ int DaemonCommand::Run(const po::variables_map& vm, const std::vector<std::strin
Log(LogInformation, "cli") Log(LogInformation, "cli")
<< "Icinga application loader (version: " << Application::GetVersion() << "Icinga application loader (version: " << Application::GetVersion()
#ifdef _DEBUG #ifdef I2_DEBUG
<< "; debug" << "; debug"
#endif /* _DEBUG */ #endif /* I2_DEBUG */
<< ")"; << ")";
String appType = LoadAppType(Application::GetApplicationType()); String appType = LoadAppType(Application::GetApplicationType());

View File

@ -263,10 +263,10 @@ int PkiUtility::RequestCertificate(const String& host, const String& port, const
if (response && response->Contains("error")) { if (response && response->Contains("error")) {
Log(LogCritical, "cli", "Could not fetch valid response. Please check the master log (notice or debug)."); 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 */ /* we shouldn't expose master errors to the user in production environments */
Log(LogCritical, "cli", response->Get("error")); Log(LogCritical, "cli", response->Get("error"));
#endif /* _DEBUG */ #endif /* I2_DEBUG */
return 1; return 1;
} }

View File

@ -142,10 +142,10 @@ DynamicObject::Ptr ConfigItem::Commit(bool discard)
{ {
ASSERT(!OwnsLock()); ASSERT(!OwnsLock());
#ifdef _DEBUG #ifdef I2_DEBUG
Log(LogDebug, "ConfigItem") Log(LogDebug, "ConfigItem")
<< "Commit called for ConfigItem Type=" << GetType() << ", Name=" << GetName(); << "Commit called for ConfigItem Type=" << GetType() << ", Name=" << GetName();
#endif /* _DEBUG */ #endif /* I2_DEBUG */
/* Make sure the type is valid. */ /* Make sure the type is valid. */
Type::Ptr type = Type::GetByName(GetType()); Type::Ptr type = Type::GetByName(GetType());
@ -369,23 +369,23 @@ bool ConfigItem::ActivateItems(void)
if (object->IsActive()) if (object->IsActive())
continue; continue;
#ifdef _DEBUG #ifdef I2_DEBUG
Log(LogDebug, "ConfigItem") Log(LogDebug, "ConfigItem")
<< "Activating object '" << object->GetName() << "' of type '" << object->GetType()->GetName() << "'"; << "Activating object '" << object->GetName() << "' of type '" << object->GetType()->GetName() << "'";
#endif /* _DEBUG */ #endif /* I2_DEBUG */
upq.Enqueue(boost::bind(&DynamicObject::Activate, object)); upq.Enqueue(boost::bind(&DynamicObject::Activate, object));
} }
} }
upq.Join(); upq.Join();
#ifdef _DEBUG #ifdef I2_DEBUG
BOOST_FOREACH(const DynamicType::Ptr& type, DynamicType::GetTypes()) { BOOST_FOREACH(const DynamicType::Ptr& type, DynamicType::GetTypes()) {
BOOST_FOREACH(const DynamicObject::Ptr& object, type->GetObjects()) { BOOST_FOREACH(const DynamicObject::Ptr& object, type->GetObjects()) {
ASSERT(object->IsActive()); ASSERT(object->IsActive());
} }
} }
#endif /* _DEBUG */ #endif /* I2_DEBUG */
Log(LogInformation, "ConfigItem", "Activated all objects."); Log(LogInformation, "ConfigItem", "Activated all objects.");

View File

@ -38,12 +38,12 @@ Expression::~Expression(void)
Value Expression::Evaluate(ScriptFrame& frame, DebugHint *dhint) const Value Expression::Evaluate(ScriptFrame& frame, DebugHint *dhint) const
{ {
try { try {
#ifdef _DEBUG #ifdef I2_DEBUG
/* std::ostringstream msgbuf; /* std::ostringstream msgbuf;
ShowCodeFragment(msgbuf, GetDebugInfo(), false); ShowCodeFragment(msgbuf, GetDebugInfo(), false);
Log(LogDebug, "Expression") Log(LogDebug, "Expression")
<< "Executing:\n" << msgbuf.str();*/ << "Executing:\n" << msgbuf.str();*/
#endif /* _DEBUG */ #endif /* I2_DEBUG */
return DoEvaluate(frame, dhint); return DoEvaluate(frame, dhint);
} catch (const InterruptExecutionError&) { } catch (const InterruptExecutionError&) {

View File

@ -165,9 +165,9 @@ Comment::Ptr Checkable::GetCommentByID(const String& id)
void Checkable::AddCommentsToCache(void) void Checkable::AddCommentsToCache(void)
{ {
#ifdef _DEBUG #ifdef I2_DEBUG
Log(LogDebug, "Checkable", "Updating Checkable comments cache."); Log(LogDebug, "Checkable", "Updating Checkable comments cache.");
#endif /* _DEBUG */ #endif /* I2_DEBUG */
Dictionary::Ptr comments = GetComments(); Dictionary::Ptr comments = GetComments();

View File

@ -251,9 +251,9 @@ void Checkable::StartDowntimesExpiredTimer(void)
void Checkable::AddDowntimesToCache(void) void Checkable::AddDowntimesToCache(void)
{ {
#ifdef _DEBUG #ifdef I2_DEBUG
Log(LogDebug, "Checkable", "Updating Checkable downtimes cache."); Log(LogDebug, "Checkable", "Updating Checkable downtimes cache.");
#endif /* _DEBUG */ #endif /* I2_DEBUG */
Dictionary::Ptr downtimes = GetDowntimes(); Dictionary::Ptr downtimes = GetDowntimes();

View File

@ -452,25 +452,25 @@ Array::Ptr LegacyTimePeriod::ScriptFunc(const TimePeriod::Ptr& tp, double begin,
time_t refts = begin + i * 24 * 60 * 60; time_t refts = begin + i * 24 * 60 * 60;
tm reference = Utility::LocalTime(refts); tm reference = Utility::LocalTime(refts);
#ifdef _DEBUG #ifdef I2_DEBUG
Log(LogDebug, "LegacyTimePeriod") Log(LogDebug, "LegacyTimePeriod")
<< "Checking reference time " << refts; << "Checking reference time " << refts;
#endif /* _DEBUG */ #endif /* I2_DEBUG */
ObjectLock olock(ranges); ObjectLock olock(ranges);
BOOST_FOREACH(const Dictionary::Pair& kv, ranges) { BOOST_FOREACH(const Dictionary::Pair& kv, ranges) {
if (!IsInDayDefinition(kv.first, &reference)) { if (!IsInDayDefinition(kv.first, &reference)) {
#ifdef _DEBUG #ifdef I2_DEBUG
Log(LogDebug, "LegacyTimePeriod") Log(LogDebug, "LegacyTimePeriod")
<< "Not in day definition '" << kv.first << "'."; << "Not in day definition '" << kv.first << "'.";
#endif /* _DEBUG */ #endif /* I2_DEBUG */
continue; continue;
} }
#ifdef _DEBUG #ifdef I2_DEBUG
Log(LogDebug, "LegacyTimePeriod") Log(LogDebug, "LegacyTimePeriod")
<< "In day definition '" << kv.first << "'."; << "In day definition '" << kv.first << "'.";
#endif /* _DEBUG */ #endif /* I2_DEBUG */
ProcessTimeRanges(kv.second, &reference, segments); ProcessTimeRanges(kv.second, &reference, segments);
} }