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

#include <DebuggingServer.h>

Public Member Functions

 CDebuggingServer ()
 
 ~CDebuggingServer ()
 
void RegisterScriptinterface (std::string name, ScriptInterface *pScriptInterface)
 Register a new ScriptInerface for debugging the scripts it executes. More...
 
void UnRegisterScriptinterface (ScriptInterface *pScriptInterface)
 Unregister a ScriptInerface that was previously registered using RegisterScriptinterface. More...
 
void * MgDebuggingServerCallback (mg_event event, struct mg_connection *conn, const struct mg_request_info *request_info)
 
double AquireBreakPointAccess (std::list< CBreakPoint > **breakPoints)
 Aquire exclusive read and write access to the list of breakpoints. More...
 
void ReleaseBreakPointAccess (double breakPointsLockID)
 See AquireBreakPointAccess(). More...
 
bool GetBreakRequestedByThread ()
 Called from multiple Mongoose threads and multiple ScriptInterface threads. More...
 
bool GetBreakRequestedByUser ()
 
bool GetSettingSimultaneousThreadBreak ()
 
bool GetSettingBreakOnException ()
 
void SetBreakRequestedByThread (bool Enabled)
 
void SetBreakRequestedByUser (bool Enabled)
 

Private Member Functions

bool GetWebArgs (struct mg_connection *conn, const struct mg_request_info *request_info, std::string argName, uint &arg)
 Webserver helper function (can be called by multiple mongooser threads) More...
 
bool GetWebArgs (struct mg_connection *conn, const struct mg_request_info *request_info, std::string argName, std::string &arg)
 
void GetThreadDebuggerStatus (std::stringstream &response)
 Functions that are made available via http (can be called by multiple mongoose threads) More...
 
void ToggleBreakPoint (std::string filename, uint line)
 
void GetAllCallstacks (std::stringstream &response)
 
void GetStackFrameData (std::stringstream &response, uint nestingLevel, uint threadDebuggerID, STACK_INFO stackInfoKind)
 
bool SetNextDbgCmd (uint threadDebuggerID, DBGCMD dbgCmd)
 
void SetSettingSimultaneousThreadBreak (bool Enabled)
 
void SetSettingBreakOnException (bool Enabled)
 
void EnumVfsJSFiles (std::stringstream &response)
 Returns a list of the full vfs paths to all files with the extension .js found in the vfs root. More...
 
void GetFile (std::string filename, std::stringstream &response)
 Get the content of a .js file loaded into vfs. More...
 
void EnableHTTP ()
 Not important for this class' thread-safety. More...
 

Private Attributes

bool m_SettingSimultaneousThreadBreak
 Shared between multiple mongoose threads. More...
 
bool m_SettingBreakOnException
 
uint m_LastThreadDebuggerID
 Shared between multiple scriptinterface threads. More...
 
std::list< CThreadDebugger * > m_ThreadDebuggers
 Shared between multiple scriptinerface threads and multiple mongoose threads. More...
 
bool m_BreakRequestedByThread
 
bool m_BreakRequestedByUser
 
std::list< CBreakPointm_BreakPoints
 
SDL_semm_BreakPointsSem
 Used for controlling access to m_BreakPoints. More...
 
double m_BreakPointsLockID
 
CMutex m_Mutex
 Mutexes used to ensure thread-safety. More...
 
CMutex m_Mutex1
 
mg_contextm_MgContext
 

Static Private Attributes

static const char * header400
 

Detailed Description

Definition at line 32 of file DebuggingServer.h.

Constructor & Destructor Documentation

CDebuggingServer::CDebuggingServer ( )

Definition at line 83 of file DebuggingServer.cpp.

CDebuggingServer::~CDebuggingServer ( )

Definition at line 99 of file DebuggingServer.cpp.

Member Function Documentation

double CDebuggingServer::AquireBreakPointAccess ( std::list< CBreakPoint > **  breakPoints)

Aquire exclusive read and write access to the list of breakpoints.

Parameters
breakPointsA pointer to the list storing all breakpoints.
Returns
A number you need to pass to ReleaseBreakPointAccess().

Make sure to call ReleaseBreakPointAccess after you don't need access any longer. Using this function you get exclusive access and other threads won't be able to access the breakpoints until you call ReleaseBreakPointAccess!

Definition at line 556 of file DebuggingServer.cpp.

void CDebuggingServer::EnableHTTP ( )
private

Not important for this class' thread-safety.

Definition at line 411 of file DebuggingServer.cpp.

void CDebuggingServer::EnumVfsJSFiles ( std::stringstream &  response)
private

Returns a list of the full vfs paths to all files with the extension .js found in the vfs root.

Parameters
responseThis will contain the list as JSON array.

Definition at line 185 of file DebuggingServer.cpp.

void CDebuggingServer::GetAllCallstacks ( std::stringstream &  response)
private

Definition at line 33 of file DebuggingServer.cpp.

bool CDebuggingServer::GetBreakRequestedByThread ( )

Called from multiple Mongoose threads and multiple ScriptInterface threads.

Definition at line 134 of file DebuggingServer.cpp.

bool CDebuggingServer::GetBreakRequestedByUser ( )

Definition at line 146 of file DebuggingServer.cpp.

void CDebuggingServer::GetFile ( std::string  filename,
std::stringstream &  response 
)
private

Get the content of a .js file loaded into vfs.

Parameters
filenameA full vfs path (as returned by EnumVfsJSFiles).
responseThis will contain the contents of the requested file.

Definition at line 205 of file DebuggingServer.cpp.

bool CDebuggingServer::GetSettingBreakOnException ( )

Definition at line 164 of file DebuggingServer.cpp.

bool CDebuggingServer::GetSettingSimultaneousThreadBreak ( )

Definition at line 170 of file DebuggingServer.cpp.

void CDebuggingServer::GetStackFrameData ( std::stringstream &  response,
uint  nestingLevel,
uint  threadDebuggerID,
STACK_INFO  stackInfoKind 
)
private

Definition at line 63 of file DebuggingServer.cpp.

void CDebuggingServer::GetThreadDebuggerStatus ( std::stringstream &  response)
private

Functions that are made available via http (can be called by multiple mongoose threads)

Definition at line 490 of file DebuggingServer.cpp.

bool CDebuggingServer::GetWebArgs ( struct mg_connection conn,
const struct mg_request_info request_info,
std::string  argName,
uint &  arg 
)
private

Webserver helper function (can be called by multiple mongooser threads)

Definition at line 426 of file DebuggingServer.cpp.

bool CDebuggingServer::GetWebArgs ( struct mg_connection conn,
const struct mg_request_info request_info,
std::string  argName,
std::string &  arg 
)
private

Definition at line 446 of file DebuggingServer.cpp.

void * CDebuggingServer::MgDebuggingServerCallback ( mg_event  event,
struct mg_connection conn,
const struct mg_request_info request_info 
)

Definition at line 226 of file DebuggingServer.cpp.

void CDebuggingServer::RegisterScriptinterface ( std::string  name,
ScriptInterface pScriptInterface 
)

Register a new ScriptInerface for debugging the scripts it executes.

Parameters
nameA name for the ScriptInterface (will be sent to the debugging client an probably displayed to the user)
pScriptInterfaceA pointer to the ScriptInterface. This pointer must stay valid until UnRegisterScriptInterface ist called!

Definition at line 465 of file DebuggingServer.cpp.

void CDebuggingServer::ReleaseBreakPointAccess ( double  breakPointsLockID)

See AquireBreakPointAccess().

You must not access the pointer returend by AquireBreakPointAccess() any longer after you call this function.

Parameters
breakPointsLockIDThe number you got when aquiring the access. It's used to make sure that this function never gets used by the wrong thread.

Definition at line 566 of file DebuggingServer.cpp.

void CDebuggingServer::SetBreakRequestedByThread ( bool  Enabled)

Definition at line 128 of file DebuggingServer.cpp.

void CDebuggingServer::SetBreakRequestedByUser ( bool  Enabled)

Definition at line 140 of file DebuggingServer.cpp.

bool CDebuggingServer::SetNextDbgCmd ( uint  threadDebuggerID,
DBGCMD  dbgCmd 
)
private

Definition at line 109 of file DebuggingServer.cpp.

void CDebuggingServer::SetSettingBreakOnException ( bool  Enabled)
private

Definition at line 152 of file DebuggingServer.cpp.

void CDebuggingServer::SetSettingSimultaneousThreadBreak ( bool  Enabled)
private

Definition at line 158 of file DebuggingServer.cpp.

void CDebuggingServer::ToggleBreakPoint ( std::string  filename,
uint  line 
)
private

Definition at line 514 of file DebuggingServer.cpp.

void CDebuggingServer::UnRegisterScriptinterface ( ScriptInterface pScriptInterface)

Unregister a ScriptInerface that was previously registered using RegisterScriptinterface.

Parameters
pScriptInterfaceA pointer to the ScriptInterface

Definition at line 474 of file DebuggingServer.cpp.

Member Data Documentation

const char * CDebuggingServer::header400
staticprivate
Initial value:
=
"HTTP/1.1 400 Bad Request\r\n"
"Content-Type: text/plain; charset=utf-8\r\n\r\n"
"Invalid request"

Definition at line 85 of file DebuggingServer.h.

std::list<CBreakPoint> CDebuggingServer::m_BreakPoints
private

Definition at line 132 of file DebuggingServer.h.

double CDebuggingServer::m_BreakPointsLockID
private

Definition at line 136 of file DebuggingServer.h.

SDL_sem* CDebuggingServer::m_BreakPointsSem
private

Used for controlling access to m_BreakPoints.

Definition at line 135 of file DebuggingServer.h.

bool CDebuggingServer::m_BreakRequestedByThread
private

Definition at line 127 of file DebuggingServer.h.

bool CDebuggingServer::m_BreakRequestedByUser
private

Definition at line 128 of file DebuggingServer.h.

uint CDebuggingServer::m_LastThreadDebuggerID
private

Shared between multiple scriptinterface threads.

Definition at line 120 of file DebuggingServer.h.

mg_context* CDebuggingServer::m_MgContext
private

Definition at line 145 of file DebuggingServer.h.

CMutex CDebuggingServer::m_Mutex
private

Mutexes used to ensure thread-safety.

Currently we just use one Mutex (m_Mutex) and if we detect possible sources of deadlocks, we use the second mutex for some members to avoid it.

Definition at line 140 of file DebuggingServer.h.

CMutex CDebuggingServer::m_Mutex1
private

Definition at line 141 of file DebuggingServer.h.

bool CDebuggingServer::m_SettingBreakOnException
private

Definition at line 117 of file DebuggingServer.h.

bool CDebuggingServer::m_SettingSimultaneousThreadBreak
private

Shared between multiple mongoose threads.

Definition at line 116 of file DebuggingServer.h.

std::list<CThreadDebugger*> CDebuggingServer::m_ThreadDebuggers
private

Shared between multiple scriptinerface threads and multiple mongoose threads.

Definition at line 123 of file DebuggingServer.h.


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