#include <debugger.h>
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. | |
Task * | getTask () const |
bool | isDebugging () const |
bool | isLocked () const |
returns state of object. | |
template<> | |
Timer * | mSingleton |
template<> | |
Timer * | mSingleton |
template<> | |
Profiler * | mSingleton |
template<> | |
LogManager * | mSingleton |
template<> | |
debugger::Debugger * | mSingleton |
template<> | |
debugger::CommandParser * | mSingleton |
template<> | |
Application * | mSingleton |
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 Debugger & | getSingleton () |
static Debugger * | getSingletonPtr () |
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 Data & | process () |
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 | |
CodeInstructor * | mActiveCodeInstructor |
CodeInstructorMap | mCodeInstructorMap |
std::string | mExpression |
bool | mIsDebug |
size_t | mLine |
std::string | mOriginalSource |
Task * | mTask |
Definition at line 54 of file debugger.h.
typedef std::map<std::string, CodeInstructor *> gpucalc::debugger::Debugger::CodeInstructorMap [private] |
Definition at line 139 of file debugger.h.
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 | ( | ) |
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 }
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] |
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.
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. |
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] |
bool gpucalc::debugger::Debugger::isDebugging | ( | ) | const [inline] |
bool gpucalc::Object::isLocked | ( | ) | const [inline, inherited] |
void gpucalc::Object::lock | ( | ) | [inline, protected, inherited] |
Timer * gpucalc::Singleton< Timer >::mSingleton | ( | ) | [inline, inherited] |
Definition at line 42 of file win32_timer_impl.cpp.
Timer * gpucalc::Singleton< Timer >::mSingleton | ( | ) | [inline, inherited] |
Definition at line 45 of file unix_timer_impl.cpp.
Profiler * gpucalc::Singleton< Profiler >::mSingleton | ( | ) | [inline, inherited] |
Definition at line 39 of file profiler.cpp.
LogManager * gpucalc::Singleton< LogManager >::mSingleton | ( | ) | [inline, inherited] |
Definition at line 38 of file log_manager.cpp.
debugger::Debugger * gpucalc::Singleton< debugger::Debugger >::mSingleton | ( | ) | [inline, inherited] |
Definition at line 42 of file debugger.cpp.
debugger::CommandParser * gpucalc::Singleton< debugger::CommandParser >::mSingleton | ( | ) | [inline, inherited] |
Definition at line 41 of file command_parser.cpp.
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.
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 143 of file debugger.h.
Definition at line 140 of file debugger.h.
std::string gpucalc::debugger::Debugger::mExpression [private] |
Definition at line 155 of file debugger.h.
bool gpucalc::debugger::Debugger::mIsDebug [private] |
Definition at line 146 of file debugger.h.
size_t gpucalc::debugger::Debugger::mLine [private] |
Definition at line 158 of file debugger.h.
std::string gpucalc::debugger::Debugger::mOriginalSource [private] |
Definition at line 152 of file debugger.h.
T* gpucalc::Singleton< T >::mSingleton [static, protected, inherited] |
Definition at line 108 of file singleton.h.
Task* gpucalc::debugger::Debugger::mTask [private] |
Definition at line 149 of file debugger.h.