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

Unified Diff: runtime/vm/debugger.cc

Issue 9706038: Fix breakpoint location (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/debugger.cc
===================================================================
--- runtime/vm/debugger.cc (revision 5473)
+++ runtime/vm/debugger.cc (working copy)
@@ -541,11 +541,26 @@
Code& code = Code::Handle(func.unoptimized_code());
ASSERT(!code.IsNull());
PcDescriptors& desc = PcDescriptors::Handle(code.pc_descriptors());
+ intptr_t best_fit_index = -1;
+ intptr_t best_fit = INTPTR_MAX;
for (int i = 0; i < desc.Length(); i++) {
- if (desc.TokenIndex(i) < token_index) {
+ intptr_t desc_token_index = desc.TokenIndex(i);
+ if (desc_token_index < token_index) {
srdjan 2012/03/14 22:47:43 You are searching for closest token after 'token_i
hausner 2012/03/14 23:10:25 The token index just before the requested index lo
continue;
}
- CodeBreakpoint* bpt = GetCodeBreakpoint(desc.PC(i));
+ PcDescriptors::Kind kind = desc.DescriptorKind(i);
+ if ((kind == PcDescriptors::kIcCall) ||
+ (kind == PcDescriptors::kFuncCall) ||
+ (kind == PcDescriptors::kReturn)) {
+ if ((desc_token_index - token_index) < best_fit) {
+ best_fit = desc_token_index - token_index;
+ ASSERT(best_fit >= 0);
+ best_fit_index = i;
+ }
+ }
+ }
+ if (best_fit_index >= 0) {
+ CodeBreakpoint* bpt = GetCodeBreakpoint(desc.PC(best_fit_index));
// We should only ever have one code breakpoint at the same address.
// If we find an existing breakpoint, it must be an internal one which
// is used for stepping.
@@ -554,21 +569,16 @@
return bpt;
}
- PcDescriptors::Kind kind = desc.DescriptorKind(i);
- if ((kind == PcDescriptors::kIcCall) ||
- (kind == PcDescriptors::kFuncCall) ||
- (kind == PcDescriptors::kReturn)) {
- bpt = new CodeBreakpoint(func, i);
- if (verbose) {
- OS::Print("Setting breakpoint in function '%s' (%s:%d) (PC %p)\n",
- String::Handle(func.name()).ToCString(),
- String::Handle(bpt->SourceUrl()).ToCString(),
- bpt->LineNumber(),
- bpt->pc());
- }
- RegisterCodeBreakpoint(bpt);
- return bpt;
+ bpt = new CodeBreakpoint(func, best_fit_index);
+ if (verbose) {
+ OS::Print("Setting breakpoint in function '%s' (%s:%d) (PC %p)\n",
+ String::Handle(func.name()).ToCString(),
+ String::Handle(bpt->SourceUrl()).ToCString(),
+ bpt->LineNumber(),
+ bpt->pc());
}
+ RegisterCodeBreakpoint(bpt);
+ return bpt;
}
return NULL;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698