Skip to content

Commit

Permalink
Json tracing updates and fixes (enable in all clusters, fix lists and…
Browse files Browse the repository at this point in the history
… large payloads) (#28022)

* Fix json tracing

* Increase the buffer size for json tracing as well

* Full json trace decoding for all clusters app on linux

* Better formatting of lists - make indices make sense

* Restyle

* Updated comments based on code review

* Restyled by whitespace

* Add error logging when exit container fails

* Fix typo

* Update src/tracing/json/json_tracing.cpp

Co-authored-by: Boris Zbarsky <[email protected]>

* rename [] to Anonymous<> for lists

* Rename exit to end for containers

* Use a `@` format instead of -

* One more anonymous update

* Fix unit tests

---------

Co-authored-by: Andrei Litvin <[email protected]>
Co-authored-by: Restyled.io <[email protected]>
Co-authored-by: Boris Zbarsky <[email protected]>
  • Loading branch information
4 people authored and pull[bot] committed Jan 30, 2024
1 parent f432b43 commit 2e2715f
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 51 deletions.
2 changes: 2 additions & 0 deletions examples/all-clusters-app/linux/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ chip_project_config_include_dirs =
chip_project_config_include_dirs += [ "${chip_root}/config/standalone" ]

matter_enable_tracing_support = true
matter_log_json_payload_decode_full = true
matter_log_json_payload_hex = true

# Perfetto requires C++17
cpp_standard = "gnu++17"
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const Entry<ItemInfo> _all_clusters[] = {

// For any non-structure list like u64[] or similar.
const Entry<ItemInfo> _primitive_type_list[] = {
{ { AnonymousTag(), "[]", ItemType::kDefault }, kInvalidNodeIndex },
{ { AnonymousTag(), "Anonymous<>", ItemType::kDefault }, kInvalidNodeIndex },
};

} // namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def GenerateTables(self) -> Generator[Table, None, None]:
entries=[
TableEntry(
code="AnonymousTag()",
name="[]",
name="Anonymous<>",
reference=name,
real_type="%s[]" % name,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const Entry<ItemInfo> _DemoCluster_ArmFailSafeRequest[] = {
};

const Entry<ItemInfo> _DemoCluster_ArmFailSafeRequest_list_[] = {
{ { AnonymousTag(), "[]", ItemType::kDefault }, 3 }, // DemoCluster_ArmFailSafeRequest[]
{ { AnonymousTag(), "Anonymous<>", ItemType::kDefault }, 3 }, // DemoCluster_ArmFailSafeRequest[]
};

const Entry<ItemInfo> _all_clusters[] = {
Expand All @@ -29,7 +29,7 @@ const Entry<ItemInfo> _all_clusters[] = {

// For any non-structure list like u64[] or similar.
const Entry<ItemInfo> _primitive_type_list[] = {
{ { AnonymousTag(), "[]", ItemType::kDefault }, kInvalidNodeIndex },
{ { AnonymousTag(), "Anonymous<>", ItemType::kDefault }, kInvalidNodeIndex },
};

} // namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const Entry<ItemInfo> _all_clusters[] = {

// For any non-structure list like u64[] or similar.
const Entry<ItemInfo> _primitive_type_list[] = {
{ { AnonymousTag(), "[]", ItemType::kDefault }, kInvalidNodeIndex },
{ { AnonymousTag(), "Anonymous<>", ItemType::kDefault }, kInvalidNodeIndex },
};

} // namespace
Expand Down
10 changes: 9 additions & 1 deletion src/lib/format/protocol_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,15 @@ void PayloadDecoderBase::ExitContainer(PayloadEntry & entry)
{
mPayloadPosition.Exit();
}
mReader.ExitContainer(mNestingEnters[--mCurrentNesting]);
CHIP_ERROR err = mReader.ExitContainer(mNestingEnters[--mCurrentNesting]);
if (err != CHIP_NO_ERROR)
{
mValueBuilder.AddFormat("ERROR: %" CHIP_ERROR_FORMAT, err.Format());
mNameBuilder.AddFormat("END CONTAINER");
entry = PayloadEntry::SimpleValue(mNameBuilder.c_str(), mValueBuilder.c_str());
mState = State::kDone;
return;
}
}

if (mCurrentNesting == 0)
Expand Down
82 changes: 41 additions & 41 deletions src/lib/format/tests/TestDecoding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,82 +174,82 @@ void TestFullDataDecoding(nlTestSuite * inSuite, void * inContext)
TestSampleData(inSuite, params, im_protocol_read_request,
"read_request\n"
" attribute_requests\n"
" []\n"
" Anonymous<>\n"
" cluster_id: 49 == 'NetworkCommissioning'\n"
" attribute_id: 65532 == 'featureMap'\n"
" []\n"
" Anonymous<>\n"
" endpoint_id: 0\n"
" cluster_id: 48 == 'GeneralCommissioning'\n"
" attribute_id: 0 == 'breadcrumb'\n"
" []\n"
" Anonymous<>\n"
" endpoint_id: 0\n"
" cluster_id: 48 == 'GeneralCommissioning'\n"
" attribute_id: 1 == 'basicCommissioningInfo'\n"
" []\n"
" Anonymous<>\n"
" endpoint_id: 0\n"
" cluster_id: 48 == 'GeneralCommissioning'\n"
" attribute_id: 2 == 'regulatoryConfig'\n"
" []\n"
" Anonymous<>\n"
" endpoint_id: 0\n"
" cluster_id: 48 == 'GeneralCommissioning'\n"
" attribute_id: 3 == 'locationCapability'\n"
" []\n"
" Anonymous<>\n"
" endpoint_id: 0\n"
" cluster_id: 40 == 'BasicInformation'\n"
" attribute_id: 2 == 'vendorID'\n"
" []\n"
" Anonymous<>\n"
" endpoint_id: 0\n"
" cluster_id: 40 == 'BasicInformation'\n"
" attribute_id: 4 == 'productID'\n"
" []\n"
" Anonymous<>\n"
" cluster_id: 49 == 'NetworkCommissioning'\n"
" attribute_id: 3 == 'connectMaxTimeSeconds'\n"
" fabric_filtered: false\n"
" interaction_model_revison: 1\n");
TestSampleData(inSuite, params, im_protocol_report_data,
"report_data\n"
" attribute_reports\n"
" []\n"
" Anonymous<>\n"
" attribute_data\n"
" data_version: 28559721\n"
" path\n"
" endpoint_id: 0\n"
" cluster_id: 49 == 'NetworkCommissioning'\n"
" attribute_id: 3 == 'connectMaxTimeSeconds'\n"
" NetworkCommissioning::connectMaxTimeSeconds: 0\n"
" []\n"
" Anonymous<>\n"
" attribute_data\n"
" data_version: 664978787\n"
" path\n"
" endpoint_id: 0\n"
" cluster_id: 40 == 'BasicInformation'\n"
" attribute_id: 4 == 'productID'\n"
" BasicInformation::productID: 32769\n"
" []\n"
" Anonymous<>\n"
" attribute_data\n"
" data_version: 664978787\n"
" path\n"
" endpoint_id: 0\n"
" cluster_id: 40 == 'BasicInformation'\n"
" attribute_id: 2 == 'vendorID'\n"
" BasicInformation::vendorID: 65521\n"
" []\n"
" Anonymous<>\n"
" attribute_data\n"
" data_version: 1414030794\n"
" path\n"
" endpoint_id: 0\n"
" cluster_id: 48 == 'GeneralCommissioning'\n"
" attribute_id: 3 == 'locationCapability'\n"
" GeneralCommissioning::locationCapability: 2 == kIndoorOutdoor\n"
" []\n"
" Anonymous<>\n"
" attribute_data\n"
" data_version: 1414030794\n"
" path\n"
" endpoint_id: 0\n"
" cluster_id: 48 == 'GeneralCommissioning'\n"
" attribute_id: 2 == 'regulatoryConfig'\n"
" GeneralCommissioning::regulatoryConfig: 0 == kIndoor\n"
" []\n"
" Anonymous<>\n"
" attribute_data\n"
" data_version: 1414030794\n"
" path\n"
Expand All @@ -259,15 +259,15 @@ void TestFullDataDecoding(nlTestSuite * inSuite, void * inContext)
" GeneralCommissioning::basicCommissioningInfo\n"
" failSafeExpiryLengthSeconds: 60\n"
" maxCumulativeFailsafeSeconds: 900\n"
" []\n"
" Anonymous<>\n"
" attribute_data\n"
" data_version: 1414030794\n"
" path\n"
" endpoint_id: 0\n"
" cluster_id: 48 == 'GeneralCommissioning'\n"
" attribute_id: 0 == 'breadcrumb'\n"
" GeneralCommissioning::breadcrumb: 0\n"
" []\n"
" Anonymous<>\n"
" attribute_data\n"
" data_version: 28559721\n"
" path\n"
Expand All @@ -282,19 +282,19 @@ void TestFullDataDecoding(nlTestSuite * inSuite, void * inContext)
TestSampleData(inSuite, params, im_protocol_report_data_acl,
"report_data\n"
" attribute_reports\n"
" []\n"
" Anonymous<>\n"
" attribute_data\n"
" data_version: 3420147058\n"
" path\n"
" endpoint_id: 0\n"
" cluster_id: 31 == 'AccessControl'\n"
" attribute_id: 0 == 'acl'\n"
" AccessControl::acl\n"
" []\n"
" Anonymous<>\n"
" privilege: 5 == kAdminister\n"
" authMode: 2 == kCASE\n"
" subjects\n"
" []: 112233\n"
" Anonymous<>: 112233\n"
" targets: NULL\n"
" fabricIndex: 1\n"
" suppress_response: true\n"
Expand All @@ -304,7 +304,7 @@ void TestFullDataDecoding(nlTestSuite * inSuite, void * inContext)
inSuite, params, im_protocol_report_data_window_covering,
"report_data\n"
" attribute_reports\n"
" []\n"
" Anonymous<>\n"
" attribute_data\n"
" data_version: 2054986218\n"
" path\n"
Expand All @@ -320,7 +320,7 @@ void TestFullDataDecoding(nlTestSuite * inSuite, void * inContext)
" suppress_response: false\n"
" timed_request: false\n"
" invoke_requests\n"
" []\n"
" Anonymous<>\n"
" path\n"
" endpoint_id: 1\n"
" cluster_id: 6 == 'OnOff'\n"
Expand All @@ -332,7 +332,7 @@ void TestFullDataDecoding(nlTestSuite * inSuite, void * inContext)
"invoke_response\n"
" suppress_response: false\n"
" invoke_responses\n"
" []\n"
" Anonymous<>\n"
" status\n"
" path\n"
" endpoint_id: 1\n"
Expand All @@ -347,7 +347,7 @@ void TestFullDataDecoding(nlTestSuite * inSuite, void * inContext)
" suppress_response: false\n"
" timed_request: false\n"
" invoke_requests\n"
" []\n"
" Anonymous<>\n"
" path\n"
" endpoint_id: 1\n"
" cluster_id: 1284 == 'Channel'\n"
Expand Down Expand Up @@ -375,98 +375,98 @@ void TestMetaDataOnlyDecoding(nlTestSuite * inSuite, void * inContext)
TestSampleData(inSuite, params, im_protocol_read_request,
"read_request\n"
" attribute_requests\n"
" []\n"
" Anonymous<>\n"
" cluster_id: 49\n"
" attribute_id: 65532\n"
" []\n"
" Anonymous<>\n"
" endpoint_id: 0\n"
" cluster_id: 48\n"
" attribute_id: 0\n"
" []\n"
" Anonymous<>\n"
" endpoint_id: 0\n"
" cluster_id: 48\n"
" attribute_id: 1\n"
" []\n"
" Anonymous<>\n"
" endpoint_id: 0\n"
" cluster_id: 48\n"
" attribute_id: 2\n"
" []\n"
" Anonymous<>\n"
" endpoint_id: 0\n"
" cluster_id: 48\n"
" attribute_id: 3\n"
" []\n"
" Anonymous<>\n"
" endpoint_id: 0\n"
" cluster_id: 40\n"
" attribute_id: 2\n"
" []\n"
" Anonymous<>\n"
" endpoint_id: 0\n"
" cluster_id: 40\n"
" attribute_id: 4\n"
" []\n"
" Anonymous<>\n"
" cluster_id: 49\n"
" attribute_id: 3\n"
" fabric_filtered: false\n"
" interaction_model_revison: 1\n");
TestSampleData(inSuite, params, im_protocol_report_data,
"report_data\n"
" attribute_reports\n"
" []\n"
" Anonymous<>\n"
" attribute_data\n"
" data_version: 28559721\n"
" path\n"
" endpoint_id: 0\n"
" cluster_id: 49\n"
" attribute_id: 3\n"
" ATTRIBUTE: 49/3\n"
" []\n"
" Anonymous<>\n"
" attribute_data\n"
" data_version: 664978787\n"
" path\n"
" endpoint_id: 0\n"
" cluster_id: 40\n"
" attribute_id: 4\n"
" ATTRIBUTE: 40/4\n"
" []\n"
" Anonymous<>\n"
" attribute_data\n"
" data_version: 664978787\n"
" path\n"
" endpoint_id: 0\n"
" cluster_id: 40\n"
" attribute_id: 2\n"
" ATTRIBUTE: 40/2\n"
" []\n"
" Anonymous<>\n"
" attribute_data\n"
" data_version: 1414030794\n"
" path\n"
" endpoint_id: 0\n"
" cluster_id: 48\n"
" attribute_id: 3\n"
" ATTRIBUTE: 48/3\n"
" []\n"
" Anonymous<>\n"
" attribute_data\n"
" data_version: 1414030794\n"
" path\n"
" endpoint_id: 0\n"
" cluster_id: 48\n"
" attribute_id: 2\n"
" ATTRIBUTE: 48/2\n"
" []\n"
" Anonymous<>\n"
" attribute_data\n"
" data_version: 1414030794\n"
" path\n"
" endpoint_id: 0\n"
" cluster_id: 48\n"
" attribute_id: 1\n"
" ATTRIBUTE: 48/1\n"
" []\n"
" Anonymous<>\n"
" attribute_data\n"
" data_version: 1414030794\n"
" path\n"
" endpoint_id: 0\n"
" cluster_id: 48\n"
" attribute_id: 0\n"
" ATTRIBUTE: 48/0\n"
" []\n"
" Anonymous<>\n"
" attribute_data\n"
" data_version: 28559721\n"
" path\n"
Expand All @@ -481,7 +481,7 @@ void TestMetaDataOnlyDecoding(nlTestSuite * inSuite, void * inContext)
TestSampleData(inSuite, params, im_protocol_report_data_acl,
"report_data\n"
" attribute_reports\n"
" []\n"
" Anonymous<>\n"
" attribute_data\n"
" data_version: 3420147058\n"
" path\n"
Expand All @@ -503,7 +503,7 @@ void TestEmptyClusterMetaDataDecode(nlTestSuite * inSuite, void * inContext)
TestSampleData(inSuite, params, im_protocol_report_data_acl,
"report_data\n"
" attribute_reports\n"
" []\n"
" Anonymous<>\n"
" attribute_data\n"
" data_version: 3420147058\n"
" path\n"
Expand Down
Loading

0 comments on commit 2e2715f

Please sign in to comment.