Path: /sdk/add_on/debugger/
The CDebugger
implements common debugging functionality for scripts, e.g. setting breakpoints, stepping through the code, examining values of variables, etc.
To use the debugger the line callback should be set in the context. This will allow the debugger to take over whenever a breakpoint is reached, so the script can be debugged.
By default the debugger uses the standard in and standard out streams to interact with the user, but this can be easily overloaded by deriving from the CDebugger
class and implementing the methods TakeCommands
and Output
. With this it is possible to implement a graphical interface, or even remote debugging for an application.
The application developer may also be interested in registering to-string callbacks for registered types with calls to RegisterToStringCallback
. Optionally the ToString
method in the debugger can be overridden to implement custom to-string logic.
- See also
- The sample Command line runner for a complete example of how to use the debugger
Public C++ interface
class CDebugger
{
public:
CDebugger();
virtual ~CDebugger();
typedef std::string (*ToStringCallback)(void *obj, int expandMembersLevel, CDebugger *dbg);
virtual void RegisterToStringCallback(
const asITypeInfo *type, ToStringCallback callback);
virtual void Output(const std::string &str);
virtual void PrintHelp();
virtual void AddFileBreakPoint(const std::string &file, int lineNbr);
virtual void AddFuncBreakPoint(const std::string &func);
virtual void ListBreakPoints();
virtual std::string ToString(
void *value,
asUINT typeId,
int expandMembersLevel,
asIScriptEngine *engine);
};
unsigned int asUINT
32 bit unsigned integer
Definition: angelscript.h:127
The interface to the virtual machine.
Definition: angelscript.h:2764
The engine interface.
Definition: angelscript.h:1125
The interface for describing types This interface is used to describe the types in the script engine.
Definition: angelscript.h:3735
Example usage
CDebugger dbg;
{
dbg.TakeCommands(ctx);
}
@ asCALL_THISCALL
A thiscall class method.
Definition: angelscript.h:311
#define asMETHOD(c, m)
Returns an asSFuncPtr representing the class method specified by class and method name.
Definition: angelscript.h:773
virtual int Execute()=0
Executes the prepared function.
virtual int SetLineCallback(asSFuncPtr callback, void *obj, int callConv)=0
Sets a line callback function. The function will be called for each executed script statement.