[Lldb-commits] [lldb] Add the ability to break on call-site locations, improve inline stepping (PR #112939)
Adrian Prantl via lldb-commits
lldb-commits at lists.llvm.org
Fri Oct 18 11:03:32 PDT 2024
================
@@ -312,6 +315,112 @@ void CompileUnit::ResolveSymbolContext(
0, file_indexes, src_location_spec, &line_entry);
}
+ // If we didn't manage to find a breakpoint that matched the line number
+ // requested, that might be because it is only an inline call site, and
+ // doesn't have a line entry in the line table. Scan for that here.
+ //
+ // We are making the assumption that if there was an inlined function it will
+ // contribute at least 1 non-call-site entry to the line table. That's handy
+ // because we don't move line breakpoints over function boundaries, so if we
+ // found a hit, and there were also a call site entry, it would have to be in
+ // the function containing the PC of the line table match. That way we can
+ // limit the call site search to that function.
+ // We will miss functions that ONLY exist as a call site entry.
+
+ if (line_entry.IsValid() &&
+ (line_entry.line != line || line_entry.column != column_num) &&
+ resolve_scope & eSymbolContextLineEntry && check_inlines) {
+ // We don't move lines over function boundaries, so the address in the
+ // line entry will be the in function that contained the line that might
+ // be a CallSite, and we can just iterate over that function to find any
+ // inline records, and dig up their call sites.
+ Address start_addr = line_entry.range.GetBaseAddress();
+ Function *function = start_addr.CalculateSymbolContextFunction();
+
+ Declaration sought_decl(file_spec, line, column_num);
+ // We use this recursive function to descend the block structure looking
+ // for a block that has this Declaration as in it's CallSite info.
+ // This function recursively scans the sibling blocks of the incoming
+ // block parameter.
+ std::function<void(Block &)> examine_block =
+ [&sought_decl, &sc_list, &src_location_spec, resolve_scope,
+ &examine_block](Block &block) -> void {
+ // Iterate over the sibling child blocks of the incoming block.
+ Block *sibling_block = block.GetFirstChild();
+ while (sibling_block) {
+ // We only have to descend through the regular blocks, looking for
+ // immediate inlines, since those are the only ones that will have this
+ // callsite.
+ const InlineFunctionInfo *inline_info =
+ sibling_block->GetInlinedFunctionInfo();
+ if (inline_info) {
----------------
adrian-prantl wrote:
```suggestion
if (!inline_info)
continue;
```
https://github.com/llvm/llvm-project/pull/112939
More information about the lldb-commits
mailing list