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