ns-3
Debugging
Collaboration diagram for Debugging:

Modules

 Assert
 assert functions and macros
 Fatal Error Handler
 Functions to help clean up when fatal error is encountered.
 Logging
 Logging functions and macros.

Macros

#define NS_ABORT_MSG(msg)
 Abnormal program termination.
#define NS_ABORT_IF(cond)
 Abnormal program termination if cond is true.
#define NS_ABORT_MSG_IF(cond, msg)
 Abnormal program termination if cond is true.
#define NS_ABORT_UNLESS(cond)   NS_ABORT_IF (!(cond))
 Abnormal program termination if cond is false.
#define NS_ABORT_MSG_UNLESS(cond, msg)   NS_ABORT_MSG_IF (!(cond),msg)
 Abnormal program termination if cond is false.
#define NS_BREAKPOINT()   ns3::BreakpointFallback ()
#define NS_FATAL_ERROR_NO_MSG()
 fatal error handling
#define NS_FATAL_ERROR(msg)
 fatal error handling

Detailed Description


Macro Definition Documentation

#define NS_ABORT_IF (   cond)
Value:
do { \
if (cond) \
{ \
std::cerr << "aborted. cond=\"" << # cond << ", "; \
NS_FATAL_ERROR_NO_MSG (); \
} \
} while (false)

Abnormal program termination if cond is true.

Parameters:
condcondition to be evaluated.

This is similar to NS_ASSERT(!(cond)), except this check is enabled in all builds. If cond is evaluated to true, the espression evaluating to true is printed to stderr, followed by a call to the NS_FATAL_ERROR_NO_MSG() macro which prints the details of filename and line number to stderr. The program will be halted by calling std::terminate(), triggering any clean up code registered by std::set_terminate (NS3 default is a stream-flushing code, but may be overridden).

This macro is enable unconditionally in all builds, including debug and optimized builds.

Referenced by ns3::EpcSgwPgwApplication::ActivateS1Bearer(), ns3::EpcTft::Add(), and ns3::UeInfo::GetRadioBearer().

#define NS_ABORT_MSG (   msg)
Value:
do { \
std::cerr << "aborted. "; \
NS_FATAL_ERROR (msg); \
} while (false)

Abnormal program termination.

Parameters:
msgmessage to output when this macro is hit.

This macro is essentially equivalent to NS_FATAL_ERROR, excepts it prepends the error message with the string "aborted. ". When this macro is hit a runtime, the program will be halted using std::terminate, which triggers clean up code regestered by std::set_terminate.

This macro is enable unconditionally in all builds, including debug and optimized builds.

See also:
NS_FATAL_ERROR

Referenced by ns3::YansWifiPhyHelper::SetPcapDataLinkType(), and ns3::Time::Time().

#define NS_ABORT_MSG_IF (   cond,
  msg 
)
Value:
do { \
if (cond) \
{ \
std::cerr << "aborted. cond=\"" << # cond << "\", "; \
NS_FATAL_ERROR (msg); \
} \
} while (false)

Abnormal program termination if cond is true.

Parameters:
condcondition to be evaluated.
msgmessage to output when cond is true.

This is similar to NS_ASSERT_MSG(!(cond)), except this check is enabled in all builds. If cond is evaluated to true, the espression evaluating to true is printed to stderr, followed by a call to the NS_FATAL_ERROR() macro which prints the user-specified error message, and details of filename and line number to stderr. The program will be halted by calling std::terminate(), triggering any clean up code registered by std::set_terminate (NS3 default is a stream-flushing code, but may be overridden).

This macro is enable unconditionally in all builds, including debug and optimized builds.

Referenced by ns3::WaypointMobilityModel::AddWaypoint(), ns3::PcapHelper::CreateFile(), ns3::GlobalRouter::DiscoverLSAs(), ns3::LteEnbNetDevice::DoStart(), ns3::PcapHelperForDevice::EnablePcap(), ns3::RadioEnvironmentMapHelper::Install(), ns3::AthstatsWifiTraceSink::Open(), ns3::TcpSocketBase::Recv(), ns3::TcpSocketBase::Send(), and ns3::Ipv4Header::SetFragmentOffset().

#define NS_ABORT_MSG_UNLESS (   cond,
  msg 
)    NS_ABORT_MSG_IF (!(cond),msg)

Abnormal program termination if cond is false.

Parameters:
condcondition to be evaluated.
msgmessage to output if cond is false.

This is an alias for NS_ABORT_MSG_IF(!(cond))

See also:
NS_ABORT_MSG_IF

Referenced by ns3::Names::Add(), ns3::GlobalRouter::DiscoverLSAs(), ns3::PcapHelper::GetFilenameFromDevice(), ns3::AsciiTraceHelper::GetFilenameFromDevice(), ns3::PcapHelper::GetFilenameFromInterfacePair(), ns3::AsciiTraceHelper::GetFilenameFromInterfacePair(), ns3::AthstatsWifiTraceSink::Open(), and ns3::Names::Rename().

#define NS_ABORT_UNLESS (   cond)    NS_ABORT_IF (!(cond))

Abnormal program termination if cond is false.

Parameters:
condcondition to be evaluated.

This is an alias for NS_ABORT_IF(!(cond))

See also:
NS_ABORT_IF
#define NS_BREAKPOINT ( )    ns3::BreakpointFallback ()

Inserts a breakpoint instruction (or equivalent system call) into the code for selected machines. When an NS_ASSERT cannot verify its condition, this macro is used. Falls back to calling AssertBreakpoint() for architectures where breakpoint assembly instructions are not supported.

#define NS_FATAL_ERROR (   msg)
Value:
do \
{ \
std::cerr << "msg=\"" << msg << "\", "; \
NS_FATAL_ERROR_NO_MSG (); \
} \
while (false)

fatal error handling

Parameters:
msgmessage to output when this macro is hit.

When this macro is hit at runtime, the user-specified error message is printed to stderr, followed by a call to the NS_FATAL_ERROR_NO_MSG() macro which prints the details of filename and line number to stderr. The program will be halted by calling std::terminate(), triggering any clean up code registered by std::set_terminate (NS3 default is a stream-flushing code, but may be overridden).

This macro is enabled unconditionally in all builds, including debug and optimized builds.

Referenced by ns3::Ipv6L3Protocol::AddAutoconfiguredAddress(), ns3::BridgeNetDevice::AddBridgePort(), ns3::ConnectionManager::AddConnection(), ns3::CsmaNetDevice::AddHeader(), ns3::MeshPointDevice::AddInterface(), ns3::WimaxNetDevice::AddLinkChangeCallback(), ns3::NixVector::AddNeighborIndex(), ns3::TestCase::AddTestCase(), ns3::Object::AggregateObject(), ns3::GlobalValue::Bind(), ns3::Building::Building(), ns3::AcousticModemEnergyModel::ChangeState(), ns3::WifiRadioEnergyModel::ChangeState(), ns3::WimaxHelper::CreateBSScheduler(), ns3::ConnectionManager::CreateConnection(), ns3::WimaxHelper::CreatePhy(), ns3::WimaxHelper::CreatePhyWithoutChannel(), ns3::WimaxHelper::CreateUplinkScheduler(), ns3::WifiModeFactory::CreateWifiMode(), ns3::CtrlBAckRequestHeader::Deserialize(), ns3::dot11s::PeerLinkFrameStart::Deserialize(), ns3::Tlv::Deserialize(), ns3::CtrlBAckResponseHeader::Deserialize(), ns3::ObjectPtrContainerValue::DeserializeFromString(), ns3::dot11s::IeConfiguration::DeserializeInformationField(), ns3::MeshInformationElementVector::DeserializeSingleIe(), ns3::WifiInformationElementVector::DeserializeSingleIe(), ns3::MpiInterface::Disable(), ns3::olsr::RoutingProtocol::DoStart(), ns3::MpiInterface::Enable(), ns3::RegularWifiMac::Enqueue(), ns3::BlockAckManager::ExistsAgreementInState(), ns3::NixVector::ExtractNeighborIndex(), ns3::Ipv4FlowClassifier::FindFlow(), ns3::SystemPath::FindSelfDirectory(), ns3::RegularWifiMac::FinishConfigureStandard(), ns3::CidFactory::FreeCid(), ns3::ObjectBase::GetAttribute(), ns3::EmuNetDevice::GetChannel(), ns3::LteSpectrumValueHelper::GetChannelBandwidth(), ns3::ConnectionManager::GetConnections(), ns3::MeshPointDevice::GetInterface(), ns3::PointToPointGridHelper::GetIpv4Address(), ns3::PointToPointGridHelper::GetIpv6Address(), ns3::EmuNetDevice::GetMtu(), ns3::UanNetDevice::GetMulticast(), ns3::PointToPointGridHelper::GetNode(), ns3::EpsBearer::GetPacketDelayBudgetMs(), ns3::EpsBearer::GetPacketErrorLossRate(), ns3::UanPhyDual::GetPacketRx(), ns3::WifiPhy::GetPayloadDurationMicroSeconds(), ns3::WifiPhy::GetPlcpHeaderDurationMicroSeconds(), ns3::WifiPhy::GetPlcpHeaderMode(), ns3::WifiPhy::GetPlcpPreambleDurationMicroSeconds(), ns3::EpsBearer::GetPriority(), ns3::Ipv4ListRouting::GetRoutingProtocol(), ns3::Ipv6ListRouting::GetRoutingProtocol(), ns3::CtrlBAckRequestHeader::GetSerializedSize(), ns3::CtrlBAckResponseHeader::GetSerializedSize(), ns3::ByteTagIterator::Item::GetTag(), ns3::GlobalValue::GetValue(), ns3::GlobalValue::GetValueByName(), ns3::GlobalValue::GlobalValue(), ns3::RadioEnvironmentMapHelper::Install(), ns3::InternetStackHelper::Install(), ns3::MeshHelper::Install(), ns3::MobilityHelper::Install(), ns3::IpcsClassifierRecord::IpcsClassifierRecord(), ns3::EpsBearer::IsGbr(), ns3::LogComponentEnable(), ns3::ArpL3Protocol::Lookup(), ns3::LteEnbPhy::LteEnbPhy(), ns3::LtePhy::LtePhy(), ns3::LteUePhy::LteUePhy(), ns3::Ipv6AddressHelper::NewAddress(), ns3::BlockAckManager::NotifyGotBlockAck(), ns3::WifiRadioEnergyModelPhyListener::NotifyMaybeCcaBusyStart(), ns3::WifiRadioEnergyModelPhyListener::NotifyRxEndError(), ns3::WifiRadioEnergyModelPhyListener::NotifyRxEndOk(), ns3::WifiRadioEnergyModelPhyListener::NotifyRxStart(), ns3::WifiRadioEnergyModelPhyListener::NotifySwitchingStart(), ns3::WifiRadioEnergyModelPhyListener::NotifyTxStart(), ns3::Ns2MobilityHelper::Ns2MobilityHelper(), ns3::operator<<(), ns3::PointToPointGridHelper::PointToPointGridHelper(), ns3::WifiMacHeader::Print(), ns3::SystemPath::ReadFiles(), ns3::flame::FlameProtocolMac::Receive(), ns3::RegularWifiMac::Receive(), ns3::LteUePhy::ReceiveIdealControlMessage(), ns3::MpiInterface::ReceiveMessages(), ns3::MacLow::ReceiveOk(), ns3::LteUeRrc::ReleaseRadioBearer(), ns3::dot11s::HwmpProtocol::RemoveRoutingStuff(), ns3::flame::FlameProtocol::RemoveRoutingStuff(), ns3::LteEnbRrc::RemoveUe(), ns3::dot11s::HwmpProtocol::RequestRoute(), ns3::flame::FlameProtocol::RequestRoute(), ns3::DistributedSimulatorImpl::Run(), ns3::Timer::Schedule(), ns3::Ipv4L3Protocol::Send(), ns3::TapBridge::Send(), ns3::LteNetDevice::SendFrom(), ns3::EmuNetDevice::SendFrom(), ns3::TapBridge::SendFrom(), ns3::MeshWifiInterfaceMac::SendManagementFrame(), ns3::MpiInterface::SendPacket(), ns3::CtrlBAckRequestHeader::Serialize(), ns3::CtrlBAckResponseHeader::Serialize(), ns3::EnumValue::SerializeToString(), ns3::ObjectFactory::Set(), ns3::Watchdog::SetArguments(), ns3::Timer::SetArguments(), ns3::ObjectBase::SetAttribute(), ns3::RadioEnvironmentMapHelper::SetBandwidth(), ns3::TapBridge::SetBridgedNetDevice(), ns3::EmuNetDevice::SetDataRate(), ns3::Config::SetDefault(), ns3::LteEnbNetDevice::SetDlBandwidth(), ns3::Simulator::SetImplementation(), ns3::EmuNetDevice::SetMtu(), ns3::AnimationInterface::SetOutputFile(), ns3::MeshHelper::SetStackInstaller(), ns3::LteEnbNetDevice::SetUlBandwidth(), ns3::TcpSocketBase::SetupEndpoint(), ns3::FdReader::Start(), ns3::LteSpectrumPhy::StartRx(), ns3::LteSpectrumPhy::StartTx(), ns3::MpiInterface::TestSendComplete(), ns3::PointToPointRemoteChannel::TransmitStart(), ns3::flame::FlameProtocolMac::UpdateOutcomingFrame(), and ns3::dot11s::HwmpProtocolMac::UpdateOutcomingFrame().

#define NS_FATAL_ERROR_NO_MSG ( )
Value:
do \
{ \
std::cerr << "file=" << __FILE__ << ", line=" << \
__LINE__ << std::endl; \
std::terminate (); \
} \
while (false)

fatal error handling

When this macro is hit at runtime, details of filename and line number is printed to stderr, and the program is halted by calling std::terminate(). This will trigger any clean up code registered by std::set_terminate (NS3 default is a stream-flushing code), but may be overridden.

This macro is enabled unconditionally in all builds, including debug and optimized builds.