gpucalc::debugger::Debugger Class Reference

Debugger performs debugging of our program. More...

#include <debugger.h>

Inheritance diagram for gpucalc::debugger::Debugger:

Inheritance graph

List of all members.

Public Member Functions

void addCodeInstructor (CodeInstructor *CodeInst)
 Debugger ()
const std::string & getClassName () const
 Returns name of class of our object.
const std::string & getObjectName () const
 Returns name of our object.
std::string getOriginalSource () const
void getSpecificParameter (const std::string &ParameterName, void *ParameterValue)
 Method for obtaining some specific parameters, such as texture specific params, and so on.
TaskgetTask () const
bool isDebugging () const
bool isLocked () const
 returns state of object.
template<>
TimermSingleton
template<>
TimermSingleton
template<>
ProfilermSingleton
template<>
LogManagermSingleton
template<>
debugger::DebuggermSingleton
template<>
debugger::CommandParsermSingleton
template<>
ApplicationmSingleton
void print (const std::string &expression)
 This method prints the value of variable in place, where program stops.
void setBreakPoint (size_t line)
 This method sets breakpoint.
void setTask (Task *task)
void stepInto ()
void stepOver ()
void stop ()
 Stops debugging and returns to normal program execution.
 ~Debugger ()

Static Public Member Functions

static void doPrintingData (const Data &data, size_t xcomp, size_t ycomp=0, size_t zcomp=0)
 This method prints given data to std::cout stream.
static DebuggergetSingleton ()
static DebuggergetSingletonPtr ()

Protected Member Functions

void addSpecificParameter (const std::string &ParameterName, void *ParameterValue, size_t Size)
void lock ()
void unlock ()

Static Protected Attributes

static T * mSingleton

Private Types

typedef std::map< std::string,
CodeInstructor * > 
CodeInstructorMap

Private Member Functions

const Dataprocess ()

Static Private Member Functions

template<typename T>
static void elseOnePrintingData (const Data &data, size_t xcomp, size_t ycomp=0, size_t zcomp=0)

Private Attributes

CodeInstructormActiveCodeInstructor
CodeInstructorMap mCodeInstructorMap
std::string mExpression
bool mIsDebug
size_t mLine
std::string mOriginalSource
TaskmTask


Detailed Description

Debugger performs debugging of our program.

Definition at line 54 of file debugger.h.


Member Typedef Documentation

typedef std::map<std::string, CodeInstructor *> gpucalc::debugger::Debugger::CodeInstructorMap [private]

Definition at line 139 of file debugger.h.


Constructor & Destructor Documentation

gpucalc::debugger::Debugger::Debugger (  ) 

Definition at line 59 of file debugger.cpp.

00059                     : Singleton<Debugger>(_DebuggerName), mCodeInstructorMap(), mActiveCodeInstructor(0),
00060    mIsDebug(false), mTask(0), mOriginalSource(), mExpression(), mLine(0)
00061   {
00062   }

gpucalc::debugger::Debugger::~Debugger (  ) 

Definition at line 65 of file debugger.cpp.

00066   {
00067   }


Member Function Documentation

void gpucalc::debugger::Debugger::addCodeInstructor ( CodeInstructor CodeInst  ) 

Definition at line 70 of file debugger.cpp.

00071   {
00072    addToContainer(CodeInst, CodeInst->getLanguageID(), mCodeInstructorMap);
00073   }

void gpucalc::Object::addSpecificParameter ( const std::string &  ParameterName,
void *  ParameterValue,
size_t  Size 
) [inline, protected, inherited]

Definition at line 254 of file object.h.

00255    {
00256     SpecificParametersMap::iterator i = mSpecificParameters.find(ParameterName);
00257     if (i != mSpecificParameters.end())
00258     {
00259      mSpecificParameters.erase(i);
00260     }
00261     mSpecificParameters[ParameterName] = Any(ParameterValue, Size);
00262    }

void gpucalc::debugger::Debugger::doPrintingData ( const Data data,
size_t  xcomp,
size_t  ycomp = 0,
size_t  zcomp = 0 
) [static]

This method prints given data to std::cout stream.

This method may be used without debugging, programmer may prints results of computation via this method (even if Debugger object is not constructed)

Definition at line 170 of file debugger.cpp.

00171   {
00172    switch (data.getValueType())
00173    {
00174     case FloatType:
00175      elseOnePrintingData<float>(data, xcomp, ycomp, zcomp);
00176      break;
00177 
00178     case CharType:
00179      elseOnePrintingData<char>(data, xcomp, ycomp, zcomp);
00180      break;
00181 
00182     default:
00183      Except<ERR_NOT_IMPLEMENTED>(Object(_SingletonClassName, _DebuggerName), "Other value types is not implemented yet.",
00184       "debugger::Debugger::doPrintingData()", __FILE__, __LINE__);
00185      break;
00186    }
00187   }

template<typename T>
void gpucalc::debugger::Debugger::elseOnePrintingData ( const Data data,
size_t  xcomp,
size_t  ycomp = 0,
size_t  zcomp = 0 
) [inline, static, private]

Definition at line 190 of file debugger.cpp.

00191   {
00192    size_t offset = data.getNumberOfComponents() * (data.getSizeX() * (zcomp * data.getSizeY() + ycomp) + xcomp);
00193    for (size_t i = 0; i < data.getNumberOfComponents(); ++i)
00194    {
00195     std::cout << static_cast<const T *>(data.pointer())[offset + i] << "\t";
00196    }
00197    std::cout << std::endl;
00198   }

const std::string& gpucalc::Object::getClassName (  )  const [inline, inherited]

Returns name of class of our object.

Definition at line 92 of file object.h.

00093    {
00094     return mClassName;
00095    }

const std::string& gpucalc::Object::getObjectName (  )  const [inline, inherited]

Returns name of our object.

Definition at line 101 of file object.h.

00102    {
00103     return mObjectName;
00104    }

std::string gpucalc::debugger::Debugger::getOriginalSource (  )  const [inline]

Definition at line 81 of file debugger.h.

00082     {
00083      return mOriginalSource;
00084     }

debugger::Debugger & gpucalc::debugger::Debugger::getSingleton (  )  [static]

Override standard Singleton retrieval.

Why do we do this? Well, it's because the Singleton implementation is in a .h file, which means it gets compiled into anybody who includes it. This is needed for the Singleton template to work, but we actually only want it compiled into the implementation of the class based on the Singleton, not all of them. If we don't change this, we get link errors when trying to use the Singleton-based class from an outside dll.

This method just delegates to the template version anyway, but the implementation stays in this single compilation unit, preventing link errors.

Reimplemented from gpucalc::Singleton< T >.

Definition at line 51 of file debugger.cpp.

00052  {
00053   assert(mSingleton);
00054   return(* mSingleton);
00055  }

debugger::Debugger * gpucalc::debugger::Debugger::getSingletonPtr (  )  [static]

Override standard Singleton retrieval.

Why do we do this? Well, it's because the Singleton implementation is in a .h file, which means it gets compiled into anybody who includes it. This is needed for the Singleton template to work, but we actually only want it compiled into the implementation of the class based on the Singleton, not all of them. If we don't change this, we get link errors when trying to use the Singleton-based class from an outside dll.

This method just delegates to the template version anyway, but the implementation stays in this single compilation unit, preventing link errors.

Reimplemented from gpucalc::Singleton< T >.

Definition at line 45 of file debugger.cpp.

00046  {
00047   return mSingleton;
00048  }

void gpucalc::Object::getSpecificParameter ( const std::string &  ParameterName,
void *  ParameterValue 
) [inline, inherited]

Method for obtaining some specific parameters, such as texture specific params, and so on.

Parameters:
ParameterName - name of parameter, usually it similar to specific method of some object (for example, GLTextureID)
ParameterValue - contain value of named parameter, it must be allocated and have sufficient size.
Todo:
Think for better realization.

Definition at line 128 of file object.h.

00129    {
00130     SpecificParametersMap::iterator i = mSpecificParameters.find(ParameterName);
00131     if (i != mSpecificParameters.end())
00132     {
00133      i->second.copyValue(ParameterValue);
00134     }
00135     else
00136     {
00137      Except<ERR_ITEM_NOT_FOUND>(this, "Parameter \"" + ParameterName + "\" does not exists.", "Object::getSpecificParameter()", __FILE__, __LINE__);
00138     }
00139    }

Task* gpucalc::debugger::Debugger::getTask (  )  const [inline]

Definition at line 75 of file debugger.h.

00076     {
00077      return mTask;
00078     }

bool gpucalc::debugger::Debugger::isDebugging (  )  const [inline]

Definition at line 120 of file debugger.h.

00121     {
00122      return mIsDebug;
00123     }

bool gpucalc::Object::isLocked (  )  const [inline, inherited]

returns state of object.

If object is locked then we cannot change some state of it, because object is used in computation. If object is unlocked then we can change some state of it, object is not in computation.

Definition at line 113 of file object.h.

00114    {
00115     return mIsLocked;
00116    }

void gpucalc::Object::lock (  )  [inline, protected, inherited]

Definition at line 265 of file object.h.

00266    {
00267     mIsLocked = true;
00268    }

template<>
Timer * gpucalc::Singleton< Timer >::mSingleton (  )  [inline, inherited]

Definition at line 42 of file win32_timer_impl.cpp.

template<>
Timer * gpucalc::Singleton< Timer >::mSingleton (  )  [inline, inherited]

Definition at line 45 of file unix_timer_impl.cpp.

template<>
Profiler * gpucalc::Singleton< Profiler >::mSingleton (  )  [inline, inherited]

Definition at line 39 of file profiler.cpp.

template<>
LogManager * gpucalc::Singleton< LogManager >::mSingleton (  )  [inline, inherited]

Definition at line 38 of file log_manager.cpp.

template<>
debugger::Debugger * gpucalc::Singleton< debugger::Debugger >::mSingleton (  )  [inline, inherited]

Definition at line 42 of file debugger.cpp.

template<>
debugger::CommandParser * gpucalc::Singleton< debugger::CommandParser >::mSingleton (  )  [inline, inherited]

Definition at line 41 of file command_parser.cpp.

template<>
Application * gpucalc::Singleton< Application >::mSingleton (  )  [inline, inherited]

Definition at line 44 of file application.cpp.

void gpucalc::debugger::Debugger::print ( const std::string &  expression  ) 

This method prints the value of variable in place, where program stops.

Definition at line 105 of file debugger.cpp.

00106   {
00107    mExpression = expression;
00108    doPrintingData(process(), 0);
00109   }

const Data & gpucalc::debugger::Debugger::process (  )  [private]

Definition at line 143 of file debugger.cpp.

00144   {
00145    if ((mLine != 0) && (mExpression.length() != 0))
00146    {
00147     std::string InstructedSource = mActiveCodeInstructor->instruct(mLine, mExpression);
00148     mTask->getActiveKernel()->getShader()->setSource(InstructedSource);
00149     mTask->compute();
00150     return  mTask->getResultData();
00151    }
00152    else
00153    {
00154     Except<ERR_INVALIDPARAMS>(this, "Line or Expression are incorrect", "debugger::Debugger::process()", __FILE__, __LINE__);
00155    }
00156   }

void gpucalc::debugger::Debugger::setBreakPoint ( size_t  line  ) 

This method sets breakpoint.

Definition at line 99 of file debugger.cpp.

00100   {
00101    mLine = line;
00102   }

void gpucalc::debugger::Debugger::setTask ( Task task  ) 

Definition at line 76 of file debugger.cpp.

00077   {
00078    mTask = task;
00079    Kernel * kernel = task->getActiveKernel();
00080    mOriginalSource = kernel->getShader()->getSource();
00081    {
00082     CodeInstructorMap::iterator i = mCodeInstructorMap.find(kernel->getShader()->getLanguageID());
00083     if (i != mCodeInstructorMap.end())
00084     {
00085      mActiveCodeInstructor = i->second;
00086     }
00087     else
00088     {
00089      Except<ERR_ITEM_NOT_FOUND>(this,
00090       "CodeInstructor with language id \"" + kernel->getShader()->getLanguageID() + "\" cannot be found. Debugging is not available.",
00091       "debugger::Debugger::setTask()", __FILE__, __LINE__);
00092     }
00093    }
00094    mActiveCodeInstructor->setOriginalSource(mOriginalSource);
00095    mIsDebug = true;
00096   }

void gpucalc::debugger::Debugger::stepInto (  ) 

Definition at line 112 of file debugger.cpp.

00113   {
00114    /*
00115    if (mActiveCodeInstructor->isExternalFunctionCalling(mLine))
00116    {
00117     mLine = mActiveCodeInstructor->getExternalFunctionBody(mActiveCodeInstructor->getExternalFunctionName(mLine));
00118    }
00119    */
00120    Warning<ERR_NOT_IMPLEMENTED>(this, "StepInto is not implemented yet.", "debugger::Debugger::stepInto()", __FILE__, __LINE__);
00121    setBreakPoint(mLine + 1);
00122   }

void gpucalc::debugger::Debugger::stepOver (  ) 

This method works only with consequent computation: loops and function calls are ignored.

Todo:
Create methods for performing steps in loops and function calls.

Definition at line 125 of file debugger.cpp.

00126   {
00132    /*
00133    if (mActiveCodeInstructor->isCycle(mLine))
00134    {
00135     mLine = mActiveCodeInstructor->getEndOfCycle(mLine);
00136    }
00137    */
00138    Warning<ERR_NOT_IMPLEMENTED>(this, "StepOver is not implemented yet.", "debugger::Debugger::stepOver()", __FILE__, __LINE__);
00139    setBreakPoint(mLine + 1);
00140   }

void gpucalc::debugger::Debugger::stop (  ) 

Stops debugging and returns to normal program execution.

Definition at line 159 of file debugger.cpp.

00160   {
00161    mIsDebug = false;
00162    mTask = 0;
00163    mOriginalSource = std::string();
00164    mExpression = std::string();
00165    mLine = 0;
00166    mActiveCodeInstructor->setOriginalSource(mOriginalSource);
00167   }

void gpucalc::Object::unlock (  )  [inline, protected, inherited]

Definition at line 271 of file object.h.

00272    {
00273     mIsLocked = false;
00274    }


Member Data Documentation

Definition at line 143 of file debugger.h.

Definition at line 140 of file debugger.h.

Definition at line 155 of file debugger.h.

Definition at line 146 of file debugger.h.

Definition at line 158 of file debugger.h.

Definition at line 152 of file debugger.h.

template<typename T>
T* gpucalc::Singleton< T >::mSingleton [static, protected, inherited]

Definition at line 108 of file singleton.h.

Definition at line 149 of file debugger.h.


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

Generated on Thu Mar 5 22:36:47 2009 for gpucalc by  doxygen 1.5.6