Data Objects

The data objects allow a consistent way to communicate with the debugger implementation. These objects represent the frames of the call stack, a breakpoint, the variable scope or a single variable as well as a source file. Not all debuggers will support all objects and it is possible to create new objects as well, if your debugger needs to.

Frame

Check out the reference guide for Frame for all supported properties

A frame represents an item on the call stack. It reference the source file it is in as well as the variables in the scope of the frame and optionally other scopes that relate to the frame as well.

var frame = new Frame({
    index: index,           // 0 based index of the frame. The top frame has index 0
    name: name              // Used to display the caption in the call stack
    line: line,             // The 0 based line number of the place where execution is paused
    column: column,         // The 0 based column number of the place where execution is paused
    id: id,                 // A unique id for the frame (usually provided by the debugger protocol)
    script: scriptName,     // The filename of the source file, used for display purposes only
    path: scriptPath,       // The full path of the source file related to this frame
    sourceId: sourceId,     // The unique id of the source file if supported.
    variables: variables,   // An array of Variable objects in the scope of this frame
    scopes: scopes          // An array of Scope objects (if applicable) related to this frame
});

Breakpoint

Check out the reference guide for Breakpoint for all supported properties

A breakpoint points to an expression in a source file where execution will be paused under the right circumstances. The expression is marked by a line and column number. When the breakpoint is not enabled it must be ignored by the debugger. When it has a condition expression it should only break execution when the condition evaluates to Truthy.

new Breakpoint({
    id: idNumber,               // A unique ID for the breakpoint, 
    path: filePath,             // The path of the source file
    line: line,                 // The line number in the source file
    column: column,             // The column number in the source file
    condition: condition,       // An optional expression that when set only breaks when true
    enabled: boolEnabled,       // Whether the breakpoint is enabled
    ignoreCount: ignoreCount,   // # of times the breakpoint is hit before execution is paused
    serverOnly: serverOnly      // Whether the breakpoint is only known by the server
});

Scope

Check out the reference guide for Scope for all supported properties

A scope represents the scope in which variables exist. There can be different types of scopes (such as global or a parent scope) and a frame can have access to different scopes.

new Scope({
    index: index,           // The index number of the scope 0 bound
    type: type,             // A string specifying the kind of scope
    frameIndex: frameIndex, // The index number of the frame
    variables: variables    // An array of variable objects that are in this scope
});

Source

Check out the reference guide for Source for all supported properties

Source files are represented by the Source object. Support for retrieving source files can be disabled by the debugger implementation.

new Source({
    id: sourceId,               // The unique id of the source file as recognized by the debugger
    name: name,                 // The name of the source file
    path: path,                 // The full path of the source file (if any)
    text: text,                 // 
    debug: isDebuggerFile,      // Whether this 'file' only exists in the context of the debugger
    lineOffset: lineOffset,     // Use to offset line # (i.e. when prepending the source)
    customSyntax: customSyntax  // The syntax of the file when opened
});

Variable

Check out the reference guide for Variable for all supported properties

A variable represents a single variable that exists in a scope. Variables have a name, a type and a value and can optionally have child variables (properties).

new Variable({
    name: name,                  // The name of this variable
    scope: scope,                // String specifying the scope for this variable
    value: value,                // The value of this variable
    type: type,                  // The type of this variable
    ref: reference,              // A unique ID for this variable recognized by the debugger
    children: boolHasProperties, // Whether this variable has any properties
    prototype: prototype,        // (optional) Variable object referencing the prototype
    proto: proto,                // (optional) Variable object referencing the proto object
    constructorFunction: cFn,    // (optional) Variable object referencing the constructor
});

Adding Custom Data Objects

Check out the reference guide for Data for all supported properties

Adding custom data objects is quite easy. You might want to do this if your debugger implementation has more data types it can handle. This might accompany an additional DebugPanel plugin that can handle this new data type.

The following code shows the implementation of the Scope object and illustrates a data object with three basic properties (index, frameIndex, type) and one array property (variables).

var Data = debug.Data;

function Scope(options) {
    this.data = options || {};
    this.tagName = "scope";
}

Scope.prototype = new Data(
    ["index", "frameIndex", "type"],
    ["variables"]
);
    
Scope.prototype.equals = function(scope) {
    if (!scope) return false;
    return this.data.index == scope.index 
      && this.data.frameIndex == scope.frameIndex;
};