Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Static Private Attributes

log_FunctionTracer Class Reference
[File, class and function identification]

This class is used to track execution stack. More...

#include <logid.h>

Collaboration diagram for log_FunctionTracer:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 log_FunctionTracer (const log_FunctionID &a_fcnID_p)
 log_FunctionTracer (const log_FunctionID &a_fcnID_p, const string &a_fcnArgs_p)
 Function entrance with parameters is written in the debug if level is > dbg_EXTAPI or dbg_INOUT flag is set.
virtual ~log_FunctionTracer ()

Static Public Member Functions

static void DumpStack (ostream &a_str)
 Dump current execution stack.
static void DumpStack (ostream &a_str, log_TraceStack *a_fstack)
static log_TraceStackGetStack ()
 Get pointer to this thread's stack.

Public Attributes

const log_FunctionIDm_fcnID_p
const string * m_fcnArgs_p

Private Member Functions

void Init ()

Static Private Attributes

static bool m_inited

Detailed Description

This class is used to track execution stack.

Constructor puts (member) pointers to function id-s and parameters on stack. Destructor pops them from stack.

See also:
log_FUNC_m
log_FunctionID

Definition at line 129 of file logid.h.


Constructor & Destructor Documentation

log_FunctionTracer::log_FunctionTracer ( const log_FunctionID a_fcnID_p  ) 

Definition at line 219 of file log_functiontracer.cpp.

References cmn_Global::dbg, dbg_LOW, dbg_NORM, g_cmn, log_Debugger::GetFlags(), Init(), cmn_Global::IsDbgActive(), IVD_COUT_LOG_m, ivd_GetThreadStack(), log_FunctionID::m_buff, log_FunctionID::m_className, m_fcnID_p, log_FunctionID::m_funcName, m_inited, log_FunctionID::m_line, log_Debugger::Write(), and log_Debugger::WriteHeader().

    : m_fcnID_p(a_fcnID_p),
      m_fcnArgs_p(NULL) {
    IVD_COUT_LOG_m(" log_FunctionTracer::log_FunctionTracer " 
             << m_fcnID_p.m_className << "::"
             << m_fcnID_p.m_funcName)

    if (!m_inited) {
        Init();
    }
    
    ivd_GetThreadStack()->push_back(this);

    // Write function entrance
    if (g_cmn.IsDbgActive() && (g_cmn.dbg.GetFlags() & dbg_INOUT) ) {
        ostringstream sstr;

        g_cmn.dbg.WriteHeader(sstr, dbg_NORM, m_fcnID_p, m_fcnID_p.m_line);

        sstr << "==> " << m_fcnID_p.m_buff;

        g_cmn.dbg.Write(dbg_LOW, sstr);
    }
} 

Here is the call graph for this function:

log_FunctionTracer::log_FunctionTracer ( const log_FunctionID a_fcnID_p,
const string &  a_fcnArgs_p 
)

Function entrance with parameters is written in the debug if level is > dbg_EXTAPI or dbg_INOUT flag is set.

Definition at line 251 of file log_functiontracer.cpp.

References cmn_Global::dbg, dbg_LOW, dbg_NORM, g_cmn, log_Debugger::GetFlags(), log_Debugger::GetLevel(), Init(), cmn_Global::IsDbgActive(), IVD_COUT_LOG_m, ivd_GetThreadStack(), log_FunctionID::m_buff, m_fcnID_p, m_inited, log_FunctionID::m_line, log_Debugger::Write(), and log_Debugger::WriteHeader().

    : m_fcnID_p(a_fcnID_p),
      m_fcnArgs_p(&a_fcnArgs_p) {
    IVD_COUT_LOG_m("log_FunctionTracer::log_FunctionTracer(ARG)")

    if (!m_inited) {
        Init();
    }
    
    ivd_GetThreadStack()->push_back(this);

    // Write function entrance
    if (   g_cmn.IsDbgActive() &&
         ( (g_cmn.dbg.GetFlags() & dbg_INOUT)
          || g_cmn.dbg.GetLevel() >= dbg_EXTAPI) ) {

        ostringstream sstr;
        g_cmn.dbg.WriteHeader(sstr, dbg_NORM, m_fcnID_p, m_fcnID_p.m_line);

        sstr
            << "==> " << m_fcnID_p.m_buff
            << "(" << (*m_fcnArgs_p) << ")";

        g_cmn.dbg.Write(dbg_LOW, sstr);
    }
}

Here is the call graph for this function:

log_FunctionTracer::~log_FunctionTracer (  )  [virtual]

Definition at line 282 of file log_functiontracer.cpp.

References cmn_Global::dbg, dbg_LOW, dbg_NORM, g_cmn, log_Debugger::GetFlags(), cmn_Global::IsDbgActive(), IVD_COUT_LOG_m, ivd_GetThreadStack(), log_FunctionID::m_buff, log_FunctionID::m_className, m_fcnID_p, log_FunctionID::m_funcName, log_FunctionID::m_line, size, log_Debugger::Write(), and log_Debugger::WriteHeader().

                                        {
    IVD_COUT_LOG_m(" log_FunctionTracer::~log_FunctionTracer " 
             << m_fcnID_p.m_className << "::"
             << m_fcnID_p.m_funcName)

    ivd_GetThreadStack()->pop_back();
    
    // Write function entrance
    if (g_cmn.IsDbgActive() && (g_cmn.dbg.GetFlags() & dbg_INOUT) ) {
        ostringstream sstr;
        g_cmn.dbg.WriteHeader(sstr, dbg_NORM, m_fcnID_p, m_fcnID_p.m_line);

        sstr << "<== " << m_fcnID_p.m_buff;

        g_cmn.dbg.Write(dbg_LOW, sstr);
    }
#if TGT_OS_windows
    if (ivd_GetThreadStack()->size() == 0) {
        delete g_traceStack, g_traceStack = NULL;
    }
#endif
}

Here is the call graph for this function:


Member Function Documentation

void log_FunctionTracer::DumpStack ( ostream &  a_str  )  [static]

Dump current execution stack.

Definition at line 307 of file log_functiontracer.cpp.

References ivd_GetThreadStack().

Referenced by log_Output().

                                                {
    DumpStack(a_str, ivd_GetThreadStack());
}

Here is the call graph for this function:

Here is the caller graph for this function:

void log_FunctionTracer::DumpStack ( ostream &  a_str,
log_TraceStack a_fstack 
) [static]

Definition at line 312 of file log_functiontracer.cpp.

References log_FunctionID::m_className, m_fcnArgs_p, m_fcnID_p, log_FileID::m_file, log_FunctionID::m_fileID, log_FunctionID::m_funcName, log_FunctionID::m_line, and log_FileID::m_revision.

                                                                           {
    a_str << endl << " Execution stack dump: " << endl;
    
    vector<const log_FunctionTracer*>::reverse_iterator it;
    size_t i(a_fstack->size());
    
    for (it = a_fstack->rbegin(); it != a_fstack->rend(); ++it, --i) {
         
        const log_FunctionTracer* fcn(*it);
        a_str << setw(8) << i << ". "
             << fcn->m_fcnID_p.m_className << "::"
             << fcn->m_fcnID_p.m_funcName;
             
        if (fcn->m_fcnArgs_p != NULL) {
            a_str << "(" << *(fcn->m_fcnArgs_p) << ")";
        }
        a_str
            << " "
            << fcn->m_fcnID_p.m_fileID.m_file << " "
            << fcn->m_fcnID_p.m_fileID.m_revision << ":"
            << fcn->m_fcnID_p.m_line
            << endl;
    }
    a_str << " End of stack dump." << endl;
}

log_TraceStack * log_FunctionTracer::GetStack (  )  [static]

Get pointer to this thread's stack.

Definition at line 341 of file log_functiontracer.cpp.

References ivd_GetThreadStack().

Referenced by ivd_BaseException::FormatText().

                                             {
    return ivd_GetThreadStack();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void log_FunctionTracer::Init (  )  [inline, private]

Definition at line 199 of file log_functiontracer.cpp.

References ie_INVALID_ARG, IVD_COUT_LOG_m, ivd_Error, ivd_GetThreadStack(), m_inited, and ThreadKeyInit().

Referenced by log_FunctionTracer().

                                     {
    m_inited = true;
#if IVD_POSIX_OS
    int result = pthread_once(&g_keyOnce, ThreadKeyInit);
    IVD_COUT_LOG_m("log_FunctionTracer::Init() g_keyOnce=" << g_keyOnce
              << " result=" << result)
    if (result != 0) {
        throw ivd_Error(
            ie_INVALID_ARG,
            "FATAL ERROR: g_idKey is not valid!",
            false); // DO NOT LOG: class used in logging!
    }
#endif

    // Get the stack that has just been created to initialize it immediatelly.
    (void) ivd_GetThreadStack();
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 142 of file logid.h.

Referenced by DumpStack(), and log_Output().

bool log_FunctionTracer::m_inited [static, private]

Definition at line 145 of file logid.h.

Referenced by Init(), and log_FunctionTracer().


The documentation for this class was generated from the following files: