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 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 IsConstructor()); | 799 IsConstructor()); |
800 functions->Add(summary); | 800 functions->Add(summary); |
801 } | 801 } |
802 | 802 |
803 | 803 |
804 void JavaScriptFrame::PrintTop(Isolate* isolate, | 804 void JavaScriptFrame::PrintTop(Isolate* isolate, |
805 FILE* file, | 805 FILE* file, |
806 bool print_args, | 806 bool print_args, |
807 bool print_line_number) { | 807 bool print_line_number) { |
808 // constructor calls | 808 // constructor calls |
| 809 HandleScope scope(isolate); |
809 DisallowHeapAllocation no_allocation; | 810 DisallowHeapAllocation no_allocation; |
810 JavaScriptFrameIterator it(isolate); | 811 JavaScriptFrameIterator it(isolate); |
811 while (!it.done()) { | 812 while (!it.done()) { |
812 if (it.frame()->is_java_script()) { | 813 if (it.frame()->is_java_script()) { |
813 JavaScriptFrame* frame = it.frame(); | 814 JavaScriptFrame* frame = it.frame(); |
814 if (frame->IsConstructor()) PrintF(file, "new "); | 815 if (frame->IsConstructor()) PrintF(file, "new "); |
815 // function name | 816 // function name |
816 JSFunction* fun = frame->function(); | 817 JSFunction* fun = frame->function(); |
817 fun->PrintName(); | 818 fun->PrintName(); |
818 Code* js_code = frame->unchecked_code(); | 819 Code* js_code = frame->unchecked_code(); |
819 Address pc = frame->pc(); | 820 Address pc = frame->pc(); |
820 int code_offset = | 821 int code_offset = |
821 static_cast<int>(pc - js_code->instruction_start()); | 822 static_cast<int>(pc - js_code->instruction_start()); |
822 PrintF("+%d", code_offset); | 823 PrintF("+%d", code_offset); |
823 SharedFunctionInfo* shared = fun->shared(); | 824 SharedFunctionInfo* shared = fun->shared(); |
824 if (print_line_number) { | 825 if (print_line_number) { |
825 Code* code = Code::cast(isolate->FindCodeObject(pc)); | 826 Code* code = Code::cast(isolate->FindCodeObject(pc)); |
826 int source_pos = code->SourcePosition(pc); | 827 int source_pos = code->SourcePosition(pc); |
827 Object* maybe_script = shared->script(); | 828 Object* maybe_script = shared->script(); |
828 if (maybe_script->IsScript()) { | 829 if (maybe_script->IsScript()) { |
829 Script* script = Script::cast(maybe_script); | 830 Handle<Script> script(Script::cast(maybe_script)); |
830 int line = script->GetLineNumber(source_pos) + 1; | 831 int line = GetScriptLineNumberSafe(script, source_pos) + 1; |
831 Object* script_name_raw = script->name(); | 832 Object* script_name_raw = script->name(); |
832 if (script_name_raw->IsString()) { | 833 if (script_name_raw->IsString()) { |
833 String* script_name = String::cast(script->name()); | 834 String* script_name = String::cast(script->name()); |
834 SmartArrayPointer<char> c_script_name = | 835 SmartArrayPointer<char> c_script_name = |
835 script_name->ToCString(DISALLOW_NULLS, | 836 script_name->ToCString(DISALLOW_NULLS, |
836 ROBUST_STRING_TRAVERSAL); | 837 ROBUST_STRING_TRAVERSAL); |
837 PrintF(file, " at %s:%d", c_script_name.get(), line); | 838 PrintF(file, " at %s:%d", c_script_name.get(), line); |
838 } else { | 839 } else { |
839 PrintF(file, " at <unknown>:%d", line); | 840 PrintF(file, " at <unknown>:%d", line); |
840 } | 841 } |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1163 void StackFrame::PrintIndex(StringStream* accumulator, | 1164 void StackFrame::PrintIndex(StringStream* accumulator, |
1164 PrintMode mode, | 1165 PrintMode mode, |
1165 int index) { | 1166 int index) { |
1166 accumulator->Add((mode == OVERVIEW) ? "%5d: " : "[%d]: ", index); | 1167 accumulator->Add((mode == OVERVIEW) ? "%5d: " : "[%d]: ", index); |
1167 } | 1168 } |
1168 | 1169 |
1169 | 1170 |
1170 void JavaScriptFrame::Print(StringStream* accumulator, | 1171 void JavaScriptFrame::Print(StringStream* accumulator, |
1171 PrintMode mode, | 1172 PrintMode mode, |
1172 int index) const { | 1173 int index) const { |
1173 DisallowHeapAllocation no_gc; | 1174 HandleScope scope(isolate()); |
1174 Object* receiver = this->receiver(); | 1175 Object* receiver = this->receiver(); |
1175 JSFunction* function = this->function(); | 1176 JSFunction* function = this->function(); |
1176 | 1177 |
1177 accumulator->PrintSecurityTokenIfChanged(function); | 1178 accumulator->PrintSecurityTokenIfChanged(function); |
1178 PrintIndex(accumulator, mode, index); | 1179 PrintIndex(accumulator, mode, index); |
1179 Code* code = NULL; | 1180 Code* code = NULL; |
1180 if (IsConstructor()) accumulator->Add("new "); | 1181 if (IsConstructor()) accumulator->Add("new "); |
1181 accumulator->PrintFunction(function, receiver, &code); | 1182 accumulator->PrintFunction(function, receiver, &code); |
1182 | 1183 |
1183 // Get scope information for nicer output, if possible. If code is NULL, or | 1184 // Get scope information for nicer output, if possible. If code is NULL, or |
1184 // doesn't contain scope info, scope_info will return 0 for the number of | 1185 // doesn't contain scope info, scope_info will return 0 for the number of |
1185 // parameters, stack local variables, context local variables, stack slots, | 1186 // parameters, stack local variables, context local variables, stack slots, |
1186 // or context slots. | 1187 // or context slots. |
1187 SharedFunctionInfo* shared = function->shared(); | 1188 Handle<ScopeInfo> scope_info(ScopeInfo::Empty(isolate())); |
1188 ScopeInfo* scope_info = shared->scope_info(); | 1189 |
| 1190 Handle<SharedFunctionInfo> shared(function->shared()); |
| 1191 scope_info = Handle<ScopeInfo>(shared->scope_info()); |
1189 Object* script_obj = shared->script(); | 1192 Object* script_obj = shared->script(); |
1190 if (script_obj->IsScript()) { | 1193 if (script_obj->IsScript()) { |
1191 Script* script = Script::cast(script_obj); | 1194 Handle<Script> script(Script::cast(script_obj)); |
1192 accumulator->Add(" ["); | 1195 accumulator->Add(" ["); |
1193 accumulator->PrintName(script->name()); | 1196 accumulator->PrintName(script->name()); |
1194 | 1197 |
1195 Address pc = this->pc(); | 1198 Address pc = this->pc(); |
1196 if (code != NULL && code->kind() == Code::FUNCTION && | 1199 if (code != NULL && code->kind() == Code::FUNCTION && |
1197 pc >= code->instruction_start() && pc < code->instruction_end()) { | 1200 pc >= code->instruction_start() && pc < code->instruction_end()) { |
1198 int source_pos = code->SourcePosition(pc); | 1201 int source_pos = code->SourcePosition(pc); |
1199 int line = script->GetLineNumber(source_pos) + 1; | 1202 int line = GetScriptLineNumberSafe(script, source_pos) + 1; |
1200 accumulator->Add(":%d", line); | 1203 accumulator->Add(":%d", line); |
1201 } else { | 1204 } else { |
1202 int function_start_pos = shared->start_position(); | 1205 int function_start_pos = shared->start_position(); |
1203 int line = script->GetLineNumber(function_start_pos) + 1; | 1206 int line = GetScriptLineNumberSafe(script, function_start_pos) + 1; |
1204 accumulator->Add(":~%d", line); | 1207 accumulator->Add(":~%d", line); |
1205 } | 1208 } |
1206 | 1209 |
1207 accumulator->Add("] "); | 1210 accumulator->Add("] "); |
1208 } | 1211 } |
1209 | 1212 |
1210 accumulator->Add("(this=%o", receiver); | 1213 accumulator->Add("(this=%o", receiver); |
1211 | 1214 |
1212 // Print the parameters. | 1215 // Print the parameters. |
1213 int parameters_count = ComputeParametersCount(); | 1216 int parameters_count = ComputeParametersCount(); |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1641 ZoneList<StackFrame*> list(10, zone); | 1644 ZoneList<StackFrame*> list(10, zone); |
1642 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { | 1645 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { |
1643 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); | 1646 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); |
1644 list.Add(frame, zone); | 1647 list.Add(frame, zone); |
1645 } | 1648 } |
1646 return list.ToVector(); | 1649 return list.ToVector(); |
1647 } | 1650 } |
1648 | 1651 |
1649 | 1652 |
1650 } } // namespace v8::internal | 1653 } } // namespace v8::internal |
OLD | NEW |