Trace: include `line_end` field in json-v1 format
Problem
After !6954 (merged) got merged, it has become easier for tools to get full stack-traces for runtime traces of a CMake program. The trace information already included in the JSON objects (line number, source file path) allows tools that display these stack traces to print the CMake source code associated to them. However, CMake commands may spawn multiple lines, and the JSON information associated to a trace only contains the line in which the command started, but not the one in which it ended. If tools want to print stack traces along the relevant source code, and they want to print the whole command associated to the stack frame, they will have to implement their own CMake language parser to know where the command ends.
Solution
In order to simplify the life of those who want to write tooling for CMake, I propose to add a line_end
field to the json-v1 trace format. If a given command spans multiple lines, the line_end
field will contain the line of the last line spanned by the command (otherwise we can keep it empty, I don't feel strongly about the case where line
and line_end
are the same).
This is an example of what I mean on an open-source project (ignore the "check", it's just prototyping)
Having line_end
allowed my tool to display the last command in full.
I actually already have a patch where I implemented this feature, but decided to take @brad.king 's advice and create an issue first. If we agree on the design, I can submit a MR.
Caveats
- Adding another field will increase the size of the trace dumps. Is this a concern? If so, we could hide the field behind a CLI flag but I don't personally think this is worth it.