A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
Fatal Implementation.
+ Collaboration diagram for Fatal Implementation.:

Files

file  fatal-impl.cc
 ns3::FatalImpl::RegisterStream(), ns3::FatalImpl::UnregisterStream(), and ns3::FatalImpl::FlushStreams() implementations; see Implementation note!
 
file  fatal-impl.h
 ns3::FatalImpl::RegisterStream(), ns3::FatalImpl::UnregisterStream(), and ns3::FatalImpl::FlushStreams() declarations.
 

Namespaces

namespace  ns3::FatalImpl
 Implementation namespace for fatal error handlers.
 
namespace  ns3::FatalImpl::anonymous_namespace{fatal-impl.cc}
 Unnamed namespace for fatal streams memory implementation and signal handler.
 

Functions

void ns3::FatalImpl::FlushStreams ()
 Flush all currently registered streams.
 
std::list< std::ostream * > * ns3::FatalImpl::anonymous_namespace{fatal-impl.cc}::GetStreamList ()
 Get the stream list, initializing it if necessary.
 
std::list< std::ostream * > ** ns3::FatalImpl::anonymous_namespace{fatal-impl.cc}::PeekStreamList ()
 Static variable pointing to the list of output streams to be flushed on fatal errors.
 
void ns3::FatalImpl::RegisterStream (std::ostream *stream)
 Register a stream to be flushed on abnormal exit.
 
void ns3::FatalImpl::anonymous_namespace{fatal-impl.cc}::sigHandler (int sig)
 Overrides normal SIGSEGV handler once the HandleTerminate function is run.
 
void ns3::FatalImpl::UnregisterStream (std::ostream *stream)
 Unregister a stream for flushing on abnormal exit.
 

Detailed Description

Function Documentation

◆ FlushStreams()

void ns3::FatalImpl::FlushStreams ( )

Flush all currently registered streams.

This function iterates through each registered stream and unregisters them. The default SIGSEGV handler is overridden when this function is being executed, and will be restored when this function returns.

If a SIGSEGV is encountered (most likely due to a bad ostream* being registered, or a registered osteam* pointing to an ostream that had already been destroyed), this function will skip the bad ostream* and continue to flush the next stream. The function will then terminate raising SIGIOT (aka SIGABRT)

DO NOT call this function until the program is ready to crash.

Definition at line 187 of file fatal-impl.cc.

References NS_LOG_FUNCTION_NOARGS.

Referenced by ns3::FatalImpl::anonymous_namespace{fatal-impl.cc}::sigHandler().

+ Here is the caller graph for this function:

◆ GetStreamList()

std::list< std::ostream * > * ns3::FatalImpl::anonymous_namespace{fatal-impl.cc}::GetStreamList ( )

Get the stream list, initializing it if necessary.

Returns
The stream list.

Definition at line 122 of file fatal-impl.cc.

References ns3::FatalImpl::anonymous_namespace{fatal-impl.cc}::GetStreamList(), NS_LOG_FUNCTION_NOARGS, and ns3::FatalImpl::anonymous_namespace{fatal-impl.cc}::PeekStreamList().

Referenced by ns3::FatalImpl::anonymous_namespace{fatal-impl.cc}::GetStreamList().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PeekStreamList()

std::list< std::ostream * > ** ns3::FatalImpl::anonymous_namespace{fatal-impl.cc}::PeekStreamList ( )

Static variable pointing to the list of output streams to be flushed on fatal errors.

Returns
The address of the static pointer.

Definition at line 108 of file fatal-impl.cc.

References NS_LOG_FUNCTION_NOARGS, and ns3::FatalImpl::anonymous_namespace{fatal-impl.cc}::PeekStreamList().

Referenced by ns3::FatalImpl::anonymous_namespace{fatal-impl.cc}::GetStreamList(), and ns3::FatalImpl::anonymous_namespace{fatal-impl.cc}::PeekStreamList().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RegisterStream()

void ns3::FatalImpl::RegisterStream ( std::ostream *  stream)

Register a stream to be flushed on abnormal exit.

If a std::terminate() call is encountered after the stream had been registered and before it has been unregistered, stream->flush() will be called. Users of this function should ensure the stream remains valid until it had been unregistered.

Parameters
[in]streamThe stream to be flushed on abnormal exit.

Definition at line 136 of file fatal-impl.cc.

References NS_LOG_FUNCTION.

Referenced by ns3::AsciiFile::AsciiFile(), ns3::OutputStreamWrapper::OutputStreamWrapper(), and ns3::PcapFile::PcapFile().

+ Here is the caller graph for this function:

◆ sigHandler()

void ns3::FatalImpl::anonymous_namespace{fatal-impl.cc}::sigHandler ( int  sig)

Overrides normal SIGSEGV handler once the HandleTerminate function is run.

This is private to the fatal implementation.

Parameters
[in]sigThe signal condition.

Definition at line 178 of file fatal-impl.cc.

References ns3::FatalImpl::FlushStreams(), NS_LOG_FUNCTION, and ns3::FatalImpl::anonymous_namespace{fatal-impl.cc}::sigHandler().

Referenced by ns3::FatalImpl::anonymous_namespace{fatal-impl.cc}::sigHandler().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UnregisterStream()

void ns3::FatalImpl::UnregisterStream ( std::ostream *  stream)

Unregister a stream for flushing on abnormal exit.

After a stream had been unregistered, stream->flush() will no longer be called should abnormal termination be encountered.

If the stream is not registered, nothing will happen.

Parameters
[in]streamThe stream to be unregistered.

Definition at line 143 of file fatal-impl.cc.

References NS_LOG_FUNCTION.

Referenced by ns3::AsciiFile::~AsciiFile(), ns3::OutputStreamWrapper::~OutputStreamWrapper(), and ns3::PcapFile::~PcapFile().

+ Here is the caller graph for this function: