{"_id":"54fa1d54e7a0ba2f0030630c","user":"54cfa8e1a8a4fd0d00b7fd1d","parentDoc":null,"version":{"_id":"54d5635532d98b0d00384afb","project":"54d53c7b23010a0d001aca0c","__v":10,"forked_from":"54d53c7c23010a0d001aca0f","createdAt":"2015-02-07T00:59:01.934Z","releaseDate":"2015-02-07T00:59:01.934Z","categories":["54d5635632d98b0d00384afc","54d5635632d98b0d00384afd","54d5635632d98b0d00384afe","54d5635632d98b0d00384aff","54d5635632d98b0d00384b00","54d5635632d98b0d00384b01","54d5635632d98b0d00384b02","54d652097e05890d006f153e","54dd1315ca1e5219007e9daa","54e21e2b22de1c230094b147","54e68e62a43fe13500db3879","54fa1d3fe7a0ba2f00306309","551c453a23a1ee190034d19a","551df586e52a0b23000c62b6","551f39be6886f8230055f02a","55a6720751457325000e4d97"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"","version_clean":"0.1.0","version":"0.1"},"category":{"_id":"54fa1d3fe7a0ba2f00306309","project":"54d53c7b23010a0d001aca0c","version":"54d5635532d98b0d00384afb","__v":5,"pages":["54fa1d54e7a0ba2f0030630c","54fa1d5de7a0ba2f0030630e","54fa1d65961fea210092064f","54fa1dcff63cf9210041c4c0","551f404b6886f8230055f02f"],"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-03-06T21:33:51.375Z","from_sync":false,"order":6,"slug":"runners-debuggers","title":"Runners & Debuggers"},"project":"54d53c7b23010a0d001aca0c","__v":2,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-03-06T21:34:12.388Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":2,"body":"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.\n\n# Frame\n\n*Check out [the reference guide for Frame](https://docs.c9.io/api/#!/api/debugger.Frame) for all supported properties*\n\nA 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.\n\n```javascript\nvar frame = new Frame({\n    index: index,           // 0 based index of the frame. The top frame has index 0\n    name: name              // Used to display the caption in the call stack\n    line: line,             // The 0 based line number of the place where execution is paused\n    column: column,         // The 0 based column number of the place where execution is paused\n    id: id,                 // A unique id for the frame (usually provided by the debugger protocol)\n    script: scriptName,     // The filename of the source file, used for display purposes only\n    path: scriptPath,       // The full path of the source file related to this frame\n    sourceId: sourceId,     // The unique id of the source file if supported.\n    variables: variables,   // An array of Variable objects in the scope of this frame\n    scopes: scopes          // An array of Scope objects (if applicable) related to this frame\n});\n```\n\n# Breakpoint\n\n*Check out [the reference guide for Breakpoint](https://docs.c9.io/api/#!/api/debugger.Breakpoint) for all supported properties*\n\nA 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.\n\n```\nnew Breakpoint({\n    id: idNumber,               // A unique ID for the breakpoint, \n    path: filePath,             // The path of the source file\n    line: line,                 // The line number in the source file\n    column: column,             // The column number in the source file\n    condition: condition,       // An optional expression that when set only breaks when true\n    enabled: boolEnabled,       // Whether the breakpoint is enabled\n    ignoreCount: ignoreCount,   // # of times the breakpoint is hit before execution is paused\n    serverOnly: serverOnly      // Whether the breakpoint is only known by the server\n});\n```\n\n# Scope\n\n*Check out [the reference guide for Scope](https://docs.c9.io/api/#!/api/debugger.Scope) for all supported properties*\n\nA 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.\n\n```\nnew Scope({\n    index: index,           // The index number of the scope 0 bound\n    type: type,             // A string specifying the kind of scope\n    frameIndex: frameIndex, // The index number of the frame\n    variables: variables    // An array of variable objects that are in this scope\n});\n```\n\n# Source\n*Check out [the reference guide for Source](https://docs.c9.io/api/#!/api/debugger.Source) for all supported properties*\n\nSource files are represented by the `Source` object. Support for retrieving source files can be disabled by the debugger implementation.\n\n```\nnew Source({\n    id: sourceId,               // The unique id of the source file as recognized by the debugger\n    name: name,                 // The name of the source file\n    path: path,                 // The full path of the source file (if any)\n    text: text,                 // \n    debug: isDebuggerFile,      // Whether this 'file' only exists in the context of the debugger\n    lineOffset: lineOffset,     // Use to offset line # (i.e. when prepending the source)\n    customSyntax: customSyntax  // The syntax of the file when opened\n});\n```\n\n# Variable\n*Check out [the reference guide for Variable](https://docs.c9.io/api/#!/api/debugger.Variable) for all supported properties*\n\nA 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).\n\n```\nnew Variable({\n    name: name,                  // The name of this variable\n    scope: scope,                // String specifying the scope for this variable\n    value: value,                // The value of this variable\n    type: type,                  // The type of this variable\n    ref: reference,              // A unique ID for this variable recognized by the debugger\n    children: boolHasProperties, // Whether this variable has any properties\n    prototype: prototype,        // (optional) Variable object referencing the prototype\n    proto: proto,                // (optional) Variable object referencing the proto object\n    constructorFunction: cFn,    // (optional) Variable object referencing the constructor\n});\n```\n\n# Adding Custom Data Objects\n*Check out [the reference guide for Data](https://docs.c9.io/api/#!/api/debugger.Data) for all supported properties*\n\nAdding 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.\n\nThe 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).\n\n```\nvar Data = debug.Data;\n\nfunction Scope(options) {\n    this.data = options || {};\n    this.tagName = \"scope\";\n}\n\nScope.prototype = new Data(\n    [\"index\", \"frameIndex\", \"type\"],\n    [\"variables\"]\n);\n    \nScope.prototype.equals = function(scope) {\n    if (!scope) return false;\n    return this.data.index == scope.index \n      && this.data.frameIndex == scope.frameIndex;\n};\n```","excerpt":"","slug":"data-objects","type":"basic","title":"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](https://docs.c9.io/api/#!/api/debugger.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. ```javascript 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](https://docs.c9.io/api/#!/api/debugger.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](https://docs.c9.io/api/#!/api/debugger.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](https://docs.c9.io/api/#!/api/debugger.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](https://docs.c9.io/api/#!/api/debugger.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](https://docs.c9.io/api/#!/api/debugger.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; }; ```