Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: src/runtime/runtime-debug.cc

Issue 1234833003: Debugger: use debug break slots to break at function exit. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix for arm Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/objects-printer.cc ('k') | src/x64/assembler-x64.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/arguments.h" 8 #include "src/arguments.h"
9 #include "src/compiler.h" 9 #include "src/compiler.h"
10 #include "src/debug.h" 10 #include "src/debug.h"
(...skipping 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after
1383 // Catch the case when the debugger stops in an internal function. 1383 // Catch the case when the debugger stops in an internal function.
1384 Handle<SharedFunctionInfo> shared_info(function_->shared()); 1384 Handle<SharedFunctionInfo> shared_info(function_->shared());
1385 Handle<ScopeInfo> scope_info(shared_info->scope_info()); 1385 Handle<ScopeInfo> scope_info(shared_info->scope_info());
1386 if (shared_info->script() == isolate->heap()->undefined_value()) { 1386 if (shared_info->script() == isolate->heap()->undefined_value()) {
1387 while (context_->closure() == *function_) { 1387 while (context_->closure() == *function_) {
1388 context_ = Handle<Context>(context_->previous(), isolate_); 1388 context_ = Handle<Context>(context_->previous(), isolate_);
1389 } 1389 }
1390 return; 1390 return;
1391 } 1391 }
1392 1392
1393 // Get the debug info (create it if it does not exist).
1394 if (!isolate->debug()->EnsureDebugInfo(shared_info, function_)) {
1395 // Return if ensuring debug info failed.
1396 return;
1397 }
1398
1399 // Currently it takes too much time to find nested scopes due to script 1393 // Currently it takes too much time to find nested scopes due to script
1400 // parsing. Sometimes we want to run the ScopeIterator as fast as possible 1394 // parsing. Sometimes we want to run the ScopeIterator as fast as possible
1401 // (for example, while collecting async call stacks on every 1395 // (for example, while collecting async call stacks on every
1402 // addEventListener call), even if we drop some nested scopes. 1396 // addEventListener call), even if we drop some nested scopes.
1403 // Later we may optimize getting the nested scopes (cache the result?) 1397 // Later we may optimize getting the nested scopes (cache the result?)
1404 // and include nested scopes into the "fast" iteration case as well. 1398 // and include nested scopes into the "fast" iteration case as well.
1405 if (!ignore_nested_scopes) { 1399
1400 if (!ignore_nested_scopes && !shared_info->debug_info()->IsUndefined()) {
1401 // The source position at return is always the end of the function,
1402 // which is not consistent with the current scope chain. Therefore all
1403 // nested with, catch and block contexts are skipped, and we can only
1404 // inspect the function scope.
1405 // This can only happen if we set a break point inside right before the
1406 // return, which requires a debug info to be available.
1406 Handle<DebugInfo> debug_info = Debug::GetDebugInfo(shared_info); 1407 Handle<DebugInfo> debug_info = Debug::GetDebugInfo(shared_info);
1407 1408
1408 // PC points to the instruction after the current one, possibly a break 1409 // PC points to the instruction after the current one, possibly a break
1409 // location as well. So the "- 1" to exclude it from the search. 1410 // location as well. So the "- 1" to exclude it from the search.
1410 Address call_pc = frame->pc() - 1; 1411 Address call_pc = frame->pc() - 1;
1411 1412
1412 // Find the break point where execution has stopped. 1413 // Find the break point where execution has stopped.
1413 BreakLocation location = 1414 BreakLocation location =
1414 BreakLocation::FromAddress(debug_info, ALL_BREAK_LOCATIONS, call_pc); 1415 BreakLocation::FromAddress(debug_info, ALL_BREAK_LOCATIONS, call_pc);
1415 1416
1416 // Within the return sequence at the moment it is not possible to 1417 ignore_nested_scopes = location.IsReturn();
1417 // get a source position which is consistent with the current scope chain.
1418 // Thus all nested with, catch and block contexts are skipped and we only
1419 // provide the function scope.
1420 ignore_nested_scopes = location.IsExit();
1421 } 1418 }
1422 1419
1423 if (ignore_nested_scopes) { 1420 if (ignore_nested_scopes) {
1424 if (scope_info->HasContext()) { 1421 if (scope_info->HasContext()) {
1425 context_ = Handle<Context>(context_->declaration_context(), isolate_); 1422 context_ = Handle<Context>(context_->declaration_context(), isolate_);
1426 } else { 1423 } else {
1427 while (context_->closure() == *function_) { 1424 while (context_->closure() == *function_) {
1428 context_ = Handle<Context>(context_->previous(), isolate_); 1425 context_ = Handle<Context>(context_->previous(), isolate_);
1429 } 1426 }
1430 } 1427 }
(...skipping 1790 matching lines...) Expand 10 before | Expand all | Expand 10 after
3221 return *isolate->factory()->undefined_value(); 3218 return *isolate->factory()->undefined_value();
3222 } 3219 }
3223 3220
3224 3221
3225 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) { 3222 RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) {
3226 UNIMPLEMENTED(); 3223 UNIMPLEMENTED();
3227 return NULL; 3224 return NULL;
3228 } 3225 }
3229 } // namespace internal 3226 } // namespace internal
3230 } // namespace v8 3227 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects-printer.cc ('k') | src/x64/assembler-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698