Menu

SnapStack

Debugging (4)
rwaury

Call Stack Snaphots for Windows, AIX and IBM i.


Files

SnapStack.cpp
SnapStack.h


Classes

InvocationEntry

Methods:

  • const char* GetContext()

  • const char* GetProgram()

  • const char* GetModule()

  • const char* GetFunction()

  • unsigned GetLineNumber()

InvocationCallStack

Methods:

  • bool Snapshot()

  • bool Snapshot(EXCEPTION_POINTERS *SEHInfo)
    on Windows only

  • int GetNumEntries()

  • void FreeEntry(InvocationEntry *Current)

  • InvocationEntry* GetFirstEntry()

  • InvocationEntry* GetLastEntry()

  • InvocationEntry* GetNextEntry(InvocationEntry *Current)

  • InvocationEntry* GetPrevEntry(InvocationEntry *Current)


Usage

Example:

#include <stdio.h>
#include <stdlib.h>

#include <SnapStack.h>
#include <LevelTrace.h>

void PrintStack(InvocationCallStack &Stack)
        {
        InvocationEntry *Current = Stack.GetFirstEntry();
        while (Current)
                {
                if (*Current->GetFunction())
                        {
                        TPRINT(("%s (%s:%u)",
                                Current->GetFunction(),
                                Current->GetModule(),
                                Current->GetLineNumber()));
                        }
                else    {
                        TPRINT(("%s (%u)",Current->GetProgram(),
                                          Current->GetLineNumber()));
                        }
                Current = Stack.GetNextEntry(Current);
                }
        return;
        }

void Test(InvocationCallStack &Stack)
        {
        Stack.Snapshot();
        return;        
        }

main()
        {
        InvocationCallStack Stack;
        Test(Stack);
        PrintStack(Stack);

  #ifdef __BORLANDC__
        printf("Press <enter> to continue\n");
        getc(stdin);
  #endif
        return 0;
        }

Related

Wiki: Home

MongoDB Logo MongoDB