Index: runtime/vm/object.cc |
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc |
index b78cc697313a673a13185cc41ad7b0381ee57931..77793adfc3d3f8fee0423cb9317670f0d49406d9 100644 |
--- a/runtime/vm/object.cc |
+++ b/runtime/vm/object.cc |
@@ -30,6 +30,7 @@ |
#include "vm/intrinsifier.h" |
#include "vm/isolate_reload.h" |
#include "vm/kernel_to_il.h" |
+#include "vm/native_symbol.h" |
#include "vm/object_store.h" |
#include "vm/parser.h" |
#include "vm/precompiler.h" |
@@ -9160,7 +9161,7 @@ intptr_t Script::GetTokenLineUsingLineStarts( |
} |
ASSERT(line_starts_array.Length() > 0); |
- intptr_t offset = target_token_pos.value(); |
+ intptr_t offset = target_token_pos.Pos(); |
intptr_t min = 0; |
intptr_t max = line_starts_array.Length() - 1; |
@@ -22551,10 +22552,23 @@ const char* StackTrace::ToCStringInternal(const StackTrace& stack_trace_in, |
StackTrace& stack_trace = StackTrace::Handle(zone, stack_trace_in.raw()); |
Function& function = Function::Handle(zone); |
Code& code = Code::Handle(zone); |
+ |
GrowableArray<const Function*> inlined_functions; |
GrowableArray<TokenPosition> inlined_token_positions; |
ZoneTextBuffer buffer(zone, 1024); |
+#if defined(DART_PRECOMPILER) || defined(DART_PRECOMPILED_RUNTIME) |
+ if (FLAG_dwarf_stack_traces) { |
+ // This prologue imitates Android's debuggerd to make it possible to paste |
+ // the stack trace into ndk-stack. |
+ buffer.Printf( |
+ "*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***\n"); |
+ OSThread* thread = OSThread::Current(); |
+ buffer.Printf("pid: %" Pd ", tid: %" Pd ", name %s\n", OS::ProcessId(), |
+ OSThread::ThreadIdToIntPtr(thread->id()), thread->name()); |
+ } |
+#endif |
+ |
// Iterate through the stack frames and create C string description |
// for each frame. |
do { |
@@ -22581,6 +22595,30 @@ const char* StackTrace::ToCStringInternal(const StackTrace& stack_trace_in, |
} else { |
ASSERT(code.IsFunctionCode()); |
intptr_t pc_offset = Smi::Value(stack_trace.PcOffsetAtFrame(i)); |
+ |
+#if defined(DART_PRECOMPILER) || defined(DART_PRECOMPILED_RUNTIME) |
+ if (FLAG_dwarf_stack_traces) { |
+ // This output is formatted like Android's debuggerd. Note debuggerd |
+ // prints call addresses instead of return addresses. |
+ uword return_addr = code.PayloadStart() + pc_offset; |
+ uword call_addr = return_addr - 1; |
Cutch
2017/03/15 14:54:13
This function is getting too complex. Refactor thi
rmacnak
2017/03/16 17:50:11
Split into Dart and Android print functions. Also
|
+ uword dso_base; |
+ char* dso_name; |
+ if (NativeSymbolResolver::LookupSharedObject(call_addr, &dso_base, |
+ &dso_name)) { |
+ uword dso_offset = call_addr - dso_base; |
+ buffer.Printf(" #%02" Pd " pc %" Pp " %s\n", *frame_index, |
+ dso_offset, dso_name); |
+ NativeSymbolResolver::FreeSymbolName(dso_name); |
+ } else { |
+ buffer.Printf(" #%02" Pd " pc %" Pp " <unknown>\n", |
+ *frame_index, call_addr); |
+ } |
+ (*frame_index)++; |
+ continue; |
+ } |
+#endif |
+ |
if (code.is_optimized() && stack_trace.expand_inlined()) { |
code.GetInlinedFunctionsAtReturnAddress(pc_offset, &inlined_functions, |
&inlined_token_positions); |