Make updated tracing scope/begin/end/instant use char* instead of enums (#27327)
* Create varargs macros for tracing, including tests
* Add matter trace scope macros
* Add missing semicolon
* Add labels to trace end
* Restyled by whitespace
* Restyled by clang-format
* Restyled by gn
* Use a buildconfig header for tracing configuration
* Fix missing include
* Restyled by gn
---------
Co-authored-by: Restyled.io <commits@restyled.io>
Co-authored-by: Andrei Litvin <andreilitvin@google.com>
diff --git a/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp b/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp
index 6e5893a..09a3e6a 100644
--- a/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp
+++ b/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp
@@ -156,7 +156,7 @@
const Commands::ArmFailSafe::DecodableType & commandData)
{
MATTER_TRACE_EVENT_SCOPE("ArmFailSafe", "GeneralCommissioning");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::GeneralCommissioning_ArmFailSafe);
+ MATTER_TRACE_SCOPE("ArmFailSafe", "GeneralCommissioning");
auto & failSafeContext = Server::GetInstance().GetFailSafeContext();
Commands::ArmFailSafeResponse::Type response;
@@ -219,7 +219,7 @@
const Commands::CommissioningComplete::DecodableType & commandData)
{
MATTER_TRACE_EVENT_SCOPE("CommissioningComplete", "GeneralCommissioning");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::GeneralCommissioning_CommissioningComplete);
+ MATTER_TRACE_SCOPE("CommissioningComplete", "GeneralCommissioning");
DeviceControlServer * devCtrl = &DeviceLayer::DeviceControlServer::DeviceControlSvr();
auto & failSafe = Server::GetInstance().GetFailSafeContext();
@@ -287,7 +287,7 @@
const Commands::SetRegulatoryConfig::DecodableType & commandData)
{
MATTER_TRACE_EVENT_SCOPE("SetRegulatoryConfig", "GeneralCommissioning");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::GeneralCommissioning_SetRegulatoryConfig);
+ MATTER_TRACE_SCOPE("SetRegulatoryConfig", "GeneralCommissioning");
DeviceControlServer * server = &DeviceLayer::DeviceControlServer::DeviceControlSvr();
Commands::SetRegulatoryConfigResponse::Type response;
diff --git a/src/app/clusters/network-commissioning/network-commissioning.cpp b/src/app/clusters/network-commissioning/network-commissioning.cpp
index 7dea1a6..53b4ffe 100644
--- a/src/app/clusters/network-commissioning/network-commissioning.cpp
+++ b/src/app/clusters/network-commissioning/network-commissioning.cpp
@@ -245,7 +245,7 @@
void Instance::HandleScanNetworks(HandlerContext & ctx, const Commands::ScanNetworks::DecodableType & req)
{
MATTER_TRACE_EVENT_SCOPE("HandleScanNetwork", "NetworkCommissioning");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::NetworkCommissioning_HandleScanNetwork);
+ MATTER_TRACE_SCOPE("HandleScanNetwork", "NetworkCommissioning");
if (mFeatureFlags.Has(Feature::kWiFiNetworkInterface))
{
ByteSpan ssid;
@@ -318,7 +318,7 @@
void Instance::HandleAddOrUpdateWiFiNetwork(HandlerContext & ctx, const Commands::AddOrUpdateWiFiNetwork::DecodableType & req)
{
MATTER_TRACE_EVENT_SCOPE("HandleAddOrUpdateWiFiNetwork", "NetworkCommissioning");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::NetworkCommissioning_HandleAddOrUpdateWiFiNetwork);
+ MATTER_TRACE_SCOPE("HandleAddOrUpdateWiFiNetwork", "NetworkCommissioning");
VerifyOrReturn(CheckFailSafeArmed(ctx));
@@ -377,7 +377,7 @@
void Instance::HandleAddOrUpdateThreadNetwork(HandlerContext & ctx, const Commands::AddOrUpdateThreadNetwork::DecodableType & req)
{
MATTER_TRACE_EVENT_SCOPE("HandleAddOrUpdateThreadNetwork", "NetworkCommissioning");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::NetworkCommissioning_HandleAddOrUpdateThreadNetwork);
+ MATTER_TRACE_SCOPE("HandleAddOrUpdateThreadNetwork", "NetworkCommissioning");
VerifyOrReturn(CheckFailSafeArmed(ctx));
@@ -415,7 +415,7 @@
void Instance::HandleRemoveNetwork(HandlerContext & ctx, const Commands::RemoveNetwork::DecodableType & req)
{
MATTER_TRACE_EVENT_SCOPE("HandleRemoveNetwork", "NetworkCommissioning");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::NetworkCommissioning_HandleRemoveNetwork);
+ MATTER_TRACE_SCOPE("HandleRemoveNetwork", "NetworkCommissioning");
VerifyOrReturn(CheckFailSafeArmed(ctx));
@@ -438,7 +438,7 @@
void Instance::HandleConnectNetwork(HandlerContext & ctx, const Commands::ConnectNetwork::DecodableType & req)
{
MATTER_TRACE_EVENT_SCOPE("HandleConnectNetwork", "NetworkCommissioning");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::NetworkCommissioning_HandleConnectNetwork);
+ MATTER_TRACE_SCOPE("HandleConnectNetwork", "NetworkCommissioning");
if (req.networkID.size() > DeviceLayer::NetworkCommissioning::kMaxNetworkIDLen)
{
ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Protocols::InteractionModel::Status::InvalidValue);
@@ -457,7 +457,7 @@
void Instance::HandleReorderNetwork(HandlerContext & ctx, const Commands::ReorderNetwork::DecodableType & req)
{
MATTER_TRACE_EVENT_SCOPE("HandleReorderNetwork", "NetworkCommissioning");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::NetworkCommissioning_HandleReorderNetwork);
+ MATTER_TRACE_SCOPE("HandleReorderNetwork", "NetworkCommissioning");
Commands::NetworkConfigResponse::Type response;
MutableCharSpan debugText;
#if CHIP_CONFIG_NETWORK_COMMISSIONING_DEBUG_TEXT_BUFFER_SIZE
diff --git a/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp b/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp
index 765c0de..1846cb2 100644
--- a/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp
+++ b/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp
@@ -409,7 +409,7 @@
const Commands::RemoveFabric::DecodableType & commandData)
{
MATTER_TRACE_EVENT_SCOPE("RemoveFabric", "OperationalCredentials");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::OperationalCredentials_RemoveFabric);
+ MATTER_TRACE_SCOPE("RemoveFabric", "OperationalCredentials");
auto & fabricBeingRemoved = commandData.fabricIndex;
ChipLogProgress(Zcl, "OpCreds: Received a RemoveFabric Command for FabricIndex 0x%x",
@@ -470,7 +470,7 @@
const Commands::UpdateFabricLabel::DecodableType & commandData)
{
MATTER_TRACE_EVENT_SCOPE("UpdateFabricLabel", "OperationalCredentials");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::OperationalCredentials_UpdateFabricLabel);
+ MATTER_TRACE_SCOPE("UpdateFabricLabel", "OperationalCredentials");
auto & label = commandData.label;
auto ourFabricIndex = commandObj->GetAccessingFabricIndex();
auto finalStatus = Status::Failure;
@@ -593,7 +593,7 @@
const Commands::AddNOC::DecodableType & commandData)
{
MATTER_TRACE_EVENT_SCOPE("AddNOC", "OperationalCredentials");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::OperationalCredentials_AddNOC);
+ MATTER_TRACE_SCOPE("AddNOC", "OperationalCredentials");
auto & NOCValue = commandData.NOCValue;
auto & ICACValue = commandData.ICACValue;
auto & adminVendorId = commandData.adminVendorId;
@@ -767,7 +767,7 @@
const Commands::UpdateNOC::DecodableType & commandData)
{
MATTER_TRACE_EVENT_SCOPE("UpdateNOC", "OperationalCredentials");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::OperationalCredentials_UpdateNOC);
+ MATTER_TRACE_SCOPE("UpdateNOC", "OperationalCredentials");
auto & NOCValue = commandData.NOCValue;
auto & ICACValue = commandData.ICACValue;
@@ -860,7 +860,7 @@
const Commands::CertificateChainRequest::DecodableType & commandData)
{
MATTER_TRACE_EVENT_SCOPE("CertificateChainRequest", "OperationalCredentials");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::OperationalCredentials_CertificateChainRequest);
+ MATTER_TRACE_SCOPE("CertificateChainRequest", "OperationalCredentials");
auto & certificateType = commandData.certificateType;
CHIP_ERROR err = CHIP_NO_ERROR;
@@ -909,7 +909,7 @@
const Commands::AttestationRequest::DecodableType & commandData)
{
MATTER_TRACE_EVENT_SCOPE("AttestationRequest", "OperationalCredentials");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::OperationalCredentials_AttestationRequest);
+ MATTER_TRACE_SCOPE("AttestationRequest", "OperationalCredentials");
auto & attestationNonce = commandData.attestationNonce;
auto finalStatus = Status::Failure;
@@ -1006,7 +1006,7 @@
const Commands::CSRRequest::DecodableType & commandData)
{
MATTER_TRACE_EVENT_SCOPE("CSRRequest", "OperationalCredentials");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::OperationalCredentials_CSRRequest);
+ MATTER_TRACE_SCOPE("CSRRequest", "OperationalCredentials");
ChipLogProgress(Zcl, "OpCreds: Received a CSRRequest command");
chip::Platform::ScopedMemoryBuffer<uint8_t> nocsrElements;
@@ -1142,7 +1142,7 @@
const Commands::AddTrustedRootCertificate::DecodableType & commandData)
{
MATTER_TRACE_EVENT_SCOPE("AddTrustedRootCertificate", "OperationalCredentials");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::OperationalCredentials_AddTrustedRootCertificate);
+ MATTER_TRACE_SCOPE("AddTrustedRootCertificate", "OperationalCredentials");
auto & fabricTable = Server::GetInstance().GetFabricTable();
auto finalStatus = Status::Failure;
diff --git a/src/controller/CHIPDeviceController.cpp b/src/controller/CHIPDeviceController.cpp
index acb5247..e095201 100644
--- a/src/controller/CHIPDeviceController.cpp
+++ b/src/controller/CHIPDeviceController.cpp
@@ -521,7 +521,7 @@
CommissioneeDeviceProxy * DeviceCommissioner::FindCommissioneeDevice(NodeId id)
{
MATTER_TRACE_EVENT_SCOPE("FindCommissioneeDevice", "DeviceCommissioner");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::DeviceCommissioner_FindCommissioneeDevice);
+ MATTER_TRACE_SCOPE("FindCommissioneeDevice", "DeviceCommissioner");
CommissioneeDeviceProxy * foundDevice = nullptr;
mCommissioneeDevicePool.ForEachActiveObject([&](auto * deviceProxy) {
if (deviceProxy->GetDeviceId() == id)
@@ -592,7 +592,7 @@
DiscoveryType discoveryType, Optional<Dnssd::CommonResolutionData> resolutionData)
{
MATTER_TRACE_EVENT_SCOPE("PairDevice", "DeviceCommissioner");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::DeviceCommissioner_PairDevice);
+ MATTER_TRACE_SCOPE("PairDevice", "DeviceCommissioner");
if (mDefaultCommissioner == nullptr)
{
@@ -609,7 +609,7 @@
Optional<Dnssd::CommonResolutionData> resolutionData)
{
MATTER_TRACE_EVENT_SCOPE("PairDevice", "DeviceCommissioner");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::DeviceCommissioner_PairDevice);
+ MATTER_TRACE_SCOPE("PairDevice", "DeviceCommissioner");
return mSetUpCodePairer.PairDevice(remoteDeviceId, setUpCode, SetupCodePairerBehaviour::kCommission, discoveryType,
resolutionData);
}
@@ -617,7 +617,7 @@
CHIP_ERROR DeviceCommissioner::PairDevice(NodeId remoteDeviceId, RendezvousParameters & params)
{
MATTER_TRACE_EVENT_SCOPE("PairDevice", "DeviceCommissioner");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::DeviceCommissioner_PairDevice);
+ MATTER_TRACE_SCOPE("PairDevice", "DeviceCommissioner");
ReturnErrorOnFailure(EstablishPASEConnection(remoteDeviceId, params));
return Commission(remoteDeviceId);
}
@@ -626,7 +626,7 @@
CommissioningParameters & commissioningParams)
{
MATTER_TRACE_EVENT_SCOPE("PairDevice", "DeviceCommissioner");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::DeviceCommissioner_PairDevice);
+ MATTER_TRACE_SCOPE("PairDevice", "DeviceCommissioner");
ReturnErrorOnFailure(EstablishPASEConnection(remoteDeviceId, rendezvousParams));
return Commission(remoteDeviceId, commissioningParams);
}
@@ -635,7 +635,7 @@
Optional<Dnssd::CommonResolutionData> resolutionData)
{
MATTER_TRACE_EVENT_SCOPE("EstablishPASEConnection", "DeviceCommissioner");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::DeviceCommissioner_EstablishPASEConnection);
+ MATTER_TRACE_SCOPE("EstablishPASEConnection", "DeviceCommissioner");
return mSetUpCodePairer.PairDevice(remoteDeviceId, setUpCode, SetupCodePairerBehaviour::kPaseOnly, discoveryType,
resolutionData);
}
@@ -643,7 +643,7 @@
CHIP_ERROR DeviceCommissioner::EstablishPASEConnection(NodeId remoteDeviceId, RendezvousParameters & params)
{
MATTER_TRACE_EVENT_SCOPE("EstablishPASEConnection", "DeviceCommissioner");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::DeviceCommissioner_EstablishPASEConnection);
+ MATTER_TRACE_SCOPE("EstablishPASEConnection", "DeviceCommissioner");
CHIP_ERROR err = CHIP_NO_ERROR;
CommissioneeDeviceProxy * device = nullptr;
CommissioneeDeviceProxy * current = nullptr;
@@ -831,7 +831,7 @@
CHIP_ERROR DeviceCommissioner::Commission(NodeId remoteDeviceId)
{
MATTER_TRACE_EVENT_SCOPE("Commission", "DeviceCommissioner");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::DeviceCommissioner_Commission);
+ MATTER_TRACE_SCOPE("Commission", "DeviceCommissioner");
CommissioneeDeviceProxy * device = FindCommissioneeDevice(remoteDeviceId);
if (device == nullptr || (!device->IsSecureConnected() && !device->IsSessionSetupInProgress()))
{
@@ -876,7 +876,7 @@
Credentials::AttestationVerificationResult attestationResult)
{
MATTER_TRACE_EVENT_SCOPE("continueCommissioningDevice", "DeviceCommissioner");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::DeviceCommissioner_continueCommissioningDevice);
+ MATTER_TRACE_SCOPE("continueCommissioningDevice", "DeviceCommissioner");
if (device == nullptr || device != mDeviceBeingCommissioned)
{
ChipLogError(Controller, "Invalid device for commissioning %p", device);
@@ -941,7 +941,7 @@
CHIP_ERROR DeviceCommissioner::UnpairDevice(NodeId remoteDeviceId)
{
MATTER_TRACE_EVENT_SCOPE("UnpairDevice", "DeviceCommissioner");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::DeviceCommissioner_UnpairDevice);
+ MATTER_TRACE_SCOPE("UnpairDevice", "DeviceCommissioner");
VerifyOrReturnError(mState == State::Initialized, CHIP_ERROR_INCORRECT_STATE);
return AutoCurrentFabricRemover::RemoveCurrentFabric(this, remoteDeviceId);
@@ -1010,7 +1010,7 @@
Optional<System::Clock::Timeout> timeout)
{
MATTER_TRACE_EVENT_SCOPE("SendCertificateChainRequestCommand", "DeviceCommissioner");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::DeviceCommissioner_SendCertificateChainRequestCommand);
+ MATTER_TRACE_SCOPE("SendCertificateChainRequestCommand", "DeviceCommissioner");
ChipLogDetail(Controller, "Sending Certificate Chain request to %p device", device);
VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
@@ -1024,7 +1024,7 @@
void DeviceCommissioner::OnCertificateChainFailureResponse(void * context, CHIP_ERROR error)
{
MATTER_TRACE_EVENT_SCOPE("OnCertificateChainFailureResponse", "DeviceCommissioner");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::DeviceCommissioner_OnCertificateChainFailureResponse);
+ MATTER_TRACE_SCOPE("OnCertificateChainFailureResponse", "DeviceCommissioner");
ChipLogProgress(Controller, "Device failed to receive the Certificate Chain request Response: %s", chip::ErrorStr(error));
DeviceCommissioner * commissioner = reinterpret_cast<DeviceCommissioner *>(context);
commissioner->CommissioningStageComplete(error);
@@ -1034,7 +1034,7 @@
void * context, const chip::app::Clusters::OperationalCredentials::Commands::CertificateChainResponse::DecodableType & response)
{
MATTER_TRACE_EVENT_SCOPE("OnCertificateChainResponse", "DeviceCommissioner");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::DeviceCommissioner_OnCertificateChainResponse);
+ MATTER_TRACE_SCOPE("OnCertificateChainResponse", "DeviceCommissioner");
ChipLogProgress(Controller, "Received certificate chain from the device");
DeviceCommissioner * commissioner = reinterpret_cast<DeviceCommissioner *>(context);
@@ -1048,7 +1048,7 @@
Optional<System::Clock::Timeout> timeout)
{
MATTER_TRACE_EVENT_SCOPE("SendAttestationRequestCommand", "DeviceCommissioner");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::DeviceCommissioner_SendAttestationRequestCommand);
+ MATTER_TRACE_SCOPE("SendAttestationRequestCommand", "DeviceCommissioner");
ChipLogDetail(Controller, "Sending Attestation request to %p device", device);
VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
@@ -1063,7 +1063,7 @@
void DeviceCommissioner::OnAttestationFailureResponse(void * context, CHIP_ERROR error)
{
MATTER_TRACE_EVENT_SCOPE("OnAttestationFailureResponse", "DeviceCommissioner");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::DeviceCommissioner_OnAttestationFailureResponse);
+ MATTER_TRACE_SCOPE("OnAttestationFailureResponse", "DeviceCommissioner");
ChipLogProgress(Controller, "Device failed to receive the Attestation Information Response: %s", chip::ErrorStr(error));
DeviceCommissioner * commissioner = reinterpret_cast<DeviceCommissioner *>(context);
commissioner->CommissioningStageComplete(error);
@@ -1073,7 +1073,7 @@
const OperationalCredentials::Commands::AttestationResponse::DecodableType & data)
{
MATTER_TRACE_EVENT_SCOPE("OnAttestationResponse", "DeviceCommissioner");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::DeviceCommissioner_OnAttestationResponse);
+ MATTER_TRACE_SCOPE("OnAttestationResponse", "DeviceCommissioner");
ChipLogProgress(Controller, "Received Attestation Information from the device");
DeviceCommissioner * commissioner = reinterpret_cast<DeviceCommissioner *>(context);
@@ -1086,7 +1086,7 @@
void * context, const Credentials::DeviceAttestationVerifier::AttestationInfo & info, AttestationVerificationResult result)
{
MATTER_TRACE_EVENT_SCOPE("OnDeviceAttestationInformationVerification", "DeviceCommissioner");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::DeviceCommissioner_OnDeviceAttestationInformationVerification);
+ MATTER_TRACE_SCOPE("OnDeviceAttestationInformationVerification", "DeviceCommissioner");
DeviceCommissioner * commissioner = reinterpret_cast<DeviceCommissioner *>(context);
if (!commissioner->mDeviceBeingCommissioned)
@@ -1255,7 +1255,7 @@
CHIP_ERROR DeviceCommissioner::ValidateAttestationInfo(const Credentials::DeviceAttestationVerifier::AttestationInfo & info)
{
MATTER_TRACE_EVENT_SCOPE("ValidateAttestationInfo", "DeviceCommissioner");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::DeviceCommissioner_ValidateAttestationInfo);
+ MATTER_TRACE_SCOPE("ValidateAttestationInfo", "DeviceCommissioner");
VerifyOrReturnError(mState == State::Initialized, CHIP_ERROR_INCORRECT_STATE);
VerifyOrReturnError(mDeviceAttestationVerifier != nullptr, CHIP_ERROR_INCORRECT_STATE);
@@ -1270,7 +1270,7 @@
const ByteSpan & AttestationSignature, const ByteSpan & dac, const ByteSpan & csrNonce)
{
MATTER_TRACE_EVENT_SCOPE("ValidateCSR", "DeviceCommissioner");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::DeviceCommissioner_ValidateCSR);
+ MATTER_TRACE_SCOPE("ValidateCSR", "DeviceCommissioner");
VerifyOrReturnError(mState == State::Initialized, CHIP_ERROR_INCORRECT_STATE);
VerifyOrReturnError(mDeviceAttestationVerifier != nullptr, CHIP_ERROR_INCORRECT_STATE);
@@ -1290,7 +1290,7 @@
Optional<System::Clock::Timeout> timeout)
{
MATTER_TRACE_EVENT_SCOPE("SendOperationalCertificateSigningRequestCommand", "DeviceCommissioner");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::DeviceCommissioner_SendOperationalCertificateSigningRequestCommand);
+ MATTER_TRACE_SCOPE("SendOperationalCertificateSigningRequestCommand", "DeviceCommissioner");
ChipLogDetail(Controller, "Sending CSR request to %p device", device);
VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
@@ -1305,7 +1305,7 @@
void DeviceCommissioner::OnCSRFailureResponse(void * context, CHIP_ERROR error)
{
MATTER_TRACE_EVENT_SCOPE("OnCSRFailureResponse", "DeviceCommissioner");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::DeviceCommissioner_OnCSRFailureResponse);
+ MATTER_TRACE_SCOPE("OnCSRFailureResponse", "DeviceCommissioner");
ChipLogProgress(Controller, "Device failed to receive the CSR request Response: %s", chip::ErrorStr(error));
DeviceCommissioner * commissioner = static_cast<DeviceCommissioner *>(context);
commissioner->CommissioningStageComplete(error);
@@ -1315,7 +1315,7 @@
void * context, const OperationalCredentials::Commands::CSRResponse::DecodableType & data)
{
MATTER_TRACE_EVENT_SCOPE("OnOperationalCertificateSigningRequest", "DeviceCommissioner");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::DeviceCommissioner_OnOperationalCertificateSigningRequest);
+ MATTER_TRACE_SCOPE("OnOperationalCertificateSigningRequest", "DeviceCommissioner");
ChipLogProgress(Controller, "Received certificate signing request from the device");
DeviceCommissioner * commissioner = static_cast<DeviceCommissioner *>(context);
@@ -1329,7 +1329,7 @@
Optional<NodeId> adminSubject)
{
MATTER_TRACE_EVENT_SCOPE("OnDeviceNOCChainGeneration", "DeviceCommissioner");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::DeviceCommissioner_OnDeviceNOCChainGeneration);
+ MATTER_TRACE_SCOPE("OnDeviceNOCChainGeneration", "DeviceCommissioner");
DeviceCommissioner * commissioner = static_cast<DeviceCommissioner *>(context);
// The placeholder IPK is not satisfactory, but is there to fill the NocChain struct on error. It will still fail.
@@ -1362,7 +1362,7 @@
chip::Callback::Callback<OnNOCChainGeneration> * callback)
{
MATTER_TRACE_EVENT_SCOPE("IssueNOCChain", "DeviceCommissioner");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::DeviceCommissioner_IssueNOCChain);
+ MATTER_TRACE_SCOPE("IssueNOCChain", "DeviceCommissioner");
VerifyOrReturnError(mState == State::Initialized, CHIP_ERROR_INCORRECT_STATE);
ChipLogProgress(Controller, "Getting certificate chain for the device on fabric idx %u", static_cast<unsigned>(mFabricIndex));
@@ -1385,7 +1385,7 @@
const ByteSpan & csrNonce)
{
MATTER_TRACE_EVENT_SCOPE("ProcessOpCSR", "DeviceCommissioner");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::DeviceCommissioner_ProcessOpCSR);
+ MATTER_TRACE_SCOPE("ProcessOpCSR", "DeviceCommissioner");
VerifyOrReturnError(mState == State::Initialized, CHIP_ERROR_INCORRECT_STATE);
ChipLogProgress(Controller, "Getting certificate chain for the device from the issuer");
@@ -1414,7 +1414,7 @@
Optional<System::Clock::Timeout> timeout)
{
MATTER_TRACE_EVENT_SCOPE("SendOperationalCertificate", "DeviceCommissioner");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::DeviceCommissioner_SendOperationalCertificate);
+ MATTER_TRACE_SCOPE("SendOperationalCertificate", "DeviceCommissioner");
VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
@@ -1468,7 +1468,7 @@
void DeviceCommissioner::OnAddNOCFailureResponse(void * context, CHIP_ERROR error)
{
MATTER_TRACE_EVENT_SCOPE("OnAddNOCFailureResponse", "DeviceCommissioner");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::DeviceCommissioner_OnAddNOCFailureResponse);
+ MATTER_TRACE_SCOPE("OnAddNOCFailureResponse", "DeviceCommissioner");
ChipLogProgress(Controller, "Device failed to receive the operational certificate Response: %s", chip::ErrorStr(error));
DeviceCommissioner * commissioner = static_cast<DeviceCommissioner *>(context);
commissioner->CommissioningStageComplete(error);
@@ -1478,7 +1478,7 @@
void * context, const OperationalCredentials::Commands::NOCResponse::DecodableType & data)
{
MATTER_TRACE_EVENT_SCOPE("OnOperationalCertificateAddResponse", "DeviceCommissioner");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::DeviceCommissioner_OnOperationalCertificateAddResponse);
+ MATTER_TRACE_SCOPE("OnOperationalCertificateAddResponse", "DeviceCommissioner");
ChipLogProgress(Controller, "Device returned status %d on receiving the NOC", to_underlying(data.statusCode));
DeviceCommissioner * commissioner = static_cast<DeviceCommissioner *>(context);
@@ -1505,7 +1505,7 @@
Optional<System::Clock::Timeout> timeout)
{
MATTER_TRACE_EVENT_SCOPE("SendTrustedRootCertificate", "DeviceCommissioner");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::DeviceCommissioner_SendTrustedRootCertificate);
+ MATTER_TRACE_SCOPE("SendTrustedRootCertificate", "DeviceCommissioner");
VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
ChipLogProgress(Controller, "Sending root certificate to the device");
@@ -1522,7 +1522,7 @@
void DeviceCommissioner::OnRootCertSuccessResponse(void * context, const chip::app::DataModel::NullObjectType &)
{
MATTER_TRACE_EVENT_SCOPE("OnRootCertSuccessResponse", "DeviceCommissioner");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::DeviceCommissioner_OnRootCertSuccessResponse);
+ MATTER_TRACE_SCOPE("OnRootCertSuccessResponse", "DeviceCommissioner");
ChipLogProgress(Controller, "Device confirmed that it has received the root certificate");
DeviceCommissioner * commissioner = static_cast<DeviceCommissioner *>(context);
commissioner->CommissioningStageComplete(CHIP_NO_ERROR);
@@ -1531,7 +1531,7 @@
void DeviceCommissioner::OnRootCertFailureResponse(void * context, CHIP_ERROR error)
{
MATTER_TRACE_EVENT_SCOPE("OnRootCertFailureResponse", "DeviceCommissioner");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::DeviceCommissioner_OnRootCertFailureResponse);
+ MATTER_TRACE_SCOPE("OnRootCertFailureResponse", "DeviceCommissioner");
ChipLogProgress(Controller, "Device failed to receive the root certificate Response: %s", chip::ErrorStr(error));
DeviceCommissioner * commissioner = static_cast<DeviceCommissioner *>(context);
commissioner->CommissioningStageComplete(error);
@@ -1540,7 +1540,7 @@
CHIP_ERROR DeviceCommissioner::OnOperationalCredentialsProvisioningCompletion(DeviceProxy * device)
{
MATTER_TRACE_EVENT_SCOPE("OnOperationalCredentialsProvisioningCompletion", "DeviceCommissioner");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::DeviceCommissioner_OnOperationalCredentialsProvisioningCompletion);
+ MATTER_TRACE_SCOPE("OnOperationalCredentialsProvisioningCompletion", "DeviceCommissioner");
ChipLogProgress(Controller, "Operational credentials provisioned on device %p", device);
VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
@@ -1732,7 +1732,7 @@
{
// Once this stage is complete, reset mDeviceBeingCommissioned - this will be reset when the delegate calls the next step.
MATTER_TRACE_EVENT_SCOPE("CommissioningStageComplete", "DeviceCommissioner");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::DeviceCommissioner_CommissioningStageComplete);
+ MATTER_TRACE_SCOPE("CommissioningStageComplete", "DeviceCommissioner");
if (mDeviceBeingCommissioned == nullptr)
{
// We are getting a stray callback (e.g. due to un-cancellable
diff --git a/src/lib/dnssd/IncrementalResolve.cpp b/src/lib/dnssd/IncrementalResolve.cpp
index 1b8915a..baa150a 100644
--- a/src/lib/dnssd/IncrementalResolve.cpp
+++ b/src/lib/dnssd/IncrementalResolve.cpp
@@ -24,7 +24,6 @@
#include <lib/support/CHIPMemString.h>
#include <tracing/macros.h>
#include <tracing/scope.h>
-#include <tracing/scopes.h>
namespace chip {
namespace Dnssd {
@@ -241,7 +240,7 @@
CHIP_ERROR IncrementalResolver::OnRecord(Inet::InterfaceId interface, const ResourceData & data, BytesRange packetRange)
{
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::Resolve_IncrementalRecordParse);
+ MATTER_TRACE_SCOPE("Incremental record parse", "Resolver");
if (!IsActive())
{
@@ -253,15 +252,14 @@
case QType::TXT:
if (data.GetName() != mRecordName.Get())
{
- MATTER_TRACE_INSTANT(::chip::Tracing::Instant::Resolve_TxtNotApplicable);
-
+ MATTER_TRACE_INSTANT("TXT not applicable", "Resolver");
return CHIP_NO_ERROR;
}
return OnTxtRecord(data, packetRange);
case QType::A: {
if (data.GetName() != mTargetHostName.Get())
{
- MATTER_TRACE_INSTANT(::chip::Tracing::Instant::Resolve_Ipv4NotApplicable);
+ MATTER_TRACE_INSTANT("IPv4 not applicable", "Resolver");
return CHIP_NO_ERROR;
}
@@ -284,7 +282,7 @@
case QType::AAAA: {
if (data.GetName() != mTargetHostName.Get())
{
- MATTER_TRACE_INSTANT(::chip::Tracing::Instant::Resolve_Ipv6NotApplicable);
+ MATTER_TRACE_INSTANT("IPv6 not applicable", "Resolver");
return CHIP_NO_ERROR;
}
diff --git a/src/protocols/secure_channel/CASESession.cpp b/src/protocols/secure_channel/CASESession.cpp
index 4974dd7..e21633a 100644
--- a/src/protocols/secure_channel/CASESession.cpp
+++ b/src/protocols/secure_channel/CASESession.cpp
@@ -433,7 +433,7 @@
Optional<ReliableMessageProtocolConfig> mrpLocalConfig)
{
MATTER_TRACE_EVENT_SCOPE("EstablishSession", "CASESession");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::CASESession_EstablishSession);
+ MATTER_TRACE_SCOPE("EstablishSession", "CASESession");
CHIP_ERROR err = CHIP_NO_ERROR;
// Return early on error here, as we have not initialized any state yet
@@ -582,7 +582,7 @@
CHIP_ERROR CASESession::SendSigma1()
{
MATTER_TRACE_EVENT_SCOPE("SendSigma1", "CASESession");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::CASESession_SendSigma1);
+ MATTER_TRACE_SCOPE("SendSigma1", "CASESession");
const size_t mrpParamsSize = mLocalMRPConfig.HasValue() ? TLV::EstimateStructOverhead(sizeof(uint16_t), sizeof(uint16_t)) : 0;
size_t data_len = TLV::EstimateStructOverhead(kSigmaParamRandomNumberSize, // initiatorRandom
sizeof(uint16_t), // initiatorSessionId,
@@ -689,7 +689,7 @@
CHIP_ERROR CASESession::HandleSigma1_and_SendSigma2(System::PacketBufferHandle && msg)
{
MATTER_TRACE_EVENT_SCOPE("HandleSigma1_and_SendSigma2", "CASESession");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::CASESession_HandleSigma1_and_SendSigma2);
+ MATTER_TRACE_SCOPE("HandleSigma1_and_SendSigma2", "CASESession");
ReturnErrorOnFailure(HandleSigma1(std::move(msg)));
return CHIP_NO_ERROR;
@@ -775,7 +775,7 @@
CHIP_ERROR CASESession::HandleSigma1(System::PacketBufferHandle && msg)
{
MATTER_TRACE_EVENT_SCOPE("HandleSigma1", "CASESession");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::CASESession_HandleSigma1);
+ MATTER_TRACE_SCOPE("HandleSigma1", "CASESession");
CHIP_ERROR err = CHIP_NO_ERROR;
System::PacketBufferTLVReader tlvReader;
@@ -860,7 +860,7 @@
CHIP_ERROR CASESession::SendSigma2Resume()
{
MATTER_TRACE_EVENT_SCOPE("SendSigma2Resume", "CASESession");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::CASESession_SendSigma2Resume);
+ MATTER_TRACE_SCOPE("SendSigma2Resume", "CASESession");
const size_t mrpParamsSize = mLocalMRPConfig.HasValue() ? TLV::EstimateStructOverhead(sizeof(uint16_t), sizeof(uint16_t)) : 0;
size_t max_sigma2_resume_data_len = TLV::EstimateStructOverhead(
SessionResumptionStorage::kResumptionIdSize, CHIP_CRYPTO_AEAD_MIC_LENGTH_BYTES, sizeof(uint16_t), mrpParamsSize);
@@ -915,7 +915,7 @@
CHIP_ERROR CASESession::SendSigma2()
{
MATTER_TRACE_EVENT_SCOPE("SendSigma2", "CASESession");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::CASESession_SendSigma2);
+ MATTER_TRACE_SCOPE("SendSigma2", "CASESession");
VerifyOrReturnError(GetLocalSessionId().HasValue(), CHIP_ERROR_INCORRECT_STATE);
VerifyOrReturnError(mFabricsTable != nullptr, CHIP_ERROR_INCORRECT_STATE);
@@ -1054,7 +1054,7 @@
CHIP_ERROR CASESession::HandleSigma2Resume(System::PacketBufferHandle && msg)
{
MATTER_TRACE_EVENT_SCOPE("HandleSigma2Resume", "CASESession");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::CASESession_HandleSigma2Resume);
+ MATTER_TRACE_SCOPE("HandleSigma2Resume", "CASESession");
CHIP_ERROR err = CHIP_NO_ERROR;
System::PacketBufferTLVReader tlvReader;
TLV::TLVType containerType = TLV::kTLVType_Structure;
@@ -1121,7 +1121,7 @@
CHIP_ERROR CASESession::HandleSigma2_and_SendSigma3(System::PacketBufferHandle && msg)
{
MATTER_TRACE_EVENT_SCOPE("HandleSigma2_and_SendSigma3", "CASESession");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::CASESession_HandleSigma2_and_SendSigma3);
+ MATTER_TRACE_SCOPE("HandleSigma2_and_SendSigma3", "CASESession");
ReturnErrorOnFailure(HandleSigma2(std::move(msg)));
ReturnErrorOnFailure(SendSigma3a());
@@ -1131,7 +1131,7 @@
CHIP_ERROR CASESession::HandleSigma2(System::PacketBufferHandle && msg)
{
MATTER_TRACE_EVENT_SCOPE("HandleSigma2", "CASESession");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::CASESession_HandleSigma2);
+ MATTER_TRACE_SCOPE("HandleSigma2", "CASESession");
CHIP_ERROR err = CHIP_NO_ERROR;
System::PacketBufferTLVReader tlvReader;
TLV::TLVReader decryptedDataTlvReader;
@@ -1301,7 +1301,7 @@
CHIP_ERROR CASESession::SendSigma3a()
{
MATTER_TRACE_EVENT_SCOPE("SendSigma3", "CASESession");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::CASESession_SendSigma3);
+ MATTER_TRACE_SCOPE("SendSigma3", "CASESession");
CHIP_ERROR err = CHIP_NO_ERROR;
ChipLogDetail(SecureChannel, "Sending Sigma3");
@@ -1516,7 +1516,7 @@
CHIP_ERROR CASESession::HandleSigma3a(System::PacketBufferHandle && msg)
{
MATTER_TRACE_EVENT_SCOPE("HandleSigma3", "CASESession");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::CASESession_HandleSigma3);
+ MATTER_TRACE_SCOPE("HandleSigma3", "CASESession");
CHIP_ERROR err = CHIP_NO_ERROR;
System::PacketBufferTLVReader tlvReader;
TLV::TLVReader decryptedDataTlvReader;
diff --git a/src/protocols/secure_channel/PASESession.cpp b/src/protocols/secure_channel/PASESession.cpp
index c8ee3bc..efe1973 100644
--- a/src/protocols/secure_channel/PASESession.cpp
+++ b/src/protocols/secure_channel/PASESession.cpp
@@ -136,7 +136,7 @@
bool useRandomPIN, uint32_t & setupPINCode)
{
MATTER_TRACE_EVENT_SCOPE("GeneratePASEVerifier", "PASESession");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::PASESession_GeneratePASEVerifier);
+ MATTER_TRACE_SCOPE("GeneratePASEVerifier", "PASESession");
if (useRandomPIN)
{
@@ -152,7 +152,7 @@
CHIP_ERROR PASESession::SetupSpake2p()
{
MATTER_TRACE_EVENT_SCOPE("SetupSpake2p", "PASESession");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::PASESession_SetupSpake2p);
+ MATTER_TRACE_SCOPE("SetupSpake2p", "PASESession");
uint8_t context[kSHA256_Hash_Length] = { 0 };
MutableByteSpan contextSpan{ context };
@@ -214,7 +214,7 @@
SessionEstablishmentDelegate * delegate)
{
MATTER_TRACE_EVENT_SCOPE("Pair", "PASESession");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::PASESession_Pair);
+ MATTER_TRACE_SCOPE("Pair", "PASESession");
ReturnErrorCodeIf(exchangeCtxt == nullptr, CHIP_ERROR_INVALID_ARGUMENT);
CHIP_ERROR err = Init(sessionManager, peerSetUpPINCode, delegate);
SuccessOrExit(err);
@@ -269,7 +269,7 @@
CHIP_ERROR PASESession::SendPBKDFParamRequest()
{
MATTER_TRACE_EVENT_SCOPE("SendPBKDFParamRequest", "PASESession");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::PASESession_SendPBKDFParamRequest);
+ MATTER_TRACE_SCOPE("SendPBKDFParamRequest", "PASESession");
VerifyOrReturnError(GetLocalSessionId().HasValue(), CHIP_ERROR_INCORRECT_STATE);
@@ -319,7 +319,7 @@
CHIP_ERROR PASESession::HandlePBKDFParamRequest(System::PacketBufferHandle && msg)
{
MATTER_TRACE_EVENT_SCOPE("HandlePBKDFParamRequest", "PASESession");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::PASESession_HandlePBKDFParamRequest);
+ MATTER_TRACE_SCOPE("HandlePBKDFParamRequest", "PASESession");
CHIP_ERROR err = CHIP_NO_ERROR;
System::PacketBufferTLVReader tlvReader;
@@ -383,7 +383,7 @@
CHIP_ERROR PASESession::SendPBKDFParamResponse(ByteSpan initiatorRandom, bool initiatorHasPBKDFParams)
{
MATTER_TRACE_EVENT_SCOPE("SendPBKDFParamResponse", "PASESession");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::PASESession_SendPBKDFParamResponse);
+ MATTER_TRACE_SCOPE("SendPBKDFParamResponse", "PASESession");
VerifyOrReturnError(GetLocalSessionId().HasValue(), CHIP_ERROR_INCORRECT_STATE);
@@ -445,7 +445,7 @@
CHIP_ERROR PASESession::HandlePBKDFParamResponse(System::PacketBufferHandle && msg)
{
MATTER_TRACE_EVENT_SCOPE("HandlePBKDFParamResponse", "PASESession");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::PASESession_HandlePBKDFParamResponse);
+ MATTER_TRACE_SCOPE("HandlePBKDFParamResponse", "PASESession");
CHIP_ERROR err = CHIP_NO_ERROR;
System::PacketBufferTLVReader tlvReader;
@@ -542,7 +542,7 @@
CHIP_ERROR PASESession::SendMsg1()
{
MATTER_TRACE_EVENT_SCOPE("SendMsg1", "PASESession");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::PASESession_SendMsg1);
+ MATTER_TRACE_SCOPE("SendMsg1", "PASESession");
const size_t max_msg_len = TLV::EstimateStructOverhead(kMAX_Point_Length);
System::PacketBufferHandle msg = System::PacketBufferHandle::New(max_msg_len);
VerifyOrReturnError(!msg.IsNull(), CHIP_ERROR_NO_MEMORY);
@@ -576,7 +576,7 @@
CHIP_ERROR PASESession::HandleMsg1_and_SendMsg2(System::PacketBufferHandle && msg1)
{
MATTER_TRACE_EVENT_SCOPE("HandleMsg1_and_SendMsg2", "PASESession");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::PASESession_HandleMsg1_and_SendMsg2);
+ MATTER_TRACE_SCOPE("HandleMsg1_and_SendMsg2", "PASESession");
CHIP_ERROR err = CHIP_NO_ERROR;
uint8_t Y[kMAX_Point_Length];
@@ -647,7 +647,7 @@
CHIP_ERROR PASESession::HandleMsg2_and_SendMsg3(System::PacketBufferHandle && msg2)
{
MATTER_TRACE_EVENT_SCOPE("HandleMsg2_and_SendMsg3", "PASESession");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::PASESession_HandleMsg2_and_SendMsg3);
+ MATTER_TRACE_SCOPE("HandleMsg2_and_SendMsg3", "PASESession");
CHIP_ERROR err = CHIP_NO_ERROR;
uint8_t verifier[kMAX_Hash_Length];
@@ -724,7 +724,7 @@
CHIP_ERROR PASESession::HandleMsg3(System::PacketBufferHandle && msg)
{
MATTER_TRACE_EVENT_SCOPE("HandleMsg3", "PASESession");
- MATTER_TRACE_SCOPE(::chip::Tracing::Scope::PASESession_HandleMsg3);
+ MATTER_TRACE_SCOPE("HandleMsg3", "PASESession");
CHIP_ERROR err = CHIP_NO_ERROR;
ChipLogDetail(SecureChannel, "Received spake2p msg3");
diff --git a/src/tracing/BUILD.gn b/src/tracing/BUILD.gn
index 218962c..5a081a9 100644
--- a/src/tracing/BUILD.gn
+++ b/src/tracing/BUILD.gn
@@ -15,10 +15,27 @@
import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")
+import("${chip_root}/build/chip/buildconfig_header.gni")
import("${chip_root}/src/tracing/tracing_args.gni")
-config("tracing_enabled") {
- defines = [ "MATTER_TRACING_ENABLED" ]
+buildconfig_header("tracing_buildconfig") {
+ header = "build_config.h"
+ header_dir = "matter/tracing"
+
+ defines = []
+
+ if (matter_enable_tracing_support) {
+ defines += [ "MATTER_TRACING_ENABLED=1" ]
+ }
+
+ if (matter_trace_config == "multiplexed") {
+ defines += [ "MATTER_TRACE_MULTIPLEXED=1" ]
+ } else if (matter_trace_config == "none") {
+ defines += [ "MATTER_TRACE_NONE=1" ]
+ } else {
+ # Expect a separate config to be set, that provides
+ # matter/tracing/macros_impl.h
+ }
}
static_library("tracing") {
@@ -29,12 +46,16 @@
"registry.cpp",
"registry.h",
"scope.h",
- "scopes.h",
]
- public_deps = [ "${chip_root}/src/lib/support" ]
+ public_deps = [
+ ":tracing_buildconfig",
+ "${chip_root}/src/lib/support",
+ ]
if (matter_enable_tracing_support) {
- public_configs = [ ":tracing_enabled" ]
+ if (matter_trace_config != "multiplexed" && matter_trace_config != "none") {
+ public_configs += [ matter_trace_config ]
+ }
}
}
diff --git a/src/tracing/backend.h b/src/tracing/backend.h
index adf6b75..db8eb58 100644
--- a/src/tracing/backend.h
+++ b/src/tracing/backend.h
@@ -18,7 +18,6 @@
#include <lib/support/IntrusiveList.h>
#include <tracing/log_declares.h>
-#include <tracing/scopes.h>
namespace chip {
namespace Tracing {
@@ -34,35 +33,31 @@
/// Begin a trace for the specified scope.
///
- /// Scopes must be completed by a corresponding
- /// TraceEnd call.
- virtual void TraceBegin(Scope scope) = 0;
+ /// Scope WILL be completed by a corresponding TraceEnd call.
+ virtual void TraceBegin(const char * label, const char * group) {}
- /// Tracing end assumes completing a previously
- /// started scope with TraceBegin and nesting is assumed.
+ /// Tracing end assumes completing a previously started scope with TraceBegin
+ /// and nesting is assumed.
///
/// Expect scopes like:
- /// TraceBegin(Foo)
- /// TraceBegin(Bar)
- /// TraceEnd(Bar)
- /// TraceEnd(Foo)
+ /// TraceBegin("foo", "A")
+ /// TraceBegin("bar", "A")
///
- /// The following is NOT acceptable:
- /// TraceBegin(Foo)
- /// TraceBegin(Bar)
- /// TraceEnd(Foo)
- /// TraceEnd(Bar)
- virtual void TraceEnd(Scope scope) = 0;
+ /// // NOT VALID HERE: TraceEnd("foo", "A")
+ ///
+ /// TraceEnd("bar", "A") // ends "BAR"
+ /// TraceEnd("foo", "A") // ends "FOO"
+ virtual void TraceEnd(const char * label, const char * group) {}
/// Trace a zero-sized event
- virtual void TraceInstant(Instant instant) = 0;
+ virtual void TraceInstant(const char * label, const char * group) {}
- virtual void LogMessageSend(MessageSendInfo &) { TraceInstant(Instant::Log_MessageSend); }
- virtual void LogMessageReceived(MessageReceivedInfo &) { TraceInstant(Instant::Log_MessageReceived); }
+ virtual void LogMessageSend(MessageSendInfo &) { TraceInstant("MessageSent", "Messaging"); }
+ virtual void LogMessageReceived(MessageReceivedInfo &) { TraceInstant("MessageReceived", "Messaging"); }
- virtual void LogNodeLookup(NodeLookupInfo &) { TraceInstant(Instant::Log_NodeLookup); }
- virtual void LogNodeDiscovered(NodeDiscoveredInfo &) { TraceInstant(Instant::Log_NodeDiscovered); }
- virtual void LogNodeDiscoveryFailed(NodeDiscoveryFailedInfo &) { TraceInstant(Instant::Log_NodeDiscoveryFailed); }
+ virtual void LogNodeLookup(NodeLookupInfo &) { TraceInstant("Lookup", "DNSSD"); }
+ virtual void LogNodeDiscovered(NodeDiscoveredInfo &) { TraceInstant("Node Discovered", "DNSSD"); }
+ virtual void LogNodeDiscoveryFailed(NodeDiscoveryFailedInfo &) { TraceInstant("Discovery Failed", "DNSSD"); }
};
} // namespace Tracing
diff --git a/src/tracing/log_json/log_json_tracing.cpp b/src/tracing/log_json/log_json_tracing.cpp
index 933009d..1dc46c1 100644
--- a/src/tracing/log_json/log_json_tracing.cpp
+++ b/src/tracing/log_json/log_json_tracing.cpp
@@ -36,177 +36,6 @@
using chip::StringBuilder;
-std::string ScopeToString(Scope scope)
-{
- switch (scope)
- {
- case Scope::CASESession_EstablishSession:
- return "CASESession::EstablishSession";
- case Scope::CASESession_HandleSigma1:
- return "CASESession::HandleSigma1";
- case Scope::CASESession_HandleSigma1_and_SendSigma2:
- return "CASESession_HandleSigma1_and::SendSigma2";
- case Scope::CASESession_HandleSigma2:
- return "CASESession::HandleSigma2";
- case Scope::CASESession_HandleSigma2_and_SendSigma3:
- return "CASESession_HandleSigma2_and::SendSigma3";
- case Scope::CASESession_HandleSigma2Resume:
- return "CASESession::HandleSigma2Resume";
- case Scope::CASESession_HandleSigma3:
- return "CASESession::HandleSigma3";
- case Scope::CASESession_SendSigma1:
- return "CASESession::SendSigma1";
- case Scope::CASESession_SendSigma2:
- return "CASESession::SendSigma2";
- case Scope::CASESession_SendSigma2Resume:
- return "CASESession::SendSigma2Resume";
- case Scope::CASESession_SendSigma3:
- return "CASESession::SendSigma3";
- case Scope::DeviceCommissioner_Commission:
- return "DeviceCommissioner::Commission";
- case Scope::DeviceCommissioner_CommissioningStageComplete:
- return "DeviceCommissioner::CommissioningStageComplete";
- case Scope::DeviceCommissioner_continueCommissioningDevice:
- return "DeviceCommissioner::continueCommissioningDevice";
- case Scope::DeviceCommissioner_EstablishPASEConnection:
- return "DeviceCommissioner::EstablishPASEConnection";
- case Scope::DeviceCommissioner_FindCommissioneeDevice:
- return "DeviceCommissioner::FindCommissioneeDevice";
- case Scope::DeviceCommissioner_IssueNOCChain:
- return "DeviceCommissioner::IssueNOCChain";
- case Scope::DeviceCommissioner_OnAddNOCFailureResponse:
- return "DeviceCommissioner::OnAddNOCFailureResponse";
- case Scope::DeviceCommissioner_OnAttestationFailureResponse:
- return "DeviceCommissioner::OnAttestationFailureResponse";
- case Scope::DeviceCommissioner_OnAttestationResponse:
- return "DeviceCommissioner::OnAttestationResponse";
- case Scope::DeviceCommissioner_OnCertificateChainFailureResponse:
- return "DeviceCommissioner::OnCertificateChainFailureResponse";
- case Scope::DeviceCommissioner_OnCertificateChainResponse:
- return "DeviceCommissioner::OnCertificateChainResponse";
- case Scope::DeviceCommissioner_OnCSRFailureResponse:
- return "DeviceCommissioner::OnCSRFailureResponse";
- case Scope::DeviceCommissioner_OnDeviceAttestationInformationVerification:
- return "DeviceCommissioner::OnDeviceAttestationInformationVerification";
- case Scope::DeviceCommissioner_OnDeviceNOCChainGeneration:
- return "DeviceCommissioner::OnDeviceNOCChainGeneration";
- case Scope::DeviceCommissioner_OnOperationalCertificateAddResponse:
- return "DeviceCommissioner::OnOperationalCertificateAddResponse";
- case Scope::DeviceCommissioner_OnOperationalCertificateSigningRequest:
- return "DeviceCommissioner::OnOperationalCertificateSigningRequest";
- case Scope::DeviceCommissioner_OnOperationalCredentialsProvisioningCompletion:
- return "DeviceCommissioner::OnOperationalCredentialsProvisioningCompletion";
- case Scope::DeviceCommissioner_OnRootCertFailureResponse:
- return "DeviceCommissioner::OnRootCertFailureResponse";
- case Scope::DeviceCommissioner_OnRootCertSuccessResponse:
- return "DeviceCommissioner::OnRootCertSuccessResponse";
- case Scope::DeviceCommissioner_PairDevice:
- return "DeviceCommissioner::PairDevice";
- case Scope::DeviceCommissioner_ProcessOpCSR:
- return "DeviceCommissioner::ProcessOpCSR";
- case Scope::DeviceCommissioner_SendAttestationRequestCommand:
- return "DeviceCommissioner::SendAttestationRequestCommand";
- case Scope::DeviceCommissioner_SendCertificateChainRequestCommand:
- return "DeviceCommissioner::SendCertificateChainRequestCommand";
- case Scope::DeviceCommissioner_SendOperationalCertificate:
- return "DeviceCommissioner::SendOperationalCertificate";
- case Scope::DeviceCommissioner_SendOperationalCertificateSigningRequestCommand:
- return "DeviceCommissioner::SendOperationalCertificateSigningRequestCommand";
- case Scope::DeviceCommissioner_SendTrustedRootCertificate:
- return "DeviceCommissioner::SendTrustedRootCertificate";
- case Scope::DeviceCommissioner_UnpairDevice:
- return "DeviceCommissioner::UnpairDevice";
- case Scope::DeviceCommissioner_ValidateAttestationInfo:
- return "DeviceCommissioner::ValidateAttestationInfo";
- case Scope::DeviceCommissioner_ValidateCSR:
- return "DeviceCommissioner::ValidateCSR";
- case Scope::GeneralCommissioning_ArmFailSafe:
- return "GeneralCommissioning::ArmFailSafe";
- case Scope::GeneralCommissioning_CommissioningComplete:
- return "GeneralCommissioning::CommissioningComplete";
- case Scope::GeneralCommissioning_SetRegulatoryConfig:
- return "GeneralCommissioning::SetRegulatoryConfig";
- case Scope::NetworkCommissioning_HandleAddOrUpdateThreadNetwork:
- return "NetworkCommissioning::HandleAddOrUpdateThreadNetwork";
- case Scope::NetworkCommissioning_HandleAddOrUpdateWiFiNetwork:
- return "NetworkCommissioning::HandleAddOrUpdateWiFiNetwork";
- case Scope::NetworkCommissioning_HandleConnectNetwork:
- return "NetworkCommissioning::HandleConnectNetwork";
- case Scope::NetworkCommissioning_HandleRemoveNetwork:
- return "NetworkCommissioning::HandleRemoveNetwork";
- case Scope::NetworkCommissioning_HandleReorderNetwork:
- return "NetworkCommissioning::HandleReorderNetwork";
- case Scope::NetworkCommissioning_HandleScanNetwork:
- return "NetworkCommissioning::HandleScanNetwork";
- case Scope::OperationalCredentials_AddNOC:
- return "OperationalCredentials::AddNOC";
- case Scope::OperationalCredentials_AddTrustedRootCertificate:
- return "OperationalCredentials::AddTrustedRootCertificate";
- case Scope::OperationalCredentials_AttestationRequest:
- return "OperationalCredentials::AttestationRequest";
- case Scope::OperationalCredentials_CertificateChainRequest:
- return "OperationalCredentials::CertificateChainRequest";
- case Scope::OperationalCredentials_CSRRequest:
- return "OperationalCredentials::CSRRequest";
- case Scope::OperationalCredentials_RemoveFabric:
- return "OperationalCredentials::RemoveFabric";
- case Scope::OperationalCredentials_UpdateFabricLabel:
- return "OperationalCredentials::UpdateFabricLabel";
- case Scope::OperationalCredentials_UpdateNOC:
- return "OperationalCredentials::UpdateNOC";
- case Scope::PASESession_GeneratePASEVerifier:
- return "PASESession::GeneratePASEVerifier";
- case Scope::PASESession_HandleMsg1_and_SendMsg2:
- return "PASESession_HandleMsg1_and::SendMsg2";
- case Scope::PASESession_HandleMsg2_and_SendMsg3:
- return "PASESession_HandleMsg2_and::SendMsg3";
- case Scope::PASESession_HandleMsg3:
- return "PASESession::HandleMsg3";
- case Scope::PASESession_HandlePBKDFParamRequest:
- return "PASESession::HandlePBKDFParamRequest";
- case Scope::PASESession_HandlePBKDFParamResponse:
- return "PASESession::HandlePBKDFParamResponse";
- case Scope::PASESession_Pair:
- return "PASESession::Pair";
- case Scope::PASESession_SendMsg1:
- return "PASESession::SendMsg1";
- case Scope::PASESession_SendPBKDFParamRequest:
- return "PASESession::SendPBKDFParamRequest";
- case Scope::PASESession_SendPBKDFParamResponse:
- return "PASESession::SendPBKDFParamResponse";
- case Scope::PASESession_SetupSpake2p:
- return "PASESession::SetupSpake2p";
- case Scope::Resolve_IncrementalRecordParse:
- return "Resolve::IncrementalRecordParse";
- default: {
- StringBuilder<64> builder;
- builder.Add("Scope::Unknown(");
- builder.Add(static_cast<int>(scope));
- builder.Add(")");
- return builder.c_str();
- }
- }
-}
-
-std::string InstantToString(Instant instant)
-{
- switch (instant)
- {
- case Instant::Resolve_TxtNotApplicable:
- return "Resolve::TxtNotApplicable";
- case Instant::Resolve_Ipv4NotApplicable:
- return "Resolve::Ipv4NotApplicable";
- case Instant::Resolve_Ipv6NotApplicable:
- return "Resolve::Ipv6NotApplicable";
- default: {
- StringBuilder<64> builder;
- builder.Add("Instant::Unknown(");
- builder.Add(static_cast<int>(instant));
- builder.Add(")");
- return builder.c_str();
- }
- }
-}
/// Writes the given value to chip log
void LogJsonValue(Json::Value const & value)
{
@@ -279,27 +108,30 @@
} // namespace
-void LogJsonBackend::TraceBegin(Scope scope)
+void LogJsonBackend::TraceBegin(const char * label, const char * group)
{
Json::Value value;
- value["event"] = "begin";
- value["scope"] = ScopeToString(scope);
+ value["event"] = "TraceBegin";
+ value["label"] = label;
+ value["group"] = group;
LogJsonValue(value);
}
-void LogJsonBackend::TraceEnd(Scope scope)
+void LogJsonBackend::TraceEnd(const char * label, const char * group)
{
Json::Value value;
- value["event"] = "end";
- value["scope"] = ScopeToString(scope);
+ value["event"] = "TraceEnd";
+ value["label"] = label;
+ value["group"] = group;
LogJsonValue(value);
}
-void LogJsonBackend::TraceInstant(Instant instant)
+void LogJsonBackend::TraceInstant(const char * label, const char * group)
{
Json::Value value;
- value["event"] = "instant";
- value["instant"] = InstantToString(instant);
+ value["event"] = "TraceInstant";
+ value["label"] = label;
+ value["group"] = group;
LogJsonValue(value);
}
diff --git a/src/tracing/log_json/log_json_tracing.h b/src/tracing/log_json/log_json_tracing.h
index ef462c9..d75de53 100644
--- a/src/tracing/log_json/log_json_tracing.h
+++ b/src/tracing/log_json/log_json_tracing.h
@@ -31,9 +31,9 @@
public:
LogJsonBackend() = default;
- void TraceBegin(Scope scope) override;
- void TraceEnd(Scope scope) override;
- void TraceInstant(Instant instant) override;
+ void TraceBegin(const char * label, const char * group) override;
+ void TraceEnd(const char * label, const char * group) override;
+ void TraceInstant(const char * label, const char * group) override;
void LogMessageSend(MessageSendInfo &) override;
void LogMessageReceived(MessageReceivedInfo &) override;
void LogNodeLookup(NodeLookupInfo &) override;
diff --git a/src/tracing/macros.h b/src/tracing/macros.h
index 3f9a828..ff12900 100644
--- a/src/tracing/macros.h
+++ b/src/tracing/macros.h
@@ -17,16 +17,17 @@
*/
#pragma once
-#ifndef MATTER_TRACING_ENABLED
+#include <matter/tracing/build_config.h>
#define _MATTER_TRACE_DISABLE(...) \
do \
{ \
} while (false)
+#ifndef MATTER_TRACING_ENABLED
+
#define MATTER_TRACE_BEGIN(...) _MATTER_TRACE_DISABLE(__VA_ARGS__)
#define MATTER_TRACE_END(...) _MATTER_TRACE_DISABLE(__VA_ARGS__)
-
#define MATTER_TRACE_INSTANT(...) _MATTER_TRACE_DISABLE(__VA_ARGS__)
#define MATTER_LOG_MESSAGE_SEND(...) _MATTER_TRACE_DISABLE(__VA_ARGS__)
@@ -40,11 +41,33 @@
#include <tracing/log_declares.h>
#include <tracing/registry.h>
-#include <tracing/scopes.h>
-#define MATTER_TRACE_BEGIN(scope) ::chip::Tracing::Internal::Begin(scope)
-#define MATTER_TRACE_END(scope) ::chip::Tracing::Internal::End(scope)
-#define MATTER_TRACE_INSTANT(scope) ::chip::Tracing::Internal::Instant(scope)
+////////////////////// TRACE MESSAGES
+
+#ifdef MATTER_TRACE_NONE
+
+#define MATTER_TRACE_BEGIN(...) _MATTER_TRACE_DISABLE(__VA_ARGS__)
+#define MATTER_TRACE_END(...) _MATTER_TRACE_DISABLE(__VA_ARGS__)
+#define MATTER_TRACE_INSTANT(...) _MATTER_TRACE_DISABLE(__VA_ARGS__)
+
+#elif defined(MATTER_TRACE_MULTIPLEXED)
+
+// This gets forwarded to the multiplexed instance
+#define MATTER_TRACE_BEGIN(label, group) ::chip::Tracing::Internal::Begin(label, group)
+#define MATTER_TRACE_END(label, group) ::chip::Tracing::Internal::End(label, group)
+#define MATTER_TRACE_INSTANT(label, group) ::chip::Tracing::Internal::Instant(label, group)
+
+#else
+// if matter trace config is set, macros for this have to be provided
+//
+// Expected macros provided by implementations:
+// MATTER_TRACE_BEGIN(label, group)
+// MATTER_TRACE_END(label, group)
+// MATTER_TRACE_INSTANT(label, group)
+#include <matter/tracing/macros_impl.h>
+#endif
+
+////////////////////// DATA LOGGING
#define MATTER_LOG_MESSAGE_SEND(...) \
do \
diff --git a/src/tracing/registry.cpp b/src/tracing/registry.cpp
index bb98623..f98f9a1 100644
--- a/src/tracing/registry.cpp
+++ b/src/tracing/registry.cpp
@@ -16,6 +16,7 @@
*/
#include <lib/support/IntrusiveList.h>
+#include <matter/tracing/build_config.h>
#include <platform/LockTracker.h>
#include <tracing/registry.h>
@@ -43,26 +44,27 @@
namespace Internal {
-void Begin(::chip::Tracing::Scope scope)
+void Begin(const char * label, const char * group)
{
for (auto & backend : gTracingBackends)
{
- backend.TraceBegin(scope);
+ backend.TraceBegin(label, group);
}
}
-void End(::chip::Tracing::Scope scope)
+void End(const char * label, const char * group)
{
for (auto & backend : gTracingBackends)
{
- backend.TraceEnd(scope);
+ backend.TraceEnd(label, group);
}
}
-void Instant(::chip::Tracing::Instant instant)
+
+void Instant(const char * label, const char * group)
{
for (auto & backend : gTracingBackends)
{
- backend.TraceInstant(instant);
+ backend.TraceInstant(label, group);
}
}
diff --git a/src/tracing/registry.h b/src/tracing/registry.h
index b3a5a6a..755c116 100644
--- a/src/tracing/registry.h
+++ b/src/tracing/registry.h
@@ -59,9 +59,9 @@
// Internal calls, that will delegate to appropriate backends as needed
namespace Internal {
-void Begin(::chip::Tracing::Scope scope);
-void End(::chip::Tracing::Scope scope);
-void Instant(::chip::Tracing::Instant instant);
+void Begin(const char * label, const char * group);
+void End(const char * label, const char * group);
+void Instant(const char * label, const char * group);
void LogMessageSend(::chip::Tracing::MessageSendInfo & info);
void LogMessageReceived(::chip::Tracing::MessageReceivedInfo & info);
diff --git a/src/tracing/scope.h b/src/tracing/scope.h
index 5bbcd07..71dd04f 100644
--- a/src/tracing/scope.h
+++ b/src/tracing/scope.h
@@ -17,11 +17,18 @@
*/
#pragma once
+#include <matter/tracing/build_config.h>
+
#include <tracing/macros.h>
-#include <tracing/scopes.h>
#ifdef MATTER_TRACING_ENABLED
+#ifdef MATTER_TRACE_NONE
+
+#define MATTER_TRACE_SCOPE(...) _MATTER_TRACE_DISABLE(__VA_ARGS__)
+
+#elif defined(MATTER_TRACE_MULTIPLEXED)
+
namespace chip {
namespace Tracing {
@@ -29,7 +36,7 @@
///
/// Usage:
/// {
-/// ::chip::Tracing::Scoped scope(::chip::Tracing::Scope::CASESession_SendSigma1);
+/// ::chip::Tracing::Scoped scope("label", "group");
/// // TRACE_BEGIN called here
///
/// // ... add code here
@@ -39,11 +46,12 @@
class Scoped
{
public:
- inline Scoped(Scope scope) : mScope(scope) { MATTER_TRACE_BEGIN(scope); }
- inline ~Scoped() { MATTER_TRACE_END(mScope); }
+ inline Scoped(const char * label, const char * group) : mLabel(label), mGroup(group) { MATTER_TRACE_BEGIN(label, group); }
+ inline ~Scoped() { MATTER_TRACE_END(mLabel, mGroup); }
private:
- Scope mScope;
+ const char * mLabel;
+ const char * mGroup;
};
} // namespace Tracing
@@ -62,13 +70,15 @@
/// // ... add code here
///
/// } // TRACE_END called here
-#define MATTER_TRACE_SCOPE(scope) ::chip::Tracing::Scoped _MACRO_CONCAT(_trace_scope, __COUNTER__)(scope)
+#define MATTER_TRACE_SCOPE(label, group) ::chip::Tracing::Scoped _MACRO_CONCAT(_trace_scope, __COUNTER__)(label, group)
+
+#else
+// backends MUST provide a config for this
+#include <matter/tracing/macros_impl.h>
+#endif
#else // ifdef MATTER_TRACING_ENABLED
-#define MATTER_TRACE_SCOPE(scope) \
- do \
- { \
- } while (false)
+#define MATTER_TRACE_SCOPE(...) _MATTER_TRACE_DISABLE(__VA_ARGS__)
#endif
diff --git a/src/tracing/scopes.h b/src/tracing/scopes.h
deleted file mode 100644
index 5447652..0000000
--- a/src/tracing/scopes.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (c) 2023 Project CHIP Authors
- * All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-namespace chip {
-namespace Tracing {
-
-/// Trace scopes defined as an enumeration, since various tracing back-ends
-/// may need to use constant strings for tracing.
-///
-/// As a result, tracing scopes in CHIP are from a known list.
-enum class Scope
-{
- UndefinedDoNotUse = 0,
-
- CASESession_EstablishSession = 1,
- CASESession_HandleSigma1 = 2,
- CASESession_HandleSigma1_and_SendSigma2 = 3,
- CASESession_HandleSigma2 = 4,
- CASESession_HandleSigma2_and_SendSigma3 = 5,
- CASESession_HandleSigma2Resume = 6,
- CASESession_HandleSigma3 = 7,
- CASESession_SendSigma1 = 8,
- CASESession_SendSigma2 = 9,
- CASESession_SendSigma2Resume = 10,
- CASESession_SendSigma3 = 11,
- DeviceCommissioner_Commission = 12,
- DeviceCommissioner_CommissioningStageComplete = 13,
- DeviceCommissioner_continueCommissioningDevice = 14,
- DeviceCommissioner_EstablishPASEConnection = 15,
- DeviceCommissioner_FindCommissioneeDevice = 16,
- DeviceCommissioner_IssueNOCChain = 17,
- DeviceCommissioner_OnAddNOCFailureResponse = 18,
- DeviceCommissioner_OnAttestationFailureResponse = 19,
- DeviceCommissioner_OnAttestationResponse = 20,
- DeviceCommissioner_OnCertificateChainFailureResponse = 21,
- DeviceCommissioner_OnCertificateChainResponse = 22,
- DeviceCommissioner_OnCSRFailureResponse = 23,
- DeviceCommissioner_OnDeviceAttestationInformationVerification = 24,
- DeviceCommissioner_OnDeviceNOCChainGeneration = 25,
- DeviceCommissioner_OnOperationalCertificateAddResponse = 26,
- DeviceCommissioner_OnOperationalCertificateSigningRequest = 27,
- DeviceCommissioner_OnOperationalCredentialsProvisioningCompletion = 28,
- DeviceCommissioner_OnRootCertFailureResponse = 29,
- DeviceCommissioner_OnRootCertSuccessResponse = 30,
- DeviceCommissioner_PairDevice = 31,
- DeviceCommissioner_ProcessOpCSR = 32,
- DeviceCommissioner_SendAttestationRequestCommand = 33,
- DeviceCommissioner_SendCertificateChainRequestCommand = 34,
- DeviceCommissioner_SendOperationalCertificate = 35,
- DeviceCommissioner_SendOperationalCertificateSigningRequestCommand = 36,
- DeviceCommissioner_SendTrustedRootCertificate = 37,
- DeviceCommissioner_UnpairDevice = 38,
- DeviceCommissioner_ValidateAttestationInfo = 39,
- DeviceCommissioner_ValidateCSR = 40,
- GeneralCommissioning_ArmFailSafe = 41,
- GeneralCommissioning_CommissioningComplete = 42,
- GeneralCommissioning_SetRegulatoryConfig = 43,
- NetworkCommissioning_HandleAddOrUpdateThreadNetwork = 44,
- NetworkCommissioning_HandleAddOrUpdateWiFiNetwork = 45,
- NetworkCommissioning_HandleConnectNetwork = 46,
- NetworkCommissioning_HandleRemoveNetwork = 47,
- NetworkCommissioning_HandleReorderNetwork = 48,
- NetworkCommissioning_HandleScanNetwork = 49,
- OperationalCredentials_AddNOC = 50,
- OperationalCredentials_AddTrustedRootCertificate = 51,
- OperationalCredentials_AttestationRequest = 52,
- OperationalCredentials_CertificateChainRequest = 53,
- OperationalCredentials_CSRRequest = 54,
- OperationalCredentials_RemoveFabric = 55,
- OperationalCredentials_UpdateFabricLabel = 56,
- OperationalCredentials_UpdateNOC = 57,
- PASESession_GeneratePASEVerifier = 58,
- PASESession_HandleMsg1_and_SendMsg2 = 59,
- PASESession_HandleMsg2_and_SendMsg3 = 60,
- PASESession_HandleMsg3 = 61,
- PASESession_HandlePBKDFParamRequest = 62,
- PASESession_HandlePBKDFParamResponse = 63,
- PASESession_Pair = 64,
- PASESession_SendMsg1 = 65,
- PASESession_SendPBKDFParamRequest = 66,
- PASESession_SendPBKDFParamResponse = 67,
- PASESession_SetupSpake2p = 68,
- Resolve_IncrementalRecordParse = 69,
-};
-
-/// An event that happened at an instant (like a zero sized scope)
-enum class Instant
-{
- UndefinedDoNotUse = 0,
-
- // General instant notifications
- Resolve_TxtNotApplicable = 1,
- Resolve_Ipv4NotApplicable = 2,
- Resolve_Ipv6NotApplicable = 3,
-
- // Used if and only if default "Log*" requests
- // are not implemented in the backend.
- Log_MessageSend = 1000,
- Log_MessageReceived = 1001,
- Log_NodeLookup = 1002,
- Log_NodeDiscovered = 1003,
- Log_NodeDiscoveryFailed = 1004,
-};
-
-} // namespace Tracing
-} // namespace chip
diff --git a/src/tracing/tests/BUILD.gn b/src/tracing/tests/BUILD.gn
index 081a830..8d193e5 100644
--- a/src/tracing/tests/BUILD.gn
+++ b/src/tracing/tests/BUILD.gn
@@ -19,7 +19,7 @@
import("${chip_root}/build/chip/chip_test_suite.gni")
import("${chip_root}/src/tracing/tracing_args.gni")
-if (matter_enable_tracing_support) {
+if (matter_enable_tracing_support && matter_trace_config == "multiplexed") {
chip_test_suite("tests") {
output_name = "libTracingTests"
diff --git a/src/tracing/tests/TestTracing.cpp b/src/tracing/tests/TestTracing.cpp
index 2026f37..f0ae871 100644
--- a/src/tracing/tests/TestTracing.cpp
+++ b/src/tracing/tests/TestTracing.cpp
@@ -21,6 +21,7 @@
#include <nlunit-test.h>
#include <algorithm>
+#include <string>
#include <vector>
using namespace chip;
@@ -32,35 +33,24 @@
class LoggingTraceBackend : public Backend
{
public:
- enum class TraceEventType
- {
- BEGIN,
- END
- };
-
- struct ReceivedTraceEvent
- {
- TraceEventType type;
- Scope scope;
-
- bool operator==(const ReceivedTraceEvent & other) const { return (type == other.type) && (scope == other.scope); }
- };
-
LoggingTraceBackend() {}
- const std::vector<ReceivedTraceEvent> & traces() const { return mTraces; }
+ const std::vector<std::string> & traces() const { return mTraces; }
// Implementation
- void TraceBegin(Scope scope) override { mTraces.push_back(ReceivedTraceEvent{ TraceEventType::BEGIN, scope }); }
-
- void TraceEnd(Scope scope) override { mTraces.push_back(ReceivedTraceEvent{ TraceEventType::END, scope }); }
-
- void TraceInstant(Instant instant) override
+ void TraceBegin(const char * label, const char * group) override
{
- // NOT SUPPORTED HERE
+ mTraces.push_back(std::string("BEGIN:") + group + ":" + label);
+ }
+
+ void TraceEnd(const char * label, const char * group) override { mTraces.push_back(std::string("END:") + group + ":" + label); }
+
+ void TraceInstant(const char * label, const char * group) override
+ {
+ mTraces.push_back(std::string("INSTANT:") + group + ":" + label);
}
private:
- std::vector<ReceivedTraceEvent> mTraces;
+ std::vector<std::string> mTraces;
};
void TestBasicTracing(nlTestSuite * inSuite, void * inContext)
@@ -70,32 +60,25 @@
{
ScopedRegistration scope(backend);
- MATTER_TRACE_SCOPE(Scope::CASESession_SendSigma1);
+ MATTER_TRACE_SCOPE("A", "Group");
{
- MATTER_TRACE_SCOPE(Scope::CASESession_SendSigma2);
+ MATTER_TRACE_SCOPE("B", "Group");
// direct scope begin/end (not usual, but should work)
- MATTER_TRACE_BEGIN(Scope::OperationalCredentials_AddNOC);
- MATTER_TRACE_BEGIN(Scope::OperationalCredentials_UpdateNOC);
- MATTER_TRACE_END(Scope::OperationalCredentials_UpdateNOC);
- MATTER_TRACE_END(Scope::OperationalCredentials_AddNOC);
+ MATTER_TRACE_BEGIN("C", "Group");
+ MATTER_TRACE_BEGIN("D", "Group");
+ MATTER_TRACE_END("D", "Group");
+ MATTER_TRACE_INSTANT("FOO", "Group");
+ MATTER_TRACE_END("C", "Group");
}
{
- MATTER_TRACE_SCOPE(Scope::CASESession_SendSigma3);
+ MATTER_TRACE_SCOPE("E", "Group");
}
}
- std::vector<LoggingTraceBackend::ReceivedTraceEvent> expected = {
- { LoggingTraceBackend::TraceEventType::BEGIN, Scope::CASESession_SendSigma1 },
- { LoggingTraceBackend::TraceEventType::BEGIN, Scope::CASESession_SendSigma2 },
- { LoggingTraceBackend::TraceEventType::BEGIN, Scope::OperationalCredentials_AddNOC },
- { LoggingTraceBackend::TraceEventType::BEGIN, Scope::OperationalCredentials_UpdateNOC },
- { LoggingTraceBackend::TraceEventType::END, Scope::OperationalCredentials_UpdateNOC },
- { LoggingTraceBackend::TraceEventType::END, Scope::OperationalCredentials_AddNOC },
- { LoggingTraceBackend::TraceEventType::END, Scope::CASESession_SendSigma2 },
- { LoggingTraceBackend::TraceEventType::BEGIN, Scope::CASESession_SendSigma3 },
- { LoggingTraceBackend::TraceEventType::END, Scope::CASESession_SendSigma3 },
- { LoggingTraceBackend::TraceEventType::END, Scope::CASESession_SendSigma1 },
+ std::vector<std::string> expected = {
+ "BEGIN:Group:A", "BEGIN:Group:B", "BEGIN:Group:C", "BEGIN:Group:D", "END:Group:D", "INSTANT:Group:FOO",
+ "END:Group:C", "END:Group:B", "BEGIN:Group:E", "END:Group:E", "END:Group:A",
};
NL_TEST_ASSERT(inSuite, backend.traces().size() == expected.size());
@@ -110,51 +93,39 @@
{
ScopedRegistration register1(b1);
- MATTER_TRACE_SCOPE(Scope::CASESession_SendSigma1);
+ MATTER_TRACE_SCOPE("1", "G");
{
ScopedRegistration register2(b2);
- MATTER_TRACE_SCOPE(Scope::CASESession_SendSigma2);
+ MATTER_TRACE_SCOPE("2", "G");
{
ScopedRegistration register3(b3);
- MATTER_TRACE_SCOPE(Scope::CASESession_SendSigma3);
+ MATTER_TRACE_SCOPE("3", "G");
}
{
- MATTER_TRACE_SCOPE(Scope::OperationalCredentials_AddNOC);
+ MATTER_TRACE_SCOPE("4", "G");
}
}
}
- std::vector<LoggingTraceBackend::ReceivedTraceEvent> expected1 = {
- { LoggingTraceBackend::TraceEventType::BEGIN, Scope::CASESession_SendSigma1 },
- { LoggingTraceBackend::TraceEventType::BEGIN, Scope::CASESession_SendSigma2 },
- { LoggingTraceBackend::TraceEventType::BEGIN, Scope::CASESession_SendSigma3 },
- { LoggingTraceBackend::TraceEventType::END, Scope::CASESession_SendSigma3 },
- { LoggingTraceBackend::TraceEventType::BEGIN, Scope::OperationalCredentials_AddNOC },
- { LoggingTraceBackend::TraceEventType::END, Scope::OperationalCredentials_AddNOC },
- { LoggingTraceBackend::TraceEventType::END, Scope::CASESession_SendSigma2 },
- { LoggingTraceBackend::TraceEventType::END, Scope::CASESession_SendSigma1 },
+ std::vector<std::string> expected1 = {
+ "BEGIN:G:1", "BEGIN:G:2", "BEGIN:G:3", "END:G:3", "BEGIN:G:4", "END:G:4", "END:G:2", "END:G:1",
};
NL_TEST_ASSERT(inSuite, b1.traces().size() == expected1.size());
NL_TEST_ASSERT(inSuite, std::equal(b1.traces().begin(), b1.traces().end(), expected1.begin(), expected1.end()));
- std::vector<LoggingTraceBackend::ReceivedTraceEvent> expected2 = {
- { LoggingTraceBackend::TraceEventType::BEGIN, Scope::CASESession_SendSigma2 },
- { LoggingTraceBackend::TraceEventType::BEGIN, Scope::CASESession_SendSigma3 },
- { LoggingTraceBackend::TraceEventType::END, Scope::CASESession_SendSigma3 },
- { LoggingTraceBackend::TraceEventType::BEGIN, Scope::OperationalCredentials_AddNOC },
- { LoggingTraceBackend::TraceEventType::END, Scope::OperationalCredentials_AddNOC },
- { LoggingTraceBackend::TraceEventType::END, Scope::CASESession_SendSigma2 },
+ std::vector<std::string> expected2 = {
+ "BEGIN:G:2", "BEGIN:G:3", "END:G:3", "BEGIN:G:4", "END:G:4", "END:G:2",
};
NL_TEST_ASSERT(inSuite, b2.traces().size() == expected2.size());
NL_TEST_ASSERT(inSuite, std::equal(b2.traces().begin(), b2.traces().end(), expected2.begin(), expected2.end()));
- std::vector<LoggingTraceBackend::ReceivedTraceEvent> expected3 = {
- { LoggingTraceBackend::TraceEventType::BEGIN, Scope::CASESession_SendSigma3 },
- { LoggingTraceBackend::TraceEventType::END, Scope::CASESession_SendSigma3 },
+ std::vector<std::string> expected3 = {
+ "BEGIN:G:3",
+ "END:G:3",
};
NL_TEST_ASSERT(inSuite, b3.traces().size() == expected3.size());
diff --git a/src/tracing/tracing_args.gni b/src/tracing/tracing_args.gni
index 7ae979b..7c4cde5 100644
--- a/src/tracing/tracing_args.gni
+++ b/src/tracing/tracing_args.gni
@@ -17,4 +17,28 @@
# the impact minimal (the backends themselves add some size), however
# for now tracing is opt-in
matter_enable_tracing_support = target_os == "linux"
+
+ # Defines the trace backend. Current matter tracing splits the logic
+ # into two parts:
+ # - data logging, well defined and using type-safe data
+ # - trace begin/end/instant states for monitoring execution and
+ # checking execution time and performance
+ # For tracing specifically, due to performance constraints, several
+ # backends prefer to be the one and only tracing provider (e.g.
+ # pw_tracing uses tokenization to reduce string sizes and allow
+ # for fast tracing even when the communication channels are slow).
+ #
+ # The setting below controls the destination of the tracing macros
+ # with the following values available:
+ # - "none" makes tracing completely disabled
+ # - "multiplexed" allows using the "backend.h" for tracing, which
+ # will multiplex however will only work on fast backends (e.g.
+ # large systems with fast logging when writing to logs)
+ # - any other value will provide a tracing config, which
+ # MUST include a path to `matter/tracing/macros_impl.h`
+ if (target_os == "linux") {
+ matter_trace_config = "multiplexed"
+ } else {
+ matter_trace_config = "none"
+ }
}