Teuchos Package Browser (Single Doxygen Collection) Version of the Day
Classes
Teuchos::RCPNodeTracer Class Reference

Debug-mode RCPNode tracing class. More...

#include <Teuchos_RCPNode.hpp>

List of all members.

Classes

struct  RCPNodeStatistics
 RCP statistics struct. More...

General user functions (can be called by any client)

static bool isTracingActiveRCPNodes ()
 Return if we are tracing active nodes or not.
static int numActiveRCPNodes ()
 Print the number of active RCPNode objects currently being tracked.
static RCPNodeStatistics getRCPNodeStatistics ()
 Return the statistics on RCPNode allocations.
static void printRCPNodeStatistics (const RCPNodeStatistics &rcpNodeStatistics, std::ostream &out)
 Print the RCPNode allocation statistics.
static void setPrintRCPNodeStatisticsOnExit (bool printRCPNodeStatisticsOnExit)
 Set if RCPNode usage statistics will be printed when the program ends or not.
static bool getPrintRCPNodeStatisticsOnExit ()
 Reteurn if RCPNode usage statistics will be printed when the program ends or not.
static void printActiveRCPNodes (std::ostream &out)
 Print the list of currently active RCP nodes.

Internal implementation functions (not to be called by general

clients).

static void addNewRCPNode (RCPNode *rcp_node, const std::string &info)
 Add new RCPNode to the global list.
static void removeRCPNode (RCPNode *rcp_node)
 Remove an RCPNode from global list.
template<class T >
static const void * getRCPNodeBaseObjMapKeyVoidPtr (T *p)
 Get a const void* address to be used as the lookup key for an RCPNode given its embedded object's typed pointer.
static RCPNodegetExistingRCPNodeGivenLookupKey (const void *lookupKey)
 Return a raw pointer to an existing owning RCPNode given its lookup key.
template<class T >
static RCPNodegetExistingRCPNode (T *p)
 Return a raw pointer to an existing owning RCPNode given the address to the underlying object if it exits.
static std::string getActiveRCPNodeHeaderString ()
 Header string used in printActiveRCPNodes().
static std::string getCommonDebugNotesString ()
 Common error message string on how to debug RCPNode problems.

Detailed Description

Debug-mode RCPNode tracing class.

This is a static class that is used to trace all RCP nodes that are created and destroyed and to look-up RCPNodes given an an object's address. This database is used for several different types of debug-mode runtime checking including a) the detection of cicular references, b) detecting the creation of duplicate owning RCPNode objects for the same reference-counted object, and c) to create weak RCP objects for existing RCPNode objects.

This is primarily an internal implementation class but there are a few functions (maked as such below) that can be called by general users to turn on and off node tracing and to print the active RCPNode objects at any time.

Definition at line 307 of file Teuchos_RCPNode.hpp.


Member Function Documentation

bool Teuchos::RCPNodeTracer::isTracingActiveRCPNodes ( ) [static]

Return if we are tracing active nodes or not.

NOTE: This will always return false when TEUCHOS_DEBUG is not defined.

Definition at line 291 of file Teuchos_RCPNode.cpp.

int Teuchos::RCPNodeTracer::numActiveRCPNodes ( ) [static]

Print the number of active RCPNode objects currently being tracked.

Definition at line 305 of file Teuchos_RCPNode.cpp.

RCPNodeTracer::RCPNodeStatistics Teuchos::RCPNodeTracer::getRCPNodeStatistics ( ) [static]

Return the statistics on RCPNode allocations.

Definition at line 315 of file Teuchos_RCPNode.cpp.

void Teuchos::RCPNodeTracer::printRCPNodeStatistics ( const RCPNodeStatistics rcpNodeStatistics,
std::ostream &  out 
) [static]

Print the RCPNode allocation statistics.

Definition at line 320 of file Teuchos_RCPNode.cpp.

void Teuchos::RCPNodeTracer::setPrintRCPNodeStatisticsOnExit ( bool  printRCPNodeStatisticsOnExit) [static]

Set if RCPNode usage statistics will be printed when the program ends or not.

Definition at line 334 of file Teuchos_RCPNode.cpp.

bool Teuchos::RCPNodeTracer::getPrintRCPNodeStatisticsOnExit ( ) [static]

Reteurn if RCPNode usage statistics will be printed when the program ends or not.

Definition at line 341 of file Teuchos_RCPNode.cpp.

void Teuchos::RCPNodeTracer::printActiveRCPNodes ( std::ostream &  out) [static]

Print the list of currently active RCP nodes.

When the macro TEUCHOS_SHOW_ACTIVE_REFCOUNTPTR_NODE_TRACE is defined, this function will print out all of the RCP nodes that are currently active. This function can be called at any time during a program.

When the macro TEUCHOS_SHOW_ACTIVE_REFCOUNTPTR_NODE_TRACE is defined this function will get called automatically after the program ends and all of the local and global RCP objects have been destroyed. If any RCP nodes are printed at that time, then this is an indication that there may be some circular references that will caused memory leaks. You memory checking tool such as valgrind or purify should complain about this!

Definition at line 347 of file Teuchos_RCPNode.cpp.

void Teuchos::RCPNodeTracer::addNewRCPNode ( RCPNode rcp_node,
const std::string &  info 
) [static]

Add new RCPNode to the global list.

Only gets called when RCPNode tracing has been activated.

Definition at line 393 of file Teuchos_RCPNode.cpp.

void Teuchos::RCPNodeTracer::removeRCPNode ( RCPNode rcp_node) [static]

Remove an RCPNode from global list.

Always gets called in a debug build (TEUCHOS_DEBUG defined) when node tracing is enabled.

Definition at line 485 of file Teuchos_RCPNode.cpp.

template<class T >
static const void* Teuchos::RCPNodeTracer::getRCPNodeBaseObjMapKeyVoidPtr ( T *  p) [inline, static]

Get a const void* address to be used as the lookup key for an RCPNode given its embedded object's typed pointer.

This only returns the base address reliabily for all types if HAS_TEUCHOS_GET_BASE_OBJ_VOID_PTR is defined.

Returns:
0 if p == 0.

Definition at line 426 of file Teuchos_RCPNode.hpp.

RCPNode * Teuchos::RCPNodeTracer::getExistingRCPNodeGivenLookupKey ( const void *  lookupKey) [static]

Return a raw pointer to an existing owning RCPNode given its lookup key.

Returns:
returnVal != 0 if an owning RCPNode exists, 0 otherwsise.

Definition at line 540 of file Teuchos_RCPNode.cpp.

template<class T >
static RCPNode* Teuchos::RCPNodeTracer::getExistingRCPNode ( T *  p) [inline, static]

Return a raw pointer to an existing owning RCPNode given the address to the underlying object if it exits.

Returns:
returnVal != 0 if an owning RCPNode exists, 0 otherwsise.

Definition at line 456 of file Teuchos_RCPNode.hpp.

std::string Teuchos::RCPNodeTracer::getActiveRCPNodeHeaderString ( ) [static]

Header string used in printActiveRCPNodes().

Definition at line 559 of file Teuchos_RCPNode.cpp.

std::string Teuchos::RCPNodeTracer::getCommonDebugNotesString ( ) [static]

Common error message string on how to debug RCPNode problems.

Definition at line 586 of file Teuchos_RCPNode.cpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines