| 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 <stdlib.h> | 5 #include <stdlib.h> |
| 6 | 6 |
| 7 #include <fstream> // NOLINT(readability/streams) | 7 #include <fstream> // NOLINT(readability/streams) |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 | 9 |
| 10 #include "src/v8.h" | 10 #include "src/v8.h" |
| (...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 frames_seen++; | 660 frames_seen++; |
| 661 } | 661 } |
| 662 it.Advance(); | 662 it.Advance(); |
| 663 } | 663 } |
| 664 | 664 |
| 665 stack_trace->set_length(Smi::FromInt(frames_seen)); | 665 stack_trace->set_length(Smi::FromInt(frames_seen)); |
| 666 return stack_trace; | 666 return stack_trace; |
| 667 } | 667 } |
| 668 | 668 |
| 669 | 669 |
| 670 void Isolate::PrintStack(FILE* out) { | 670 void Isolate::PrintStack(FILE* out, PrintStackMode mode) { |
| 671 if (stack_trace_nesting_level_ == 0) { | 671 if (stack_trace_nesting_level_ == 0) { |
| 672 stack_trace_nesting_level_++; | 672 stack_trace_nesting_level_++; |
| 673 StringStream::ClearMentionedObjectCache(this); | 673 StringStream::ClearMentionedObjectCache(this); |
| 674 HeapStringAllocator allocator; | 674 HeapStringAllocator allocator; |
| 675 StringStream accumulator(&allocator); | 675 StringStream accumulator(&allocator); |
| 676 incomplete_message_ = &accumulator; | 676 incomplete_message_ = &accumulator; |
| 677 PrintStack(&accumulator); | 677 PrintStack(&accumulator, mode); |
| 678 accumulator.OutputToFile(out); | 678 accumulator.OutputToFile(out); |
| 679 InitializeLoggingAndCounters(); | 679 InitializeLoggingAndCounters(); |
| 680 accumulator.Log(this); | 680 accumulator.Log(this); |
| 681 incomplete_message_ = NULL; | 681 incomplete_message_ = NULL; |
| 682 stack_trace_nesting_level_ = 0; | 682 stack_trace_nesting_level_ = 0; |
| 683 } else if (stack_trace_nesting_level_ == 1) { | 683 } else if (stack_trace_nesting_level_ == 1) { |
| 684 stack_trace_nesting_level_++; | 684 stack_trace_nesting_level_++; |
| 685 base::OS::PrintError( | 685 base::OS::PrintError( |
| 686 "\n\nAttempt to print stack while printing stack (double fault)\n"); | 686 "\n\nAttempt to print stack while printing stack (double fault)\n"); |
| 687 base::OS::PrintError( | 687 base::OS::PrintError( |
| 688 "If you are lucky you may find a partial stack dump on stdout.\n\n"); | 688 "If you are lucky you may find a partial stack dump on stdout.\n\n"); |
| 689 incomplete_message_->OutputToFile(out); | 689 incomplete_message_->OutputToFile(out); |
| 690 } | 690 } |
| 691 } | 691 } |
| 692 | 692 |
| 693 | 693 |
| 694 static void PrintFrames(Isolate* isolate, | 694 static void PrintFrames(Isolate* isolate, |
| 695 StringStream* accumulator, | 695 StringStream* accumulator, |
| 696 StackFrame::PrintMode mode) { | 696 StackFrame::PrintMode mode) { |
| 697 StackFrameIterator it(isolate); | 697 StackFrameIterator it(isolate); |
| 698 for (int i = 0; !it.done(); it.Advance()) { | 698 for (int i = 0; !it.done(); it.Advance()) { |
| 699 it.frame()->Print(accumulator, mode, i++); | 699 it.frame()->Print(accumulator, mode, i++); |
| 700 } | 700 } |
| 701 } | 701 } |
| 702 | 702 |
| 703 | 703 |
| 704 void Isolate::PrintStack(StringStream* accumulator) { | 704 void Isolate::PrintStack(StringStream* accumulator, PrintStackMode mode) { |
| 705 // The MentionedObjectCache is not GC-proof at the moment. | 705 // The MentionedObjectCache is not GC-proof at the moment. |
| 706 DisallowHeapAllocation no_gc; | 706 DisallowHeapAllocation no_gc; |
| 707 DCHECK(StringStream::IsMentionedObjectCacheClear(this)); | 707 DCHECK(StringStream::IsMentionedObjectCacheClear(this)); |
| 708 | 708 |
| 709 // Avoid printing anything if there are no frames. | 709 // Avoid printing anything if there are no frames. |
| 710 if (c_entry_fp(thread_local_top()) == 0) return; | 710 if (c_entry_fp(thread_local_top()) == 0) return; |
| 711 | 711 |
| 712 accumulator->Add( | 712 accumulator->Add( |
| 713 "\n==== JS stack trace =========================================\n\n"); | 713 "\n==== JS stack trace =========================================\n\n"); |
| 714 PrintFrames(this, accumulator, StackFrame::OVERVIEW); | 714 PrintFrames(this, accumulator, StackFrame::OVERVIEW); |
| 715 | 715 if (mode == kPrintStackVerbose) { |
| 716 accumulator->Add( | 716 accumulator->Add( |
| 717 "\n==== Details ================================================\n\n"); | 717 "\n==== Details ================================================\n\n"); |
| 718 PrintFrames(this, accumulator, StackFrame::DETAILS); | 718 PrintFrames(this, accumulator, StackFrame::DETAILS); |
| 719 | 719 accumulator->PrintMentionedObjectCache(this); |
| 720 accumulator->PrintMentionedObjectCache(this); | 720 } |
| 721 accumulator->Add("=====================\n\n"); | 721 accumulator->Add("=====================\n\n"); |
| 722 } | 722 } |
| 723 | 723 |
| 724 | 724 |
| 725 void Isolate::SetFailedAccessCheckCallback( | 725 void Isolate::SetFailedAccessCheckCallback( |
| 726 v8::FailedAccessCheckCallback callback) { | 726 v8::FailedAccessCheckCallback callback) { |
| 727 thread_local_top()->failed_access_check_callback_ = callback; | 727 thread_local_top()->failed_access_check_callback_ = callback; |
| 728 } | 728 } |
| 729 | 729 |
| 730 | 730 |
| (...skipping 2029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2760 if (prev_ && prev_->Intercept(flag)) return true; | 2760 if (prev_ && prev_->Intercept(flag)) return true; |
| 2761 // Then check whether this scope intercepts. | 2761 // Then check whether this scope intercepts. |
| 2762 if ((flag & intercept_mask_)) { | 2762 if ((flag & intercept_mask_)) { |
| 2763 intercepted_flags_ |= flag; | 2763 intercepted_flags_ |= flag; |
| 2764 return true; | 2764 return true; |
| 2765 } | 2765 } |
| 2766 return false; | 2766 return false; |
| 2767 } | 2767 } |
| 2768 | 2768 |
| 2769 } } // namespace v8::internal | 2769 } } // namespace v8::internal |
| OLD | NEW |