Skip to content

Commit

Permalink
additional work on hidden scripts
Browse files Browse the repository at this point in the history
- use regexp instead of strings comparison for config.hidden
- step out when break hits hidden script
  • Loading branch information
dannycoates committed Nov 23, 2010
1 parent 62dccc4 commit 9084c79
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 25 deletions.
5 changes: 5 additions & 0 deletions bin/inspector.js
Expand Up @@ -36,6 +36,11 @@ fs.readFile(path.join(__dirname, '../config.json'), function(err, data) {
}
else {
config = JSON.parse(data);
if (config.hidden) {
config.hidden = config.hidden.map(function(s) {
return new RegExp(s, 'i');
});
}
}
dserver.create(options, config).on('close', function () {
console.log('session closed');
Expand Down
15 changes: 1 addition & 14 deletions config.json
@@ -1,16 +1,3 @@
{
"hidden": [
"buffer.js",
"dns.js",
"events.js",
"freelist.js",
"fs.js",
"http.js",
"net.js",
"node.js",
"path.js",
"stream.js",
"timers.js",
"util.js"
]
"hidden": []
}
65 changes: 54 additions & 11 deletions lib/session.js
Expand Up @@ -128,8 +128,10 @@ exports.create = function (conn, debuggerPort, config) {
}

function breakEvent(obj) {
var data = {}, args;
if(!sourceIDs[obj.body.script.id]) {
var data = {},
source = sourceIDs[obj.body.script.id],
args;
if(!source) {
args = {
arguments: {
includeSource: true,
Expand All @@ -138,7 +140,12 @@ exports.create = function (conn, debuggerPort, config) {
}};
debug.request('scripts', args, parsedScripts);
}
sendBacktrace();
else if (source.hidden) {
debug.request('continue', { arguments: {stepaction:'out'}});
}
else {
sendBacktrace();
}
}

function parsedScripts(msg) {
Expand Down Expand Up @@ -168,10 +175,13 @@ exports.create = function (conn, debuggerPort, config) {
return s.join('/');
}
scripts.forEach(function(s) {
sourceIDs[s.sourceID] = s.url;
var hidden;
s.url = shorten(s.path);
hidden = config.hidden &&
config.hidden.some(function(r) { return r.test(s.url); });
sourceIDs[s.sourceID] = { url: s.url, hidden: hidden };
delete s.path;
if (!config.hidden || config.hidden.indexOf(s.url) === -1) {
if (!hidden) {
sendEvent('parsedScriptSource', s);
}
});
Expand Down Expand Up @@ -228,7 +238,7 @@ exports.create = function (conn, debuggerPort, config) {
if (bp.type === 'scriptId') {
data = {
sourceID: bp.script_id,
url: sourceIDs[bp.script_id],
url: sourceIDs[bp.script_id].url,
line: bp.line + 1,
enabled: bp.active,
condition: bp.condition,
Expand Down Expand Up @@ -281,7 +291,16 @@ exports.create = function (conn, debuggerPort, config) {
var ref = tokens[2];

if (ref === 'backtrace') {
debug.request('scope', { arguments: { number:scope, frameNumber:frame, inlineRefs:true }},
debug.request(
'scope',
{
arguments:
{
number:scope,
frameNumber:frame,
inlineRefs:true
}
},
function(msg) {
if (msg.success) {
var refs = {};
Expand Down Expand Up @@ -313,7 +332,15 @@ exports.create = function (conn, debuggerPort, config) {
}]});
seq = 0;
}, LOOKUP_TIMEOUT);
debug.request('lookup', { arguments: { handles:[handle], includeSource: false }},
debug.request(
'lookup',
{
arguments:
{
handles:[handle],
includeSource: false
}
},
function(msg) {
clearTimeout(timeout);
//TODO break out commonality with above
Expand Down Expand Up @@ -370,10 +397,26 @@ exports.create = function (conn, debuggerPort, config) {
else {
var evalResponse = function (msg) {
if (msg.success) {
sendResponse(seq, true, { result: refToObject(msg.body),isException: false });
sendResponse(
seq,
true,
{
result: refToObject(msg.body),
isException: false
});
}
else {
sendResponse(seq, true, { result: { type:'error', description:msg.message }, isException:false });
sendResponse(
seq,
true,
{
result:
{
type:'error',
description: msg.message
},
isException:false
});
}
}
if (methodName === 'evaluateInCallFrame') {
Expand Down Expand Up @@ -436,7 +479,7 @@ exports.create = function (conn, debuggerPort, config) {
var b = msg.body;
breakpoints[b.script_id + ':' + (b.line + 1)] = {
sourceID: b.script_id,
url: sourceIDs[b.script_id],
url: sourceIDs[b.script_id].url,
line: b.line + 1,
enabled: enabled,
condition: condition,
Expand Down

0 comments on commit 9084c79

Please sign in to comment.