Added support to backtrace from botton of stack to debugger protocol.
Fixed backtrace in D8 debugger and added gdb like syntax 'bt n' and 'bt -n' in addition to the already existing 'bt from to'. Review URL: http://codereview.chromium.org/99342 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1929 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
83f2c1968f
commit
ada3d37219
27
src/d8.js
27
src/d8.js
@ -498,9 +498,26 @@ DebugRequest.prototype.stepCommandToJSONRequest_ = function(args) {
|
|||||||
DebugRequest.prototype.backtraceCommandToJSONRequest_ = function(args) {
|
DebugRequest.prototype.backtraceCommandToJSONRequest_ = function(args) {
|
||||||
// Build a backtrace request from the text command.
|
// Build a backtrace request from the text command.
|
||||||
var request = this.createRequest('backtrace');
|
var request = this.createRequest('backtrace');
|
||||||
args = args.split(/\s*[ ]+\s*/g);
|
|
||||||
if (args.length == 2) {
|
// Default is to show top 10 frames.
|
||||||
request.arguments = {};
|
request.arguments = {};
|
||||||
|
request.arguments.fromFrame = 0;
|
||||||
|
request.arguments.toFrame = 10;
|
||||||
|
|
||||||
|
args = args.split(/\s*[ ]+\s*/g);
|
||||||
|
if (args.length == 1 && args[0].length > 0) {
|
||||||
|
var frameCount = parseInt(args[0]);
|
||||||
|
if (frameCount > 0) {
|
||||||
|
// Show top frames.
|
||||||
|
request.arguments.fromFrame = 0;
|
||||||
|
request.arguments.toFrame = frameCount;
|
||||||
|
} else {
|
||||||
|
// Show bottom frames.
|
||||||
|
request.arguments.fromFrame = 0;
|
||||||
|
request.arguments.toFrame = -frameCount;
|
||||||
|
request.arguments.bottom = true;
|
||||||
|
}
|
||||||
|
} else if (args.length == 2) {
|
||||||
var fromFrame = parseInt(args[0]);
|
var fromFrame = parseInt(args[0]);
|
||||||
var toFrame = parseInt(args[1]);
|
var toFrame = parseInt(args[1]);
|
||||||
if (isNaN(fromFrame) || fromFrame < 0) {
|
if (isNaN(fromFrame) || fromFrame < 0) {
|
||||||
@ -513,9 +530,13 @@ DebugRequest.prototype.backtraceCommandToJSONRequest_ = function(args) {
|
|||||||
throw new Error('Invalid arguments start frame cannot be larger ' +
|
throw new Error('Invalid arguments start frame cannot be larger ' +
|
||||||
'than end frame.');
|
'than end frame.');
|
||||||
}
|
}
|
||||||
|
// Show frame range.
|
||||||
request.arguments.fromFrame = fromFrame;
|
request.arguments.fromFrame = fromFrame;
|
||||||
request.arguments.toFrame = toFrame + 1;
|
request.arguments.toFrame = toFrame + 1;
|
||||||
|
} else if (args.length > 2) {
|
||||||
|
throw new Error('Invalid backtrace arguments.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return request.toJSONProtocol();
|
return request.toJSONProtocol();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -755,7 +776,7 @@ DebugRequest.prototype.helpCommand_ = function(args) {
|
|||||||
print(' break on function: location is #<id>#');
|
print(' break on function: location is #<id>#');
|
||||||
print(' break on script position: location is name:line[:column]');
|
print(' break on script position: location is name:line[:column]');
|
||||||
print('clear <breakpoint #>');
|
print('clear <breakpoint #>');
|
||||||
print('backtrace [from frame #] [to frame #]]');
|
print('backtrace [n] | [-n] | [from to]');
|
||||||
print('frame <frame #>');
|
print('frame <frame #>');
|
||||||
print('step [in | next | out| min [step count]]');
|
print('step [in | next | out| min [step count]]');
|
||||||
print('print <expression>');
|
print('print <expression>');
|
||||||
|
@ -1452,12 +1452,18 @@ DebugCommandProcessor.prototype.backtraceRequest_ = function(request, response)
|
|||||||
|
|
||||||
// Get the range from the arguments.
|
// Get the range from the arguments.
|
||||||
if (request.arguments) {
|
if (request.arguments) {
|
||||||
|
if (request.arguments.fromFrame) {
|
||||||
from_index = request.arguments.fromFrame;
|
from_index = request.arguments.fromFrame;
|
||||||
if (from_index < 0) {
|
|
||||||
return response.failed('Invalid frame number');
|
|
||||||
}
|
}
|
||||||
|
if (request.arguments.toFrame) {
|
||||||
to_index = request.arguments.toFrame;
|
to_index = request.arguments.toFrame;
|
||||||
if (to_index < 0) {
|
}
|
||||||
|
if (request.arguments.bottom) {
|
||||||
|
var tmp_index = total_frames - from_index;
|
||||||
|
from_index = total_frames - to_index
|
||||||
|
to_index = tmp_index;
|
||||||
|
}
|
||||||
|
if (from_index < 0 || to_index < 0) {
|
||||||
return response.failed('Invalid frame number');
|
return response.failed('Invalid frame number');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,8 +80,9 @@ function listener(event, exec_state, event_data, data) {
|
|||||||
{
|
{
|
||||||
// The expected backtrace is
|
// The expected backtrace is
|
||||||
// 0: f
|
// 0: f
|
||||||
// 1: g
|
// 1: m
|
||||||
// 2: [anonymous]
|
// 2: g
|
||||||
|
// 3: [anonymous]
|
||||||
|
|
||||||
var response;
|
var response;
|
||||||
var backtrace;
|
var backtrace;
|
||||||
@ -133,6 +134,23 @@ function listener(event, exec_state, event_data, data) {
|
|||||||
assertEquals(2, frames[1].index);
|
assertEquals(2, frames[1].index);
|
||||||
assertEquals("g", response.lookup(frames[1].func.ref).name);
|
assertEquals("g", response.lookup(frames[1].func.ref).name);
|
||||||
|
|
||||||
|
// Get backtrace with bottom two frames.
|
||||||
|
json = '{"seq":0,"type":"request","command":"backtrace","arguments":{"fromFrame":0,"toFrame":2, "bottom":true}}'
|
||||||
|
response = new ParsedResponse(dcp.processDebugJSONRequest(json));
|
||||||
|
backtrace = response.body();
|
||||||
|
assertEquals(2, backtrace.fromFrame);
|
||||||
|
assertEquals(4, backtrace.toFrame);
|
||||||
|
assertEquals(4, backtrace.totalFrames);
|
||||||
|
var frames = backtrace.frames;
|
||||||
|
assertEquals(2, frames.length);
|
||||||
|
for (var i = 0; i < frames.length; i++) {
|
||||||
|
assertEquals('frame', frames[i].type);
|
||||||
|
}
|
||||||
|
assertEquals(2, frames[0].index);
|
||||||
|
assertEquals("g", response.lookup(frames[0].func.ref).name);
|
||||||
|
assertEquals(3, frames[1].index);
|
||||||
|
assertEquals("", response.lookup(frames[1].func.ref).name);
|
||||||
|
|
||||||
// Get the individual frames.
|
// Get the individual frames.
|
||||||
json = '{"seq":0,"type":"request","command":"frame"}'
|
json = '{"seq":0,"type":"request","command":"frame"}'
|
||||||
response = new ParsedResponse(dcp.processDebugJSONRequest(json));
|
response = new ParsedResponse(dcp.processDebugJSONRequest(json));
|
||||||
|
Loading…
Reference in New Issue
Block a user