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/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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 debug_info_list_(NULL), | 55 debug_info_list_(NULL), |
56 feature_tracker_(isolate), | 56 feature_tracker_(isolate), |
57 isolate_(isolate) { | 57 isolate_(isolate) { |
58 ThreadInit(); | 58 ThreadInit(); |
59 } | 59 } |
60 | 60 |
61 BreakLocation BreakLocation::FromFrame(Handle<DebugInfo> debug_info, | 61 BreakLocation BreakLocation::FromFrame(Handle<DebugInfo> debug_info, |
62 JavaScriptFrame* frame) { | 62 JavaScriptFrame* frame) { |
63 FrameSummary summary = FrameSummary::GetFirst(frame); | 63 FrameSummary summary = FrameSummary::GetFirst(frame); |
64 int offset = summary.code_offset(); | 64 int offset = summary.code_offset(); |
65 Handle<AbstractCode> abstract_code = summary.abstract_code(); | 65 Handle<AbstractCode> abstract_code = summary.AsJavaScript().abstract_code(); |
66 if (abstract_code->IsCode()) offset = offset - 1; | 66 if (abstract_code->IsCode()) offset = offset - 1; |
67 auto it = BreakIterator::GetIterator(debug_info, abstract_code); | 67 auto it = BreakIterator::GetIterator(debug_info, abstract_code); |
68 it->SkipTo(BreakIndexFromCodeOffset(debug_info, abstract_code, offset)); | 68 it->SkipTo(BreakIndexFromCodeOffset(debug_info, abstract_code, offset)); |
69 return it->GetBreakLocation(); | 69 return it->GetBreakLocation(); |
70 } | 70 } |
71 | 71 |
72 void BreakLocation::AllAtCurrentStatement(Handle<DebugInfo> debug_info, | 72 void BreakLocation::AllAtCurrentStatement(Handle<DebugInfo> debug_info, |
73 JavaScriptFrame* frame, | 73 JavaScriptFrame* frame, |
74 List<BreakLocation>* result_out) { | 74 List<BreakLocation>* result_out) { |
75 FrameSummary summary = FrameSummary::GetFirst(frame); | 75 auto summary = FrameSummary::GetFirst(frame).AsJavaScript(); |
76 int offset = summary.code_offset(); | 76 int offset = summary.code_offset(); |
77 Handle<AbstractCode> abstract_code = summary.abstract_code(); | 77 Handle<AbstractCode> abstract_code = summary.abstract_code(); |
78 if (abstract_code->IsCode()) offset = offset - 1; | 78 if (abstract_code->IsCode()) offset = offset - 1; |
79 int statement_position; | 79 int statement_position; |
80 { | 80 { |
81 auto it = BreakIterator::GetIterator(debug_info, abstract_code); | 81 auto it = BreakIterator::GetIterator(debug_info, abstract_code); |
82 it->SkipTo(BreakIndexFromCodeOffset(debug_info, abstract_code, offset)); | 82 it->SkipTo(BreakIndexFromCodeOffset(debug_info, abstract_code, offset)); |
83 statement_position = it->statement_position(); | 83 statement_position = it->statement_position(); |
84 } | 84 } |
85 for (auto it = BreakIterator::GetIterator(debug_info, abstract_code); | 85 for (auto it = BreakIterator::GetIterator(debug_info, abstract_code); |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 step_break = true; | 551 step_break = true; |
552 break; | 552 break; |
553 case StepNext: | 553 case StepNext: |
554 // Step next should not break in a deeper frame. | 554 // Step next should not break in a deeper frame. |
555 if (current_fp < target_fp) return; | 555 if (current_fp < target_fp) return; |
556 // For step-next, a tail call is like a return and should break. | 556 // For step-next, a tail call is like a return and should break. |
557 step_break = location.IsTailCall(); | 557 step_break = location.IsTailCall(); |
558 // Fall through. | 558 // Fall through. |
559 case StepIn: { | 559 case StepIn: { |
560 FrameSummary summary = FrameSummary::GetFirst(frame); | 560 FrameSummary summary = FrameSummary::GetFirst(frame); |
561 int offset = summary.code_offset(); | 561 step_break = step_break || location.IsReturn() || current_fp != last_fp || |
562 step_break = step_break || location.IsReturn() || | 562 thread_local_.last_statement_position_ != |
563 (current_fp != last_fp) || | 563 summary.SourceStatementPosition(); |
564 (thread_local_.last_statement_position_ != | |
565 summary.abstract_code()->SourceStatementPosition(offset)); | |
566 break; | 564 break; |
567 } | 565 } |
568 case StepFrame: | 566 case StepFrame: |
569 step_break = current_fp != last_fp; | 567 step_break = current_fp != last_fp; |
570 break; | 568 break; |
571 } | 569 } |
572 | 570 |
573 // Clear all current stepping setup. | 571 // Clear all current stepping setup. |
574 ClearStepping(); | 572 ClearStepping(); |
575 | 573 |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 // Step out: Find the calling JavaScript frame and flood it with | 991 // Step out: Find the calling JavaScript frame and flood it with |
994 // breakpoints. | 992 // breakpoints. |
995 frames_it.Advance(); | 993 frames_it.Advance(); |
996 // Fill the function to return to with one-shot break points. | 994 // Fill the function to return to with one-shot break points. |
997 JSFunction* function = frames_it.frame()->function(); | 995 JSFunction* function = frames_it.frame()->function(); |
998 FloodWithOneShot(Handle<JSFunction>(function)); | 996 FloodWithOneShot(Handle<JSFunction>(function)); |
999 return; | 997 return; |
1000 } | 998 } |
1001 | 999 |
1002 // Get the debug info (create it if it does not exist). | 1000 // Get the debug info (create it if it does not exist). |
1003 FrameSummary summary = FrameSummary::GetFirst(frame); | 1001 auto summary = FrameSummary::GetFirst(frame).AsJavaScript(); |
1004 Handle<JSFunction> function(summary.function()); | 1002 Handle<JSFunction> function(summary.function()); |
1005 Handle<SharedFunctionInfo> shared(function->shared()); | 1003 Handle<SharedFunctionInfo> shared(function->shared()); |
1006 if (!EnsureDebugInfo(shared, function)) { | 1004 if (!EnsureDebugInfo(shared, function)) { |
1007 // Return if ensuring debug info failed. | 1005 // Return if ensuring debug info failed. |
1008 return; | 1006 return; |
1009 } | 1007 } |
1010 | 1008 |
1011 Handle<DebugInfo> debug_info(shared->GetDebugInfo()); | 1009 Handle<DebugInfo> debug_info(shared->GetDebugInfo()); |
1012 BreakLocation location = BreakLocation::FromFrame(debug_info, frame); | 1010 BreakLocation location = BreakLocation::FromFrame(debug_info, frame); |
1013 | 1011 |
(...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2252 } | 2250 } |
2253 | 2251 |
2254 #ifdef DEBUG | 2252 #ifdef DEBUG |
2255 void Debug::PrintBreakLocation() { | 2253 void Debug::PrintBreakLocation() { |
2256 if (!FLAG_print_break_location) return; | 2254 if (!FLAG_print_break_location) return; |
2257 HandleScope scope(isolate_); | 2255 HandleScope scope(isolate_); |
2258 JavaScriptFrameIterator iterator(isolate_); | 2256 JavaScriptFrameIterator iterator(isolate_); |
2259 if (iterator.done()) return; | 2257 if (iterator.done()) return; |
2260 JavaScriptFrame* frame = iterator.frame(); | 2258 JavaScriptFrame* frame = iterator.frame(); |
2261 FrameSummary summary = FrameSummary::GetFirst(frame); | 2259 FrameSummary summary = FrameSummary::GetFirst(frame); |
2262 int source_position = | 2260 int source_position = summary.SourcePosition(); |
2263 summary.abstract_code()->SourcePosition(summary.code_offset()); | 2261 Handle<Object> script_obj = summary.script(); |
2264 Handle<Object> script_obj(summary.function()->shared()->script(), isolate_); | |
2265 PrintF("[debug] break in function '"); | 2262 PrintF("[debug] break in function '"); |
2266 summary.function()->PrintName(); | 2263 summary.FunctionName()->PrintOn(stdout); |
2267 PrintF("'.\n"); | 2264 PrintF("'.\n"); |
2268 if (script_obj->IsScript()) { | 2265 if (script_obj->IsScript()) { |
2269 Handle<Script> script = Handle<Script>::cast(script_obj); | 2266 Handle<Script> script = Handle<Script>::cast(script_obj); |
2270 Handle<String> source(String::cast(script->source())); | 2267 Handle<String> source(String::cast(script->source())); |
2271 Script::InitLineEnds(script); | 2268 Script::InitLineEnds(script); |
2272 int line = | 2269 int line = |
2273 Script::GetLineNumber(script, source_position) - script->line_offset(); | 2270 Script::GetLineNumber(script, source_position) - script->line_offset(); |
2274 int column = Script::GetColumnNumber(script, source_position) - | 2271 int column = Script::GetColumnNumber(script, source_position) - |
2275 (line == 0 ? script->column_offset() : 0); | 2272 (line == 0 ? script->column_offset() : 0); |
2276 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends())); | 2273 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends())); |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2615 logger_->DebugEvent("Put", message.text()); | 2612 logger_->DebugEvent("Put", message.text()); |
2616 } | 2613 } |
2617 | 2614 |
2618 void LockingCommandMessageQueue::Clear() { | 2615 void LockingCommandMessageQueue::Clear() { |
2619 base::LockGuard<base::Mutex> lock_guard(&mutex_); | 2616 base::LockGuard<base::Mutex> lock_guard(&mutex_); |
2620 queue_.Clear(); | 2617 queue_.Clear(); |
2621 } | 2618 } |
2622 | 2619 |
2623 } // namespace internal | 2620 } // namespace internal |
2624 } // namespace v8 | 2621 } // namespace v8 |
OLD | NEW |