Skip to content

Commit

Permalink
Add "CHIP_" prefix to trace macros to avoid macro collision. (#16305)
Browse files Browse the repository at this point in the history
* Add "CHIP_" prefix to trace macros to avoid macro collision.

* Restyled by clang-format

* Change trace macros to prefix "MATTER_"

* Restyled by clang-format

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed May 3, 2022
1 parent b7d74f0 commit 2185618
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 55 deletions.
22 changes: 11 additions & 11 deletions src/protocols/secure_channel/CASESession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ CHIP_ERROR CASESession::EstablishSession(const Transport::PeerAddress peerAddres
uint16_t localSessionId, ExchangeContext * exchangeCtxt,
SessionEstablishmentDelegate * delegate, Optional<ReliableMessageProtocolConfig> mrpConfig)
{
TRACE_EVENT_SCOPE("EstablishSession", "CASESession");
MATTER_TRACE_EVENT_SCOPE("EstablishSession", "CASESession");
CHIP_ERROR err = CHIP_NO_ERROR;

#if CHIP_PROGRESS_LOGGING
Expand Down Expand Up @@ -313,7 +313,7 @@ CHIP_ERROR CASESession::DeriveSecureSession(CryptoContext & session, CryptoConte

CHIP_ERROR CASESession::SendSigma1()
{
TRACE_EVENT_SCOPE("SendSigma1", "CASESession");
MATTER_TRACE_EVENT_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,
Expand Down Expand Up @@ -396,15 +396,15 @@ CHIP_ERROR CASESession::SendSigma1()

CHIP_ERROR CASESession::HandleSigma1_and_SendSigma2(System::PacketBufferHandle && msg)
{
TRACE_EVENT_SCOPE("HandleSigma1_and_SendSigma2", "CASESession");
MATTER_TRACE_EVENT_SCOPE("HandleSigma1_and_SendSigma2", "CASESession");
ReturnErrorOnFailure(HandleSigma1(std::move(msg)));

return CHIP_NO_ERROR;
}

CHIP_ERROR CASESession::HandleSigma1(System::PacketBufferHandle && msg)
{
TRACE_EVENT_SCOPE("HandleSigma1", "CASESession");
MATTER_TRACE_EVENT_SCOPE("HandleSigma1", "CASESession");
CHIP_ERROR err = CHIP_NO_ERROR;
System::PacketBufferTLVReader tlvReader;

Expand Down Expand Up @@ -482,7 +482,7 @@ CHIP_ERROR CASESession::HandleSigma1(System::PacketBufferHandle && msg)

CHIP_ERROR CASESession::SendSigma2Resume(const ByteSpan & initiatorRandom)
{
TRACE_EVENT_SCOPE("SendSigma2Resume", "CASESession");
MATTER_TRACE_EVENT_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(kCASEResumptionIDSize, CHIP_CRYPTO_AEAD_MIC_LENGTH_BYTES, sizeof(uint16_t), mrpParamsSize);
Expand Down Expand Up @@ -533,7 +533,7 @@ CHIP_ERROR CASESession::SendSigma2Resume(const ByteSpan & initiatorRandom)

CHIP_ERROR CASESession::SendSigma2()
{
TRACE_EVENT_SCOPE("SendSigma2", "CASESession");
MATTER_TRACE_EVENT_SCOPE("SendSigma2", "CASESession");
VerifyOrReturnError(mFabricInfo != nullptr, CHIP_ERROR_INCORRECT_STATE);

ByteSpan icaCert;
Expand Down Expand Up @@ -664,7 +664,7 @@ CHIP_ERROR CASESession::SendSigma2()

CHIP_ERROR CASESession::HandleSigma2Resume(System::PacketBufferHandle && msg)
{
TRACE_EVENT_SCOPE("HandleSigma2Resume", "CASESession");
MATTER_TRACE_EVENT_SCOPE("HandleSigma2Resume", "CASESession");
CHIP_ERROR err = CHIP_NO_ERROR;
System::PacketBufferTLVReader tlvReader;
TLV::TLVType containerType = TLV::kTLVType_Structure;
Expand Down Expand Up @@ -731,7 +731,7 @@ CHIP_ERROR CASESession::HandleSigma2Resume(System::PacketBufferHandle && msg)

CHIP_ERROR CASESession::HandleSigma2_and_SendSigma3(System::PacketBufferHandle && msg)
{
TRACE_EVENT_SCOPE("HandleSigma2_and_SendSigma3", "CASESession");
MATTER_TRACE_EVENT_SCOPE("HandleSigma2_and_SendSigma3", "CASESession");
ReturnErrorOnFailure(HandleSigma2(std::move(msg)));
ReturnErrorOnFailure(SendSigma3());

Expand All @@ -740,7 +740,7 @@ CHIP_ERROR CASESession::HandleSigma2_and_SendSigma3(System::PacketBufferHandle &

CHIP_ERROR CASESession::HandleSigma2(System::PacketBufferHandle && msg)
{
TRACE_EVENT_SCOPE("HandleSigma2", "CASESession");
MATTER_TRACE_EVENT_SCOPE("HandleSigma2", "CASESession");
CHIP_ERROR err = CHIP_NO_ERROR;
System::PacketBufferTLVReader tlvReader;
TLV::TLVReader decryptedDataTlvReader;
Expand Down Expand Up @@ -899,7 +899,7 @@ CHIP_ERROR CASESession::HandleSigma2(System::PacketBufferHandle && msg)

CHIP_ERROR CASESession::SendSigma3()
{
TRACE_EVENT_SCOPE("SendSigma3", "CASESession");
MATTER_TRACE_EVENT_SCOPE("SendSigma3", "CASESession");
CHIP_ERROR err = CHIP_NO_ERROR;

MutableByteSpan messageDigestSpan(mMessageDigest);
Expand Down Expand Up @@ -1034,7 +1034,7 @@ CHIP_ERROR CASESession::SendSigma3()

CHIP_ERROR CASESession::HandleSigma3(System::PacketBufferHandle && msg)
{
TRACE_EVENT_SCOPE("HandleSigma3", "CASESession");
MATTER_TRACE_EVENT_SCOPE("HandleSigma3", "CASESession");
CHIP_ERROR err = CHIP_NO_ERROR;
MutableByteSpan messageDigestSpan(mMessageDigest);
System::PacketBufferTLVReader tlvReader;
Expand Down
22 changes: 11 additions & 11 deletions src/protocols/secure_channel/PASESession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ CHIP_ERROR PASESession::Init(uint16_t mySessionId, uint32_t setupCode, SessionEs
CHIP_ERROR PASESession::GeneratePASEVerifier(Spake2pVerifier & verifier, uint32_t pbkdf2IterCount, const ByteSpan & salt,
bool useRandomPIN, uint32_t & setupPINCode)
{
TRACE_EVENT_SCOPE("GeneratePASEVerifier", "PASESession");
MATTER_TRACE_EVENT_SCOPE("GeneratePASEVerifier", "PASESession");

if (useRandomPIN)
{
Expand All @@ -222,7 +222,7 @@ CHIP_ERROR PASESession::GeneratePASEVerifier(Spake2pVerifier & verifier, uint32_

CHIP_ERROR PASESession::SetupSpake2p()
{
TRACE_EVENT_SCOPE("SetupSpake2p", "PASESession");
MATTER_TRACE_EVENT_SCOPE("SetupSpake2p", "PASESession");
uint8_t context[kSHA256_Hash_Length] = { 0 };
MutableByteSpan contextSpan{ context };

Expand Down Expand Up @@ -283,7 +283,7 @@ CHIP_ERROR PASESession::Pair(const Transport::PeerAddress peerAddress, uint32_t
Optional<ReliableMessageProtocolConfig> mrpConfig, Messaging::ExchangeContext * exchangeCtxt,
SessionEstablishmentDelegate * delegate)
{
TRACE_EVENT_SCOPE("Pair", "PASESession");
MATTER_TRACE_EVENT_SCOPE("Pair", "PASESession");
ReturnErrorCodeIf(exchangeCtxt == nullptr, CHIP_ERROR_INVALID_ARGUMENT);
CHIP_ERROR err = Init(mySessionId, peerSetUpPINCode, delegate);
SuccessOrExit(err);
Expand Down Expand Up @@ -333,7 +333,7 @@ CHIP_ERROR PASESession::DeriveSecureSession(CryptoContext & session, CryptoConte

CHIP_ERROR PASESession::SendPBKDFParamRequest()
{
TRACE_EVENT_SCOPE("SendPBKDFParamRequest", "PASESession");
MATTER_TRACE_EVENT_SCOPE("SendPBKDFParamRequest", "PASESession");
ReturnErrorOnFailure(DRBG_get_bytes(mPBKDFLocalRandomData, sizeof(mPBKDFLocalRandomData)));

const size_t mrpParamsSize = mLocalMRPConfig.HasValue() ? TLV::EstimateStructOverhead(sizeof(uint16_t), sizeof(uint16_t)) : 0;
Expand Down Expand Up @@ -379,7 +379,7 @@ CHIP_ERROR PASESession::SendPBKDFParamRequest()

CHIP_ERROR PASESession::HandlePBKDFParamRequest(System::PacketBufferHandle && msg)
{
TRACE_EVENT_SCOPE("HandlePBKDFParamRequest", "PASESession");
MATTER_TRACE_EVENT_SCOPE("HandlePBKDFParamRequest", "PASESession");
CHIP_ERROR err = CHIP_NO_ERROR;

System::PacketBufferTLVReader tlvReader;
Expand Down Expand Up @@ -441,7 +441,7 @@ CHIP_ERROR PASESession::HandlePBKDFParamRequest(System::PacketBufferHandle && ms

CHIP_ERROR PASESession::SendPBKDFParamResponse(ByteSpan initiatorRandom, bool initiatorHasPBKDFParams)
{
TRACE_EVENT_SCOPE("SendPBKDFParamResponse", "PASESession");
MATTER_TRACE_EVENT_SCOPE("SendPBKDFParamResponse", "PASESession");
ReturnErrorOnFailure(DRBG_get_bytes(mPBKDFLocalRandomData, sizeof(mPBKDFLocalRandomData)));

const size_t mrpParamsSize = mLocalMRPConfig.HasValue() ? TLV::EstimateStructOverhead(sizeof(uint16_t), sizeof(uint16_t)) : 0;
Expand Down Expand Up @@ -499,7 +499,7 @@ CHIP_ERROR PASESession::SendPBKDFParamResponse(ByteSpan initiatorRandom, bool in

CHIP_ERROR PASESession::HandlePBKDFParamResponse(System::PacketBufferHandle && msg)
{
TRACE_EVENT_SCOPE("HandlePBKDFParamResponse", "PASESession");
MATTER_TRACE_EVENT_SCOPE("HandlePBKDFParamResponse", "PASESession");
CHIP_ERROR err = CHIP_NO_ERROR;

System::PacketBufferTLVReader tlvReader;
Expand Down Expand Up @@ -593,7 +593,7 @@ CHIP_ERROR PASESession::HandlePBKDFParamResponse(System::PacketBufferHandle && m

CHIP_ERROR PASESession::SendMsg1()
{
TRACE_EVENT_SCOPE("SendMsg1", "PASESession");
MATTER_TRACE_EVENT_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);
Expand Down Expand Up @@ -626,7 +626,7 @@ CHIP_ERROR PASESession::SendMsg1()

CHIP_ERROR PASESession::HandleMsg1_and_SendMsg2(System::PacketBufferHandle && msg1)
{
TRACE_EVENT_SCOPE("HandleMsg1_and_SendMsg2", "PASESession");
MATTER_TRACE_EVENT_SCOPE("HandleMsg1_and_SendMsg2", "PASESession");
CHIP_ERROR err = CHIP_NO_ERROR;

uint8_t Y[kMAX_Point_Length];
Expand Down Expand Up @@ -696,7 +696,7 @@ CHIP_ERROR PASESession::HandleMsg1_and_SendMsg2(System::PacketBufferHandle && ms

CHIP_ERROR PASESession::HandleMsg2_and_SendMsg3(System::PacketBufferHandle && msg2)
{
TRACE_EVENT_SCOPE("HandleMsg2_and_SendMsg3", "PASESession");
MATTER_TRACE_EVENT_SCOPE("HandleMsg2_and_SendMsg3", "PASESession");
CHIP_ERROR err = CHIP_NO_ERROR;

uint8_t verifier[kMAX_Hash_Length];
Expand Down Expand Up @@ -772,7 +772,7 @@ CHIP_ERROR PASESession::HandleMsg2_and_SendMsg3(System::PacketBufferHandle && ms

CHIP_ERROR PASESession::HandleMsg3(System::PacketBufferHandle && msg)
{
TRACE_EVENT_SCOPE("HandleMsg3", "PASESession");
MATTER_TRACE_EVENT_SCOPE("HandleMsg3", "PASESession");
CHIP_ERROR err = CHIP_NO_ERROR;

ChipLogDetail(SecureChannel, "Received spake2p msg3");
Expand Down
66 changes: 33 additions & 33 deletions src/trace/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,45 +21,45 @@

#include <pw_trace/trace.h>

#define TRACE_EVENT_INSTANT(...) PW_TRACE_INSTANT(__VA_ARGS__)
#define TRACE_EVENT_INSTANT_FLAG(...) PW_TRACE_INSTANT_FLAG(__VA_ARGS__)
#define TRACE_EVENT_INSTANT_DATA(...) PW_TRACE_INSTANT_DATA(__VA_ARGS__)
#define TRACE_EVENT_INSTANT_DATA_FLAG(...) PW_TRACE_INSTANT_DATA_FLAG(__VA_ARGS__)
#define TRACE_EVENT_START(...) PW_TRACE_START(__VA_ARGS__)
#define TRACE_EVENT_START_FLAG(...) PW_TRACE_START_FLAG(__VA_ARGS__)
#define TRACE_EVENT_START_DATA(...) PW_TRACE_START_DATA(__VA_ARGS__)
#define TRACE_EVENT_START_DATA_FLAG(...) PW_TRACE_START_DATA_FLAG(__VA_ARGS__)
#define TRACE_EVENT_END(...) PW_TRACE_END(__VA_ARGS__)
#define TRACE_EVENT_END_FLAG(...) PW_TRACE_END_FLAG(__VA_ARGS__)
#define TRACE_EVENT_END_DATA(...) PW_TRACE_END_DATA(__VA_ARGS__)
#define TRACE_EVENT_END_DATA_FLAG(...) PW_TRACE_END_DATA_FLAG(__VA_ARGS__)
#define TRACE_EVENT_SCOPE(...) PW_TRACE_SCOPE(__VA_ARGS__)
#define TRACE_EVENT_SCOPE_FLAG(...) PW_TRACE_SCOPE_FLAG(__VA_ARGS__)
#define TRACE_EVENT_FUNCTION(...) PW_TRACE_FUNCTION(__VA_ARGS__)
#define TRACE_EVENT_FUNCTION_FLAG(...) PW_TRACE_FUNCTION_FLAG(__VA_ARGS__)
#define MATTER_TRACE_EVENT_INSTANT(...) PW_TRACE_INSTANT(__VA_ARGS__)
#define MATTER_TRACE_EVENT_INSTANT_FLAG(...) PW_TRACE_INSTANT_FLAG(__VA_ARGS__)
#define MATTER_TRACE_EVENT_INSTANT_DATA(...) PW_TRACE_INSTANT_DATA(__VA_ARGS__)
#define MATTER_TRACE_EVENT_INSTANT_DATA_FLAG(...) PW_TRACE_INSTANT_DATA_FLAG(__VA_ARGS__)
#define MATTER_TRACE_EVENT_START(...) PW_TRACE_START(__VA_ARGS__)
#define MATTER_TRACE_EVENT_START_FLAG(...) PW_TRACE_START_FLAG(__VA_ARGS__)
#define MATTER_TRACE_EVENT_START_DATA(...) PW_TRACE_START_DATA(__VA_ARGS__)
#define MATTER_TRACE_EVENT_START_DATA_FLAG(...) PW_TRACE_START_DATA_FLAG(__VA_ARGS__)
#define MATTER_TRACE_EVENT_END(...) PW_TRACE_END(__VA_ARGS__)
#define MATTER_TRACE_EVENT_END_FLAG(...) PW_TRACE_END_FLAG(__VA_ARGS__)
#define MATTER_TRACE_EVENT_END_DATA(...) PW_TRACE_END_DATA(__VA_ARGS__)
#define MATTER_TRACE_EVENT_END_DATA_FLAG(...) PW_TRACE_END_DATA_FLAG(__VA_ARGS__)
#define MATTER_TRACE_EVENT_SCOPE(...) PW_TRACE_SCOPE(__VA_ARGS__)
#define MATTER_TRACE_EVENT_SCOPE_FLAG(...) PW_TRACE_SCOPE_FLAG(__VA_ARGS__)
#define MATTER_TRACE_EVENT_FUNCTION(...) PW_TRACE_FUNCTION(__VA_ARGS__)
#define MATTER_TRACE_EVENT_FUNCTION_FLAG(...) PW_TRACE_FUNCTION_FLAG(__VA_ARGS__)

#else // defined(PW_TRACE_BACKEND_SET) && PW_TRACE_BACKEND_SET

#define _TRACE_EVENT_DISABLE(...) \
#define _MATTER_TRACE_EVENT_DISABLE(...) \
do \
{ \
} while (0)

#define TRACE_EVENT_INSTANT(...) _TRACE_EVENT_DISABLE(__VA_ARGS__)
#define TRACE_EVENT_INSTANT_FLAG(...) _TRACE_EVENT_DISABLE(__VA_ARGS__)
#define TRACE_EVENT_INSTANT_DATA(...) _TRACE_EVENT_DISABLE(__VA_ARGS__)
#define TRACE_EVENT_INSTANT_DATA_FLAG(...) _TRACE_EVENT_DISABLE(__VA_ARGS__)
#define TRACE_EVENT_START(...) _TRACE_EVENT_DISABLE(__VA_ARGS__)
#define TRACE_EVENT_START_FLAG(...) _TRACE_EVENT_DISABLE(__VA_ARGS__)
#define TRACE_EVENT_START_DATA(...) _TRACE_EVENT_DISABLE(__VA_ARGS__)
#define TRACE_EVENT_START_DATA_FLAG(...) _TRACE_EVENT_DISABLE(__VA_ARGS__)
#define TRACE_EVENT_END(...) _TRACE_EVENT_DISABLE(__VA_ARGS__)
#define TRACE_EVENT_END_FLAG(...) _TRACE_EVENT_DISABLE(__VA_ARGS__)
#define TRACE_EVENT_END_DATA(...) _TRACE_EVENT_DISABLE(__VA_ARGS__)
#define TRACE_EVENT_END_DATA_FLAG(...) _TRACE_EVENT_DISABLE(__VA_ARGS__)
#define TRACE_EVENT_SCOPE(...) _TRACE_EVENT_DISABLE(__VA_ARGS__)
#define TRACE_EVENT_SCOPE_FLAG(...) _TRACE_EVENT_DISABLE(__VA_ARGS__)
#define TRACE_EVENT_FUNCTION(...) _TRACE_EVENT_DISABLE(__VA_ARGS__)
#define TRACE_EVENT_FUNCTION_FLAG(...) _TRACE_EVENT_DISABLE(__VA_ARGS__)
#define MATTER_TRACE_EVENT_INSTANT(...) _MATTER_TRACE_EVENT_DISABLE(__VA_ARGS__)
#define MATTER_TRACE_EVENT_INSTANT_FLAG(...) _MATTER_TRACE_EVENT_DISABLE(__VA_ARGS__)
#define MATTER_TRACE_EVENT_INSTANT_DATA(...) _MATTER_TRACE_EVENT_DISABLE(__VA_ARGS__)
#define MATTER_TRACE_EVENT_INSTANT_DATA_FLAG(...) _MATTER_TRACE_EVENT_DISABLE(__VA_ARGS__)
#define MATTER_TRACE_EVENT_START(...) _MATTER_TRACE_EVENT_DISABLE(__VA_ARGS__)
#define MATTER_TRACE_EVENT_START_FLAG(...) _MATTER_TRACE_EVENT_DISABLE(__VA_ARGS__)
#define MATTER_TRACE_EVENT_START_DATA(...) _MATTER_TRACE_EVENT_DISABLE(__VA_ARGS__)
#define MATTER_TRACE_EVENT_START_DATA_FLAG(...) _MATTER_TRACE_EVENT_DISABLE(__VA_ARGS__)
#define MATTER_TRACE_EVENT_END(...) _MATTER_TRACE_EVENT_DISABLE(__VA_ARGS__)
#define MATTER_TRACE_EVENT_END_FLAG(...) _MATTER_TRACE_EVENT_DISABLE(__VA_ARGS__)
#define MATTER_TRACE_EVENT_END_DATA(...) _MATTER_TRACE_EVENT_DISABLE(__VA_ARGS__)
#define MATTER_TRACE_EVENT_END_DATA_FLAG(...) _MATTER_TRACE_EVENT_DISABLE(__VA_ARGS__)
#define MATTER_TRACE_EVENT_SCOPE(...) _MATTER_TRACE_EVENT_DISABLE(__VA_ARGS__)
#define MATTER_TRACE_EVENT_SCOPE_FLAG(...) _MATTER_TRACE_EVENT_DISABLE(__VA_ARGS__)
#define MATTER_TRACE_EVENT_FUNCTION(...) _MATTER_TRACE_EVENT_DISABLE(__VA_ARGS__)
#define MATTER_TRACE_EVENT_FUNCTION_FLAG(...) _MATTER_TRACE_EVENT_DISABLE(__VA_ARGS__)

#endif // defined(PW_TRACE_BACKEND_SET) && PW_TRACE_BACKEND_SET

0 comments on commit 2185618

Please sign in to comment.