KJS::Debugger

#include <debugger.h>

Inheritance diagram for KJS::Debugger:

Public Member Functions

 Debugger ()
 
virtual ~Debugger ()
 
virtual bool atStatement (ExecState *exec, int sourceId, int firstLine, int lastLine)
 
virtual void attach (Interpreter *interp)
 
virtual void detach (Interpreter *interp)
 
virtual bool enterContext (ExecState *exec, int sourceId, int lineno, JSObject *function, const List &args)
 
virtual bool exception (ExecState *exec, int sourceId, int lineno, JSValue *exception)
 
virtual bool exitContext (ExecState *exec, int sourceId, int lineno, JSObject *function)
 
bool hasHandledException (ExecState *, JSValue *)
 
DebuggerImp * imp () const
 
void reportAtStatement (ExecState *exec, int sourceId, int firstLine, int lastLine)
 
void reportException (ExecState *exec, JSValue *exception)
 
void reportSourceParsed (ExecState *exec, FunctionBodyNode *body, int sourceId, UString sourceURL, const UString &source, int startingLineNumber, int errorLine, const UString &errorMsg)
 
virtual bool shouldReindentSources () const
 
virtual bool shouldReportCaught () const
 
virtual bool sourceParsed (ExecState *exec, int sourceId, const UString &sourceURL, const UString &source, int startingLineNumber, int errorLine, const UString &errorMsg)
 

Static Public Attributes

static int debuggersPresent = 0
 

Detailed Description

Provides an interface which receives notification about various script-execution related events such as statement execution and function calls.

WARNING: This interface is still a work in progress and is not yet officially publicly available. It is likely to change in binary incompatible (and possibly source incompatible) ways in future versions. It is anticipated that at some stage the interface will be frozen and made available for general use.

Definition at line 54 of file debugger.h.

Constructor & Destructor Documentation

Debugger::Debugger ( )

Creates a new debugger.

Definition at line 51 of file debugger.cpp.

Debugger::~Debugger ( )
virtual

Destroys the debugger.

If the debugger is attached to any interpreters, it is automatically detached.

Definition at line 58 of file debugger.cpp.

Member Function Documentation

bool Debugger::atStatement ( ExecState exec,
int  sourceId,
int  firstLine,
int  lastLine 
)
virtual

Called when a line of the script is reached (before it is executed)

The default implementation does nothing. Override this method if you want to process this event.

Parameters
execThe current execution state
sourceIdThe ID of the source code being executed
firstLineThe starting line of the statement that is about to be executed
lastLineThe ending line of the statement that is about to be executed (usually the same as firstLine)
Returns
true if execution should be continue, false if it should be aborted

Definition at line 122 of file debugger.cpp.

void Debugger::attach ( Interpreter interp)
virtual

Attaches the debugger to specified interpreter.

This will cause this object to receive notification of events from the interpreter.

If the interpreter is deleted, the debugger will automatically be detached.

Note: only one debugger can be attached to an interpreter at a time. Attaching another debugger to the same interpreter will cause the original debugger to be detached from that interpreter.

Parameters
interpThe interpreter to attach to
See also
detach()

Definition at line 64 of file debugger.cpp.

void Debugger::detach ( Interpreter interp)
virtual

Detach the debugger from an interpreter.

Parameters
interpThe interpreter to detach from. If 0, the debugger will be detached from all interpreters to which it is attached.
See also
attach()

Definition at line 77 of file debugger.cpp.

bool Debugger::enterContext ( ExecState exec,
int  sourceId,
int  lineno,
JSObject *  function,
const List args 
)
virtual

Called when the interpreter enters a new execution context (stack frame).

This can happen in three situations:

  • A call to Interpreter::evaluate(). This has a codeType of GlobalCode
  • A call to the builtin eval() function. The sourceId corresponds to the code passed in to eval. This has a codeType of EvalCode. The lineno here is always 0 since execution starts at the beginning of the script.
  • A function call. This only occurs for functions defined in ECMAScript code, whether via the normal function() { ... } syntax or a call to the built-in Function() constructor (anonymous functions). In the former case, the sourceId and lineno indicate the location at which the function was defined. For anonymous functions, the sourceId corresponds to the code passed into the Function() constructor.

enterContext() is not called for functions implemented in the native code, since these do not use an execution context.

Parameters
execThe current execution state (corresponding to the new stack)
sourceIdThe ID of the source code being executed
linenoThe line that is about to be executed
functionThe function being called. 0 in non-function context.
argsThe arguments that were passed to the function line is being executed. Empty in non-function contexts.
Returns
true if execution should be continued, false if it should be aborted

Definition at line 141 of file debugger.cpp.

bool Debugger::exception ( ExecState exec,
int  sourceId,
int  lineno,
JSValue exception 
)
virtual

Called when an exception is thrown during script execution.

The default implementation does nothing. Override this method if you want to process this event.

Parameters
execThe current execution state
sourceIdThe ID of the source code being executed
linenoThe line at which the error occurred
exceptionThe exception object
Returns
true if execution should be continue, false if it should be aborted

Definition at line 116 of file debugger.cpp.

bool Debugger::exitContext ( ExecState exec,
int  sourceId,
int  lineno,
JSObject *  function 
)
virtual

Called when the interpreter exits an execution context.

This always corresponds to a previous call to enterContext()

The default implementation does nothing. Override this method if you want to process this event.

Parameters
execThe current execution state
sourceIdThe ID of the source code being executed
linenoThe line that is about to be executed
functionThe function being returned from, if there is one
Returns
true if execution should be continue, false if it should be aborted

Definition at line 147 of file debugger.cpp.

bool Debugger::sourceParsed ( ExecState exec,
int  sourceId,
const UString sourceURL,
const UString source,
int  startingLineNumber,
int  errorLine,
const UString errorMsg 
)
virtual

Called to notify the debugger that some javascript source code has been parsed.

For calls to Interpreter::evaluate(), this will be called with the supplied source code before any other code is parsed. Other situations in which this may be called include creation of a function using the Function() constructor, or the eval() function.

The default implementation does nothing. Override this method if you want to process this event.

Parameters
execThe current execution state
sourceIdThe ID of the source code (corresponds to the sourceId supplied in other functions such as atStatement()
sourceURLWhere the source code that was parsed came from
sourceThe source code that was parsed
startingLineNumberThe line number at which parsing started
errorLineThe line number at which parsing encountered an error, or -1 if the source code was valid and parsed successfully
errorMsgThe error description, or null if the source code was valid and parsed successfully
Returns
true if execution should be continue, false if it should be aborted

Definition at line 110 of file debugger.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Aug 10 2020 23:04:04 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.