ScummVM
GUI::Debugger Class Reference

#include <debugger.h>

Inherited by Access::Debugger, Adl::Console, Agi::Console, Agi::MickeyConsole, Agi::WinnieConsole, AGOS::Debugger, Avalanche::AvalancheConsole, BladeRunner::Debugger, CGE2::CGE2Console, CGE::CGEConsole, CGE::Console, Chewy::Console, Cine::CineConsole, Composer::Console, Cruise::Debugger, Cryo::Console, Cryo::Debugger, DM::Console, Draci::DraciConsole, Drascula::Console, DreamWeb::DreamWebConsole, Fullpipe::Console, Glk::Debugger, Gnap::Debugger, Gob::GobConsole, Groovie::Debugger, Hopkins::Debugger, Hugo::HugoConsole, Kyra::Debugger, Lab::Console, LastExpress::Debugger, Lilliput::LilliputConsole, Lure::Debugger, MacVenture::Console, Made::MadeConsole, MADS::Debugger, Mohawk::CSTimeConsole, Mohawk::LivingBooksConsole, Mohawk::MystConsole, Mohawk::RivenConsole, Mortevielle::Debugger, MutationOfJB::Console, Neverhood::Console, Parallaction::Debugger, Pegasus::PegasusConsole, Pink::Console, Plumbers::Console, Prince::Debugger, Queen::Debugger, Saga::Console, Sci::Console, Scumm::ScummDebugger, Sherlock::Debugger, Sky::Debugger, Sludge::SludgeConsole, StarTrek::Console, Supernova::Console, Sword1::SwordConsole, Sword25::Sword25Console, Sword2::Debugger, TeenAgent::Console, Tinsel::Console, Titanic::Debugger, Toltecs::Console, Tony::Debugger, Toon::ToonConsole, Touche::ToucheConsole, TsAGE::Debugger, Tucker::TuckerConsole, Voyeur::Debugger, Wage::Console, Wage::Debugger, Wintermute::Console, Xeen::Debugger, and ZVision::Console.

Collaboration diagram for GUI::Debugger:

Classes

struct  Var
 

Public Member Functions

 Debugger ()
 
virtual ~Debugger ()
 
int getCharsPerLine ()
 
int debugPrintf (const char *format,...) GCC_PRINTF(2
 
int void debugPrintColumns (const Common::StringArray &list)
 
virtual void onFrame ()
 The onFrame() method should be invoked by the engine at regular intervals (usually once per main loop iteration) whenever the debugger is attached. More...
 
virtual void attach (const char *entry=0)
 'Attach' the debugger. More...
 
bool isActive () const
 Return true if the debugger is currently active (i.e. More...
 

Protected Types

enum  VarType {
  DVAR_BYTE, DVAR_INT, DVAR_BOOL, DVAR_INTARRAY,
  DVAR_STRING
}
 
typedef Common::Functor2< int, const char **, bool > Debuglet
 

Protected Member Functions

void registerVar (const Common::String &varname, byte *variable)
 
void registerVar (const Common::String &varname, int *variable)
 
void registerVar (const Common::String &varname, bool *variable)
 
void registerVar (const Common::String &varname, int32 **variable, int arraySize)
 
void registerVar (const Common::String &varname, Common::String *variable)
 
void registerCmd (const Common::String &cmdname, Debuglet *debuglet)
 
virtual void preEnter ()
 Hook for subclasses which is called just before enter() is run. More...
 
virtual void postEnter ()
 Hook for subclasses which is called just after enter() was run. More...
 
void detach ()
 Subclasses should invoke the detach() method in their cmdFOO methods if that command will resume execution of the program (as opposed to executing, say, a "single step through code" command). More...
 
bool cmdExit (int argc, const char **argv)
 
bool cmdHelp (int argc, const char **argv)
 
bool cmdOpenLog (int argc, const char **argv)
 
bool cmdMd5 (int argc, const char **argv)
 
bool cmdMd5Mac (int argc, const char **argv)
 
bool cmdDebugLevel (int argc, const char **argv)
 
bool cmdDebugFlagsList (int argc, const char **argv)
 
bool cmdDebugFlagEnable (int argc, const char **argv)
 
bool cmdDebugFlagDisable (int argc, const char **argv)
 

Private Types

typedef Common::HashMap< Common::String, Common::SharedPtr< Debuglet >, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualToCommandsMap
 

Private Member Functions

void registerVar (const Common::String &varname, void *variable, VarType type, int arraySize)
 Register a variable with the debugger. More...
 
void enter ()
 
void splitCommand (Common::String &input, int &argc, const char **argv)
 Splits up the input into individual parameters. More...
 
bool parseCommand (const char *input)
 
bool tabComplete (const char *input, Common::String &completion) const
 
virtual bool handleCommand (int argc, const char **argv, bool &keepRunning)
 Process the given command line. More...
 

Static Private Member Functions

static bool debuggerInputCallback (GUI::ConsoleDialog *console, const char *input, void *refCon)
 
static bool debuggerCompletionCallback (GUI::ConsoleDialog *console, const char *input, Common::String &completion, void *refCon)
 

Private Attributes

uint _frameCountdown
 The frame countdown specifies a number of frames that must pass until the console will show up. More...
 
Common::Array< Var_vars
 
CommandsMap _cmds
 
bool _isActive
 True if the debugger is currently active (i.e. More...
 
Common::String _errStr
 
bool _firstTime
 Initially true, set to false when Debugger::enter is called the first time. More...
 
GUI::ConsoleDialog_debuggerDialog
 

Detailed Description

Definition at line 40 of file debugger.h.

Member Typedef Documentation

◆ CommandsMap

◆ Debuglet

typedef Common::Functor2<int, const char **, bool> GUI::Debugger::Debuglet
protected

Definition at line 77 of file debugger.h.

Member Enumeration Documentation

◆ VarType

enum GUI::Debugger::VarType
protected
Enumerator
DVAR_BYTE 
DVAR_INT 
DVAR_BOOL 
DVAR_INTARRAY 
DVAR_STRING 

Definition at line 90 of file debugger.h.

Constructor & Destructor Documentation

◆ Debugger()

GUI::Debugger::Debugger ( )

Definition at line 51 of file debugger.cpp.

◆ ~Debugger()

Member Function Documentation

◆ attach()

void GUI::Debugger::attach ( const char *  entry = 0)
virtual

'Attach' the debugger.

This ensures that the next time onFrame() is invoked, the debugger will activate and accept user input.

Definition at line 157 of file debugger.cpp.

◆ cmdDebugFlagDisable()

bool GUI::Debugger::cmdDebugFlagDisable ( int  argc,
const char **  argv 
)
protected

Definition at line 763 of file debugger.cpp.

◆ cmdDebugFlagEnable()

bool GUI::Debugger::cmdDebugFlagEnable ( int  argc,
const char **  argv 
)
protected

Definition at line 747 of file debugger.cpp.

◆ cmdDebugFlagsList()

bool GUI::Debugger::cmdDebugFlagsList ( int  argc,
const char **  argv 
)
protected

Definition at line 729 of file debugger.cpp.

◆ cmdDebugLevel()

bool GUI::Debugger::cmdDebugLevel ( int  argc,
const char **  argv 
)
protected

Definition at line 710 of file debugger.cpp.

◆ cmdExit()

bool GUI::Debugger::cmdExit ( int  argc,
const char **  argv 
)
protected

Definition at line 545 of file debugger.cpp.

◆ cmdHelp()

bool GUI::Debugger::cmdHelp ( int  argc,
const char **  argv 
)
protected

Definition at line 552 of file debugger.cpp.

◆ cmdMd5()

bool GUI::Debugger::cmdMd5 ( int  argc,
const char **  argv 
)
protected

Definition at line 618 of file debugger.cpp.

◆ cmdMd5Mac()

bool GUI::Debugger::cmdMd5Mac ( int  argc,
const char **  argv 
)
protected

Definition at line 658 of file debugger.cpp.

◆ cmdOpenLog()

bool GUI::Debugger::cmdOpenLog ( int  argc,
const char **  argv 
)
protected

Definition at line 603 of file debugger.cpp.

◆ debuggerCompletionCallback()

bool GUI::Debugger::debuggerCompletionCallback ( GUI::ConsoleDialog console,
const char *  input,
Common::String completion,
void refCon 
)
staticprivate

Definition at line 788 of file debugger.cpp.

◆ debuggerInputCallback()

bool GUI::Debugger::debuggerInputCallback ( GUI::ConsoleDialog console,
const char *  input,
void refCon 
)
staticprivate

Definition at line 781 of file debugger.cpp.

◆ debugPrintColumns()

void GUI::Debugger::debugPrintColumns ( const Common::StringArray list)

Definition at line 118 of file debugger.cpp.

◆ debugPrintf()

int GUI::Debugger::debugPrintf ( const char *  format,
  ... 
)

Definition at line 103 of file debugger.cpp.

◆ detach()

void GUI::Debugger::detach ( )
protected

Subclasses should invoke the detach() method in their cmdFOO methods if that command will resume execution of the program (as opposed to executing, say, a "single step through code" command).

This currently only hides the virtual keyboard, if any.

Definition at line 167 of file debugger.cpp.

◆ enter()

void GUI::Debugger::enter ( )
private

Definition at line 214 of file debugger.cpp.

◆ getCharsPerLine()

int GUI::Debugger::getCharsPerLine ( )

Definition at line 90 of file debugger.cpp.

◆ handleCommand()

bool GUI::Debugger::handleCommand ( int  argc,
const char **  argv,
bool &  keepRunning 
)
privatevirtual

Process the given command line.

Returns true if and only if argv[0] is a known command and was handled, false otherwise.

Definition at line 276 of file debugger.cpp.

◆ isActive()

bool GUI::Debugger::isActive ( ) const
inline

Return true if the debugger is currently active (i.e.

executing a command or waiting for use input).

Definition at line 74 of file debugger.h.

◆ onFrame()

void GUI::Debugger::onFrame ( )
virtual

The onFrame() method should be invoked by the engine at regular intervals (usually once per main loop iteration) whenever the debugger is attached.

This will open up the console and accept user input if certain preconditions are met, such as the frame countdown having reached zero.

Subclasses can override this to e.g. check for breakpoints being triggered.

Definition at line 172 of file debugger.cpp.

◆ parseCommand()

bool GUI::Debugger::parseCommand ( const char *  input)
private

Definition at line 289 of file debugger.cpp.

◆ postEnter()

void GUI::Debugger::postEnter ( )
protectedvirtual

Hook for subclasses which is called just after enter() was run.

A typical usage example is resuming music and sound effects.

The default implementation invokes Engine::pauseEngine(false).

Reimplemented in Sherlock::Debugger, Sword2::Debugger, Sci::Console, Access::Debugger, Queen::Debugger, Sky::Debugger, Scumm::ScummDebugger, and Parallaction::Debugger.

Definition at line 153 of file debugger.cpp.

◆ preEnter()

void GUI::Debugger::preEnter ( )
protectedvirtual

Hook for subclasses which is called just before enter() is run.

A typical usage example is pausing music and sound effects.

The default implementation invokes Engine::pauseEngine(true).

Reimplemented in Sword2::Debugger, Sci::Console, Queen::Debugger, Sky::Debugger, Scumm::ScummDebugger, and Parallaction::Debugger.

Definition at line 149 of file debugger.cpp.

◆ registerCmd()

void GUI::Debugger::registerCmd ( const Common::String cmdname,
Debuglet debuglet 
)
protected

Definition at line 538 of file debugger.cpp.

◆ registerVar() [1/6]

void GUI::Debugger::registerVar ( const Common::String varname,
void variable,
VarType  type,
int  arraySize 
)
private

Register a variable with the debugger.

This allows the user to read and modify this variable.

Parameters
varnamethe identifier with which the user may access the variable
variablepointer to the actual storage of the variable
typethe type of the variable (byte, int, bool, ...)
arraySizefor type DVAR_INTARRAY this specifies the size of the array

Definition at line 523 of file debugger.cpp.

◆ registerVar() [2/6]

void GUI::Debugger::registerVar ( const Common::String varname,
byte variable 
)
inlineprotected

Definition at line 117 of file debugger.h.

◆ registerVar() [3/6]

void GUI::Debugger::registerVar ( const Common::String varname,
int variable 
)
inlineprotected

Definition at line 121 of file debugger.h.

◆ registerVar() [4/6]

void GUI::Debugger::registerVar ( const Common::String varname,
bool *  variable 
)
inlineprotected

Definition at line 125 of file debugger.h.

◆ registerVar() [5/6]

void GUI::Debugger::registerVar ( const Common::String varname,
int32 **  variable,
int  arraySize 
)
inlineprotected

Definition at line 129 of file debugger.h.

◆ registerVar() [6/6]

void GUI::Debugger::registerVar ( const Common::String varname,
Common::String variable 
)
inlineprotected

Definition at line 133 of file debugger.h.

◆ splitCommand()

void GUI::Debugger::splitCommand ( Common::String input,
int argc,
const char **  argv 
)
private

Splits up the input into individual parameters.

Remarks
Adapted from code provided by torek on StackOverflow

Definition at line 396 of file debugger.cpp.

◆ tabComplete()

bool GUI::Debugger::tabComplete ( const char *  input,
Common::String completion 
) const
private

Definition at line 451 of file debugger.cpp.

Member Data Documentation

◆ _cmds

CommandsMap GUI::Debugger::_cmds
private

Definition at line 157 of file debugger.h.

◆ _debuggerDialog

GUI::ConsoleDialog* GUI::Debugger::_debuggerDialog
private

Definition at line 176 of file debugger.h.

◆ _errStr

Common::String GUI::Debugger::_errStr
private

Definition at line 165 of file debugger.h.

◆ _firstTime

bool GUI::Debugger::_firstTime
private

Initially true, set to false when Debugger::enter is called the first time.

We use this flag to show a greeting message to the user once, when he opens the debugger for the first time.

Definition at line 173 of file debugger.h.

◆ _frameCountdown

uint GUI::Debugger::_frameCountdown
private

The frame countdown specifies a number of frames that must pass until the console will show up.

This value is decremented by one each time onFrame() is called, until it reaches 0, at which point onFrame() will open the console and handle input into it.

The user can modify this value using the debug_countdown command.

Note: The console must be in attached state, otherwise, it won't show up (and the countdown won't count down either).

Definition at line 152 of file debugger.h.

◆ _isActive

bool GUI::Debugger::_isActive
private

True if the debugger is currently active (i.e.

executing a command or waiting for use input).

Definition at line 163 of file debugger.h.

◆ _vars

Common::Array<Var> GUI::Debugger::_vars
private

Definition at line 154 of file debugger.h.


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