@@ -578,7 +578,7 @@ intptr_t ActivationFrame::DeoptId() {
578578
579579intptr_t ActivationFrame::LineNumber () {
580580 // Compute line number lazily since it causes scanning of the script.
581- const TokenPosition& token_pos = TokenPos ();
581+ const TokenPosition& token_pos = TokenPos (). ToRealIfSynthetic () ;
582582 if ((line_number_ < 0 ) && token_pos.IsReal ()) {
583583 const Script& script = Script::Handle (SourceScript ());
584584 script.GetTokenLocation (token_pos, &line_number_, &column_number_);
@@ -588,7 +588,7 @@ intptr_t ActivationFrame::LineNumber() {
588588
589589intptr_t ActivationFrame::ColumnNumber () {
590590 // Compute column number lazily since it causes scanning of the script.
591- const TokenPosition& token_pos = TokenPos ();
591+ const TokenPosition& token_pos = TokenPos (). ToRealIfSynthetic () ;
592592 if ((column_number_ < 0 ) && token_pos.IsReal ()) {
593593 const Script& script = Script::Handle (SourceScript ());
594594 script.GetTokenLocation (token_pos, &line_number_, &column_number_);
@@ -2063,36 +2063,42 @@ DebuggerStackTrace* DebuggerStackTrace::From(const class StackTrace& ex_trace) {
20632063 // pre-allocated trace (such as a stack overflow) or (b) because a stack has
20642064 // fewer frames that the pre-allocated trace (such as memory exhaustion with
20652065 // a shallow stack).
2066- if (!code_object.IsNull ()) {
2067- code ^= code_object.ptr ();
2066+ function = Function::null ();
2067+ uword start = 0 ;
2068+ bool is_optimized_code = false ;
2069+ if (code_object.IsCode ()) {
2070+ const auto & code = Code::Cast (code_object);
20682071 ASSERT (code.IsFunctionCode ());
20692072 function = code.function ();
2070- if (function.is_visible ()) {
2073+ start = code.PayloadStart ();
2074+ is_optimized_code = code.is_optimized ();
2075+ } else if (code_object.IsBytecode ()) {
2076+ const auto & bytecode = Bytecode::Cast (code_object);
2077+ function = bytecode.function ();
2078+ start = bytecode.PayloadStart ();
2079+ }
2080+ if (function.IsNull () || !function.is_visible ()) continue ;
2081+ const uword pc = start + ex_trace.PcOffsetAtFrame (i);
2082+ if (is_optimized_code && ex_trace.expand_inlined ()) {
2083+ // Traverse inlined frames.
2084+ code ^= code_object.ptr ();
2085+ for (InlinedFunctionsIterator it (code, pc); !it.Done (); it.Advance ()) {
2086+ function = it.function ();
2087+ code = it.code ();
20712088 ASSERT (function.ptr () == code.function ());
2072- uword pc = code.PayloadStart () + ex_trace.PcOffsetAtFrame (i);
2073- if (code.is_optimized () && ex_trace.expand_inlined ()) {
2074- // Traverse inlined frames.
2075- for (InlinedFunctionsIterator it (code, pc); !it.Done ();
2076- it.Advance ()) {
2077- function = it.function ();
2078- code = it.code ();
2079- ASSERT (function.ptr () == code.function ());
2080- uword pc = it.pc ();
2081- ASSERT (pc != 0 );
2082- ASSERT (code.PayloadStart () <= pc);
2083- ASSERT (pc < (code.PayloadStart () + code.Size ()));
2084-
2085- ActivationFrame* activation = new ActivationFrame (
2086- pc, fp, sp, function, code, deopt_frame, deopt_frame_offset);
2087- stack_trace->AddActivation (activation);
2088- }
2089- } else {
2090- ActivationFrame* activation = new ActivationFrame (
2091- pc, fp, sp, function, code, deopt_frame, deopt_frame_offset);
2092- stack_trace->AddActivation (activation);
2093- }
2089+ uword pc = it.pc ();
2090+ ASSERT (pc != 0 );
2091+ ASSERT (code.PayloadStart () <= pc);
2092+ ASSERT (pc < (code.PayloadStart () + code.Size ()));
2093+
2094+ auto * const activation = new ActivationFrame (
2095+ pc, fp, sp, function, code, deopt_frame, deopt_frame_offset);
2096+ stack_trace->AddActivation (activation);
20942097 }
20952098 }
2099+ auto * const activation = new ActivationFrame (
2100+ pc, fp, sp, function, code_object, deopt_frame, deopt_frame_offset);
2101+ stack_trace->AddActivation (activation);
20962102 }
20972103 return stack_trace;
20982104}
0 commit comments