@@ -508,8 +508,20 @@ void BreakpointLocation::GetDescription(Stream *s,
508508 s->PutCString (" re-exported target = " );
509509 else
510510 s->PutCString (" where = " );
511+
512+ // If there's a preferred line entry for printing, use that.
513+ bool show_function_info = true ;
514+ if (auto preferred = GetPreferredLineEntry ()) {
515+ sc.line_entry = *preferred;
516+ // FIXME: We're going to get the function name wrong when the preferred
517+ // line entry is not the lowest one. For now, just leave the function
518+ // out in this case, but we really should also figure out how to easily
519+ // fake the function name here.
520+ show_function_info = false ;
521+ }
511522 sc.DumpStopContext (s, m_owner.GetTarget ().GetProcessSP ().get (), m_address,
512- false , true , false , true , true , true );
523+ false , true , false , show_function_info,
524+ show_function_info, show_function_info);
513525 } else {
514526 if (sc.module_sp ) {
515527 s->EOL ();
@@ -537,7 +549,10 @@ void BreakpointLocation::GetDescription(Stream *s,
537549 if (sc.line_entry .line > 0 ) {
538550 s->EOL ();
539551 s->Indent (" location = " );
540- sc.line_entry .DumpStopContext (s, true );
552+ if (auto preferred = GetPreferredLineEntry ())
553+ preferred->DumpStopContext (s, true );
554+ else
555+ sc.line_entry .DumpStopContext (s, true );
541556 }
542557
543558 } else {
@@ -656,6 +671,50 @@ void BreakpointLocation::SendBreakpointLocationChangedEvent(
656671 }
657672}
658673
674+ std::optional<uint32_t > BreakpointLocation::GetSuggestedStackFrameIndex () {
675+ auto preferred_opt = GetPreferredLineEntry ();
676+ if (!preferred_opt)
677+ return {};
678+ LineEntry preferred = *preferred_opt;
679+ SymbolContext sc;
680+ if (!m_address.CalculateSymbolContext (&sc))
681+ return {};
682+ // Don't return anything special if frame 0 is the preferred line entry.
683+ // We not really telling the stack frame list to do anything special in that
684+ // case.
685+ if (!LineEntry::Compare (sc.line_entry , preferred))
686+ return {};
687+
688+ if (!sc.block )
689+ return {};
690+
691+ // Blocks have their line info in Declaration form, so make one here:
692+ Declaration preferred_decl (preferred.GetFile (), preferred.line ,
693+ preferred.column );
694+
695+ uint32_t depth = 0 ;
696+ Block *inlined_block = sc.block ->GetContainingInlinedBlock ();
697+ while (inlined_block) {
698+ // If we've moved to a block that this isn't the start of, that's not
699+ // our inlining info or call site, so we can stop here.
700+ Address start_address;
701+ if (!inlined_block->GetStartAddress (start_address) ||
702+ start_address != m_address)
703+ return {};
704+
705+ const InlineFunctionInfo *info = inlined_block->GetInlinedFunctionInfo ();
706+ if (info) {
707+ if (preferred_decl == info->GetDeclaration ())
708+ return depth;
709+ if (preferred_decl == info->GetCallSite ())
710+ return depth + 1 ;
711+ }
712+ inlined_block = inlined_block->GetInlinedParent ();
713+ depth++;
714+ }
715+ return {};
716+ }
717+
659718void BreakpointLocation::SwapLocation (BreakpointLocationSP swap_from) {
660719 m_address = swap_from->m_address ;
661720 m_should_resolve_indirect_functions =
0 commit comments