Permalink
Browse files

roughed in pulling snapshot data from v8.log file

  • Loading branch information...
1 parent e6d9260 commit 41cded93399981e8650a3bd693e6515457eb1a59 @dannycoates dannycoates committed Oct 5, 2010
View
@@ -1,25 +0,0 @@
-var getLines = require('./profiler').getLogLines;
-
-
-var procProto = global.v8debug.DebugCommandProcessor.prototype;
-var oldReqHandler = procProto.processDebugJSONRequest;
-
-function newReqHandler(json_request) {
- var req = JSON.parse(json_request);
- if (req.command === 'getloglines') {
- var res = response = this.createResponse(req);
- try {
- res.body = getLines(req.position);
- }
- catch (e) {
- res.failed('profiler error');
- }
- res.running = this.running_;
- return res.toJSONProtocol();
- }
- else {
- return oldReqHandler.call(this, json_request);
- }
-};
-
-procProto.processDebugJSONRequest = newReqHandler;
View
Binary file not shown.
View
@@ -211,7 +211,7 @@ var WebInspector = {
this.panels.timeline = new WebInspector.TimelinePanel();
if (hiddenPanels.indexOf("profiles") === -1) {
this.panels.profiles = new WebInspector.ProfilesPanel();
- this.panels.profiles.registerProfileType(new WebInspector.CPUProfileType());
+ //this.panels.profiles.registerProfileType(new WebInspector.CPUProfileType());
}
if (hiddenPanels.indexOf("storage") === -1 && hiddenPanels.indexOf("databases") === -1)
this.panels.storage = new WebInspector.StoragePanel();
@@ -47,6 +47,7 @@ WebInspector.nodeDebugger = (function() {
debugr = {
port: 5858,
pauseOnExceptions: false,
+ logPath: '',
connect: function() {
var addr;
if (['http:', 'https:'].indexOf(window.location.protocol) > -1) {
@@ -180,7 +181,7 @@ WebInspector.nodeDebugger = (function() {
sendRequest('profile', {arguments: {command: 'pause', modules: 1, tag: 0}});
},
enableProfiler: function() {
- //sendRequest('enableprof');
+ sendRequest('setLog', {arguments: {path:this.logPath}});
},
getLogLines: function(pos, callId) {
sendRequest('logLines', {arguments: {position: pos}}, callId);
@@ -369,7 +369,7 @@ WebInspector.InspectorFrontendHostStub.prototype = {
loaded: function()
{
- Preferences.samplingCPUProfiler = true;
+ Preferences.samplingCPUProfiler = false;
Preferences.heapProfilerPresent = true;
Preferences.debuggerAlwaysEnabled = true;
Preferences.profilerAlwaysEnabled = true;
@@ -2,6 +2,7 @@
window.addEventListener("load", function() {
WebInspector.WatchExpressionsSection.NewWatchExpression = "''";
+ //Source Frame
WebInspector.SourceFrame.prototype._mouseDown = function(event)
{
this._resetHoverTimer();
@@ -34,15 +35,16 @@
event.preventDefault();
};
- var panel = WebInspector.panels.scripts.panelEnablerView;
- panel.choicesForm.removeChild(panel.disclaimerElement);
- panel.choicesForm.removeChild(panel.enabledForSession.parentNode);
- panel.choicesForm.removeChild(panel.enabledAlways.parentNode);
- panel.headerElement.textContent = "all your node are belong to us";
- panel.enableButton.textContent = 'Connect to Node';
+ //Script Panel
+ var sPanel = WebInspector.panels.scripts.panelEnablerView;
+ sPanel.choicesForm.removeChild(sPanel.disclaimerElement);
+ sPanel.choicesForm.removeChild(sPanel.enabledForSession.parentNode);
+ sPanel.choicesForm.removeChild(sPanel.enabledAlways.parentNode);
+ sPanel.headerElement.textContent = "all your node are belong to us";
+ sPanel.enableButton.textContent = 'Connect to Node';
var div = document.createElement('div');
- panel.error = document.createElement('h3');
- panel.error.style.color = 'red';
+ sPanel.error = document.createElement('h3');
+ sPanel.error.style.color = 'red';
var plabel = document.createElement('label');
plabel.style.left = '65px';
var port = document.createElement('input');
@@ -52,12 +54,30 @@
plabel.appendChild(document.createTextNode('Debug port: '));
plabel.appendChild(port);
div.appendChild(plabel);
- panel.choicesForm.insertBefore(div, panel.enableButton);
- panel.choicesForm.appendChild(panel.error);
+ sPanel.choicesForm.insertBefore(div, sPanel.enableButton);
+ sPanel.choicesForm.appendChild(sPanel.error);
- panel.enableButton.addEventListener("click", function() {
- panel.error.textContent = ' ';
+ sPanel.enableButton.addEventListener("click", function() {
+ sPanel.error.textContent = ' ';
WebInspector.nodeDebugger.port = parseInt(port.value, 10);
}, false);
+
+ //Profile Panel
+ var pPanel = WebInspector.panels.profiles.panelEnablerView;
+ pPanel.choicesForm.removeChild(pPanel.disclaimerElement);
+ pPanel.choicesForm.removeChild(pPanel.enabledForSession.parentNode);
+ pPanel.choicesForm.removeChild(pPanel.enabledAlways.parentNode);
+ pPanel.headerElement.textContent = 'Enter the path to the V8 log file';
+ pPanel.enableButton.textContent = 'Set';
+ var path = document.createElement('input');
+ path.style.width = '300px';
+ path.type = 'text';
+ path.value = '/absolute/path/to/your/v8.log';
+ var dv = document.createElement('div');
+ dv.appendChild(path);
+ pPanel.choicesForm.insertBefore(dv, pPanel.enableButton);
+ path.addEventListener('blur', function() {
+ WebInspector.nodeDebugger.logPath = path.value;
+ }, false);
}, false);
}())
View
@@ -1,5 +1,6 @@
var http = require('http'),
events = require('events'),
+ fs = require('fs'),
path = require('path'),
debugr = require('./debugger');
@@ -11,13 +12,12 @@ exports.createSession = function () {
clients = [],
breakpoints = {},
pending = {},
+ logPath = null,
direct = ['scripts',
'scope',
'lookup',
'evaluate',
'backtrace',
- 'logLines',
- 'profile',
'listbreakpoints'],
session;
@@ -101,6 +101,40 @@ exports.createSession = function () {
}
return;
}
+ else if (msg.command === 'setLog') {
+ logPath = msg.arguments.path;
+ }
+ else if (msg.command === 'logLines') {
+ if (logPath) {
+ fs.open(logPath, 'r', 0444, function (err, fd) {
+ if (err) {
+ conn.write(JSON.stringify({type:'response', command:'logLines', success:false}));
+ return;
+ }
+ var buf = new Buffer(65366);
+ var pos = msg.arguments.position;
+ fs.read(fd, buf, 0, buf.length, pos, function (err, bytesRead) {
+ conn.write(
+ JSON.stringify(
+ {
+ request_seq: msg.seq,
+ type:'response',
+ command:'logLines',
+ success:true,
+ body:
+ {
+ position: pos + bytesRead,
+ lines: buf.toString('utf8',0, bytesRead)
+ }
+ }));
+ });
+ });
+ }
+ else {
+ conn.write(JSON.stringify({type:'response', command:'logLines', success:false}));
+ }
+ return;
+ }
else if (direct.indexOf(msg.command) > -1) {
pending[msg.seq] = conn;
}

0 comments on commit 41cded9

Please sign in to comment.