OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 position_ = rinfo()->data() - debug_info_->shared()->start_position(); | 106 position_ = rinfo()->data() - debug_info_->shared()->start_position(); |
107 ASSERT(position_ >= 0); | 107 ASSERT(position_ >= 0); |
108 ASSERT(statement_position_ >= 0); | 108 ASSERT(statement_position_ >= 0); |
109 } | 109 } |
110 | 110 |
111 // Check for breakable code target. Look in the original code as setting | 111 // Check for breakable code target. Look in the original code as setting |
112 // break points can cause the code targets in the running (debugged) code to | 112 // break points can cause the code targets in the running (debugged) code to |
113 // be of a different kind than in the original code. | 113 // be of a different kind than in the original code. |
114 if (RelocInfo::IsCodeTarget(rmode())) { | 114 if (RelocInfo::IsCodeTarget(rmode())) { |
115 Address target = original_rinfo()->target_address(); | 115 Address target = original_rinfo()->target_address(); |
116 Code* code = Debug::GetCodeTarget(target); | 116 Code* code = Code::GetCodeFromTargetAddress(target); |
117 if (code->is_inline_cache_stub() || RelocInfo::IsConstructCall(rmode())) { | 117 if (code->is_inline_cache_stub() || RelocInfo::IsConstructCall(rmode())) { |
118 break_point_++; | 118 break_point_++; |
119 return; | 119 return; |
120 } | 120 } |
121 if (code->kind() == Code::STUB) { | 121 if (code->kind() == Code::STUB) { |
122 if (type_ == ALL_BREAK_LOCATIONS) { | 122 if (type_ == ALL_BREAK_LOCATIONS) { |
123 if (Debug::IsBreakStub(code)) { | 123 if (Debug::IsBreakStub(code)) { |
124 break_point_++; | 124 break_point_++; |
125 return; | 125 return; |
126 } | 126 } |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 rinfo()->set_target_address(original_rinfo()->target_address()); | 318 rinfo()->set_target_address(original_rinfo()->target_address()); |
319 } | 319 } |
320 ASSERT(!IsDebugBreak()); | 320 ASSERT(!IsDebugBreak()); |
321 } | 321 } |
322 | 322 |
323 | 323 |
324 void BreakLocationIterator::PrepareStepIn() { | 324 void BreakLocationIterator::PrepareStepIn() { |
325 // Step in can only be prepared if currently positioned on an IC call or | 325 // Step in can only be prepared if currently positioned on an IC call or |
326 // construct call. | 326 // construct call. |
327 Address target = rinfo()->target_address(); | 327 Address target = rinfo()->target_address(); |
328 Code* code = Debug::GetCodeTarget(target); | 328 Code* code = Code::GetCodeFromTargetAddress(target); |
329 if (code->is_call_stub()) { | 329 if (code->is_call_stub()) { |
330 // Step in through IC call is handled by the runtime system. Therefore make | 330 // Step in through IC call is handled by the runtime system. Therefore make |
331 // sure that the any current IC is cleared and the runtime system is | 331 // sure that the any current IC is cleared and the runtime system is |
332 // called. If the executing code has a debug break at the location change | 332 // called. If the executing code has a debug break at the location change |
333 // the call in the original code as it is the code there that will be | 333 // the call in the original code as it is the code there that will be |
334 // executed in place of the debug break call. | 334 // executed in place of the debug break call. |
335 Handle<Code> stub = ComputeCallDebugPrepareStepIn(code->arguments_count()); | 335 Handle<Code> stub = ComputeCallDebugPrepareStepIn(code->arguments_count()); |
336 if (IsDebugBreak()) { | 336 if (IsDebugBreak()) { |
337 original_rinfo()->set_target_address(stub->entry()); | 337 original_rinfo()->set_target_address(stub->entry()); |
338 } else { | 338 } else { |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 Handle<DebugInfo> debug_info = GetDebugInfo(shared); | 916 Handle<DebugInfo> debug_info = GetDebugInfo(shared); |
917 | 917 |
918 // Find the break location where execution has stopped. | 918 // Find the break location where execution has stopped. |
919 BreakLocationIterator it(debug_info, ALL_BREAK_LOCATIONS); | 919 BreakLocationIterator it(debug_info, ALL_BREAK_LOCATIONS); |
920 it.FindBreakLocationFromAddress(frame->pc()); | 920 it.FindBreakLocationFromAddress(frame->pc()); |
921 | 921 |
922 // Compute whether or not the target is a call target. | 922 // Compute whether or not the target is a call target. |
923 bool is_call_target = false; | 923 bool is_call_target = false; |
924 if (RelocInfo::IsCodeTarget(it.rinfo()->rmode())) { | 924 if (RelocInfo::IsCodeTarget(it.rinfo()->rmode())) { |
925 Address target = it.rinfo()->target_address(); | 925 Address target = it.rinfo()->target_address(); |
926 Code* code = Debug::GetCodeTarget(target); | 926 Code* code = Code::GetCodeFromTargetAddress(target); |
927 if (code->is_call_stub()) is_call_target = true; | 927 if (code->is_call_stub()) is_call_target = true; |
928 } | 928 } |
929 | 929 |
930 // If this is the last break code target step out is the only possibility. | 930 // If this is the last break code target step out is the only possibility. |
931 if (it.IsExit() || step_action == StepOut) { | 931 if (it.IsExit() || step_action == StepOut) { |
932 // Step out: If there is a JavaScript caller frame, we need to | 932 // Step out: If there is a JavaScript caller frame, we need to |
933 // flood it with breakpoints. | 933 // flood it with breakpoints. |
934 frames_it.Advance(); | 934 frames_it.Advance(); |
935 if (!frames_it.done()) { | 935 if (!frames_it.done()) { |
936 // Fill the function to return to with one-shot break points. | 936 // Fill the function to return to with one-shot break points. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
984 } | 984 } |
985 | 985 |
986 // No step next action - don't continue. | 986 // No step next action - don't continue. |
987 return false; | 987 return false; |
988 } | 988 } |
989 | 989 |
990 | 990 |
991 // Check whether the code object at the specified address is a debug break code | 991 // Check whether the code object at the specified address is a debug break code |
992 // object. | 992 // object. |
993 bool Debug::IsDebugBreak(Address addr) { | 993 bool Debug::IsDebugBreak(Address addr) { |
994 Code* code = GetCodeTarget(addr); | 994 Code* code = Code::GetCodeFromTargetAddress(addr); |
995 return code->ic_state() == DEBUG_BREAK; | 995 return code->ic_state() == DEBUG_BREAK; |
996 } | 996 } |
997 | 997 |
998 | 998 |
999 // Check whether a code stub with the specified major key is a possible break | 999 // Check whether a code stub with the specified major key is a possible break |
1000 // point location when looking for source break locations. | 1000 // point location when looking for source break locations. |
1001 bool Debug::IsSourceBreakStub(Code* code) { | 1001 bool Debug::IsSourceBreakStub(Code* code) { |
1002 CodeStub::Major major_key = code->major_key(); | 1002 CodeStub::Major major_key = code->major_key(); |
1003 return major_key == CodeStub::CallFunction; | 1003 return major_key == CodeStub::CallFunction; |
1004 } | 1004 } |
1005 | 1005 |
1006 | 1006 |
1007 // Check whether a code stub with the specified major key is a possible break | 1007 // Check whether a code stub with the specified major key is a possible break |
1008 // location. | 1008 // location. |
1009 bool Debug::IsBreakStub(Code* code) { | 1009 bool Debug::IsBreakStub(Code* code) { |
1010 CodeStub::Major major_key = code->major_key(); | 1010 CodeStub::Major major_key = code->major_key(); |
1011 return major_key == CodeStub::CallFunction || | 1011 return major_key == CodeStub::CallFunction || |
1012 major_key == CodeStub::StackCheck; | 1012 major_key == CodeStub::StackCheck; |
1013 } | 1013 } |
1014 | 1014 |
1015 | 1015 |
1016 // Find the builtin to use for invoking the debug break | 1016 // Find the builtin to use for invoking the debug break |
1017 Handle<Code> Debug::FindDebugBreak(RelocInfo* rinfo) { | 1017 Handle<Code> Debug::FindDebugBreak(RelocInfo* rinfo) { |
1018 // Find the builtin debug break function matching the calling convention | 1018 // Find the builtin debug break function matching the calling convention |
1019 // used by the call site. | 1019 // used by the call site. |
1020 RelocInfo::Mode mode = rinfo->rmode(); | 1020 RelocInfo::Mode mode = rinfo->rmode(); |
1021 | 1021 |
1022 if (RelocInfo::IsCodeTarget(mode)) { | 1022 if (RelocInfo::IsCodeTarget(mode)) { |
1023 Address target = rinfo->target_address(); | 1023 Address target = rinfo->target_address(); |
1024 Code* code = Debug::GetCodeTarget(target); | 1024 Code* code = Code::GetCodeFromTargetAddress(target); |
1025 if (code->is_inline_cache_stub()) { | 1025 if (code->is_inline_cache_stub()) { |
1026 if (code->is_call_stub()) { | 1026 if (code->is_call_stub()) { |
1027 return ComputeCallDebugBreak(code->arguments_count()); | 1027 return ComputeCallDebugBreak(code->arguments_count()); |
1028 } | 1028 } |
1029 if (code->is_load_stub()) { | 1029 if (code->is_load_stub()) { |
1030 return Handle<Code>(Builtins::builtin(Builtins::LoadIC_DebugBreak)); | 1030 return Handle<Code>(Builtins::builtin(Builtins::LoadIC_DebugBreak)); |
1031 } | 1031 } |
1032 if (code->is_store_stub()) { | 1032 if (code->is_store_stub()) { |
1033 return Handle<Code>(Builtins::builtin(Builtins::StoreIC_DebugBreak)); | 1033 return Handle<Code>(Builtins::builtin(Builtins::StoreIC_DebugBreak)); |
1034 } | 1034 } |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1255 addr += original_code->instruction_start() - code->instruction_start(); | 1255 addr += original_code->instruction_start() - code->instruction_start(); |
1256 } | 1256 } |
1257 | 1257 |
1258 // Install jump to the call address in the original code. This will be the | 1258 // Install jump to the call address in the original code. This will be the |
1259 // call which was overwritten by the call to DebugBreakXXX. | 1259 // call which was overwritten by the call to DebugBreakXXX. |
1260 thread_local_.after_break_target_ = Assembler::target_address_at(addr); | 1260 thread_local_.after_break_target_ = Assembler::target_address_at(addr); |
1261 } | 1261 } |
1262 } | 1262 } |
1263 | 1263 |
1264 | 1264 |
1265 Code* Debug::GetCodeTarget(Address target) { | |
1266 // Maybe this can be refactored with the stuff in ic-inl.h? | |
1267 Code* result = | |
1268 Code::cast(HeapObject::FromAddress(target - Code::kHeaderSize)); | |
1269 return result; | |
1270 } | |
1271 | |
1272 | |
1273 bool Debug::IsDebugGlobal(GlobalObject* global) { | 1265 bool Debug::IsDebugGlobal(GlobalObject* global) { |
1274 return IsLoaded() && global == Debug::debug_context()->global(); | 1266 return IsLoaded() && global == Debug::debug_context()->global(); |
1275 } | 1267 } |
1276 | 1268 |
1277 | 1269 |
1278 bool Debugger::debugger_active_ = false; | 1270 bool Debugger::debugger_active_ = false; |
1279 bool Debugger::compiling_natives_ = false; | 1271 bool Debugger::compiling_natives_ = false; |
1280 bool Debugger::is_loading_debugger_ = false; | 1272 bool Debugger::is_loading_debugger_ = false; |
1281 DebugMessageThread* Debugger::message_thread_ = NULL; | 1273 DebugMessageThread* Debugger::message_thread_ = NULL; |
1282 v8::DebugMessageHandler Debugger::debug_message_handler_ = NULL; | 1274 v8::DebugMessageHandler Debugger::debug_message_handler_ = NULL; |
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1960 } | 1952 } |
1961 | 1953 |
1962 | 1954 |
1963 void LockingMessageQueue::Clear() { | 1955 void LockingMessageQueue::Clear() { |
1964 ScopedLock sl(lock_); | 1956 ScopedLock sl(lock_); |
1965 queue_.Clear(); | 1957 queue_.Clear(); |
1966 } | 1958 } |
1967 | 1959 |
1968 | 1960 |
1969 } } // namespace v8::internal | 1961 } } // namespace v8::internal |
OLD | NEW |