Index: src/d8.js |
=================================================================== |
--- src/d8.js (revision 1840) |
+++ src/d8.js (working copy) |
@@ -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>'); |