Chromium Code Reviews| Index: runtime/vm/object.cc |
| diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc |
| index aea7d1f6e31e48b7f8a15d8863559c72508260a0..c238e3fc49427e37135887152d469a75042dd906 100644 |
| --- a/runtime/vm/object.cc |
| +++ b/runtime/vm/object.cc |
| @@ -11019,6 +11019,87 @@ void PcDescriptors::Verify(const Function& function) const { |
| } |
| +TokenPosition CodeSourceMap::TokenPositionForPCOffset( |
| + uword pc_offset) const { |
| + Iterator iterator(*this); |
| + |
| + TokenPosition result = TokenPosition::kNoSource; |
| + |
| + while (iterator.MoveNext()) { |
| + if (iterator.PcOffset() > pc_offset) { |
| + break; |
| + } |
| + result = iterator.TokenPos(); |
| + } |
| + |
| + return result; |
| +} |
| + |
| + |
| +RawFunction* CodeSourceMap::FunctionForPCOffset(const Code& code, |
| + const Function& function, |
| + uword pc_offset) const { |
| + GrowableArray<Function*> inlined_functions; |
| + code.GetInlinedFunctionsAt(pc_offset, &inlined_functions); |
| + if (inlined_functions.length() > 0) { |
| + Function* inlined_function = inlined_functions[0]; |
| + return inlined_function->raw(); |
| + } else { |
| + return function.raw(); |
| + } |
| +} |
| + |
| + |
| +RawScript* CodeSourceMap::ScriptForPCOffset(const Code& code, |
| + const Function& function, |
| + uword pc_offset) const { |
| + const Function& func = |
| + Function::Handle(FunctionForPCOffset(code, function, pc_offset)); |
| + return func.script(); |
| +} |
| + |
| + |
| +void CodeSourceMap::Dump(const CodeSourceMap& code_source_map, |
| + const Code& code, |
| + const Function& function) { |
| + const String& code_name = String::Handle(code.PrettyName()); |
| + THR_Print("Dumping Code Source Map for %s\n", code_name.ToCString()); |
| + if (code_source_map.Length() == 0) { |
| + THR_Print("<empty>\n"); |
| + return; |
| + } |
| + |
| + const int addr_width = kBitsPerWord / 4; |
| + |
| + Iterator iterator(code_source_map); |
| + Function& current_function = Function::Handle(); |
| + Script& current_script = Script::Handle(); |
| + TokenPosition tp; |
| + while (iterator.MoveNext()) { |
| + const uword pc_offset = iterator.PcOffset(); |
| + tp = code_source_map.TokenPositionForPCOffset(pc_offset); |
| + current_function ^= |
| + code_source_map.FunctionForPCOffset(code, function, pc_offset); |
| + current_script ^= |
| + code_source_map.ScriptForPCOffset(code, function, pc_offset); |
| + if (current_function.IsNull() || current_script.IsNull()) { |
| + THR_Print("%#-*" Px "\t%s\t%s\n", addr_width, |
| + pc_offset, |
|
rmacnak
2016/02/25 23:04:40
indent
Cutch
2016/02/26 15:59:22
Done.
|
| + tp.ToCString(), |
| + code_name.ToCString()); |
| + continue; |
| + } |
| + const String& uri = String::Handle(current_script.url()); |
| + ASSERT(!uri.IsNull()); |
| + THR_Print("%#-*" Px "\t%s\t%s\t%s\n", addr_width, |
| + pc_offset, |
| + tp.ToCString(), |
| + current_function.ToQualifiedCString(), |
| + uri.ToCString()); |
| + } |
| +} |
| + |
| + |
| intptr_t CodeSourceMap::Length() const { |
| return raw_ptr()->length_; |
| } |