Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FF master -> dev branch #3

Merged
merged 55 commits into from
Jun 5, 2023
Merged

Conversation

marktrayer
Copy link
Owner

FF master -> dev branch

andy31415 and others added 30 commits May 31, 2023 18:55
#26958)

This is ending up not working quite right because when structs have struct-typed
(or list-of-struct-typed) fields, the type expectations people have get messed
up.  They're still messed up even after this PR, but at least we're not sort of
promising they won't be messed up.

This reverts #26763 and #26495.
It's building 6 example apps plus darwin-framework-tool.  The example apps now
take 8-10 minutes each in CI, and darwin-framework-tool takes 15-20, so 75
minutes is too short.
bt_adapter_le_set_advertising_flags() is provided from Tizen 8.0

Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
Log message is clearly copy and pasted and has not been adapted.
…#26960)

* Fix Thread diagnostic nullable attributes so they read as null when the device is not associated to a thread network. Add a encoding method to encode directly encode null when a provide condition evaluate to false

* Revert "Fix Thread diagnostic nullable attributes so they read as null when the device is not associated to a thread network. Add a encoding method to encode directly encode null when a provide condition evaluate to false"

This reverts commit 0a406ac.

* Simplify how the nullEncode cases are caught. The condition is based on dataset being commissioned rather than the attachment state as valuable data can be fetched with the dataset even if thread is detached or disabled

* update comment

* Apply suggestions from code review

Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>

---------

Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
Regular update of nRF Connect SDK to 2.4.0 version
* [Telink]: Added delegate to shut down BLE after commissioning window timed out

Signed-off-by: Misha Tkachenko <misha.tkachenko@telink-semi.com>

* Restyled by clang-format

* [Telink]: Fixed wrong behavior on Commissioning window close

Signed-off-by: Misha Tkachenko <misha.tkachenko@telink-semi.com>

* Restyled by whitespace

* Restyled by clang-format

---------

Signed-off-by: Misha Tkachenko <misha.tkachenko@telink-semi.com>
Co-authored-by: Misha Tkachenko <misha.tkachenko@telink-semi.com>
Co-authored-by: Restyled.io <commits@restyled.io>
Co-authored-by: Misha Tkachenko <36621698+mishadesh@users.noreply.github.com>
* [K32W0] Sync with SDK NCCL change

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* [K32W0] Add a flag chip_with_pdm_encryption to disable PDM encryption

* [K32W0] Fix name for OPENTHREAD_CONFIG_MAC_DEFAULT_MAX_FRAME_RETRIES_DIRECT

* [K32W0] Fix reboot reason bug

* [K32W0] Change date type for rebootCause, uint8_t is enough

* [K32W0] Add stop advertising retry

If stop advertising fails (timeout on event wait), then
rearm the timer as fast as possible to retry.
Once stop advertising is successful, slow advertising can start.

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* [K32W0] Add ExitAction to OTATlvProcessor API

An OTA TLV processor should have the option of executing an action
when before a new processor is selected. This is called an exit
action. It should be useful in the context of transferring multiple
OTA images in external flash.

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* [K32W0] Update OTA SDK usage

* Application and bootloader processors are now the same, referred to as
firmware processor.
* Application can now register callbacks for descriptor
processing.
* When using default processors, the OTA flags gOTAUseCustomOtaEntry
and gOTAAllowCustomStartAddress are defined and set to 1.

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* [K32W0] Add JSON support for custom TLVs

*A user can now specify a custom TLV format (tag, descriptor and path)
by following the design of the ota_payload.schema. Option `--json` should
be used to specify the JSON file path.
* Add SSBL payload generation.

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* [K32W0] Call ExitAction from TLV processor when all block has been consumed - Move code from ApplyAction to ExitAction method

* [K32W0] Update usage of new OTA SDK APIs

* [K32W0] Set custom OTA entry flags

Custom OTA entry structure will be saved at the top of external flash by default.
Fix heap start address. It should start after the stack size is subtracted from the top.

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* [K32W0] Access OTA entry at Init and check OTA status

* [K32W0] Update OTA tool to support SSBL

Add a few examples to generate:
* application update image
* factory data update image
* SSBL update image
* app + SSBL + factory data update image
* maximum number of custom OTA entries image

Add README for K32W OTA.

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* [K32W0] Add example for max entries testing

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* [K32W0] Split default processors options

* chip_enable_ota_firmware_processor enables the firmware (App/SSBL)
processor. Enabled by default.
* chip_enable_ota_factory_data_processor enables the factory data
processor. Disabled by default.

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* [K32W0] Update README SSBL/PSECT sections

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* [K32W0] Bring README files up to date

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* [K32W0] Fix chip_crypto_flavour name

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* [K32W0] Fix readmes for k32w0 apps

* [K32W0] Update SecLib path in SDK build file

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* [K32W0] Fix typo in README files regarding OTA image tool

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* [K32W0] Extend factory data restore mechanism

The default restore mechanism is implemented as a weak function:
`FactoryDataDefaultRestoreMechanism`. It is registered in
`K32W0FactoryDataProvider::Init`, before factory data validation,
and it can be overwritten at application level.

Application can register additional restore mechanisms using the API:
`K32W0FactoryDataProvider::RegisterRestoreMechanism`.

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* [K32W0] Improve rotating device id

Add README section related to rotating device id.
If unique id is not found in factory data, use the
default one.

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* [K32W0] Fix error status for rotating device id getter

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* [K32W0] Add retry mechanism when OTA is aborted

Upon an aborted transfer, the OTA will retry a query on the
backed up provider if CONFIG_CHIP_K32W0_OTA_ABORT_HOOK is set.

The retry mechanism is disabled by default.

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* [K32W0] Add ota_custom_entry_address option

ota_custom_entry_address specifies at which address in external flash
the OTA custom entry is saved during OTA. By default, it is set to the
end of the PDM area: 0x000C1000.

Add internal/external flash description in linker.

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* [K32W0] Revert all applied actions upon error

AbortAction for all selected OTA TLV processors will be called
if any processor fails to apply its action. This is a safety
mechanism to avoid having incompatible apps/data caused by partial
updates (e.g. incompatibility between SSBL and app).

Other changes:
* Clean factory data RAM buffer

* Increase reset resilience during OTA

During OTA, if factory data is updated, it is firstly backed up
in a PDM entry with id kNvmId_FactoryDataBackup. This entry should
be deleted only if the OTA entry state is otaApplied, which means
the device reset happened as expected.

If OTA entry state is not otaApplied, it means the reset was caused
by a different factor (e.g. power loss etc.) and the factory data
should be restored from the PDM (for the default registered mechanism).

* AbortAction should delete PDM id for factory data backup

* Add reset state for OTATlvProcessor base class

Derived classes should call OTATlvProcessor::ClearInternal() whenever
they want to reset their state.

* Update abort action for firmware processor

OTA_ResetCurrentEepromAddress should be called before setting
the offset to 0 through OTA_SetStartEepromOffset. Otherwise,
a check in OTA_SetStartEepromOffset will fail and the state is
not reset correctly.

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* [K32W0] Add SPIFI_DUAL_MODE_SUPPORT info in README files

For K32W041AM, the multi-image SSBL must also be compiled with
SPIFI_DUAL_MODE_SUPPORT=1.

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* [K32W0] Enclose CheckOtaEntry in OTA flag

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* [K32W0] Enclose factory data backup usage in corresponding flag

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* [K32W0] Update SDK in README files

Fix minor issue with image partitions information.

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* [K32W0] Fix DiagnosticDataProvider memory leak

GetNetworkInterfaces returns some dynamically allocated data,
which is supposed to be freed upon calling ReleaseNetworkInterfaces.

Our platform implementation was using the default implementation of
ReleaseNetworkInterfaces (which does nothing). This is an obvious memory leak,
since subsequent calls to GetNetworkInterfaces dynamically allocated data that
was never freed.

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* [K32W0] Automate output binary signing

Add BUILD.gn changes to call a python script postbuild
that signs the output binary.

Add signing python script.

Update readme files.

Signed-off-by: Andrei Menzopol <andrei.menzopol@nxp.com>

* [K32W0] Fix chip_crypto_flavor typo

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* [K32W0] Bump ot-nxp to latest

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* [K32W0] Fix OTA generation tool

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* [K32W0] Bump ot-nxp to latest

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* [K32W0] Sync scripts and generated data with development

Updated manufacturing flow.

Signed-off-by: Mihai Ignat <mihai.ignat@nxp.com>
Signed-off-by: Marius Tache <marius.tache@nxp.com>

* [K32W0] Bump ot-nxp to latest

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* Restyled by whitespace

* Restyled by clang-format

* Restyled by gn

* Restyled by prettier-markdown

* Restyled by shellharden

* Restyled by shfmt

* Restyled by autopep8

* Restyled by isort

* [K32W0] Fix spell check

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* [K32W0] Remove some binary examples (not used)

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* [K32W0] Fix some lint errors

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* [K32W0] Update workflow example yaml to latest

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* Restyled by prettier-markdown

* [K32W0] Fix script issues

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* Restyled by autopep8

* Restyled by isort

* [K32W0] Add PDM ID base value for apps

Applications should use kNvmId_ApplicationBase alongside an
offset to generate their own PDM IDs.

Signed-off-by: Marius Tache <marius.tache@nxp.com>

* Restyled by clang-format

---------

Signed-off-by: Marius Tache <marius.tache@nxp.com>
Signed-off-by: Andrei Menzopol <andrei.menzopol@nxp.com>
Signed-off-by: Mihai Ignat <mihai.ignat@nxp.com>
Co-authored-by: tanyue518 <ethan.tan@nxp.com>
Co-authored-by: Martin Cuvelier <martin.cuvelier@nxp.com>
Co-authored-by: Mihai Ignat <mihai.ignat@nxp.com>
Co-authored-by: Andrei Menzopol <andrei.menzopol@nxp.com>
Co-authored-by: Restyled.io <commits@restyled.io>
* Add Replaceable Monitoring Clusters to All Clusters Example

#26831

* Fix Formatting

#26831
Bumps [third_party/pigweed/repo](https://github.com/google/pigweed) from `da76d13` to `d6b036c`.
- [Commits](google/pigweed@da76d13...d6b036c)

---
updated-dependencies:
- dependency-name: third_party/pigweed/repo
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Andrei Litvin <andreilitvin@google.com>
* [Telink]: Added delegate to shut down BLE after commissioning window timed out

Signed-off-by: Misha Tkachenko <misha.tkachenko@telink-semi.com>

* Restyled by clang-format

* [Telink]: Fixed wrong behavior on Commissioning window close

Signed-off-by: Misha Tkachenko <misha.tkachenko@telink-semi.com>

* Restyled by whitespace

* Restyled by clang-format

---------

Signed-off-by: Misha Tkachenko <misha.tkachenko@telink-semi.com>
Co-authored-by: Misha Tkachenko <misha.tkachenko@telink-semi.com>
Co-authored-by: Restyled.io <commits@restyled.io>
Co-authored-by: Misha Tkachenko <36621698+mishadesh@users.noreply.github.com>
Co-authored-by: Andrei Litvin <andreilitvin@google.com>
* Fix TC_DA_1_7.py PAA parser

- Fix TC_DA_1_7.py not to blow-up on bad PAAs, just log them.
- Fix PAA fetcher to do the same

Fixes #26979

* Update DCL mirror as of May 31, 2023

- Fix NXP DER conversion --> not 100% legal format, but kept
  since only TC_DA_1_7.py library complains
- Updated all from local run.

Commands executed from root of SDK:

```
  pip install click_option_group # somehow missing from requirements
  cd credentials/development
  python ../fetch-paa-certs-from-dcl.py --use-test-net-http
  cd ../production
  python ../fetch-paa-certs-from-dcl.py --use-main-net-http
  git add credentials/
```

Fixes #26424

* Restyled by autopep8

* Update DCL PAAs on May 31, 2023

Commands run from root. Includes temporary NXP fixups

```
cd credentials/development
rm dcld_mirror_*
python ../fetch-paa-certs-from-dcl.py --use-test-net-http
python ../fetch-paa-certs-from-dcl.py --use-main-net-http

openssl x509 -inform pem -in paa-root-certs/dcld_mirror_SERIALNUMBER_63709330400001_CN_NXP_Matter_PAA_O_NXP_Semiconductors_NV_C_NL.pem -outform der -out paa-root-certs/dcld_mirror_SERIALNUMBER_63709330400001_CN_NXP_Matter_PAA_O_NXP_Semiconductors_NV_C_NL.der
openssl x509 -inform pem -in paa-root-certs/dcld_mirror_SERIALNUMBER_63709380400001_CN_NXP_Matter_Test_PAA_O_NXP_Semiconductors_NV_C_NL.pem -outform der -out paa-root-certs/dcld_mirror_SERIALNUMBER_63709380400001_CN_NXP_Matter_Test_PAA_O_NXP_Semiconductors_NV_C_NL.der

cd ../production
rm dcld_mirror_*
python ../fetch-paa-certs-from-dcl.py --use-main-net-http
openssl x509 -inform pem -in paa-root-certs/dcld_mirror_SERIALNUMBER_63709330400001_CN_NXP_Matter_PAA_O_NXP_Semiconductors_NV_C_NL.pem -outform der -out paa-root-certs/dcld_mirror_SERIALNUMBER_63709330400001_CN_NXP_Matter_PAA_O_NXP_Semiconductors_NV_C_NL.der

cd ../..
git add credentials
```

* Add allowlist of skipped PAAs to TC_DA_1_7

* Fix formatting again

* Restyled by autopep8

---------

Co-authored-by: tennessee.carmelveilleux@gmail.com <tennessee@google.com>
Co-authored-by: Restyled.io <commits@restyled.io>
)

* Update Network Commissioning cluster XML to match specification.

Spec changes happened in CHIP-Specifications/connectedhomeip-spec#6193

Fixes #25008

* Auto-update ZAP files.

* Regenerate generated code.
When CHIP_SYSTEM_CONFIG_USE_LIBEV is set, SystemLayerImplSelect expects a *libev* mainloop to be present to schedule timers and socket watches (similar to CHIP_SYSTEM_CONFIG_USE_DISPATCH for Darwin).

A libev mainloop must be passed to SystemLayer using `SetLibEvLoop()` before any timers or socket watches are used - otherwise, `chipDie()` is invoked.

Platform manager events are also dispatched via the libev mainloop, using
ScheduleWork(). This eliminates the need for a separate thread for
dispatching events, and makes sure event handlers cannot run in parallel
with timers or I/O handlers. In consequence PostEvent() may not be called
without holding the chip lock.

The reason for running *matter* under libev in the first place
is to allow creating single-threaded apps including all of *matter*.
So disallowing PostEvent() "from any thread" is a design choice for
the libev case.

# Usage
The entire project needs to be build with `CHIP_SYSTEM_CONFIG_USE_LIBEV=1` (this can be done via invoking a project-specific extra config via the `default_configs_extra` argument in args.gni)

Setting up the libev mainloop and handing it over to SystemLayer must be done in application specific code, outside the code provided by chip examples. Also adding libev as a dependency must be done in the application's BUILD.gn.

# Background
*libev* is a multi-platform event library often used in embedded linux context to handle events, and builds the basis for various libraries with non-blocking APIs. This changeset allows using the *matter* stack with libev based applications.

# Example
The opensource bridge project p44mbrd (https://github.com/plan44/p44mbrd) is based on libev and makes use of this changeset.
* Starting with some basic class declarations

* Start defining macros for building things

* implement a convenience method for scoping traces

* Restyle

* Prepare for some testing infrastructure for tracing

* Make code compile

* Implement some backend support

* Restyle

* We now have simple tracing unit tests

* More unit tests that work

* Add chip thread locking assertions

* more documentation

* Restyle

* Make spellchecker happy

* Restyle

* Minor comment fix

* Code review updates

* add numbers to scopes

* Add numeric values to instant tracing values

* Fix uniqueness for scopes

* Use std::vector and algorithm equals to make tidy happy

---------

Co-authored-by: Andrei Litvin <andreilitvin@google.com>
These jobs are very slow, and we are already running the python-driver tests
here, as well as running the old-style tests on Darwin asan and Linux tsan.
* Fix Linux build break when thread is disabled

* Fix bloat check report
)

* Base application modifications for SiWx917 SoC

* Restyled by clang-format

---------

Co-authored-by: Restyled.io <commits@restyled.io>
* Use zcl_clusters instead of all_user_clusters

* zap regen all

* Move CHIPClientCallbacks.zapt into src/controller/java/templates

* Remove one more instance from CHIPClientCallbacks.h

* Remove more referencese to CHIPClientCallbacks.h

* Move file to the right location and regen-all

* update a LOT of paths to the new java-generated path

* Test regen

* Restyled by clang-format

---------

Co-authored-by: Andrei Litvin <andreilitvin@google.com>
Co-authored-by: Restyled.io <commits@restyled.io>
* Resolve issue with UserPrompts in test harness.

* Update UserPrompt to match legacy behavior if not expected value is set in YAML

* Update documentation and typing for request parameter.

* Add documentation of UserPrompt logging in step_start

* Make reference link a permalink
Co-authored-by: Andrei Litvin <andreilitvin@google.com>
cecille and others added 4 commits June 5, 2023 11:29
* TC-DA-1.7: Documentation for how to test locally

* Apply suggestions from code review
* Modify to use onboardingpayload library

* restyle

* Fix Android tv-app build error

* Modify android app test data

* restyle

* Fix build error
* Updated the mode select xml to match the current spec.

* Added the version bump to the mode select cluster as per PR comment.

* Fixed new command xml definitions missing the response and disableDefaultResponse specifiers.

* Renamed the mode select feature map fields to match the general behavior.

* Added data-model XML definitions for all Mode Select aliased clusters.

* Added the Mode Select alias clusters' XMLs to the relevant lists.

* Updated the controller zap file to include the new clusters.

* Fixed errors in the Mode Select alias' XML feature maps.

* Added generated code

* Restyled by prettier-json

* Simplified the Mode Select cluster XMLs.

* Matched the ModeSelect alias clusters' version to the ModeSelect cluster.

* Update src/app/zap-templates/zcl/data-model/chip/mode-select-cluster.xml

Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>

* Removed white spaces in ChangeToModeResponseStatus items

* removed the STANDARD_NAMESPACE attribute from ModeSelect XMLs

* Update src/app/zap-templates/zcl/data-model/chip/dishwasher-mode-select-cluster.xml

Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>

* Rnamed the Laundry Washer cluster to match the spec. Removed reading of depricated StandardNamespace in the TestModeSelectCluster.yaml.

* Added generated code after merge.

* Readded the STANDARD_NAMESPACE attribute to the ModeSelect XML as optional to avoid braking client APIs.

* Renamed the laundyr washer XML to match the cluster name as defined in the spec.

* Renamed the mode select alias clusters to match the latest spec changes. Fixes issue #26551.

* Updated the RVC Run ChangeToModeResponseStatus enums to match the latest spec.

* Changed the enum names based on the spec PR 6986.

* Added generated code after merge. Updated the mode select example following the renaming of the semantic tags.

* Added TagName to the ModeOptionStruct following the spce change in PR 6969.

* Depricated the MfgCode in ModeOptionStruct following the spec change in PR 6989.

* regenerated zap code.

* Generated the zap code. Updated the ModeSelect all-clustres-app example.

* Restyled by clang-format

* Updated the use of semantic tags. in the esp32 examples.

* Regenerated code after merge.

* Restyled by clang-format

* Regenerated code after merge.

* Fixed linux build.

* Fixed fake linux build...

* Updated the TestModeSelectCluster.yaml to match the new name change.

* Added expeted generated files to src/controller/data_model/BUILD.gn and sorted the list.

* Restyled by clang-format

* Restyled by prettier-yaml

* Added generated code

* Regenerated code after merge.

---------

Co-authored-by: Restyled.io <commits@restyled.io>
Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
@marktrayer marktrayer merged commit 3d8d4c9 into marktrayer:opstateyaml Jun 5, 2023
marktrayer pushed a commit that referenced this pull request Jun 26, 2023
* Fix ThreadSanitizer failure in controller factory.

The failure looks like this:

  WARNING: ThreadSanitizer: race on NSMutableArray (pid=11619)
    Read-only access of NSMutableArray at 0x7b0c0005f5b0 by thread T3:
      #0 -[__NSArrayM countByEnumeratingWithState:objects:count:] <null>:2 (CoreFoundation:x86_64+0x4a338)
      #1 -[MTRDeviceControllerFactory(InternalMethods) operationalInstanceAdded:] MTRDeviceControllerFactory.mm:855 (Matter:x86_64+0x1fd2a)
      #2 MTROperationalBrowser::OnBrowse(_DNSServiceRef_t*, unsigned int, unsigned int, int, char const*, char const*, char const*, void*) MTROperationalBrowser.mm:100 (Matter:x86_64+0x20ee63c)
      #3 handle_browse_response <null>:2 (libsystem_dnssd.dylib:x86_64+0x3733)
      project-chip#4 _dispatch_client_callout <null>:2 (libdispatch.dylib:x86_64+0x3316)

    Previous modifying access of NSMutableArray at 0x7b0c0005f5b0 by main thread:
      #0 -[__NSArrayM addObject:] <null>:2 (CoreFoundation:x86_64+0x2457a)
      #1 -[MTRDeviceControllerFactory createController] MTRDeviceControllerFactory.mm:719 (Matter:x86_64+0x1cee3)
      #2 -[MTRDeviceControllerFactory createControllerOnExistingFabric:error:] MTRDeviceControllerFactory.mm:534 (Matter:x86_64+0x19792)

The basic problem is that we are in the middle of adding an object to
_controllers on the API consumer thread when on the Matter thread we get our
browse notification.

The changes here don't aim to lock around all access to _controllers, but just
to make sure that our mutations of it can't race with the access on the Matter
thread.  More coarse locking would need to be done very carefully, given the
amount of dispath_sync to the Matter thread we have going on.

* Address review comments.
marktrayer pushed a commit that referenced this pull request Oct 24, 2023
…ist". (project-chip#29666)

The typical failure there looks like this:

==29620==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 88 byte(s) in 1 object(s) allocated from:
    #0 0x106396e12 in calloc+0xa2 (libclang_rt.asan_osx_dynamic.dylib:x86_64+0x51e12)
    #1 0x7ff800dc9789 in map_images_nolock+0x24b (libobjc.A.dylib:x86_64h+0x1789)
    #2 0x7ff800dc94db in map_images+0x42 (libobjc.A.dylib:x86_64h+0x14db)
    #3 0x113d721fa in invocation function for block in dyld4::RuntimeState::setObjCNotifiers(void (*)(unsigned int, char const* const*, mach_header const* const*), void (*)(char const*, mach_header const*), void (*)(char const*, mach_header const*))+0x112 (dyld:x86_64+0xf1fa)
    project-chip#4 0x113d6d6c8 in dyld4::RuntimeState::withLoadersReadLock(void () block_pointer)+0x28 (dyld:x86_64+0xa6c8)
    project-chip#5 0x113d720e1 in dyld4::RuntimeState::setObjCNotifiers(void (*)(unsigned int, char const* const*, mach_header const* const*), void (*)(char const*, mach_header const*), void (*)(char const*, mach_header const*))+0x51 (dyld:x86_64+0xf0e1)
    project-chip#6 0x113d85d44 in dyld4::APIs::_dyld_objc_notify_register(void (*)(unsigned int, char const* const*, mach_header const* const*), void (*)(char const*, mach_header const*), void (*)(char const*, mach_header const*))+0x4e (dyld:x86_64+0x22d44)
    project-chip#7 0x7ff800dc9343 in _objc_init+0x4fe (libobjc.A.dylib:x86_64h+0x1343)
    project-chip#8 0x7ff800d83992 in _os_object_init+0xc (libdispatch.dylib:x86_64+0x2992)
    project-chip#9 0x7ff800d911b7 in libdispatch_init+0x136 (libdispatch.dylib:x86_64+0x101b7)
    project-chip#10 0x7ff80bd34894 in libSystem_initializer+0xed (libSystem.B.dylib:x86_64+0x1894)
    project-chip#11 0x113d77e4e in invocation function for block in dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const+0xb5 (dyld:x86_64+0x14e4e)
    project-chip#12 0x113d9eaac in invocation function for block in dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, dyld3::MachOAnalyzer::VMAddrConverter const&, void (unsigned int) block_pointer, void const*) const+0xf1 (dyld:x86_64+0x3baac)
    project-chip#13 0x113d95e25 in invocation function for block in dyld3::MachOFile::forEachSection(void (dyld3::MachOFile::SectionInfo const&, bool, bool&) block_pointer) const+0x22c (dyld:x86_64+0x32e25)
    project-chip#14 0x113d64db2 in dyld3::MachOFile::forEachLoadCommand(Diagnostics&, void (load_command const*, bool&) block_pointer) const+0x80 (dyld:x86_64+0x1db2)
    project-chip#15 0x113d95bb6 in dyld3::MachOFile::forEachSection(void (dyld3::MachOFile::SectionInfo const&, bool, bool&) block_pointer) const+0xb2 (dyld:x86_64+0x32bb6)
    project-chip#16 0x113d9e603 in dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, dyld3::MachOAnalyzer::VMAddrConverter const&, void (unsigned int) block_pointer, void const*) const+0x1d1 (dyld:x86_64+0x3b603)
    project-chip#17 0x113d77d81 in dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const+0x8f (dyld:x86_64+0x14d81)
    project-chip#18 0x113d7e659 in dyld4::PrebuiltLoader::runInitializers(dyld4::RuntimeState&) const+0x1d (dyld:x86_64+0x1b659)
    project-chip#19 0x113d8b76d in dyld4::APIs::runAllInitializersForMain()+0x25 (dyld:x86_64+0x2876d)
    project-chip#20 0x113d6938c in dyld4::prepare(dyld4::APIs&, dyld3::MachOAnalyzer const*)+0xd72 (dyld:x86_64+0x638c)
    project-chip#21 0x113d684e3 in start+0x183 (dyld:x86_64+0x54e3)
marktrayer pushed a commit that referenced this pull request May 3, 2024
* Rerouted tracing macros to Darwin signposts

* Initial framework for logging scalar data event

* Handled the new metrics event changes in collector

* Modified VerifyOrExit macro to accept an optional metric key as third argument

* Removed direct use of chrono in metrics_event.h
Switched MTRMetrics to vend dictionary for metric keys

* Modified SuccessOrExit to optionally accept metric key

* Moved metric keys to separate header
Reworked metric_event names for more clarity

* Switched MATTER_TRACE_METRIC usage to MATTER_LOG_METRIC

* Restyle fixes

* Fixed unit tests

* Fixed build failure due to MetricEvent hidden inside tracing enabled

* Fixing one source of build error

* Fixing darwin build failure

* Code Review: Rename LogMetric to LogMetricEvent

* Code Review Suggestions:

1. Metric Macros take full string constants and no longer use
   preprocessor to prefix. Allows free flowing strings
2. Reworked MetricEvent class and documented
3. Handled LogEventMetric for Darwin, ESP32, Perfetto, JSON to account
   for all types
4. Removed timePoint from MetricEvent class. Timestamps and duration
   calculation is now responsibility for the handlers of the event
5. Reverted BUILD.gn in system to not break out SystemClock.h

* Code Review Feedback #2:

1. Added SuccessOrExitWithMetric and VerifyOrExitWithMetric
2. Cleaned up support .gn to remove dependedency on metrics

* Code Review Feedback #3:

1. Added ScopedMetricEvent to use RAII to track begin and end within a
   scope

* Code Review project-chip#4:

Reverted an accidental removal

* Added MTRMetricData to description as per review comment

* Restyler fixes

* Sample code of how Begin and End log metrics can be used

* Fixed compilation error when tracing is disabled

* Fixes for build failures when tracing is disabled

* Picked up code review suggestion accidently dropped

* Code Review Feedback:

1. Begin metric does not take value
2. Allow undefined value for metric
3. Misc other feedback

* Handle undefined value and error value

* Revert a comment change

* Review Feedback: Changed ScopedMetricEvent to capture error by reference

* Fixed another build failure

* Reverting usage of LOG_METRICS

* Review feedback: Fix incorrect documentation

* Code Review Feedback: Remove access to Value in MetricEvent to avoid incorrect access

* Restyler fixes

* Unregistering backend in Darwin shutdown

* Resytler fixes...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.