diff --git a/doc/doxygen.conf b/doc/doxygen.conf index dc852eb9f..f6025d2bc 100644 --- a/doc/doxygen.conf +++ b/doc/doxygen.conf @@ -1002,7 +1002,7 @@ INCLUDE_FILE_PATTERNS = # undefined via #undef or recursively expanded use the := operator # instead of the = operator. -PREDEFINED = RUN_SELF_TESTS NS3_DEBUG_ENABLE NS3_ASSERT_ENABLE NS3_LOG_ENABLE +PREDEFINED = RUN_SELF_TESTS NS3_ASSERT_ENABLE NS3_LOG_ENABLE # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. diff --git a/samples/main-debug-other.cc b/samples/main-debug-other.cc deleted file mode 100644 index da7587506..000000000 --- a/samples/main-debug-other.cc +++ /dev/null @@ -1,13 +0,0 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -#include "ns3/debug.h" - -NS_DEBUG_COMPONENT_DEFINE ("MyComponentB"); - -namespace foo { - -void OneFunction (void) -{ - NS_DEBUG ("OneFunction debug"); -} - -}; // namespace foo diff --git a/samples/main-debug.cc b/samples/main-debug.cc deleted file mode 100644 index cf2ab1a29..000000000 --- a/samples/main-debug.cc +++ /dev/null @@ -1,27 +0,0 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -#include "ns3/debug.h" -#include "ns3/assert.h" - -NS_DEBUG_COMPONENT_DEFINE ("MyComponentA"); - -// declare other function -namespace foo { -void OneFunction (void); -} - -int main (int argc, int argv) -{ - NS_DEBUG ("nargc="< namespace ns3 { diff --git a/src/core/debug.cc b/src/core/debug.cc deleted file mode 100644 index 3dfb998b5..000000000 --- a/src/core/debug.cc +++ /dev/null @@ -1,192 +0,0 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2006 INRIA - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Mathieu Lacage - */ -#include -#include -#include -#include "debug.h" -#include "assert.h" -#include "ns3/core-config.h" -#include "fatal-error.h" - -#ifdef HAVE_STDLIB_H -#include -#endif - -namespace ns3 { - -typedef std::list > ComponentList; -typedef std::list >::iterator ComponentListI; - -static -ComponentList *GetComponentList (void) -{ - static ComponentList components; - return &components; -} - - -static bool g_firstDebug = true; - -void -DebugComponentEnableEnvVar (void) -{ -#ifdef HAVE_GETENV - char *envVar = getenv("NS_DEBUG"); - if (envVar == 0) - { - return; - } - bool allFound = true; - std::string env = envVar; - std::string::size_type cur = 0; - std::string::size_type next = 0; - while (true) - { - next = env.find_first_of (";", cur); - std::string tmp = std::string (env, cur, next); - { - /* The following code is a workaround for a bug in the g++ - * c++ string library. Its goal is to remove any trailing ';' - * from the string even though there should not be any in - * it. This code should be safe even if the bug is not there. - */ - std::string::size_type trailing = tmp.find_first_of (";"); - tmp = tmp.substr (0, trailing); - } - if (tmp.size () == 0) - { - break; - } - bool found = false; - ComponentList *components = GetComponentList (); - for (ComponentListI i = components->begin (); - i != components->end (); - i++) - { - if (i->first.compare (tmp) == 0) - { - found = true; - i->second->Enable (); - break; - } - } - if (!found) - { - allFound = false; - } - if (next == std::string::npos) - { - break; - } - cur = next + 1; - if (cur >= env.size ()) - { - break; - } - } - if (allFound) - { - g_firstDebug = true; - } - -#endif -} - - -DebugComponent::DebugComponent (char const * name) - : m_isEnabled (false) -{ - ComponentList *components = GetComponentList (); - for (ComponentListI i = components->begin (); - i != components->end (); - i++) - { - NS_ASSERT (i->first != name); - } - components->push_back (std::make_pair (name, this)); -} -bool -DebugComponent::IsEnabled (void) -{ - if (g_firstDebug) - { - DebugComponentEnableEnvVar (); - } - return m_isEnabled; -} -void -DebugComponent::Enable (void) -{ - m_isEnabled = true; -} -void -DebugComponent::Disable (void) -{ - m_isEnabled = false; -} - -void -DebugComponentEnable (char const *name) -{ - ComponentList *components = GetComponentList (); - for (ComponentListI i = components->begin (); - i != components->end (); - i++) - { - if (i->first.compare (name) == 0) - { - i->second->Enable (); - break; - } - } -} -void -DebugComponentDisable (char const *name) -{ - ComponentList *components = GetComponentList (); - for (ComponentListI i = components->begin (); - i != components->end (); - i++) - { - if (i->first.compare (name) == 0) - { - i->second->Disable (); - break; - } - } -} - - -void -DebugComponentPrintList (void) -{ - ComponentList *components = GetComponentList (); - for (ComponentListI i = components->begin (); - i != components->end (); - i++) - { - std::cout << i->first << "=" << (i->second->IsEnabled ()?"enabled":"disabled") << std::endl; - } -} - -}; // namespace ns3 - - diff --git a/src/core/debug.h b/src/core/debug.h deleted file mode 100644 index 3fc6fef4b..000000000 --- a/src/core/debug.h +++ /dev/null @@ -1,140 +0,0 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2006 INRIA - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Mathieu Lacage - */ -#ifndef DEBUG_H -#define DEBUG_H - -/** - * \defgroup debugging Debugging - * \brief Debugging functions and macros - * - * - DEBUG functionality: macros which allow developers to - * send information out on screen only in debugging builds. - * All debug messages are disabled by default. To enable - * selected debug messages, use the ns3::DebugComponentEnable - * function. Alternatively, you can use the NS_DEBUG - * environment variable to define a ';'-separated list of - * messages to enable. For example, NS_DEBUG=a;b;c;DAFD;GH - * would enable the components 'a', 'b', 'c', 'DAFD', and, 'GH'. - */ - -namespace ns3 { - -/** - * \param name a debug component name - * \ingroup debugging - * - * Enable the debugging output associated with that debug component. - * The debugging output can be later disabled with a call - * to ns3::DebugComponentDisable. - */ -void DebugComponentEnable (char const *name); -/** - * \param name a debug component name - * \ingroup debugging - * - * Disable the debugging output associated with that debug component. - * The debugging output can be later re-enabled with a call - * to ns3::DebugComponentEnable. - */ -void DebugComponentDisable (char const *name); -/** - * \ingroup debugging - * Print the list of debugging messages available. - */ -void DebugComponentPrintList (void); - -class DebugComponent { -public: - DebugComponent (char const *name); - bool IsEnabled (void); - void Enable (void); - void Disable (void); -private: - bool m_isEnabled; -}; - -}; // namespace ns3 - - -#ifdef NS3_DEBUG_ENABLE - -#include -#include - - -/** - * \ingroup debugging - * \param name a string - * - * Define a Debug component with a specific name. This macro - * should be used at the top of every file in which you want - * to use the NS_DEBUG macro. This macro defines a new - * "debug component" which can be later selectively enabled - * or disabled with the ns3::DebugComponentEnable and - * ns3::DebugComponentDisable functions or with the NS_DEBUG - * environment variable. - */ -#define NS_DEBUG_COMPONENT_DEFINE(name) \ - static ns3::DebugComponent g_debug = ns3::DebugComponent (name) - -/** - * \ingroup debugging - * \param msg message to output - * - * Generate debugging output in the "debug component" of the - * current file. i.e., every call to NS_DEBUG from within - * a file implicitely generates out within the component - * defined with the NS_DEBUG_COMPONENT_DEFINE macro in the - * same file. - */ -#define NS_DEBUG(msg) \ - do \ - { \ - if (g_debug.IsEnabled ()) \ - { \ - std::cerr << msg << std::endl; \ - } \ - } \ - while (false) - -/** - * \ingroup debugging - * \param msg message to output - * - * Generate debugging output unconditionally in all - * debug builds. - */ -#define NS_DEBUG_UNCOND(msg) \ - do \ - { \ - std::cerr << msg << std::endl; \ - } \ - while (false) - -#else /* NS3_DEBUG_ENABLE */ - -#define NS_DEBUG_COMPONENT_DEFINE(name) -#define NS_DEBUG(x) -#define NS_DEBUG_UNCOND(msg) - -#endif /* NS3_DEBUG_ENABLE */ - -#endif /* DEBUG_H */ diff --git a/src/core/wscript b/src/core/wscript index bfb784825..410698d79 100644 --- a/src/core/wscript +++ b/src/core/wscript @@ -29,7 +29,6 @@ def build(bld): core = bld.create_ns3_module('core') core.source = [ 'callback-test.cc', - 'debug.cc', 'log.cc', 'breakpoint.cc', 'ptr.cc', @@ -70,7 +69,6 @@ def build(bld): 'callback.h', 'ptr.h', 'object.h', - 'debug.h', 'log.h', 'assert.h', 'breakpoint.h', diff --git a/src/mobility/ns2-mobility-file-topology.cc b/src/mobility/ns2-mobility-file-topology.cc index 7d0b8c915..2b2a32f92 100644 --- a/src/mobility/ns2-mobility-file-topology.cc +++ b/src/mobility/ns2-mobility-file-topology.cc @@ -20,14 +20,14 @@ */ #include #include -#include "ns3/debug.h" +#include "ns3/log.h" #include "ns3/simulator.h" #include "ns3/node-list.h" #include "ns3/node.h" #include "ns2-mobility-file-topology.h" #include "static-speed-mobility-model.h" -NS_DEBUG_COMPONENT_DEFINE ("Ns2MobilityFileTopology"); +NS_LOG_COMPONENT_DEFINE ("Ns2MobilityFileTopology"); namespace ns3 { @@ -101,17 +101,17 @@ Ns2MobilityFileTopology::LayoutObjectStore (const ObjectStore &store) const if (coordinate == "X") { position.x = value; - NS_DEBUG ("X=" << value); + NS_LOG_DEBUG ("X=" << value); } else if (coordinate == "Y") { position.y = value; - NS_DEBUG ("Y=" << value); + NS_LOG_DEBUG ("Y=" << value); } else if (coordinate == "Z") { position.z = value; - NS_DEBUG ("Z=" << value); + NS_LOG_DEBUG ("Z=" << value); } else { @@ -127,7 +127,7 @@ Ns2MobilityFileTopology::LayoutObjectStore (const ObjectStore &store) const double xSpeed = ReadDouble (line.substr (endNodeId + 10, xSpeedEnd - endNodeId - 10)); double ySpeed = ReadDouble (line.substr (xSpeedEnd + 1, ySpeedEnd - xSpeedEnd - 1)); double zSpeed = ReadDouble (line.substr (ySpeedEnd + 1, std::string::npos)); - NS_DEBUG ("at=" << at << "xSpeed=" << xSpeed << ", ySpeed=" << ySpeed << ", zSpeed=" << zSpeed); + NS_LOG_DEBUG ("at=" << at << "xSpeed=" << xSpeed << ", ySpeed=" << ySpeed << ", zSpeed=" << zSpeed); Simulator::Schedule (Seconds (at), &StaticSpeedMobilityModel::SetSpeed, model, Speed (xSpeed, ySpeed, zSpeed)); } diff --git a/src/mobility/random-walk-2d-mobility-model.cc b/src/mobility/random-walk-2d-mobility-model.cc index b6db1b5fa..07aa948d0 100644 --- a/src/mobility/random-walk-2d-mobility-model.cc +++ b/src/mobility/random-walk-2d-mobility-model.cc @@ -24,10 +24,10 @@ #include "ns3/rectangle-default-value.h" #include "ns3/random-variable-default-value.h" #include "ns3/simulator.h" -#include "ns3/debug.h" +#include "ns3/log.h" #include -NS_DEBUG_COMPONENT_DEFINE ("RandomWalk2d"); +NS_LOG_COMPONENT_DEFINE ("RandomWalk2d"); namespace ns3 { diff --git a/src/routing/olsr/olsr-agent-impl.cc b/src/routing/olsr/olsr-agent-impl.cc index 94bbfa75f..b2acdad7d 100644 --- a/src/routing/olsr/olsr-agent-impl.cc +++ b/src/routing/olsr/olsr-agent-impl.cc @@ -34,7 +34,7 @@ #include "ns3/udp.h" #include "ns3/internet-node.h" #include "ns3/simulator.h" -#include "ns3/debug.h" +#include "ns3/log.h" #include "ns3/random-variable.h" #include "ns3/inet-socket-address.h" #include "ns3/composite-trace-resolver.h" @@ -143,7 +143,7 @@ namespace ns3 { namespace olsr { -NS_DEBUG_COMPONENT_DEFINE ("OlsrAgent"); +NS_LOG_COMPONENT_DEFINE ("OlsrAgent"); /********** OLSR class **********/ @@ -232,7 +232,7 @@ void AgentImpl::Start () NS_ASSERT (m_mainAddress != Ipv4Address ()); } - NS_DEBUG ("Starting OLSR on node " << m_mainAddress); + NS_LOG_DEBUG ("Starting OLSR on node " << m_mainAddress); m_routingTable = Create (m_ipv4, m_mainAddress); // Add OLSR as routing protocol, with slightly lower priority than @@ -247,7 +247,7 @@ void AgentImpl::Start () TcTimerExpire (); MidTimerExpire (); - NS_DEBUG ("OLSR on node " << m_mainAddress << " started"); + NS_LOG_DEBUG ("OLSR on node " << m_mainAddress << " started"); } void AgentImpl::SetMainInterface (uint32_t interface) @@ -284,7 +284,7 @@ AgentImpl::RecvOlsr (Ptr socket, const Packet &receivedPacket, const Address &sourceAddress) { - NS_DEBUG ("OLSR node " << m_mainAddress << " received a OLSR packet"); + NS_LOG_DEBUG ("OLSR node " << m_mainAddress << " received a OLSR packet"); InetSocketAddress inetSourceAddr = InetSocketAddress::ConvertFrom (sourceAddress); // All routing messages are sent from and to port RT_PORT, @@ -308,7 +308,7 @@ AgentImpl::RecvOlsr (Ptr socket, sizeLeft -= messageHeader.GetSerializedSize (); - NS_DEBUG ("Olsr Msg received with type " + NS_LOG_DEBUG ("Olsr Msg received with type " << std::dec << int (messageHeader.GetMessageType ()) << " TTL=" << int (messageHeader.GetTimeToLive ()) << " origAddr=" << messageHeader.GetOriginatorAddress ()); @@ -343,29 +343,29 @@ AgentImpl::RecvOlsr (Ptr socket, switch (messageHeader.GetMessageType ()) { case olsr::MessageHeader::HELLO_MESSAGE: - NS_DEBUG ("OLSR node received HELLO message of size " << messageHeader.GetSerializedSize ()); + NS_LOG_DEBUG ("OLSR node received HELLO message of size " << messageHeader.GetSerializedSize ()); ProcessHello (messageHeader, m_mainAddress, inetSourceAddr.GetIpv4 ()); break; case olsr::MessageHeader::TC_MESSAGE: - NS_DEBUG ("OLSR node received TC message of size " << messageHeader.GetSerializedSize ()); + NS_LOG_DEBUG ("OLSR node received TC message of size " << messageHeader.GetSerializedSize ()); ProcessTc (messageHeader, inetSourceAddr.GetIpv4 ()); break; case olsr::MessageHeader::MID_MESSAGE: - NS_DEBUG ("OLSR node received MID message of size " << messageHeader.GetSerializedSize ()); + NS_LOG_DEBUG ("OLSR node received MID message of size " << messageHeader.GetSerializedSize ()); ProcessMid (messageHeader, inetSourceAddr.GetIpv4 ()); break; default: - NS_DEBUG ("OLSR message type " << + NS_LOG_DEBUG ("OLSR message type " << int (messageHeader.GetMessageType ()) << " not implemented"); } } else { - NS_DEBUG ("OLSR message is duplicated, not reading it."); + NS_LOG_DEBUG ("OLSR message is duplicated, not reading it."); // If the message has been considered for forwarding, it should // not be retransmitted again @@ -1092,7 +1092,7 @@ AgentImpl::QueueMessage (const olsr::MessageHeader &message, Time delay) void AgentImpl::SendPacket (Packet packet, const MessageList &containedMessages) { - NS_DEBUG ("OLSR node " << m_mainAddress << " sending a OLSR packet"); + NS_LOG_DEBUG ("OLSR node " << m_mainAddress << " sending a OLSR packet"); // Add a header olsr::PacketHeader header; @@ -1120,7 +1120,7 @@ AgentImpl::SendQueuedMessages () Packet packet; int numMessages = 0; - NS_DEBUG ("Olsr node " << m_mainAddress << ": SendQueuedMessages"); + NS_LOG_DEBUG ("Olsr node " << m_mainAddress << ": SendQueuedMessages"); MessageList msglist; @@ -1248,8 +1248,8 @@ AgentImpl::SendHello () linkMessages.push_back (linkMessage); } - NS_DEBUG ("OLSR HELLO message size: " << int (msg.GetSerializedSize ()) - << " (with " << int (linkMessages.size ()) << " link messages)"); + NS_LOG_DEBUG ("OLSR HELLO message size: " << int (msg.GetSerializedSize ()) + << " (with " << int (linkMessages.size ()) << " link messages)"); QueueMessage (msg, JITTER); } diff --git a/src/routing/olsr/routing-table.cc b/src/routing/olsr/routing-table.cc index eb17adaf1..454d51532 100644 --- a/src/routing/olsr/routing-table.cc +++ b/src/routing/olsr/routing-table.cc @@ -28,11 +28,11 @@ #include "routing-table.h" #include "ns3/packet.h" #include "ns3/ipv4-header.h" -#include "ns3/debug.h" +#include "ns3/log.h" namespace ns3 { namespace olsr { -NS_DEBUG_COMPONENT_DEFINE ("OlsrRoutingTable"); +NS_LOG_COMPONENT_DEFINE ("OlsrRoutingTable"); /// /// \brief Clears the routing table and frees the memory assigned to each one of its entries. @@ -119,19 +119,19 @@ RoutingTable::RequestRoute (uint32_t ifIndex, Ipv4Route route = Ipv4Route::CreateHostRouteTo (ipHeader.GetDestination (), entry2.nextAddr, entry2.interface); - NS_DEBUG ("Olsr node" << m_mainAddress - << ": RouteRequest for dest=" << ipHeader.GetDestination () - << " --> destHop=" << entry2.nextAddr - << " interface=" << entry2.interface); + NS_LOG_DEBUG ("Olsr node" << m_mainAddress + << ": RouteRequest for dest=" << ipHeader.GetDestination () + << " --> destHop=" << entry2.nextAddr + << " interface=" << entry2.interface); routeReply (true, route, packet, ipHeader); return true; } else { - NS_DEBUG ("Olsr node" << m_mainAddress - << ": RouteRequest for dest=" << ipHeader.GetDestination () - << " --> NOT FOUND"); + NS_LOG_DEBUG ("Olsr node" << m_mainAddress + << ": RouteRequest for dest=" << ipHeader.GetDestination () + << " --> NOT FOUND"); return false; } } diff --git a/tutorial/hello-simulator.cc b/tutorial/hello-simulator.cc index 50ded681c..a99b37f0c 100644 --- a/tutorial/hello-simulator.cc +++ b/tutorial/hello-simulator.cc @@ -15,7 +15,6 @@ */ #include "ns3/log.h" -#include "ns3/debug.h" NS_LOG_COMPONENT_DEFINE ("HelloSimulator"); @@ -24,8 +23,6 @@ using namespace ns3; int main (int argc, char *argv[]) { - DebugComponentEnable ("Log"); - // LogComponentEnable ("HelloSimulator", // LogLevel (LOG_LEVEL_INFO | LOG_PREFIX_ALL)); diff --git a/wscript b/wscript index 430675d1f..5bf302938 100644 --- a/wscript +++ b/wscript @@ -118,7 +118,6 @@ def configure(conf): variant_env.append_value('CXXFLAGS', ['-Werror']) if 'debug' in Params.g_options.debug_level.lower(): - variant_env.append_value('CXXDEFINES', 'NS3_DEBUG_ENABLE') variant_env.append_value('CXXDEFINES', 'NS3_ASSERT_ENABLE') variant_env.append_value('CXXDEFINES', 'NS3_LOG_ENABLE')