Author: [email protected]
Date: Wed May 13 01:54:50 2009
New Revision: 1929
Modified:
branches/bleeding_edge/src/d8.js
branches/bleeding_edge/src/debug-delay.js
branches/bleeding_edge/test/mjsunit/debug-backtrace.js
Log:
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
Modified: branches/bleeding_edge/src/d8.js
==============================================================================
--- branches/bleeding_edge/src/d8.js (original)
+++ branches/bleeding_edge/src/d8.js Wed May 13 01:54:50 2009
@@ -498,9 +498,26 @@
DebugRequest.prototype.backtraceCommandToJSONRequest_ = function(args) {
// Build a backtrace request from the text command.
var request = this.createRequest('backtrace');
+
+ // Default is to show top 10 frames.
+ request.arguments = {};
+ request.arguments.fromFrame = 0;
+ request.arguments.toFrame = 10;
+
args = args.split(/\s*[ ]+\s*/g);
- if (args.length == 2) {
- request.arguments = {};
+ 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 toFrame = parseInt(args[1]);
if (isNaN(fromFrame) || fromFrame < 0) {
@@ -513,9 +530,13 @@
throw new Error('Invalid arguments start frame cannot be larger ' +
'than end frame.');
}
+ // Show frame range.
request.arguments.fromFrame = fromFrame;
request.arguments.toFrame = toFrame + 1;
+ } else if (args.length > 2) {
+ throw new Error('Invalid backtrace arguments.');
}
+
return request.toJSONProtocol();
};
@@ -755,7 +776,7 @@
print(' break on function: location is #<id>#');
print(' break on script position: location is name:line[:column]');
print('clear <breakpoint #>');
- print('backtrace [from frame #] [to frame #]]');
+ print('backtrace [n] | [-n] | [from to]');
print('frame <frame #>');
print('step [in | next | out| min [step count]]');
print('print <expression>');
Modified: branches/bleeding_edge/src/debug-delay.js
==============================================================================
--- branches/bleeding_edge/src/debug-delay.js (original)
+++ branches/bleeding_edge/src/debug-delay.js Wed May 13 01:54:50 2009
@@ -1452,12 +1452,18 @@
// Get the range from the arguments.
if (request.arguments) {
- from_index = request.arguments.fromFrame;
- if (from_index < 0) {
- return response.failed('Invalid frame number');
+ if (request.arguments.fromFrame) {
+ from_index = request.arguments.fromFrame;
}
- to_index = request.arguments.toFrame;
- if (to_index < 0) {
+ if (request.arguments.toFrame) {
+ to_index = request.arguments.toFrame;
+ }
+ 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');
}
}
Modified: branches/bleeding_edge/test/mjsunit/debug-backtrace.js
==============================================================================
--- branches/bleeding_edge/test/mjsunit/debug-backtrace.js (original)
+++ branches/bleeding_edge/test/mjsunit/debug-backtrace.js Wed May 13
01:54:50 2009
@@ -37,7 +37,7 @@
};
function g() {
- m();
+ m();
};
@@ -80,8 +80,9 @@
{
// The expected backtrace is
// 0: f
- // 1: g
- // 2: [anonymous]
+ // 1: m
+ // 2: g
+ // 3: [anonymous]
var response;
var backtrace;
@@ -132,6 +133,23 @@
assertEquals("m", response.lookup(frames[0].func.ref).inferredName);
assertEquals(2, frames[1].index);
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.
json = '{"seq":0,"type":"request","command":"frame"}'
--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---