| OLD | NEW | 
|     1 // Copyright 2012 the V8 project authors. All rights reserved. |     1 // Copyright 2012 the V8 project authors. All rights reserved. | 
|     2 // Redistribution and use in source and binary forms, with or without |     2 // Redistribution and use in source and binary forms, with or without | 
|     3 // modification, are permitted provided that the following conditions are |     3 // modification, are permitted provided that the following conditions are | 
|     4 // met: |     4 // met: | 
|     5 // |     5 // | 
|     6 //     * Redistributions of source code must retain the above copyright |     6 //     * Redistributions of source code must retain the above copyright | 
|     7 //       notice, this list of conditions and the following disclaimer. |     7 //       notice, this list of conditions and the following disclaimer. | 
|     8 //     * Redistributions in binary form must reproduce the above |     8 //     * Redistributions in binary form must reproduce the above | 
|     9 //       copyright notice, this list of conditions and the following |     9 //       copyright notice, this list of conditions and the following | 
|    10 //       disclaimer in the documentation and/or other materials provided |    10 //       disclaimer in the documentation and/or other materials provided | 
| (...skipping 1939 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1950   response.body = this.exec_state_.frame(); |  1950   response.body = this.exec_state_.frame(); | 
|  1951 }; |  1951 }; | 
|  1952  |  1952  | 
|  1953  |  1953  | 
|  1954 DebugCommandProcessor.prototype.frameForScopeRequest_ = function(request) { |  1954 DebugCommandProcessor.prototype.frameForScopeRequest_ = function(request) { | 
|  1955   // Get the frame for which the scope or scopes are requested. |  1955   // Get the frame for which the scope or scopes are requested. | 
|  1956   // With no frameNumber argument use the currently selected frame. |  1956   // With no frameNumber argument use the currently selected frame. | 
|  1957   if (request.arguments && !IS_UNDEFINED(request.arguments.frameNumber)) { |  1957   if (request.arguments && !IS_UNDEFINED(request.arguments.frameNumber)) { | 
|  1958     frame_index = request.arguments.frameNumber; |  1958     frame_index = request.arguments.frameNumber; | 
|  1959     if (frame_index < 0 || this.exec_state_.frameCount() <= frame_index) { |  1959     if (frame_index < 0 || this.exec_state_.frameCount() <= frame_index) { | 
 |  1960       // TODO: this doesn't work. We cannot simply return response from here, | 
 |  1961       // use exception instead. | 
|  1960       return response.failed('Invalid frame number'); |  1962       return response.failed('Invalid frame number'); | 
|  1961     } |  1963     } | 
|  1962     return this.exec_state_.frame(frame_index); |  1964     return this.exec_state_.frame(frame_index); | 
|  1963   } else { |  1965   } else { | 
|  1964     return this.exec_state_.frame(); |  1966     return this.exec_state_.frame(); | 
|  1965   } |  1967   } | 
|  1966 }; |  1968 }; | 
|  1967  |  1969  | 
|  1968  |  1970  | 
 |  1971 // Gets scope host object from request. It is either a function | 
 |  1972 // ('functionHandle' argument must be specified) or a stack frame | 
 |  1973 // ('frameNumber' may be specified and the current frame is taken by default). | 
 |  1974 DebugCommandProcessor.prototype.scopeHolderForScopeRequest_ = | 
 |  1975     function(request) { | 
 |  1976   if (request.arguments && "functionHandle" in request.arguments) { | 
 |  1977     if (!IS_NUMBER(request.arguments.functionHandle)) { | 
 |  1978       throw new Error('Function handle must be a number'); | 
 |  1979     } | 
 |  1980     var function_mirror = LookupMirror(request.arguments.functionHandle); | 
 |  1981     if (!function_mirror) { | 
 |  1982       throw new Error('Failed to find function object by handle'); | 
 |  1983     } | 
 |  1984     if (!function_mirror.isFunction()) { | 
 |  1985       throw new Error('Value of non-function type is found by handle'); | 
 |  1986     } | 
 |  1987     return function_mirror; | 
 |  1988   } else { | 
 |  1989     // No frames no scopes. | 
 |  1990     if (this.exec_state_.frameCount() == 0) { | 
 |  1991       throw new Error('No scopes'); | 
 |  1992     } | 
 |  1993          | 
 |  1994     // Get the frame for which the scopes are requested. | 
 |  1995     var frame = this.frameForScopeRequest_(request); | 
 |  1996     return frame; | 
 |  1997   } | 
 |  1998 } | 
 |  1999  | 
 |  2000  | 
|  1969 DebugCommandProcessor.prototype.scopesRequest_ = function(request, response) { |  2001 DebugCommandProcessor.prototype.scopesRequest_ = function(request, response) { | 
|  1970   // No frames no scopes. |  2002   var scope_holder = this.scopeHolderForScopeRequest_(request); | 
|  1971   if (this.exec_state_.frameCount() == 0) { |  | 
|  1972     return response.failed('No scopes'); |  | 
|  1973   } |  | 
|  1974  |  2003  | 
|  1975   // Get the frame for which the scopes are requested. |  2004   // Fill all scopes for this frame or function. | 
|  1976   var frame = this.frameForScopeRequest_(request); |  2005   var total_scopes = scope_holder.scopeCount(); | 
|  1977  |  | 
|  1978   // Fill all scopes for this frame. |  | 
|  1979   var total_scopes = frame.scopeCount(); |  | 
|  1980   var scopes = []; |  2006   var scopes = []; | 
|  1981   for (var i = 0; i < total_scopes; i++) { |  2007   for (var i = 0; i < total_scopes; i++) { | 
|  1982     scopes.push(frame.scope(i)); |  2008     scopes.push(scope_holder.scope(i)); | 
|  1983   } |  2009   } | 
|  1984   response.body = { |  2010   response.body = { | 
|  1985     fromScope: 0, |  2011     fromScope: 0, | 
|  1986     toScope: total_scopes, |  2012     toScope: total_scopes, | 
|  1987     totalScopes: total_scopes, |  2013     totalScopes: total_scopes, | 
|  1988     scopes: scopes |  2014     scopes: scopes | 
|  1989   }; |  2015   }; | 
|  1990 }; |  2016 }; | 
|  1991  |  2017  | 
|  1992  |  2018  | 
|  1993 DebugCommandProcessor.prototype.scopeRequest_ = function(request, response) { |  2019 DebugCommandProcessor.prototype.scopeRequest_ = function(request, response) { | 
|  1994   // No frames no scopes. |  2020   // Get the frame or function for which the scope is requested. | 
|  1995   if (this.exec_state_.frameCount() == 0) { |  2021   var scope_holder = this.scopeHolderForScopeRequest_(request); | 
|  1996     return response.failed('No scopes'); |  | 
|  1997   } |  | 
|  1998  |  | 
|  1999   // Get the frame for which the scope is requested. |  | 
|  2000   var frame = this.frameForScopeRequest_(request); |  | 
|  2001  |  2022  | 
|  2002   // With no scope argument just return top scope. |  2023   // With no scope argument just return top scope. | 
|  2003   var scope_index = 0; |  2024   var scope_index = 0; | 
|  2004   if (request.arguments && !IS_UNDEFINED(request.arguments.number)) { |  2025   if (request.arguments && !IS_UNDEFINED(request.arguments.number)) { | 
|  2005     scope_index = %ToNumber(request.arguments.number); |  2026     scope_index = %ToNumber(request.arguments.number); | 
|  2006     if (scope_index < 0 || frame.scopeCount() <= scope_index) { |  2027     if (scope_index < 0 || scope_holder.scopeCount() <= scope_index) { | 
|  2007       return response.failed('Invalid scope number'); |  2028       return response.failed('Invalid scope number'); | 
|  2008     } |  2029     } | 
|  2009   } |  2030   } | 
|  2010  |  2031  | 
|  2011   response.body = frame.scope(scope_index); |  2032   response.body = scope_holder.scope(scope_index); | 
|  2012 }; |  2033 }; | 
|  2013  |  2034  | 
|  2014  |  2035  | 
|  2015 DebugCommandProcessor.prototype.evaluateRequest_ = function(request, response) { |  2036 DebugCommandProcessor.prototype.evaluateRequest_ = function(request, response) { | 
|  2016   if (!request.arguments) { |  2037   if (!request.arguments) { | 
|  2017     return response.failed('Missing arguments'); |  2038     return response.failed('Missing arguments'); | 
|  2018   } |  2039   } | 
|  2019  |  2040  | 
|  2020   // Pull out arguments. |  2041   // Pull out arguments. | 
|  2021   var expression = request.arguments.expression; |  2042   var expression = request.arguments.expression; | 
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2607     case 'string': |  2628     case 'string': | 
|  2608     case 'number': |  2629     case 'number': | 
|  2609       json = value; |  2630       json = value; | 
|  2610       break; |  2631       break; | 
|  2611  |  2632  | 
|  2612     default: |  2633     default: | 
|  2613       json = null; |  2634       json = null; | 
|  2614   } |  2635   } | 
|  2615   return json; |  2636   return json; | 
|  2616 } |  2637 } | 
| OLD | NEW |