@@ -379,10 +379,10 @@ bool ThreadPlanStepRange::SetNextBranchBreakpoint() {
379
379
!m_next_branch_bp_sp->HasResolvedLocations ())
380
380
m_could_not_resolve_hw_bp = true ;
381
381
382
+ BreakpointLocationSP bp_loc =
383
+ m_next_branch_bp_sp->GetLocationAtIndex (0 );
382
384
if (log ) {
383
385
lldb::break_id_t bp_site_id = LLDB_INVALID_BREAK_ID;
384
- BreakpointLocationSP bp_loc =
385
- m_next_branch_bp_sp->GetLocationAtIndex (0 );
386
386
if (bp_loc) {
387
387
BreakpointSiteSP bp_site = bp_loc->GetBreakpointSite ();
388
388
if (bp_site) {
@@ -395,7 +395,51 @@ bool ThreadPlanStepRange::SetNextBranchBreakpoint() {
395
395
m_next_branch_bp_sp->GetID (), bp_site_id,
396
396
run_to_address.GetLoadAddress (&m_process.GetTarget ()));
397
397
}
398
-
398
+ // The "next branch breakpoint might land on a virtual inlined call
399
+ // stack. If that's true, we should always stop at the top of the
400
+ // inlined call stack. Only virtual steps should walk deeper into the
401
+ // inlined call stack.
402
+ Block *block = run_to_address.CalculateSymbolContextBlock ();
403
+ if (bp_loc && block) {
404
+ LineEntry top_most_line_entry;
405
+ lldb::addr_t run_to_addr = run_to_address.GetFileAddress ();
406
+ for (Block *inlined_parent = block->GetContainingInlinedBlock ();
407
+ inlined_parent;
408
+ inlined_parent = inlined_parent->GetInlinedParent ()) {
409
+ AddressRange range;
410
+ if (!inlined_parent->GetRangeContainingAddress (run_to_address,
411
+ range))
412
+ break ;
413
+ Address range_start_address = range.GetBaseAddress ();
414
+ // Only compare addresses here, we may have different symbol
415
+ // contexts (for virtual inlined stacks), but we just want to know
416
+ // that they are all at the same address.
417
+ if (range_start_address.GetFileAddress () != run_to_addr)
418
+ break ;
419
+ const InlineFunctionInfo *inline_info =
420
+ inlined_parent->GetInlinedFunctionInfo ();
421
+ if (!inline_info)
422
+ break ;
423
+ const Declaration &call_site = inline_info->GetCallSite ();
424
+ top_most_line_entry.line = call_site.GetLine ();
425
+ top_most_line_entry.column = call_site.GetColumn ();
426
+ FileSpec call_site_file_spec = call_site.GetFile ();
427
+ top_most_line_entry.original_file_sp .reset (
428
+ new SupportFile (call_site_file_spec));
429
+ top_most_line_entry.range = range;
430
+ top_most_line_entry.file_sp .reset ();
431
+ top_most_line_entry.ApplyFileMappings (
432
+ GetThread ().CalculateTarget ());
433
+ if (!top_most_line_entry.file_sp )
434
+ top_most_line_entry.file_sp =
435
+ top_most_line_entry.original_file_sp ;
436
+ }
437
+ if (top_most_line_entry.IsValid ()) {
438
+ LLDB_LOG (log , " Setting preferred line entry: {0}:{1}" ,
439
+ top_most_line_entry.GetFile (), top_most_line_entry.line );
440
+ bp_loc->SetPreferredLineEntry (top_most_line_entry);
441
+ }
442
+ }
399
443
m_next_branch_bp_sp->SetThreadID (m_tid);
400
444
m_next_branch_bp_sp->SetBreakpointKind (" next-branch-location" );
401
445
0 commit comments