================ @@ -320,25 +320,37 @@ void Function::GetStartLineSourceInfo(SupportFileSP &source_file_sp, } } -void Function::GetEndLineSourceInfo(FileSpec &source_file, uint32_t &line_no) { - line_no = 0; - source_file.Clear(); - - // The -1 is kind of cheesy, but I want to get the last line entry for the - // given function, not the first entry of the next. - Address scratch_addr(GetAddressRange().GetBaseAddress()); - scratch_addr.SetOffset(scratch_addr.GetOffset() + - GetAddressRange().GetByteSize() - 1); - +llvm::Expected<std::pair<SupportFileSP, Function::SourceRange>> +Function::GetSourceInfo() { + SupportFileSP source_file_sp; + uint32_t start_line; + GetStartLineSourceInfo(source_file_sp, start_line); LineTable *line_table = m_comp_unit->GetLineTable(); - if (line_table == nullptr) - return; + if (start_line == 0 || !line_table) { ---------------- labath wrote:
That is (and was) the assumption, but that definitely isn't guaranteed. The reason this works most of the time is because the `GetStartLineSourceInfo` will preferentially pick the line number out of the debug info section (DW_AT_decl_file), so the line table will only be consulted if that is missing (which probably only happens in this test case). That is one of the corner cases I did not want to go into in this patch, though I can if you think I should. https://github.com/llvm/llvm-project/pull/126526 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits