[PATCH] D135166: [DebugInfo] getMergedLocation: Maintain the line number if they match

Orlando Cazalet-Hyams via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 10 05:19:21 PDT 2022


Orlando added a subscriber: JDevlieghere.
Orlando added a comment.

In D135166#3846516 <https://reviews.llvm.org/D135166#3846516>, @jmmartinez wrote:

> In D135166#3846325 <https://reviews.llvm.org/D135166#3846325>, @Orlando wrote:
>
>> "line 0" has a special meaning - that the instruction can't be attributed a single line number (e.g. because the instruction represents some merged instruction). I don't think that is actually mentioned anywhere in the DWARF spec but is more of a convention between DWARF emitters and consumers. Does column 0 convey the same meaning I wonder? I guess if your debugger uses column info and points at the start of the line (column 0) then that is an intuitive indication that column number isn't known, even if it's not explicit.
>
> As far as I understand it's in the DWARF standard (in section 6.2.2 https://dwarfstd.org/doc/DWARF5.pdf ):
>
> - **line**: An unsigned integer indicating a source line number. Lines are numbered beginning at 1. The compiler may emit the value 0 in cases where an instruction cannot be attributed to any source line.
> - **column**: An unsigned integer indicating a column number within a source line. Columns are numbered beginning at 1. The value 0 is reserved to indicate that a statement begins at the “left edge” of the line.
>
> The behaviour for the column is slightly different for declarations (in section 2.14): The value of the `DW_AT_decl_column` attribute represents the source column number at which the first character of the identifier of the declared object appears. The value 0 indicates that no column has been specified.

Oh, my mistake, thanks for finding that. In which case this change does seem to slightly bend the spec. IIUC, with your patch the compiler is trying to convey "the line is known but the column is unspecifiable", and DWARF doesn't give us a way to express that. Using column 0 does sound like a reasonable work-around to me (and looks like it should improve developer experience) but I think it's worth getting an opinion from someone who works on a DWARF-consumer. I've asked our (Sony's) debugger people what they think.

Perhaps we should seek input from an LLDB developer too (cc @JDevlieghere).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135166/new/

https://reviews.llvm.org/D135166



More information about the llvm-commits mailing list