| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 frames_seen++; | 828 frames_seen++; |
| 829 } | 829 } |
| 830 it.Advance(); | 830 it.Advance(); |
| 831 } | 831 } |
| 832 | 832 |
| 833 stack_trace->set_length(Smi::FromInt(frames_seen)); | 833 stack_trace->set_length(Smi::FromInt(frames_seen)); |
| 834 return stack_trace; | 834 return stack_trace; |
| 835 } | 835 } |
| 836 | 836 |
| 837 | 837 |
| 838 void Isolate::PrintStack() { | 838 void Isolate::PrintStack(FILE* out) { |
| 839 if (stack_trace_nesting_level_ == 0) { | 839 if (stack_trace_nesting_level_ == 0) { |
| 840 stack_trace_nesting_level_++; | 840 stack_trace_nesting_level_++; |
| 841 | 841 |
| 842 StringAllocator* allocator; | 842 StringAllocator* allocator; |
| 843 if (preallocated_message_space_ == NULL) { | 843 if (preallocated_message_space_ == NULL) { |
| 844 allocator = new HeapStringAllocator(); | 844 allocator = new HeapStringAllocator(); |
| 845 } else { | 845 } else { |
| 846 allocator = preallocated_message_space_; | 846 allocator = preallocated_message_space_; |
| 847 } | 847 } |
| 848 | 848 |
| 849 StringStream::ClearMentionedObjectCache(); | 849 StringStream::ClearMentionedObjectCache(); |
| 850 StringStream accumulator(allocator); | 850 StringStream accumulator(allocator); |
| 851 incomplete_message_ = &accumulator; | 851 incomplete_message_ = &accumulator; |
| 852 PrintStack(&accumulator); | 852 PrintStack(&accumulator); |
| 853 accumulator.OutputToStdOut(); | 853 accumulator.OutputToFile(out); |
| 854 InitializeLoggingAndCounters(); | 854 InitializeLoggingAndCounters(); |
| 855 accumulator.Log(); | 855 accumulator.Log(); |
| 856 incomplete_message_ = NULL; | 856 incomplete_message_ = NULL; |
| 857 stack_trace_nesting_level_ = 0; | 857 stack_trace_nesting_level_ = 0; |
| 858 if (preallocated_message_space_ == NULL) { | 858 if (preallocated_message_space_ == NULL) { |
| 859 // Remove the HeapStringAllocator created above. | 859 // Remove the HeapStringAllocator created above. |
| 860 delete allocator; | 860 delete allocator; |
| 861 } | 861 } |
| 862 } else if (stack_trace_nesting_level_ == 1) { | 862 } else if (stack_trace_nesting_level_ == 1) { |
| 863 stack_trace_nesting_level_++; | 863 stack_trace_nesting_level_++; |
| 864 OS::PrintError( | 864 OS::PrintError( |
| 865 "\n\nAttempt to print stack while printing stack (double fault)\n"); | 865 "\n\nAttempt to print stack while printing stack (double fault)\n"); |
| 866 OS::PrintError( | 866 OS::PrintError( |
| 867 "If you are lucky you may find a partial stack dump on stdout.\n\n"); | 867 "If you are lucky you may find a partial stack dump on stdout.\n\n"); |
| 868 incomplete_message_->OutputToStdOut(); | 868 incomplete_message_->OutputToFile(out); |
| 869 } | 869 } |
| 870 } | 870 } |
| 871 | 871 |
| 872 | 872 |
| 873 static void PrintFrames(Isolate* isolate, | 873 static void PrintFrames(Isolate* isolate, |
| 874 StringStream* accumulator, | 874 StringStream* accumulator, |
| 875 StackFrame::PrintMode mode) { | 875 StackFrame::PrintMode mode) { |
| 876 StackFrameIterator it(isolate); | 876 StackFrameIterator it(isolate); |
| 877 for (int i = 0; !it.done(); it.Advance()) { | 877 for (int i = 0; !it.done(); it.Advance()) { |
| 878 it.frame()->Print(accumulator, mode, i++); | 878 it.frame()->Print(accumulator, mode, i++); |
| (...skipping 1610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2489 | 2489 |
| 2490 #ifdef DEBUG | 2490 #ifdef DEBUG |
| 2491 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ | 2491 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ |
| 2492 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); | 2492 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); |
| 2493 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) | 2493 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) |
| 2494 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) | 2494 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) |
| 2495 #undef ISOLATE_FIELD_OFFSET | 2495 #undef ISOLATE_FIELD_OFFSET |
| 2496 #endif | 2496 #endif |
| 2497 | 2497 |
| 2498 } } // namespace v8::internal | 2498 } } // namespace v8::internal |
| OLD | NEW |