is_stmt and column numbers

It appears to me that from this:

That LLVM basically emits DWARF expressions where is_stmt is true only
"once per line". Is that still true? Is there an option to emit more
than one per line?

Thanks all.

-Roger Pack-


is_stmt is based fairly strictly on "the line number changed" (while
ignoring line 0). This works reasonably well at -O0 and gets clunkier as
optimization level increases. I've never been happy about it, but have
never found the time to come up with something better. The optimizer has
been getting better at not introducing gratuitous line-number changes, if
that helps.

There is no option to make it work differently. We can (usually do) emit
column numbers, which gets you more line-table entries, although they are
not flagged with is_stmt. I know at least one debugger that gave up on
is_stmt "because it's not reliable."

OK that makes sense. I've noticed that there'll be some DWARF
statements that set the line number to "0".

  [0x0000048c] Special opcode 72: advance Address by 5 to 0x1000015b0
and Line by -3 to 0
  [0x0000048d] Special opcode 78: advance Address by 5 to 0x1000015b5
and Line by 3 to 3

I assume this means some kind of internal processing? Anyway the
current work around crystal uses is to basically only accept DWARF
statements that have a positive line number [not sure if that's right
or not...], or if they're is_stmt then it accepts them :slight_smile:

The DWARF spec says line 0 means there is no relevant source location.
Sometimes it means an optimization combined operations from multiple
source locations, and it would be misleading to pick one arbitrarily;
sometimes it means the instruction came from an "artificial" bit of
source, for example a default constructor in C++, that really has no
worthwhile source location.

I can't imagine a correct producer ever setting is_stmt for line 0.