[lldb-dev] Question about building line tables

Greg Clayton via lldb-dev lldb-dev at lists.llvm.org
Mon Mar 7 15:13:26 PST 2016

> On Mar 7, 2016, at 3:07 PM, Zachary Turner via lldb-dev <lldb-dev at lists.llvm.org> wrote:
> This discussion originally started on a code review thread, but I figured I would continue it here since the patch has landed and I want to do more work as a followup.
> So LLDB's LineTable data structures have the notion of a "terminal entry".  As I understand it, LineTables are structured as a sequence of "entries".  An entry consists of:
> Start Line
> End Line
> Start Address
> Byte Length
> Is Terminal Entry

Not quite correct. There is no end line and there is no byte length. To efficiently store line entries that can be efficiently searched, we need to not have a length and not have an end line.

> and this represents some piece of source code.  If you were to examine all line entries in the debug info, you would find that not all address ranges are covered.  For example, line 10 might correspond to address 0x12345 - 0x12347, and line 11 might correspond to address 0x12360.  So address 0x12348 - 0x12359 do not map to anything.  Probably they are not even code, but just space between functions, or other random data in the .text section of a binary that isn't code.
> The problem is, building a line table requires the person parsing the debug info to specify where the terminal entries are.  Why?  Isn't it trivial to calculate this automatically?  Say you insert a bunch of line entries, now they're all sorted by address into some array of LineEntry structures.  It seems to me like n is a terminal entry if 
> (entries[n].address + entries[n].length) < entries[n+1].address
> is true.  Why do we need to store a separate flag for it?

Because there is no size in each LineEntry. We rely on the next line entry always terminating the previous one. So one marked with "i am a terminal entry" is required to finish off the previous one.

> Is there ever a case where the above condition is true but it is not the end of a sequence?  Or where the above condition is false but it is the end of a sequence?

Not sure these questions apply after what I said above.

More information about the lldb-dev mailing list