| 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 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 Debug::set_interrupts_pending(PREEMPT); | 885 Debug::set_interrupts_pending(PREEMPT); |
| 886 } | 886 } |
| 887 | 887 |
| 888 | 888 |
| 889 void Debug::Iterate(ObjectVisitor* v) { | 889 void Debug::Iterate(ObjectVisitor* v) { |
| 890 v->VisitPointer(BitCast<Object**>(&(debug_break_return_))); | 890 v->VisitPointer(BitCast<Object**>(&(debug_break_return_))); |
| 891 v->VisitPointer(BitCast<Object**>(&(debug_break_slot_))); | 891 v->VisitPointer(BitCast<Object**>(&(debug_break_slot_))); |
| 892 } | 892 } |
| 893 | 893 |
| 894 | 894 |
| 895 // TODO(131642): Remove this when fixed. | |
| 896 void Debug::PutValuesOnStackAndDie(int start, | |
| 897 Address c_entry_fp, | |
| 898 Address last_fp, | |
| 899 Address larger_fp, | |
| 900 int count, | |
| 901 char* stack, | |
| 902 int end) { | |
| 903 OS::PrintError("start: %d\n", start); | |
| 904 OS::PrintError("c_entry_fp: %p\n", static_cast<void*>(c_entry_fp)); | |
| 905 OS::PrintError("last_fp: %p\n", static_cast<void*>(last_fp)); | |
| 906 OS::PrintError("larger_fp: %p\n", static_cast<void*>(larger_fp)); | |
| 907 OS::PrintError("count: %d\n", count); | |
| 908 if (stack != NULL) { | |
| 909 OS::PrintError("stack: %s\n", stack); | |
| 910 } | |
| 911 OS::PrintError("end: %d\n", end); | |
| 912 OS::Abort(); | |
| 913 } | |
| 914 | |
| 915 | |
| 916 Object* Debug::Break(Arguments args) { | 895 Object* Debug::Break(Arguments args) { |
| 917 Heap* heap = isolate_->heap(); | 896 Heap* heap = isolate_->heap(); |
| 918 HandleScope scope(isolate_); | 897 HandleScope scope(isolate_); |
| 919 ASSERT(args.length() == 0); | 898 ASSERT(args.length() == 0); |
| 920 | 899 |
| 921 thread_local_.frame_drop_mode_ = FRAMES_UNTOUCHED; | 900 thread_local_.frame_drop_mode_ = FRAMES_UNTOUCHED; |
| 922 | 901 |
| 923 // Get the top-most JavaScript frame. | 902 // Get the top-most JavaScript frame. |
| 924 JavaScriptFrameIterator it(isolate_); | 903 JavaScriptFrameIterator it(isolate_); |
| 925 JavaScriptFrame* frame = it.frame(); | 904 JavaScriptFrame* frame = it.frame(); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1003 // and keep step count queued up in the meantime. | 982 // and keep step count queued up in the meantime. |
| 1004 if (step_action == StepNext && frame->fp() < thread_local_.last_fp_) { | 983 if (step_action == StepNext && frame->fp() < thread_local_.last_fp_) { |
| 1005 // Count frames until target frame | 984 // Count frames until target frame |
| 1006 int count = 0; | 985 int count = 0; |
| 1007 JavaScriptFrameIterator it(isolate_); | 986 JavaScriptFrameIterator it(isolate_); |
| 1008 while (!it.done() && it.frame()->fp() < thread_local_.last_fp_) { | 987 while (!it.done() && it.frame()->fp() < thread_local_.last_fp_) { |
| 1009 count++; | 988 count++; |
| 1010 it.Advance(); | 989 it.Advance(); |
| 1011 } | 990 } |
| 1012 | 991 |
| 1013 // TODO(131642): Remove this when fixed. | 992 // Check that we indeed found the frame we are looking for. |
| 1014 // Catch the cases that would lead to crashes and capture | 993 CHECK(!it.done() && (it.frame()->fp() == thread_local_.last_fp_)); |
| 1015 // - C entry FP at which to start stack crawl. | 994 if (step_count > 1) { |
| 1016 // - FP of the frame at which we plan to stop stepping out (last FP). | 995 // Save old count and action to continue stepping after StepOut. |
| 1017 // - current FP that's larger than last FP. | 996 thread_local_.queued_step_count_ = step_count - 1; |
| 1018 // - Counter for the number of steps to step out. | |
| 1019 // - stack trace string. | |
| 1020 if (it.done()) { | |
| 1021 // We crawled the entire stack, never reaching last_fp_. | |
| 1022 Handle<String> stack = isolate_->StackTraceString(); | |
| 1023 char buffer[8192]; | |
| 1024 int length = Min(8192, stack->length()); | |
| 1025 String::WriteToFlat(*stack, buffer, 0, length - 1); | |
| 1026 PutValuesOnStackAndDie(0xBEEEEEEE, | |
| 1027 frame->fp(), | |
| 1028 thread_local_.last_fp_, | |
| 1029 reinterpret_cast<Address>(0xDEADDEAD), | |
| 1030 count, | |
| 1031 buffer, | |
| 1032 0xCEEEEEEE); | |
| 1033 } else if (it.frame()->fp() != thread_local_.last_fp_) { | |
| 1034 // We crawled over last_fp_, without getting a match. | |
| 1035 Handle<String> stack = isolate_->StackTraceString(); | |
| 1036 char buffer[8192]; | |
| 1037 int length = Min(8192, stack->length()); | |
| 1038 String::WriteToFlat(*stack, buffer, 0, length - 1); | |
| 1039 PutValuesOnStackAndDie(0xDEEEEEEE, | |
| 1040 frame->fp(), | |
| 1041 thread_local_.last_fp_, | |
| 1042 it.frame()->fp(), | |
| 1043 count, | |
| 1044 buffer, | |
| 1045 0xFEEEEEEE); | |
| 1046 } | 997 } |
| 1047 | 998 |
| 1048 // If we found original frame | 999 // Set up for StepOut to reach target frame. |
| 1049 if (it.frame()->fp() == thread_local_.last_fp_) { | 1000 step_action = StepOut; |
| 1050 if (step_count > 1) { | 1001 step_count = count; |
| 1051 // Save old count and action to continue stepping after | |
| 1052 // StepOut | |
| 1053 thread_local_.queued_step_count_ = step_count - 1; | |
| 1054 } | |
| 1055 | |
| 1056 // Set up for StepOut to reach target frame | |
| 1057 step_action = StepOut; | |
| 1058 step_count = count; | |
| 1059 } | |
| 1060 } | 1002 } |
| 1061 | 1003 |
| 1062 // Clear all current stepping setup. | 1004 // Clear all current stepping setup. |
| 1063 ClearStepping(); | 1005 ClearStepping(); |
| 1064 | 1006 |
| 1065 // Set up for the remaining steps. | 1007 // Set up for the remaining steps. |
| 1066 PrepareStep(step_action, step_count); | 1008 PrepareStep(step_action, step_count); |
| 1067 } | 1009 } |
| 1068 | 1010 |
| 1069 if (thread_local_.frame_drop_mode_ == FRAMES_UNTOUCHED) { | 1011 if (thread_local_.frame_drop_mode_ == FRAMES_UNTOUCHED) { |
| (...skipping 2641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3711 { | 3653 { |
| 3712 Locker locker; | 3654 Locker locker; |
| 3713 Isolate::Current()->debugger()->CallMessageDispatchHandler(); | 3655 Isolate::Current()->debugger()->CallMessageDispatchHandler(); |
| 3714 } | 3656 } |
| 3715 } | 3657 } |
| 3716 } | 3658 } |
| 3717 | 3659 |
| 3718 #endif // ENABLE_DEBUGGER_SUPPORT | 3660 #endif // ENABLE_DEBUGGER_SUPPORT |
| 3719 | 3661 |
| 3720 } } // namespace v8::internal | 3662 } } // namespace v8::internal |
| OLD | NEW |