Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
CThreadDebugger Class Reference

#include <ThreadDebugger.h>

Public Member Functions

 CThreadDebugger ()
 
 ~CThreadDebugger ()
 
void Initialize (uint id, std::string name, ScriptInterface *pScriptInterface, CDebuggingServer *pDebuggingServer)
 Initialize the object (required before using the object!). More...
 
JSTrapStatus TrapHandler (JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval, jsval closure)
 Simply calls BreakHandler with BREAK_SRC_TRAP. More...
 
JSTrapStatus ThrowHandler (JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval)
 Hook to capture exceptions and breakpoints in code (throw "Breakpoint";) More...
 
JSTrapStatus BreakHandler (JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval, jsval closure, BREAK_SRC breakSrc)
 All other hooks call this one if the execution should be paused. More...
 
JSTrapStatus StepHandler (JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval, void *closure)
 
JSTrapStatus StepIntoHandler (JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval, void *closure)
 
JSTrapStatus StepOutHandler (JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval, void *closure)
 
JSTrapStatus CheckForBreakRequestHandler (JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval, void *closure)
 This is an interrup-hook that can be called multiple times per line of code and is used to break into the execution without previously setting a breakpoint and to break other threads when one thread triggers a breakpoint. More...
 
void ExecuteHook (JSContext *cx, const char *filename, unsigned lineno, JSScript *script, JSFunction *fun, void *callerdata)
 The callback function which gets executed for each new script that gets loaded and each function inside a script. More...
 
void NewScriptHook (JSContext *cx, const char *filename, unsigned lineno, JSScript *script, JSFunction *fun, void *callerdata)
 This hook is used to update the mapping between filename plus line-numbers and jsbytecode pointers. More...
 
void DestroyScriptHook (JSContext *cx, JSScript *script)
 This hook makes sure that invalid mappings between filename plus line-number and jsbytecode points get deleted. More...
 
void ClearTrap (CActiveBreakPoint *activeBreakPoint)
 
bool CheckIfMappingPresent (std::string filename, uint line)
 Checks if a mapping for the specified filename and line number exists in this CThreadDebugger's context. More...
 
void SetAllNewTraps ()
 Checks if a mapping exists for each breakpoint in the list of breakpoints that aren't set yet. More...
 
void SetNewTrap (CActiveBreakPoint *activeBreakPoint, std::string filename, uint line)
 Sets a new trap and stores the information in the CActiveBreakPoint pointer Make sure that a mapping exists before calling this function Threading: Locking m_Mutex is required by the callee. More...
 
bool ToggleBreakPoint (std::string filename, uint userLine)
 Toggle a breakpoint if it's active in this threadDebugger object. More...
 
void GetCallstack (std::stringstream &response)
 
void GetStackFrameData (std::stringstream &response, uint nestingLevel, STACK_INFO stackInfoKind)
 
bool CompareScriptInterfacePtr (ScriptInterface *pScriptInterface) const
 Compares the object's associated scriptinterface with the pointer passed as parameter. More...
 
std::string GetBreakFileName ()
 
bool GetIsInBreak ()
 
uint GetLastBreakLine ()
 
std::string GetName ()
 
uint GetID ()
 
void ContinueExecution ()
 
void SetNextDbgCmd (DBGCMD dbgCmd)
 
DBGCMD GetNextDbgCmd ()
 
void AddStackInfoRequest (STACK_INFO requestType, uint nestingLevel, SDL_sem *semaphore)
 

Private Member Functions

void SetBreakFileName (std::string breakFileName)
 
void SetLastBreakLine (uint breakLine)
 
void SetIsInBreak (bool isInBreak)
 
void SaveCallstack ()
 
void ClearTrapsToRemove ()
 Used only in the scriptinterface's thread. More...
 
bool CurrentFrameIsChildOf (JSStackFrame *pParentFrame)
 
void ReturnActiveBreakPoints (jsbytecode *pBytecode)
 
void SaveStackFrameData (STACK_INFO stackInfo, uint nestingLevel)
 
std::string StringifyCyclicJSON (jsval obj, bool indent)
 

Private Attributes

std::auto_ptr
< ThreadDebugger_impl
m
 

Detailed Description

Definition at line 65 of file ThreadDebugger.h.

Constructor & Destructor Documentation

CThreadDebugger::CThreadDebugger ( )

Definition at line 278 of file ThreadDebugger.cpp.

CThreadDebugger::~CThreadDebugger ( )

Definition at line 283 of file ThreadDebugger.cpp.

Member Function Documentation

void CThreadDebugger::AddStackInfoRequest ( STACK_INFO  requestType,
uint  nestingLevel,
SDL_sem semaphore 
)

Definition at line 708 of file ThreadDebugger.cpp.

JSTrapStatus CThreadDebugger::BreakHandler ( JSContext *  cx,
JSScript *  script,
jsbytecode *  pc,
jsval *  rval,
jsval  closure,
BREAK_SRC  breakSrc 
)

All other hooks call this one if the execution should be paused.

It puts the program in a wait-loop and waits for weak-up events (continue, step etc.).

Definition at line 446 of file ThreadDebugger.cpp.

JSTrapStatus CThreadDebugger::CheckForBreakRequestHandler ( JSContext *  cx,
JSScript *  script,
jsbytecode *  pc,
jsval *  rval,
void *  closure 
)

This is an interrup-hook that can be called multiple times per line of code and is used to break into the execution without previously setting a breakpoint and to break other threads when one thread triggers a breakpoint.

Definition at line 413 of file ThreadDebugger.cpp.

bool CThreadDebugger::CheckIfMappingPresent ( std::string  filename,
uint  line 
)

Checks if a mapping for the specified filename and line number exists in this CThreadDebugger's context.

Definition at line 256 of file ThreadDebugger.cpp.

void CThreadDebugger::ClearTrap ( CActiveBreakPoint activeBreakPoint)

Definition at line 204 of file ThreadDebugger.cpp.

void CThreadDebugger::ClearTrapsToRemove ( )
private

Used only in the scriptinterface's thread.

CThreadDebugger.

Definition at line 186 of file ThreadDebugger.cpp.

bool CThreadDebugger::CompareScriptInterfacePtr ( ScriptInterface pScriptInterface) const

Compares the object's associated scriptinterface with the pointer passed as parameter.

Returns
true if equal

Definition at line 871 of file ThreadDebugger.cpp.

void CThreadDebugger::ContinueExecution ( )
bool CThreadDebugger::CurrentFrameIsChildOf ( JSStackFrame *  pParentFrame)
private

Definition at line 398 of file ThreadDebugger.cpp.

void CThreadDebugger::DestroyScriptHook ( JSContext *  cx,
JSScript *  script 
)

This hook makes sure that invalid mappings between filename plus line-number and jsbytecode points get deleted.

Definition at line 587 of file ThreadDebugger.cpp.

void CThreadDebugger::ExecuteHook ( JSContext *  cx,
const char *  filename,
unsigned  lineno,
JSScript *  script,
JSFunction *  fun,
void *  callerdata 
)

The callback function which gets executed for each new script that gets loaded and each function inside a script.

We use it for "Execute-Hooks" and "Call-Hooks" in terms of Spidermonkey. This hook actually sets the traps (Breakpoints) "on the fly" that have been defined by the user previously.

Definition at line 614 of file ThreadDebugger.cpp.

std::string CThreadDebugger::GetBreakFileName ( )

Definition at line 877 of file ThreadDebugger.cpp.

void CThreadDebugger::GetCallstack ( std::stringstream &  response)

Definition at line 639 of file ThreadDebugger.cpp.

uint CThreadDebugger::GetID ( )

Definition at line 931 of file ThreadDebugger.cpp.

bool CThreadDebugger::GetIsInBreak ( )

Definition at line 901 of file ThreadDebugger.cpp.

uint CThreadDebugger::GetLastBreakLine ( )

Definition at line 889 of file ThreadDebugger.cpp.

std::string CThreadDebugger::GetName ( )

Definition at line 925 of file ThreadDebugger.cpp.

DBGCMD CThreadDebugger::GetNextDbgCmd ( )

Definition at line 919 of file ThreadDebugger.cpp.

void CThreadDebugger::GetStackFrameData ( std::stringstream &  response,
uint  nestingLevel,
STACK_INFO  stackInfoKind 
)

Definition at line 684 of file ThreadDebugger.cpp.

void CThreadDebugger::Initialize ( uint  id,
std::string  name,
ScriptInterface pScriptInterface,
CDebuggingServer pDebuggingServer 
)

Initialize the object (required before using the object!).

Parameters
idA unique identifier greater than 0 for the object inside its CDebuggingServer object.
nameA name that will be can be displayed by the UI to identify the thread.
pScriptInterfacePointer to a scriptinterface. All Hooks, breakpoint traps etc. will be registered in this scriptinterface and will be called by the thread this scriptinterface is running in.
pDebuggingServerPointer to the DebuggingServer object this Object should belong to.
Returns
Return value.

Definition at line 325 of file ThreadDebugger.cpp.

void CThreadDebugger::NewScriptHook ( JSContext *  cx,
const char *  filename,
unsigned  lineno,
JSScript *  script,
JSFunction *  fun,
void *  callerdata 
)

This hook is used to update the mapping between filename plus line-numbers and jsbytecode pointers.

Definition at line 543 of file ThreadDebugger.cpp.

void CThreadDebugger::ReturnActiveBreakPoints ( jsbytecode *  pBytecode)
private

Definition at line 298 of file ThreadDebugger.cpp.

void CThreadDebugger::SaveCallstack ( )
private

Definition at line 645 of file ThreadDebugger.cpp.

void CThreadDebugger::SaveStackFrameData ( STACK_INFO  stackInfo,
uint  nestingLevel 
)
private

Definition at line 717 of file ThreadDebugger.cpp.

void CThreadDebugger::SetAllNewTraps ( )

Checks if a mapping exists for each breakpoint in the list of breakpoints that aren't set yet.

If there is a mapping, it removes the breakpoint from the list of unset breakpoints (from CDebuggingServer), adds it to the list of active breakpoints (CThreadDebugger) and sets a trap. Threading: m_Mutex is locked in this call

Definition at line 214 of file ThreadDebugger.cpp.

void CThreadDebugger::SetBreakFileName ( std::string  breakFileName)
private

Definition at line 883 of file ThreadDebugger.cpp.

void CThreadDebugger::SetIsInBreak ( bool  isInBreak)
private

Definition at line 907 of file ThreadDebugger.cpp.

void CThreadDebugger::SetLastBreakLine ( uint  breakLine)
private

Definition at line 895 of file ThreadDebugger.cpp.

void CThreadDebugger::SetNewTrap ( CActiveBreakPoint activeBreakPoint,
std::string  filename,
uint  line 
)

Sets a new trap and stores the information in the CActiveBreakPoint pointer Make sure that a mapping exists before calling this function Threading: Locking m_Mutex is required by the callee.

Definition at line 262 of file ThreadDebugger.cpp.

void CThreadDebugger::SetNextDbgCmd ( DBGCMD  dbgCmd)

Definition at line 913 of file ThreadDebugger.cpp.

JSTrapStatus CThreadDebugger::StepHandler ( JSContext *  cx,
JSScript *  script,
jsbytecode *  pc,
jsval *  rval,
void *  closure 
)

Definition at line 345 of file ThreadDebugger.cpp.

JSTrapStatus CThreadDebugger::StepIntoHandler ( JSContext *  cx,
JSScript *  script,
jsbytecode *  pc,
jsval *  rval,
void *  closure 
)

Definition at line 365 of file ThreadDebugger.cpp.

JSTrapStatus CThreadDebugger::StepOutHandler ( JSContext *  cx,
JSScript *  script,
jsbytecode *  pc,
jsval *  rval,
void *  closure 
)

Definition at line 382 of file ThreadDebugger.cpp.

std::string CThreadDebugger::StringifyCyclicJSON ( jsval  obj,
bool  indent 
)
private

Definition at line 835 of file ThreadDebugger.cpp.

JSTrapStatus CThreadDebugger::ThrowHandler ( JSContext *  cx,
JSScript *  script,
jsbytecode *  pc,
jsval *  rval 
)

Hook to capture exceptions and breakpoints in code (throw "Breakpoint";)

Definition at line 428 of file ThreadDebugger.cpp.

bool CThreadDebugger::ToggleBreakPoint ( std::string  filename,
uint  userLine 
)

Toggle a breakpoint if it's active in this threadDebugger object.

    Threading: Locking m_Mutex is required by the callee
Parameters
filenamefull vfs path to the script filename
userLinelinenumber where the USER set the breakpoint (UserLine)
Returns
true if the breakpoint's state was changed

Definition at line 624 of file ThreadDebugger.cpp.

JSTrapStatus CThreadDebugger::TrapHandler ( JSContext *  cx,
JSScript *  script,
jsbytecode *  pc,
jsval *  rval,
jsval  closure 
)

Simply calls BreakHandler with BREAK_SRC_TRAP.

Definition at line 422 of file ThreadDebugger.cpp.

Member Data Documentation

std::auto_ptr<ThreadDebugger_impl> CThreadDebugger::m
private

Definition at line 180 of file ThreadDebugger.h.


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