mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-14 19:08:07 +08:00
Merge topic 'instrumentation-trace-names'
6929baca2f
instrumentation: Fix trace event names
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11250
This commit is contained in:
@@ -944,21 +944,25 @@ void cmInstrumentation::AppendTraceEvent(Json::Value& trace,
|
|||||||
|
|
||||||
// Provide a useful trace event name depending on what data is available
|
// Provide a useful trace event name depending on what data is available
|
||||||
// from the snippet.
|
// from the snippet.
|
||||||
std::string name = cmStrCat(snippetData["role"].asString(), ": ");
|
std::string nameSuffix;
|
||||||
if (snippetData["role"] == "compile") {
|
if (snippetData["role"] == "compile") {
|
||||||
name.append(snippetData["source"].asString());
|
nameSuffix = snippetData["source"].asString();
|
||||||
} else if (snippetData["role"] == "link") {
|
} else if (snippetData["role"] == "link") {
|
||||||
name.append(snippetData["target"].asString());
|
nameSuffix = snippetData["target"].asString();
|
||||||
} else if (snippetData["role"] == "install") {
|
} else if (snippetData["role"] == "install") {
|
||||||
cmCMakePath workingDir(snippetData["workingDir"].asCString());
|
cmCMakePath workingDir(snippetData["workingDir"].asCString());
|
||||||
std::string lastDirName = workingDir.GetFileName().String();
|
nameSuffix = workingDir.GetFileName().String();
|
||||||
name.append(lastDirName);
|
|
||||||
} else if (snippetData["role"] == "custom") {
|
} else if (snippetData["role"] == "custom") {
|
||||||
name.append(snippetData["command"].asString());
|
nameSuffix = snippetData["command"].asString();
|
||||||
} else if (snippetData["role"] == "test") {
|
} else if (snippetData["role"] == "test") {
|
||||||
name.append(snippetData["testName"].asString());
|
nameSuffix = snippetData["testName"].asString();
|
||||||
|
}
|
||||||
|
if (!nameSuffix.empty()) {
|
||||||
|
snippetTraceEvent["name"] =
|
||||||
|
cmStrCat(snippetData["role"].asString(), ": ", nameSuffix);
|
||||||
|
} else {
|
||||||
|
snippetTraceEvent["name"] = snippetData["role"].asString();
|
||||||
}
|
}
|
||||||
snippetTraceEvent["name"] = name;
|
|
||||||
|
|
||||||
snippetTraceEvent["cat"] = snippetData["role"];
|
snippetTraceEvent["cat"] = snippetData["role"];
|
||||||
snippetTraceEvent["ph"] = "X";
|
snippetTraceEvent["ph"] = "X";
|
||||||
|
@@ -49,23 +49,23 @@ function(trace_valid_entry trace entry)
|
|||||||
json_error("${trace}" "Name is empty: ${entry}")
|
json_error("${trace}" "Name is empty: ${entry}")
|
||||||
endif()
|
endif()
|
||||||
string(JSON cat GET "${entry}" cat)
|
string(JSON cat GET "${entry}" cat)
|
||||||
set(expected_name "${cat}: ")
|
set(expected_name "${cat}")
|
||||||
if (cat STREQUAL "compile")
|
if (cat STREQUAL "compile")
|
||||||
string(JSON source GET "${args}" source)
|
string(JSON source GET "${args}" source)
|
||||||
string(APPEND expected_name "${source}")
|
string(APPEND expected_name ": ${source}")
|
||||||
elseif (cat STREQUAL "link")
|
elseif (cat STREQUAL "link")
|
||||||
string(JSON target GET "${args}" target)
|
string(JSON target GET "${args}" target)
|
||||||
string(APPEND expected_name "${target}")
|
string(APPEND expected_name ": ${target}")
|
||||||
elseif (cat STREQUAL "install")
|
elseif (cat STREQUAL "install")
|
||||||
string(JSON workingDir GET "${args}" workingDir)
|
string(JSON workingDir GET "${args}" workingDir)
|
||||||
cmake_path(GET workingDir FILENAME lastDirName)
|
cmake_path(GET workingDir FILENAME lastDirName)
|
||||||
string(APPEND expected_name "${lastDirName}")
|
string(APPEND expected_name ": ${lastDirName}")
|
||||||
elseif (cat STREQUAL "custom")
|
elseif (cat STREQUAL "custom")
|
||||||
string(JSON command GET "${args}" command)
|
string(JSON command GET "${args}" command)
|
||||||
string(APPEND expected_name "${command}")
|
string(APPEND expected_name ": ${command}")
|
||||||
elseif (cat STREQUAL "test")
|
elseif (cat STREQUAL "test")
|
||||||
string(JSON testName GET "${args}" testName)
|
string(JSON testName GET "${args}" testName)
|
||||||
string(APPEND expected_name "${testName}")
|
string(APPEND expected_name ": ${testName}")
|
||||||
endif()
|
endif()
|
||||||
if (NOT name STREQUAL expected_name)
|
if (NOT name STREQUAL expected_name)
|
||||||
json_error("${trace}" "Invalid name: ${name}")
|
json_error("${trace}" "Invalid name: ${name}")
|
||||||
|
Reference in New Issue
Block a user