{"id":22013917,"url":"https://github.com/pmuellr/node-debug-context","last_synced_at":"2025-08-11T14:45:33.559Z","repository":{"id":27913784,"uuid":"31405744","full_name":"pmuellr/node-debug-context","owner":"pmuellr","description":"exploration of node's debug context","archived":false,"fork":false,"pushed_at":"2016-01-30T23:51:00.000Z","size":8,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-12T12:46:19.581Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pmuellr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-02-27T05:59:51.000Z","updated_at":"2016-01-30T23:51:01.000Z","dependencies_parsed_at":"2022-08-02T10:49:56.351Z","dependency_job_id":null,"html_url":"https://github.com/pmuellr/node-debug-context","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pmuellr/node-debug-context","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmuellr%2Fnode-debug-context","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmuellr%2Fnode-debug-context/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmuellr%2Fnode-debug-context/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmuellr%2Fnode-debug-context/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pmuellr","download_url":"https://codeload.github.com/pmuellr/node-debug-context/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmuellr%2Fnode-debug-context/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269906081,"owners_count":24494320,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-11T02:00:10.019Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-30T03:25:17.710Z","updated_at":"2025-08-11T14:45:33.490Z","avatar_url":"https://github.com/pmuellr.png","language":"JavaScript","readme":"intro\n================================================================================\n\nAn interesting feature got added to node.js 0.12 (also available in io.js):\n[`vm.runInDebugContext(code)`][vmRunInDebugContext]\n\nThe documentation says \"*The primary use case is to get access to\nthe V8 debug object*\", using the following snippet:\n\n    var vm = require(\"vm\")\n\n    var Debug = vm.runInDebugContext(\"Debug\")\n    Debug.setListener(_=\u003e_)\n    Debug.scripts().forEach(function(script) {\n      console.log(script.name)\n    })\n\nThis code snippet should list all the \"scripts\" V8 has loaded.  Try it, there\nare **TONS** of them.\n\nThe debug context gets autocleared after the end of the vm.runInDebugContext() line.  To make things work, we need to keep the context active somehow; in this case, by doing a `Debug.setListener()`. \n\nSo, what else can you do with this thing.  That's what I'm going to find out.\n\nThe place to figure this is out in the REPL, and also by checking out the V8\nsource for this stuff:\n\n* [`debug-debugger.js`][debug-debugger.js]\n* [`liveedit-debugger.js`][liveedit-debugger.js]\n* [`mirror-debugger.js`][mirror-debugger.js]\n* [mjsunit test cases][]\n\nNote that a **lot** of the text here comes directly from `debug-debugger.js`.\n\nNote that I'm going to be skipping two parts of the Debug object for now:\n\n* `TestApi`\n* `LiveEdit`\n\n\n\nobject `Debug`\n================================================================================\n\n\n\u003ca id=\"DebugEvent\"\u003e\u003c/a\u003e\nproperty `DebugEvent`\n--------------------------------------------------------------------------------\n\nAn object with the following properties, whose values are number constants:\n\n* `Break`\n* `Exception`\n* `NewFunction`\n* `BeforeCompile`\n* `AfterCompile`\n* `CompileError`\n* `PromiseEvent`\n* `AsyncTaskEvent`\n* `BreakForCommand`\n\n\nproperty `ExceptionBreak`\n--------------------------------------------------------------------------------\n\nAn object with the following properties, whose values are number constants:\n\n* `Caught`\n* `Uncaught`\n\n\nproperty `StepAction`\n--------------------------------------------------------------------------------\n\nAn object with the following properties, whose values are number constants:\n\n* `StepOut`\n* `StepNext`\n* `StepIn`\n* `StepMin`\n* `StepInMin`\n* `StepFrame`\n\n\nproperty `ScriptType`\n--------------------------------------------------------------------------------\n\nAn object with the following properties, whose values are number constants:\n\n* `Native`\n* `Extension`\n* `Normal`\n\n\nproperty `ScriptCompilationType`\n--------------------------------------------------------------------------------\n\nAn object with the following properties, whose values are number constants:\n\n* `Host`\n* `Eval`\n* `JSON`\n\n\nproperty `ScriptBreakPointType`\n--------------------------------------------------------------------------------\n\nAn object with the following properties, whose values are number constants:\n\n* `ScriptId`\n* `ScriptName`\n* `ScriptRegExp`\n\n\nproperty `BreakPositionAlignment`\n--------------------------------------------------------------------------------\n\nAn object with the following properties, whose values are number constants:\n\n* `Statement`\n* `BreakPosition`\n\n\nmethod `setListener(listener, opt_data)`\n--------------------------------------------------------------------------------\n\nSets an event listening for debug Events.\n\nsee: \u003chttps://github.com/iojs/io.js/blob/v1.x/deps/v8/test/mjsunit/debug-event-listener.js\u003e\n\n`listener` should be a function with following signature:\n\n    function(event, exec_state, event_data, data)\n\n* `event` will be one of the `DebugEvent` properties\n* `exec_state` will be an `ExecState` object\n* `event_data` is event-specific data\n* `data` is the object passed to `setListener()`'s `opt_data` parameter\n\n\nmethod `breakExecution(a)`\n--------------------------------------------------------------------------------\n\n\nmethod `breakLocations(a,b)`\n--------------------------------------------------------------------------------\n\n\nmethod `findScript(aString | aFunction | aRegExp)`\n--------------------------------------------------------------------------------\n\nReturns a `Script` object.\n\nIf the parameter is a function, the return value\nis the script in which the function is defined.\n\nIf the parameter is a string,\nthe return value is the script for which the script name has that string\nvalue.  \n\nIf it is a regexp and there is a unique script whose name matches\nwe return that, otherwise undefined.\n\n\nmethod `scriptSource(String | Function)`\n--------------------------------------------------------------------------------\n\nReturns the script source.\n\nIf the parameter is a function the return value\nis the script source for the script in which the function is defined.\n\nIf the\nparameter is a string the return value is the script for which the script\nname has that string value.\n\n\nmethod `source(aFunction)`\n--------------------------------------------------------------------------------\n\nReturns the source of a function.\n\n\nmethod `disassemble(aFunction)`\n--------------------------------------------------------------------------------\n\nReturns the disassembly of a function.\n\n\nmethod `disassembleConstructor(aFunction)`\n--------------------------------------------------------------------------------\n\nReturns the disassembly of a constructor.\n\n\nmethod `ExecuteInDebugContext(a,b)`\n--------------------------------------------------------------------------------\n\n\nmethod `sourcePosition(a)`\n--------------------------------------------------------------------------------\n\n\nmethod `findFunctionSourceLocation(a,b,c)`\n--------------------------------------------------------------------------------\n\n\nmethod `findScriptSourcePosition(a,b,c)`\n--------------------------------------------------------------------------------\n\n\nmethod `findBreakPoint(a,b)`\n--------------------------------------------------------------------------------\n\n\nmethod `findBreakPointActualLocations(a)`\n--------------------------------------------------------------------------------\n\n\nmethod `setBreakPoint(a,b,c,d)`\n--------------------------------------------------------------------------------\n\n\nmethod `setBreakPointByScriptIdAndPosition(???)`\n--------------------------------------------------------------------------------\n\n\nmethod `enableBreakPoint(a)`\n--------------------------------------------------------------------------------\n\n\nmethod `disableBreakPoint(a)`\n--------------------------------------------------------------------------------\n\n\nmethod `changeBreakPointCondition(a,b)`\n--------------------------------------------------------------------------------\n\n\nmethod `changeBreakPointIgnoreCount(a,b)`\n--------------------------------------------------------------------------------\n\n\nmethod `clearBreakPoint(a)`\n--------------------------------------------------------------------------------\n\n\nmethod `clearAllBreakPoints()`\n--------------------------------------------------------------------------------\n\n\nmethod `disableAllBreakPoints()`\n--------------------------------------------------------------------------------\n\n\nmethod `findScriptBreakPoint(a,b)`\n--------------------------------------------------------------------------------\n\n\nmethod `setScriptBreakPoint(???)`\n--------------------------------------------------------------------------------\n\n\nmethod `setScriptBreakPointById(???)`\n--------------------------------------------------------------------------------\n\n\nmethod `setScriptBreakPointByName(???)`\n--------------------------------------------------------------------------------\n\n\nmethod `setScriptBreakPointByRegExp(???)`\n--------------------------------------------------------------------------------\n\n\nmethod `enableScriptBreakPoint(a)`\n--------------------------------------------------------------------------------\n\n\nmethod `disableScriptBreakPoint(a)`\n--------------------------------------------------------------------------------\n\n\nmethod `changeScriptBreakPointCondition(???)`\n--------------------------------------------------------------------------------\n\n\nmethod `changeScriptBreakPointIgnoreCount(???)`\n--------------------------------------------------------------------------------\n\n\nmethod `scriptBreakPoints()`\n--------------------------------------------------------------------------------\n\n\nmethod `clearStepping()`\n--------------------------------------------------------------------------------\n\n\nmethod `setBreakOnException()`\n--------------------------------------------------------------------------------\n\n\nmethod `clearBreakOnException()`\n--------------------------------------------------------------------------------\n\n\nmethod `isBreakOnException()`\n--------------------------------------------------------------------------------\n\n\nmethod `setBreakOnUncaughtException()`\n--------------------------------------------------------------------------------\n\n\nmethod `clearBreakOnUncaughtException()`\n--------------------------------------------------------------------------------\n\n\nmethod `isBreakOnUncaughtException()`\n--------------------------------------------------------------------------------\n\n\nmethod `showBreakPoints(a,b,c)`\n--------------------------------------------------------------------------------\n\n\nmethod `scripts()`\n--------------------------------------------------------------------------------\n\nReturns an array of `Script` objects\n\nmethod `debuggerFlags()`\n--------------------------------------------------------------------------------\n\nReturns an object with the following properties:\n\n* `breakPointsActive`\n* `breakOnCaughtException`\n* `breakOnUncaughtException`\n\nEach of these properties is an object with a `getValue()` and `setValue()`\nmethod, which get and set the boolean value of the property.\n\n\n\nmethod `MakeMirror(a,b)`\n--------------------------------------------------------------------------------\n\n\n\n\nobject `Script`\n================================================================================\n\nA `Script` object has the following properties:\n\n* `id` - Number\n* `name` - String\n* `source` - String\n* `type` - value of `Debug.ScriptType`\n* `compilation_type` - value of `Debug.ScriptCompilationType`\n* `column_offset` - Number\n* `line_offset` - Number\n* `line_ends` - array of Number\n* `context_data` - ???\n* `eval_from_script` - ???\n* `eval_from_script_position` - ???\n* `eval_from_function_name` - ???\n* `source_url` - ???\n* `source_mapping_url` - ???\n\n\nobject `ExecState`\n================================================================================\n\n\n\u003c!-- ======================================================================= --\u003e\n\n[vmRunInDebugContext]:  https://iojs.org/api/vm.html#vm_vm_runindebugcontext_code\n[debug-debugger.js]:    https://github.com/iojs/io.js/blob/v1.x/deps/v8/src/debug-debugger.js\n[liveedit-debugger.js]: https://github.com/iojs/io.js/blob/v1.x/deps/v8/src/liveedit-debugger.js\n[mirror-debugger.js]:   https://github.com/iojs/io.js/blob/v1.x/deps/v8/src/mirror-debugger.js\n[mjsunit test cases]:   https://github.com/iojs/io.js/blob/v1.x/deps/v8/test/mjsunit/\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmuellr%2Fnode-debug-context","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpmuellr%2Fnode-debug-context","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmuellr%2Fnode-debug-context/lists"}