[all-commits] [llvm/llvm-project] fadbc3: [lldb] Add LineTable::{upper, lower}_bound (#127519)

Pavel Labath via All-commits all-commits at lists.llvm.org
Wed Feb 19 03:59:17 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: fadbc33b01d6815bf05d802d1323322262b54d42
      https://github.com/llvm/llvm-project/commit/fadbc33b01d6815bf05d802d1323322262b54d42
  Author: Pavel Labath <pavel at labath.sk>
  Date:   2025-02-19 (Wed, 19 Feb 2025)

  Changed paths:
    M lldb/include/lldb/Symbol/LineTable.h
    M lldb/source/Symbol/LineTable.cpp
    M lldb/unittests/Symbol/CMakeLists.txt
    A lldb/unittests/Symbol/LineTableTest.cpp

  Log Message:
  -----------
  [lldb] Add LineTable::{upper,lower}_bound (#127519)

The motivation is #123622 and the fact that is hard to fine the last
line entry in a given range. `FindLineEntryByAddress(range_end-1)` is
the best we have, but it's not ideal because it has a magic -1 and that
it relies on there existing a line entry at that address (generally, it
should be there, but if for some case it isn't, we might end up ignoring
the entries that are there (or -- like my incorrect fix in #123622 did
-- iterating through the entire line table).

What we really want is to get the last entry that exists in the given
range. Or, equivalently (and more STL-like) the first entry after that
range. This is what these functions do. I've used the STL names since
they do pretty much exactly what the standard functions do (the main
head-scratcher comes from the fact that our entries represent ranges
rather than single values).

The functions can also be used to simplify the maze of `if` statements
in `FindLineEntryByAddress`, but I'm keeping that as a separate patch.
For now, I'm just adding some unit testing for that function to gain
more confidence that the patch does not change the function behavior.

---------

Co-authored-by: Jonas Devlieghere <jonas at devlieghere.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list