OLD | NEW |
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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 original_rmode_(original_rinfo->rmode()), | 69 original_rmode_(original_rinfo->rmode()), |
70 data_(rinfo->data()), | 70 data_(rinfo->data()), |
71 original_data_(original_rinfo->data()), | 71 original_data_(original_rinfo->data()), |
72 position_(position), | 72 position_(position), |
73 statement_position_(statement_position) {} | 73 statement_position_(statement_position) {} |
74 | 74 |
75 | 75 |
76 BreakLocation::Iterator::Iterator(Handle<DebugInfo> debug_info, | 76 BreakLocation::Iterator::Iterator(Handle<DebugInfo> debug_info, |
77 BreakLocatorType type) | 77 BreakLocatorType type) |
78 : debug_info_(debug_info), | 78 : debug_info_(debug_info), |
79 type_(type), | 79 reloc_iterator_(debug_info->code(), GetModeMask(type)), |
80 reloc_iterator_(debug_info->code(), | 80 reloc_iterator_original_(debug_info->original_code(), GetModeMask(type)), |
81 ~RelocInfo::ModeMask(RelocInfo::CODE_AGE_SEQUENCE)), | |
82 reloc_iterator_original_( | |
83 debug_info->original_code(), | |
84 ~RelocInfo::ModeMask(RelocInfo::CODE_AGE_SEQUENCE)), | |
85 break_index_(-1), | 81 break_index_(-1), |
86 position_(1), | 82 position_(1), |
87 statement_position_(1) { | 83 statement_position_(1) { |
88 Next(); | 84 if (!RinfoDone()) Next(); |
89 } | 85 } |
90 | 86 |
91 | 87 |
| 88 int BreakLocation::Iterator::GetModeMask(BreakLocatorType type) { |
| 89 int mask = 0; |
| 90 mask |= RelocInfo::ModeMask(RelocInfo::POSITION); |
| 91 mask |= RelocInfo::ModeMask(RelocInfo::STATEMENT_POSITION); |
| 92 mask |= RelocInfo::ModeMask(RelocInfo::JS_RETURN); |
| 93 mask |= RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT_AT_CALL); |
| 94 mask |= RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT_AT_CONSTRUCT_CALL); |
| 95 if (type == ALL_BREAK_LOCATIONS) { |
| 96 mask |= RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT_AT_POSITION); |
| 97 mask |= RelocInfo::ModeMask(RelocInfo::DEBUGGER_STATEMENT); |
| 98 } |
| 99 return mask; |
| 100 } |
| 101 |
| 102 |
92 void BreakLocation::Iterator::Next() { | 103 void BreakLocation::Iterator::Next() { |
93 DisallowHeapAllocation no_gc; | 104 DisallowHeapAllocation no_gc; |
94 DCHECK(!RinfoDone()); | 105 DCHECK(!RinfoDone()); |
95 | 106 |
96 // Iterate through reloc info for code and original code stopping at each | 107 // Iterate through reloc info for code and original code stopping at each |
97 // breakable code target. | 108 // breakable code target. |
98 bool first = break_index_ == -1; | 109 bool first = break_index_ == -1; |
99 while (!RinfoDone()) { | 110 while (!RinfoDone()) { |
100 if (!first) RinfoNext(); | 111 if (!first) RinfoNext(); |
101 first = false; | 112 first = false; |
(...skipping 20 matching lines...) Expand all Loading... |
122 if (debug_info_->shared()->HasSourceCode()) { | 133 if (debug_info_->shared()->HasSourceCode()) { |
123 position_ = debug_info_->shared()->end_position() - | 134 position_ = debug_info_->shared()->end_position() - |
124 debug_info_->shared()->start_position() - 1; | 135 debug_info_->shared()->start_position() - 1; |
125 } else { | 136 } else { |
126 position_ = 0; | 137 position_ = 0; |
127 } | 138 } |
128 statement_position_ = position_; | 139 statement_position_ = position_; |
129 break; | 140 break; |
130 } | 141 } |
131 | 142 |
132 if (RelocInfo::IsDebugBreakSlot(rmode()) && | 143 DCHECK(RelocInfo::IsDebugBreakSlot(rmode()) || |
133 (type_ == ALL_BREAK_LOCATIONS || | 144 RelocInfo::IsDebuggerStatement(rmode())); |
134 RelocInfo::DebugBreakIsCall(rinfo()->data()))) { | 145 break; |
135 break; | |
136 } | |
137 | |
138 if (RelocInfo::IsDebuggerStatement(rmode()) && | |
139 type_ == ALL_BREAK_LOCATIONS) { | |
140 break; | |
141 } | |
142 } | 146 } |
143 break_index_++; | 147 break_index_++; |
144 } | 148 } |
145 | 149 |
146 | 150 |
147 // Find the break point at the supplied address, or the closest one before | 151 // Find the break point at the supplied address, or the closest one before |
148 // the address. | 152 // the address. |
149 BreakLocation BreakLocation::FromAddress(Handle<DebugInfo> debug_info, | 153 BreakLocation BreakLocation::FromAddress(Handle<DebugInfo> debug_info, |
150 BreakLocatorType type, Address pc) { | 154 BreakLocatorType type, Address pc) { |
151 Iterator it(debug_info, type); | 155 Iterator it(debug_info, type); |
(...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1270 | 1274 |
1271 // No step next action - don't continue. | 1275 // No step next action - don't continue. |
1272 return false; | 1276 return false; |
1273 } | 1277 } |
1274 | 1278 |
1275 | 1279 |
1276 // Check whether the code object at the specified address is a debug break code | 1280 // Check whether the code object at the specified address is a debug break code |
1277 // object. | 1281 // object. |
1278 bool Debug::IsDebugBreak(Address addr) { | 1282 bool Debug::IsDebugBreak(Address addr) { |
1279 Code* code = Code::GetCodeFromTargetAddress(addr); | 1283 Code* code = Code::GetCodeFromTargetAddress(addr); |
1280 return code->is_debug_stub() && code->extra_ic_state() == DEBUG_BREAK; | 1284 return code->is_debug_stub(); |
1281 } | 1285 } |
1282 | 1286 |
1283 | 1287 |
1284 // Simple function for returning the source positions for active break points. | 1288 // Simple function for returning the source positions for active break points. |
1285 Handle<Object> Debug::GetSourceBreakLocations( | 1289 Handle<Object> Debug::GetSourceBreakLocations( |
1286 Handle<SharedFunctionInfo> shared, | 1290 Handle<SharedFunctionInfo> shared, |
1287 BreakPositionAlignment position_alignment) { | 1291 BreakPositionAlignment position_alignment) { |
1288 Isolate* isolate = shared->GetIsolate(); | 1292 Isolate* isolate = shared->GetIsolate(); |
1289 Heap* heap = isolate->heap(); | 1293 Heap* heap = isolate->heap(); |
1290 if (!HasDebugInfo(shared)) { | 1294 if (!HasDebugInfo(shared)) { |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1455 } | 1459 } |
1456 | 1460 |
1457 return code_offset; | 1461 return code_offset; |
1458 } | 1462 } |
1459 | 1463 |
1460 | 1464 |
1461 // The inverse of ComputeCodeOffsetFromPcOffset. | 1465 // The inverse of ComputeCodeOffsetFromPcOffset. |
1462 static int ComputePcOffsetFromCodeOffset(Code *code, int code_offset) { | 1466 static int ComputePcOffsetFromCodeOffset(Code *code, int code_offset) { |
1463 DCHECK_EQ(code->kind(), Code::FUNCTION); | 1467 DCHECK_EQ(code->kind(), Code::FUNCTION); |
1464 | 1468 |
1465 int mask = RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT) | | 1469 int mask = RelocInfo::kDebugBreakSlotMask | |
1466 RelocInfo::ModeMask(RelocInfo::CONST_POOL) | | 1470 RelocInfo::ModeMask(RelocInfo::CONST_POOL) | |
1467 RelocInfo::ModeMask(RelocInfo::VENEER_POOL); | 1471 RelocInfo::ModeMask(RelocInfo::VENEER_POOL); |
1468 int reloc = 0; | 1472 int reloc = 0; |
1469 for (RelocIterator it(code, mask); !it.done(); it.next()) { | 1473 for (RelocIterator it(code, mask); !it.done(); it.next()) { |
1470 RelocInfo* info = it.rinfo(); | 1474 RelocInfo* info = it.rinfo(); |
1471 if (info->pc() - code->instruction_start() - reloc >= code_offset) break; | 1475 if (info->pc() - code->instruction_start() - reloc >= code_offset) break; |
1472 if (RelocInfo::IsDebugBreakSlot(info->rmode())) { | 1476 if (RelocInfo::IsDebugBreakSlot(info->rmode())) { |
1473 reloc += Assembler::kDebugBreakSlotLength; | 1477 reloc += Assembler::kDebugBreakSlotLength; |
1474 } else { | 1478 } else { |
1475 DCHECK(RelocInfo::IsConstPool(info->rmode())); | 1479 DCHECK(RelocInfo::IsConstPool(info->rmode())); |
(...skipping 1713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3189 masm->RecordDebugBreakSlotForCall(call_argc); | 3193 masm->RecordDebugBreakSlotForCall(call_argc); |
3190 return; | 3194 return; |
3191 case DEBUG_BREAK_AT_CONSTRUCT_CALL: | 3195 case DEBUG_BREAK_AT_CONSTRUCT_CALL: |
3192 masm->RecordDebugBreakSlotForConstructCall(); | 3196 masm->RecordDebugBreakSlotForConstructCall(); |
3193 return; | 3197 return; |
3194 } | 3198 } |
3195 } | 3199 } |
3196 | 3200 |
3197 } // namespace internal | 3201 } // namespace internal |
3198 } // namespace v8 | 3202 } // namespace v8 |
OLD | NEW |