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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
228 Next(); | 228 Next(); |
229 } | 229 } |
230 | 230 |
231 // Move to the break point found. | 231 // Move to the break point found. |
232 Reset(); | 232 Reset(); |
233 Next(closest_break_point); | 233 Next(closest_break_point); |
234 } | 234 } |
235 | 235 |
236 | 236 |
237 // Find the break point closest to the supplied source position. | 237 // Find the break point closest to the supplied source position. |
238 void BreakLocationIterator::FindBreakLocationFromPosition(int position) { | 238 void BreakLocationIterator::FindBreakLocationFromPosition(int position, |
239 bool statement_alighned) { | |
Yang
2013/06/25 11:32:00
Change variable name to "statement_aligned".
Sugg
Peter.Rybin
2013/06/27 14:07:29
I'm fine with this idea. I did JavaScript part as
| |
239 // Run through all break points to locate the one closest to the source | 240 // Run through all break points to locate the one closest to the source |
240 // position. | 241 // position. |
241 int closest_break_point = 0; | 242 int closest_break_point = 0; |
242 int distance = kMaxInt; | 243 int distance = kMaxInt; |
244 | |
243 while (!Done()) { | 245 while (!Done()) { |
246 int next_position; | |
247 if (statement_alighned) { | |
Yang
2013/06/25 11:32:00
You could use a ternary operator to simplify this
Peter.Rybin
2013/06/27 14:07:29
I guess with enum I should do switch? Or is it too
| |
248 next_position = this->statement_position(); | |
249 } else { | |
250 next_position = this->position(); | |
251 } | |
244 // Check if this break point is closer that what was previously found. | 252 // Check if this break point is closer that what was previously found. |
245 if (position <= statement_position() && | 253 if (position <= next_position && next_position - position < distance) { |
246 statement_position() - position < distance) { | |
247 closest_break_point = break_point(); | 254 closest_break_point = break_point(); |
248 distance = statement_position() - position; | 255 distance = next_position - position; |
249 // Check whether we can't get any closer. | 256 // Check whether we can't get any closer. |
250 if (distance == 0) break; | 257 if (distance == 0) break; |
251 } | 258 } |
252 Next(); | 259 Next(); |
253 } | 260 } |
254 | 261 |
255 // Move to the break point found. | 262 // Move to the break point found. |
256 Reset(); | 263 Reset(); |
257 Next(closest_break_point); | 264 Next(closest_break_point); |
258 } | 265 } |
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1169 // Return if retrieving debug info failed. | 1176 // Return if retrieving debug info failed. |
1170 return; | 1177 return; |
1171 } | 1178 } |
1172 | 1179 |
1173 Handle<DebugInfo> debug_info = GetDebugInfo(shared); | 1180 Handle<DebugInfo> debug_info = GetDebugInfo(shared); |
1174 // Source positions starts with zero. | 1181 // Source positions starts with zero. |
1175 ASSERT(*source_position >= 0); | 1182 ASSERT(*source_position >= 0); |
1176 | 1183 |
1177 // Find the break point and change it. | 1184 // Find the break point and change it. |
1178 BreakLocationIterator it(debug_info, SOURCE_BREAK_LOCATIONS); | 1185 BreakLocationIterator it(debug_info, SOURCE_BREAK_LOCATIONS); |
1179 it.FindBreakLocationFromPosition(*source_position); | 1186 it.FindBreakLocationFromPosition(*source_position, true); |
1180 it.SetBreakPoint(break_point_object); | 1187 it.SetBreakPoint(break_point_object); |
1181 | 1188 |
1182 *source_position = it.position(); | 1189 *source_position = it.position(); |
1183 | 1190 |
1184 // At least one active break point now. | 1191 // At least one active break point now. |
1185 ASSERT(debug_info->GetBreakPointCount() > 0); | 1192 ASSERT(debug_info->GetBreakPointCount() > 0); |
1186 } | 1193 } |
1187 | 1194 |
1188 | 1195 |
1189 bool Debug::SetBreakPointForScript(Handle<Script> script, | 1196 bool Debug::SetBreakPointForScript(Handle<Script> script, |
1190 Handle<Object> break_point_object, | 1197 Handle<Object> break_point_object, |
1191 int* source_position) { | 1198 int* source_position, |
1199 bool statement_alighned) { | |
Yang
2013/06/25 11:32:00
Ditto.
Peter.Rybin
2013/06/27 14:07:29
Done.
| |
1192 HandleScope scope(isolate_); | 1200 HandleScope scope(isolate_); |
1193 | 1201 |
1194 PrepareForBreakPoints(); | 1202 PrepareForBreakPoints(); |
1195 | 1203 |
1196 // Obtain shared function info for the function. | 1204 // Obtain shared function info for the function. |
1197 Object* result = FindSharedFunctionInfoInScript(script, *source_position); | 1205 Object* result = FindSharedFunctionInfoInScript(script, *source_position); |
1198 if (result->IsUndefined()) return false; | 1206 if (result->IsUndefined()) return false; |
1199 | 1207 |
1200 // Make sure the function has set up the debug info. | 1208 // Make sure the function has set up the debug info. |
1201 Handle<SharedFunctionInfo> shared(SharedFunctionInfo::cast(result)); | 1209 Handle<SharedFunctionInfo> shared(SharedFunctionInfo::cast(result)); |
(...skipping 10 matching lines...) Expand all Loading... | |
1212 } else { | 1220 } else { |
1213 position = *source_position - shared->start_position(); | 1221 position = *source_position - shared->start_position(); |
1214 } | 1222 } |
1215 | 1223 |
1216 Handle<DebugInfo> debug_info = GetDebugInfo(shared); | 1224 Handle<DebugInfo> debug_info = GetDebugInfo(shared); |
1217 // Source positions starts with zero. | 1225 // Source positions starts with zero. |
1218 ASSERT(position >= 0); | 1226 ASSERT(position >= 0); |
1219 | 1227 |
1220 // Find the break point and change it. | 1228 // Find the break point and change it. |
1221 BreakLocationIterator it(debug_info, SOURCE_BREAK_LOCATIONS); | 1229 BreakLocationIterator it(debug_info, SOURCE_BREAK_LOCATIONS); |
1222 it.FindBreakLocationFromPosition(position); | 1230 it.FindBreakLocationFromPosition(position, statement_alighned); |
1223 it.SetBreakPoint(break_point_object); | 1231 it.SetBreakPoint(break_point_object); |
1224 | 1232 |
1225 *source_position = it.position() + shared->start_position(); | 1233 *source_position = it.position() + shared->start_position(); |
1226 | 1234 |
1227 // At least one active break point now. | 1235 // At least one active break point now. |
1228 ASSERT(debug_info->GetBreakPointCount() > 0); | 1236 ASSERT(debug_info->GetBreakPointCount() > 0); |
1229 return true; | 1237 return true; |
1230 } | 1238 } |
1231 | 1239 |
1232 | 1240 |
(...skipping 2566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3799 { | 3807 { |
3800 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); | 3808 Locker locker(reinterpret_cast<v8::Isolate*>(isolate_)); |
3801 isolate_->debugger()->CallMessageDispatchHandler(); | 3809 isolate_->debugger()->CallMessageDispatchHandler(); |
3802 } | 3810 } |
3803 } | 3811 } |
3804 } | 3812 } |
3805 | 3813 |
3806 #endif // ENABLE_DEBUGGER_SUPPORT | 3814 #endif // ENABLE_DEBUGGER_SUPPORT |
3807 | 3815 |
3808 } } // namespace v8::internal | 3816 } } // namespace v8::internal |
OLD | NEW |