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/frames.h" | 5 #include "src/frames.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/ast/ast.h" | 9 #include "src/ast/ast.h" |
10 #include "src/ast/scopeinfo.h" | 10 #include "src/ast/scopeinfo.h" |
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
879 | 879 |
880 void JavaScriptFrame::PrintFunctionAndOffset(JSFunction* function, Code* code, | 880 void JavaScriptFrame::PrintFunctionAndOffset(JSFunction* function, Code* code, |
881 Address pc, FILE* file, | 881 Address pc, FILE* file, |
882 bool print_line_number) { | 882 bool print_line_number) { |
883 PrintF(file, "%s", function->IsOptimized() ? "*" : "~"); | 883 PrintF(file, "%s", function->IsOptimized() ? "*" : "~"); |
884 function->PrintName(file); | 884 function->PrintName(file); |
885 int code_offset = static_cast<int>(pc - code->instruction_start()); | 885 int code_offset = static_cast<int>(pc - code->instruction_start()); |
886 PrintF(file, "+%d", code_offset); | 886 PrintF(file, "+%d", code_offset); |
887 if (print_line_number) { | 887 if (print_line_number) { |
888 SharedFunctionInfo* shared = function->shared(); | 888 SharedFunctionInfo* shared = function->shared(); |
889 int source_pos = code->SourcePosition(code_offset); | 889 int source_pos = AbstractCode::cast(code)->SourcePosition(code_offset); |
890 Object* maybe_script = shared->script(); | 890 Object* maybe_script = shared->script(); |
891 if (maybe_script->IsScript()) { | 891 if (maybe_script->IsScript()) { |
892 Script* script = Script::cast(maybe_script); | 892 Script* script = Script::cast(maybe_script); |
893 int line = script->GetLineNumber(source_pos) + 1; | 893 int line = script->GetLineNumber(source_pos) + 1; |
894 Object* script_name_raw = script->name(); | 894 Object* script_name_raw = script->name(); |
895 if (script_name_raw->IsString()) { | 895 if (script_name_raw->IsString()) { |
896 String* script_name = String::cast(script->name()); | 896 String* script_name = String::cast(script->name()); |
897 base::SmartArrayPointer<char> c_script_name = | 897 base::SmartArrayPointer<char> c_script_name = |
898 script_name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 898 script_name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
899 PrintF(file, " at %s:%d", c_script_name.get(), line); | 899 PrintF(file, " at %s:%d", c_script_name.get(), line); |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1401 Object* script_obj = shared->script(); | 1401 Object* script_obj = shared->script(); |
1402 if (script_obj->IsScript()) { | 1402 if (script_obj->IsScript()) { |
1403 Script* script = Script::cast(script_obj); | 1403 Script* script = Script::cast(script_obj); |
1404 accumulator->Add(" ["); | 1404 accumulator->Add(" ["); |
1405 accumulator->PrintName(script->name()); | 1405 accumulator->PrintName(script->name()); |
1406 | 1406 |
1407 Address pc = this->pc(); | 1407 Address pc = this->pc(); |
1408 if (code != NULL && code->kind() == Code::FUNCTION && | 1408 if (code != NULL && code->kind() == Code::FUNCTION && |
1409 pc >= code->instruction_start() && pc < code->instruction_end()) { | 1409 pc >= code->instruction_start() && pc < code->instruction_end()) { |
1410 int offset = static_cast<int>(pc - code->instruction_start()); | 1410 int offset = static_cast<int>(pc - code->instruction_start()); |
1411 int source_pos = code->SourcePosition(offset); | 1411 int source_pos = AbstractCode::cast(code)->SourcePosition(offset); |
1412 int line = script->GetLineNumber(source_pos) + 1; | 1412 int line = script->GetLineNumber(source_pos) + 1; |
1413 accumulator->Add(":%d] [pc=%p]", line, pc); | 1413 accumulator->Add(":%d] [pc=%p]", line, pc); |
1414 } else if (is_interpreted()) { | 1414 } else if (is_interpreted()) { |
1415 const InterpretedFrame* iframe = | 1415 const InterpretedFrame* iframe = |
1416 reinterpret_cast<const InterpretedFrame*>(this); | 1416 reinterpret_cast<const InterpretedFrame*>(this); |
1417 BytecodeArray* bytecodes = iframe->GetBytecodeArray(); | 1417 BytecodeArray* bytecodes = iframe->GetBytecodeArray(); |
1418 int offset = iframe->GetBytecodeOffset(); | 1418 int offset = iframe->GetBytecodeOffset(); |
1419 int source_pos = bytecodes->SourcePosition(offset); | 1419 int source_pos = AbstractCode::cast(bytecodes)->SourcePosition(offset); |
1420 int line = script->GetLineNumber(source_pos) + 1; | 1420 int line = script->GetLineNumber(source_pos) + 1; |
1421 accumulator->Add(":%d] [bytecode=%p offset=%d]", line, bytecodes, offset); | 1421 accumulator->Add(":%d] [bytecode=%p offset=%d]", line, bytecodes, offset); |
1422 } else { | 1422 } else { |
1423 int function_start_pos = shared->start_position(); | 1423 int function_start_pos = shared->start_position(); |
1424 int line = script->GetLineNumber(function_start_pos) + 1; | 1424 int line = script->GetLineNumber(function_start_pos) + 1; |
1425 accumulator->Add(":~%d] [pc=%p]", line, pc); | 1425 accumulator->Add(":~%d] [pc=%p]", line, pc); |
1426 } | 1426 } |
1427 } | 1427 } |
1428 | 1428 |
1429 accumulator->Add("(this=%o", receiver); | 1429 accumulator->Add("(this=%o", receiver); |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1791 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { | 1791 for (StackFrameIterator it(isolate); !it.done(); it.Advance()) { |
1792 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); | 1792 StackFrame* frame = AllocateFrameCopy(it.frame(), zone); |
1793 list.Add(frame, zone); | 1793 list.Add(frame, zone); |
1794 } | 1794 } |
1795 return list.ToVector(); | 1795 return list.ToVector(); |
1796 } | 1796 } |
1797 | 1797 |
1798 | 1798 |
1799 } // namespace internal | 1799 } // namespace internal |
1800 } // namespace v8 | 1800 } // namespace v8 |
OLD | NEW |