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

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

Issue 2230143002: [debugger] use source position to identify break points. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: address comment Created 4 years, 4 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/debug/debug.h ('k') | src/objects.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/debug/debug.h" 5 #include "src/debug/debug.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/arguments.h" 10 #include "src/arguments.h"
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 return closest_break; 314 return closest_break;
315 } 315 }
316 316
317 317
318 void BreakLocation::SetBreakPoint(Handle<Object> break_point_object) { 318 void BreakLocation::SetBreakPoint(Handle<Object> break_point_object) {
319 // If there is not already a real break point here patch code with debug 319 // If there is not already a real break point here patch code with debug
320 // break. 320 // break.
321 if (!HasBreakPoint()) SetDebugBreak(); 321 if (!HasBreakPoint()) SetDebugBreak();
322 DCHECK(IsDebugBreak() || IsDebuggerStatement()); 322 DCHECK(IsDebugBreak() || IsDebuggerStatement());
323 // Set the break point information. 323 // Set the break point information.
324 DebugInfo::SetBreakPoint(debug_info_, code_offset_, position_, 324 DebugInfo::SetBreakPoint(debug_info_, position_, statement_position_,
325 statement_position_, break_point_object); 325 break_point_object);
326 } 326 }
327 327
328 328
329 void BreakLocation::ClearBreakPoint(Handle<Object> break_point_object) { 329 void BreakLocation::ClearBreakPoint(Handle<Object> break_point_object) {
330 // Clear the break point information. 330 // Clear the break point information.
331 DebugInfo::ClearBreakPoint(debug_info_, code_offset_, break_point_object); 331 DebugInfo::ClearBreakPoint(debug_info_, position_, break_point_object);
332 // If there are no more break points here remove the debug break. 332 // If there are no more break points here remove the debug break.
333 if (!HasBreakPoint()) { 333 if (!HasBreakPoint()) {
334 ClearDebugBreak(); 334 ClearDebugBreak();
335 DCHECK(!IsDebugBreak()); 335 DCHECK(!IsDebugBreak());
336 } 336 }
337 } 337 }
338 338
339 339
340 void BreakLocation::SetOneShot() { 340 void BreakLocation::SetOneShot() {
341 // Debugger statement always calls debugger. No need to modify it. 341 // Debugger statement always calls debugger. No need to modify it.
342 if (IsDebuggerStatement()) return; 342 if (IsDebuggerStatement()) return;
343 343
344 // If there is a real break point here no more to do.
345 if (HasBreakPoint()) {
346 DCHECK(IsDebugBreak());
347 return;
348 }
349
350 // Patch code with debug break. 344 // Patch code with debug break.
351 SetDebugBreak(); 345 SetDebugBreak();
352 } 346 }
353 347
354 348
355 void BreakLocation::ClearOneShot() { 349 void BreakLocation::ClearOneShot() {
356 // Debugger statement always calls debugger. No need to modify it. 350 // Debugger statement always calls debugger. No need to modify it.
357 if (IsDebuggerStatement()) return; 351 if (IsDebuggerStatement()) return;
358 352
359 // If there is a real break point here no more to do. 353 // If there is a real break point here no more to do.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 Address pc = code->instruction_start() + code_offset(); 422 Address pc = code->instruction_start() + code_offset();
429 return DebugCodegen::DebugBreakSlotIsPatched(pc); 423 return DebugCodegen::DebugBreakSlotIsPatched(pc);
430 } else { 424 } else {
431 BytecodeArray* bytecode_array = abstract_code()->GetBytecodeArray(); 425 BytecodeArray* bytecode_array = abstract_code()->GetBytecodeArray();
432 interpreter::Bytecode bytecode = 426 interpreter::Bytecode bytecode =
433 interpreter::Bytecodes::FromByte(bytecode_array->get(code_offset())); 427 interpreter::Bytecodes::FromByte(bytecode_array->get(code_offset()));
434 return interpreter::Bytecodes::IsDebugBreak(bytecode); 428 return interpreter::Bytecodes::IsDebugBreak(bytecode);
435 } 429 }
436 } 430 }
437 431
432 Handle<Object> BreakLocation::BreakPointObjects() const {
433 return debug_info_->GetBreakPointObjects(position_);
434 }
438 435
439 Handle<Object> BreakLocation::BreakPointObjects() const { 436 bool BreakLocation::HasBreakPoint() const {
440 return debug_info_->GetBreakPointObjects(code_offset_); 437 // First check whether there is a break point with the same source position.
438 if (!debug_info_->HasBreakPoint(position_)) return false;
439 // Then check whether a break point at that source position would have
440 // the same code offset. Otherwise it's just a break location that we can
441 // step to, but not actually a location where we can put a break point.
442 BreakLocation break_point_location = BreakLocation::FromPosition(
443 debug_info_, position_, BREAK_POSITION_ALIGNED);
444 return break_point_location.code_offset() == code_offset_;
441 } 445 }
442 446
443 void DebugFeatureTracker::Track(DebugFeatureTracker::Feature feature) { 447 void DebugFeatureTracker::Track(DebugFeatureTracker::Feature feature) {
444 uint32_t mask = 1 << feature; 448 uint32_t mask = 1 << feature;
445 // Only count one sample per feature and isolate. 449 // Only count one sample per feature and isolate.
446 if (bitfield_ & mask) return; 450 if (bitfield_ & mask) return;
447 isolate_->counters()->debug_feature_usage()->AddSample(feature); 451 isolate_->counters()->debug_feature_usage()->AddSample(feature);
448 bitfield_ |= mask; 452 bitfield_ |= mask;
449 } 453 }
450 454
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 DebugInfoListNode* node = debug_info_list_; 827 DebugInfoListNode* node = debug_info_list_;
824 while (node != NULL) { 828 while (node != NULL) {
825 Handle<Object> result = 829 Handle<Object> result =
826 DebugInfo::FindBreakPointInfo(node->debug_info(), break_point_object); 830 DebugInfo::FindBreakPointInfo(node->debug_info(), break_point_object);
827 if (!result->IsUndefined(isolate_)) { 831 if (!result->IsUndefined(isolate_)) {
828 // Get information in the break point. 832 // Get information in the break point.
829 Handle<BreakPointInfo> break_point_info = 833 Handle<BreakPointInfo> break_point_info =
830 Handle<BreakPointInfo>::cast(result); 834 Handle<BreakPointInfo>::cast(result);
831 Handle<DebugInfo> debug_info = node->debug_info(); 835 Handle<DebugInfo> debug_info = node->debug_info();
832 836
833 BreakLocation location = BreakLocation::FromCodeOffset( 837 BreakLocation location = BreakLocation::FromPosition(
834 debug_info, break_point_info->code_offset()); 838 debug_info, break_point_info->source_position(),
839 BREAK_POSITION_ALIGNED);
835 location.ClearBreakPoint(break_point_object); 840 location.ClearBreakPoint(break_point_object);
836 841
837 // If there are no more break points left remove the debug info for this 842 // If there are no more break points left remove the debug info for this
838 // function. 843 // function.
839 if (debug_info->GetBreakPointCount() == 0) { 844 if (debug_info->GetBreakPointCount() == 0) {
840 RemoveDebugInfoAndClearFromShared(debug_info); 845 RemoveDebugInfoAndClearFromShared(debug_info);
841 } 846 }
842 847
843 return; 848 return;
844 } 849 }
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 Handle<FixedArray> locations = 1092 Handle<FixedArray> locations =
1088 isolate->factory()->NewFixedArray(debug_info->GetBreakPointCount()); 1093 isolate->factory()->NewFixedArray(debug_info->GetBreakPointCount());
1089 int count = 0; 1094 int count = 0;
1090 for (int i = 0; i < debug_info->break_points()->length(); ++i) { 1095 for (int i = 0; i < debug_info->break_points()->length(); ++i) {
1091 if (!debug_info->break_points()->get(i)->IsUndefined(isolate)) { 1096 if (!debug_info->break_points()->get(i)->IsUndefined(isolate)) {
1092 BreakPointInfo* break_point_info = 1097 BreakPointInfo* break_point_info =
1093 BreakPointInfo::cast(debug_info->break_points()->get(i)); 1098 BreakPointInfo::cast(debug_info->break_points()->get(i));
1094 int break_points = break_point_info->GetBreakPointCount(); 1099 int break_points = break_point_info->GetBreakPointCount();
1095 if (break_points == 0) continue; 1100 if (break_points == 0) continue;
1096 Smi* position = NULL; 1101 Smi* position = NULL;
1097 switch (position_alignment) { 1102 if (position_alignment == STATEMENT_ALIGNED) {
1098 case STATEMENT_ALIGNED: 1103 BreakLocation break_point_location = BreakLocation::FromPosition(
1099 position = Smi::FromInt(break_point_info->statement_position()); 1104 debug_info, break_point_info->source_position(),
1100 break; 1105 BREAK_POSITION_ALIGNED);
1101 case BREAK_POSITION_ALIGNED: 1106 position = Smi::FromInt(break_point_location.statement_position());
1102 position = Smi::FromInt(break_point_info->source_position()); 1107 } else {
1103 break; 1108 DCHECK_EQ(BREAK_POSITION_ALIGNED, position_alignment);
1109 position = Smi::FromInt(break_point_info->source_position());
1104 } 1110 }
1105 for (int j = 0; j < break_points; ++j) locations->set(count++, position); 1111 for (int j = 0; j < break_points; ++j) locations->set(count++, position);
1106 } 1112 }
1107 } 1113 }
1108 return locations; 1114 return locations;
1109 } 1115 }
1110 1116
1111 1117
1112 void Debug::ClearStepping() { 1118 void Debug::ClearStepping() {
1113 // Clear the various stepping setup. 1119 // Clear the various stepping setup.
(...skipping 1463 matching lines...) Expand 10 before | Expand all | Expand 10 after
2577 } 2583 }
2578 2584
2579 2585
2580 void LockingCommandMessageQueue::Clear() { 2586 void LockingCommandMessageQueue::Clear() {
2581 base::LockGuard<base::Mutex> lock_guard(&mutex_); 2587 base::LockGuard<base::Mutex> lock_guard(&mutex_);
2582 queue_.Clear(); 2588 queue_.Clear();
2583 } 2589 }
2584 2590
2585 } // namespace internal 2591 } // namespace internal
2586 } // namespace v8 2592 } // namespace v8
OLDNEW
« no previous file with comments | « src/debug/debug.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698