[Lldb-commits] [lldb] [lldb] Fixing edge cases in "command source" (PR #126526)

via lldb-commits lldb-commits at lists.llvm.org
Mon Feb 10 10:15:27 PST 2025


================
@@ -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) {
----------------
jimingham wrote:

Is the assumption here that the first source line of a function can never legitimately be a compiler-generated line that we assign 0?  Is that guaranteed even in optimized code?

https://github.com/llvm/llvm-project/pull/126526


More information about the lldb-commits mailing list