summaryrefslogtreecommitdiffstats
path: root/Source/cmListFileCache.h
diff options
context:
space:
mode:
authorBraulio Valdivielso Martinez <bvaldivielso@bloomberg.net>2022-02-07 14:05:59 (GMT)
committerBraulio Valdivielso Martinez <bvaldivielso@bloomberg.net>2022-02-09 18:30:11 (GMT)
commit8e1e97cccab4da8907cf9403e2c13514a4c285d3 (patch)
treeea6bd5bb49eaba4c01a91a007c8e80e4d7c08ab1 /Source/cmListFileCache.h
parente40cea3fe99dc79b1ce8bc8330f662ec3a36dc8e (diff)
downloadCMake-8e1e97cccab4da8907cf9403e2c13514a4c285d3.zip
CMake-8e1e97cccab4da8907cf9403e2c13514a4c285d3.tar.gz
CMake-8e1e97cccab4da8907cf9403e2c13514a4c285d3.tar.bz2
Trace: include `line_end` field in json-v1 format
After !6954 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. In order to simplify the life of those who want to write tooling for CMake, this commit adds 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 (that of the closing parenthesis associated to the command).
Diffstat (limited to 'Source/cmListFileCache.h')
-rw-r--r--Source/cmListFileCache.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h
index 58bc57e..c3da81b 100644
--- a/Source/cmListFileCache.h
+++ b/Source/cmListFileCache.h
@@ -51,9 +51,9 @@ struct cmListFileArgument
class cmListFileFunction
{
public:
- cmListFileFunction(std::string name, long line,
+ cmListFileFunction(std::string name, long line, long lineEnd,
std::vector<cmListFileArgument> args)
- : Impl{ std::make_shared<Implementation>(std::move(name), line,
+ : Impl{ std::make_shared<Implementation>(std::move(name), line, lineEnd,
std::move(args)) }
{
}
@@ -69,6 +69,7 @@ public:
}
long Line() const noexcept { return this->Impl->Line; }
+ long LineEnd() const noexcept { return this->Impl->LineEnd; }
std::vector<cmListFileArgument> const& Arguments() const noexcept
{
@@ -78,11 +79,12 @@ public:
private:
struct Implementation
{
- Implementation(std::string name, long line,
+ Implementation(std::string name, long line, long lineEnd,
std::vector<cmListFileArgument> args)
: OriginalName{ std::move(name) }
, LowerCaseName{ cmSystemTools::LowerCase(this->OriginalName) }
, Line{ line }
+ , LineEnd{ lineEnd }
, Arguments{ std::move(args) }
{
}
@@ -90,6 +92,7 @@ private:
std::string OriginalName;
std::string LowerCaseName;
long Line = 0;
+ long LineEnd = 0;
std::vector<cmListFileArgument> Arguments;
};