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

Side by Side Diff: runtime/vm/debugger.cc

Issue 875443002: Store pc offset instead of absolute pc in the pc descriptors. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: fixed arm/mips/arm64 build Created 5 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/code_descriptors_test.cc ('k') | runtime/vm/object.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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/debugger.h" 5 #include "vm/debugger.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 8
9 #include "vm/code_generator.h" 9 #include "vm/code_generator.h"
10 #include "vm/code_patcher.h" 10 #include "vm/code_patcher.h"
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 } 380 }
381 381
382 382
383 // Compute token_pos_ and try_index_ and token_pos_initialized_. 383 // Compute token_pos_ and try_index_ and token_pos_initialized_.
384 intptr_t ActivationFrame::TokenPos() { 384 intptr_t ActivationFrame::TokenPos() {
385 if (!token_pos_initialized_) { 385 if (!token_pos_initialized_) {
386 token_pos_initialized_ = true; 386 token_pos_initialized_ = true;
387 token_pos_ = Scanner::kNoSourcePos; 387 token_pos_ = Scanner::kNoSourcePos;
388 GetPcDescriptors(); 388 GetPcDescriptors();
389 PcDescriptors::Iterator iter(pc_desc_, RawPcDescriptors::kAnyKind); 389 PcDescriptors::Iterator iter(pc_desc_, RawPcDescriptors::kAnyKind);
390 uword pc_offset = pc_ - code().EntryPoint();
390 while (iter.MoveNext()) { 391 while (iter.MoveNext()) {
391 if (iter.Pc() == pc_) { 392 if (iter.PcOffset() == pc_offset) {
392 try_index_ = iter.TryIndex(); 393 try_index_ = iter.TryIndex();
393 token_pos_ = iter.TokenPos(); 394 token_pos_ = iter.TokenPos();
394 break; 395 break;
395 } 396 }
396 } 397 }
397 } 398 }
398 return token_pos_; 399 return token_pos_;
399 } 400 }
400 401
401 402
(...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after
1463 // For all token positions on the same line, select the one 1464 // For all token positions on the same line, select the one
1464 // with the lowest compiled code address. E.g., in a line with 1465 // with the lowest compiled code address. E.g., in a line with
1465 // the nested function calls f(g(x)), the call g() will have a lower 1466 // the nested function calls f(g(x)), the call g() will have a lower
1466 // compiled code address but is not the lowest token position in the 1467 // compiled code address but is not the lowest token position in the
1467 // line. 1468 // line.
1468 if (best_fit_pos != INT_MAX) { 1469 if (best_fit_pos != INT_MAX) {
1469 const Script& script = Script::Handle(func.script()); 1470 const Script& script = Script::Handle(func.script());
1470 const TokenStream& tokens = TokenStream::Handle(script.tokens()); 1471 const TokenStream& tokens = TokenStream::Handle(script.tokens());
1471 const intptr_t begin_pos = best_fit_pos; 1472 const intptr_t begin_pos = best_fit_pos;
1472 const intptr_t end_of_line_pos = LastTokenOnLine(tokens, begin_pos); 1473 const intptr_t end_of_line_pos = LastTokenOnLine(tokens, begin_pos);
1473 uword lowest_pc = kUwordMax; 1474 uword lowest_pc_offset = kUwordMax;
1474 PcDescriptors::Iterator iter(desc, kSafepointKind); 1475 PcDescriptors::Iterator iter(desc, kSafepointKind);
1475 while (iter.MoveNext()) { 1476 while (iter.MoveNext()) {
1476 const intptr_t pos = iter.TokenPos(); 1477 const intptr_t pos = iter.TokenPos();
1477 if ((pos != Scanner::kNoSourcePos) && 1478 if ((pos != Scanner::kNoSourcePos) &&
1478 (begin_pos <= pos) && (pos <= end_of_line_pos) && 1479 (begin_pos <= pos) && (pos <= end_of_line_pos) &&
1479 (iter.Pc() < lowest_pc)) { 1480 (iter.PcOffset() < lowest_pc_offset)) {
1480 lowest_pc = iter.Pc(); 1481 lowest_pc_offset = iter.PcOffset();
1481 best_fit_pos = pos; 1482 best_fit_pos = pos;
1482 } 1483 }
1483 } 1484 }
1484 return best_fit_pos; 1485 return best_fit_pos;
1485 } 1486 }
1486 1487
1487 // We didn't find a safe point in the given token range. Try and find 1488 // We didn't find a safe point in the given token range. Try and find
1488 // a safe point in the remaining source code of the function. 1489 // a safe point in the remaining source code of the function.
1489 if (last_token_pos < func.end_token_pos()) { 1490 if (last_token_pos < func.end_token_pos()) {
1490 return ResolveBreakpointPos(func, last_token_pos, func.end_token_pos()); 1491 return ResolveBreakpointPos(func, last_token_pos, func.end_token_pos());
1491 } 1492 }
1492 return -1; 1493 return -1;
1493 } 1494 }
1494 1495
1495 1496
1496 void Debugger::MakeCodeBreakpointAt(const Function& func, 1497 void Debugger::MakeCodeBreakpointAt(const Function& func,
1497 SourceBreakpoint* bpt) { 1498 SourceBreakpoint* bpt) {
1498 ASSERT(bpt->token_pos_ != Scanner::kNoSourcePos); 1499 ASSERT(bpt->token_pos_ != Scanner::kNoSourcePos);
1499 ASSERT((bpt != NULL) && bpt->IsResolved()); 1500 ASSERT((bpt != NULL) && bpt->IsResolved());
1500 ASSERT(!func.HasOptimizedCode()); 1501 ASSERT(!func.HasOptimizedCode());
1501 Code& code = Code::Handle(func.unoptimized_code()); 1502 Code& code = Code::Handle(func.unoptimized_code());
1502 ASSERT(!code.IsNull()); 1503 ASSERT(!code.IsNull());
1503 PcDescriptors& desc = PcDescriptors::Handle(code.pc_descriptors()); 1504 PcDescriptors& desc = PcDescriptors::Handle(code.pc_descriptors());
1504 uword lowest_pc = kUwordMax; 1505 uword lowest_pc_offset = kUwordMax;
1505 RawPcDescriptors::Kind lowest_kind = RawPcDescriptors::kAnyKind; 1506 RawPcDescriptors::Kind lowest_kind = RawPcDescriptors::kAnyKind;
1506 // Find the safe point with the lowest compiled code address 1507 // Find the safe point with the lowest compiled code address
1507 // that maps to the token position of the source breakpoint. 1508 // that maps to the token position of the source breakpoint.
1508 PcDescriptors::Iterator iter(desc, kSafepointKind); 1509 PcDescriptors::Iterator iter(desc, kSafepointKind);
1509 while (iter.MoveNext()) { 1510 while (iter.MoveNext()) {
1510 if (iter.TokenPos() == bpt->token_pos_) { 1511 if (iter.TokenPos() == bpt->token_pos_) {
1511 if (iter.Pc() < lowest_pc) { 1512 if (iter.PcOffset() < lowest_pc_offset) {
1512 lowest_pc = iter.Pc(); 1513 lowest_pc_offset = iter.PcOffset();
1513 lowest_kind = iter.Kind(); 1514 lowest_kind = iter.Kind();
1514 } 1515 }
1515 } 1516 }
1516 } 1517 }
1517 if (lowest_pc == kUwordMax) { 1518 if (lowest_pc_offset == kUwordMax) {
1518 return; 1519 return;
1519 } 1520 }
1521 uword lowest_pc = code.EntryPoint() + lowest_pc_offset;
1520 CodeBreakpoint* code_bpt = GetCodeBreakpoint(lowest_pc); 1522 CodeBreakpoint* code_bpt = GetCodeBreakpoint(lowest_pc);
1521 if (code_bpt == NULL) { 1523 if (code_bpt == NULL) {
1522 // No code breakpoint for this code exists; create one. 1524 // No code breakpoint for this code exists; create one.
1523 code_bpt = new CodeBreakpoint(code, bpt->token_pos_, 1525 code_bpt = new CodeBreakpoint(code, bpt->token_pos_,
1524 lowest_pc, lowest_kind); 1526 lowest_pc, lowest_kind);
1525 RegisterCodeBreakpoint(code_bpt); 1527 RegisterCodeBreakpoint(code_bpt);
1526 } 1528 }
1527 code_bpt->set_src_bpt(bpt); 1529 code_bpt->set_src_bpt(bpt);
1528 if (bpt->IsEnabled()) { 1530 if (bpt->IsEnabled()) {
1529 code_bpt->Enable(); 1531 code_bpt->Enable();
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after
2622 } 2624 }
2623 2625
2624 2626
2625 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) { 2627 void Debugger::RegisterCodeBreakpoint(CodeBreakpoint* bpt) {
2626 ASSERT(bpt->next() == NULL); 2628 ASSERT(bpt->next() == NULL);
2627 bpt->set_next(code_breakpoints_); 2629 bpt->set_next(code_breakpoints_);
2628 code_breakpoints_ = bpt; 2630 code_breakpoints_ = bpt;
2629 } 2631 }
2630 2632
2631 } // namespace dart 2633 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/code_descriptors_test.cc ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698