diff --git a/score/datarouter/BUILD b/score/datarouter/BUILD index 5b0880fb..c28de93b 100644 --- a/score/datarouter/BUILD +++ b/score/datarouter/BUILD @@ -915,6 +915,7 @@ cc_library( "//score/mw/log/detail/data_router/shared_memory:reader", "@score_baselibs//score/concurrency", "@score_baselibs//score/os:pthread", + "@score_baselibs//score/os:unistd", "@score_communication//score/message_passing", ], ) diff --git a/score/mw/log/backend/BUILD b/score/mw/log/backend/BUILD index 9ed92d98..ecfd816a 100644 --- a/score/mw/log/backend/BUILD +++ b/score/mw/log/backend/BUILD @@ -46,12 +46,14 @@ cc_library( alwayslink = True, ) -# Plugin: Remote DLT via DataRouter -# Add this dep to your binary to enable remote DLT logging. +# Plugin: Remote DLT logging. +# By default the DLTv1 support is used. With --@score_logging//score/mw/log/flags:shm_dma_enabled=True, +# the remote backend uses the DLTv2 backend that uses the Generic Trace Library (GTL) implementation. cc_library( name = "remote", srcs = select({ "//score/mw/log/flags:Remote_Logging": ["remote_registrant.cpp"], + "//score/mw/log/flags:config_use_shm_dma_enabled": [], "//conditions:default": [], }), features = COMPILER_WARNING_FEATURES, @@ -63,6 +65,9 @@ cc_library( "//score/mw/log/flags:Remote_Logging": [ "//score/mw/log/detail/data_router:remote_dlt_recorder_factory", ], + "//score/mw/log/flags:config_use_shm_dma_enabled": [ + "//score/mw/log/detail/dlt_trace:dlt_trace_registrant", + ], "//conditions:default": [], }), alwayslink = True, diff --git a/score/mw/log/detail/common/BUILD b/score/mw/log/detail/common/BUILD index 970f2667..4b9c1555 100644 --- a/score/mw/log/detail/common/BUILD +++ b/score/mw/log/detail/common/BUILD @@ -89,6 +89,7 @@ cc_library( tags = ["FFI"], visibility = [ "//score/mw/log/detail/data_router:__pkg__", + "//score/mw/log/detail/dlt_trace:__pkg__", "//score/mw/log/detail/file_recorder:__pkg__", ], deps = [ diff --git a/score/mw/log/detail/data_router/data_router_message_client_impl.cpp b/score/mw/log/detail/data_router/data_router_message_client_impl.cpp index 60084c8b..e15000b4 100644 --- a/score/mw/log/detail/data_router/data_router_message_client_impl.cpp +++ b/score/mw/log/detail/data_router/data_router_message_client_impl.cpp @@ -327,13 +327,13 @@ void DatarouterMessageClientImpl::Shutdown() noexcept score::cpp::expected_blank DatarouterMessageClientImpl::CreateSender() noexcept { - const score::message_passing::ServiceProtocolConfig protocol_config{ + constexpr score::message_passing::ServiceProtocolConfig kProtocolConfig{ MessagePassingConfig::kDatarouterReceiverIdentifier, MessagePassingConfig::kMaxMessageSize, MessagePassingConfig::kMaxReplySize, MessagePassingConfig::kMaxNotifySize}; - const score::message_passing::IClientFactory::ClientConfig client_config{0U, 10U, false, true, false}; - sender_ = message_passing_factory_->CreateClient(protocol_config, client_config); + constexpr score::message_passing::IClientFactory::ClientConfig kClientConfig{0U, 10U, false, true, false}; + sender_ = message_passing_factory_->CreateClient(kProtocolConfig, kClientConfig); if (sender_ == nullptr) { @@ -342,16 +342,21 @@ score::cpp::expected_blank DatarouterMessageClientImpl::Create return score::cpp::make_unexpected(score::os::Error::createFromErrno(ENOMEM)); } - auto state_callback = - [&state_mutex = sender_state_change_mutex_, &state = sender_state_, &condition = state_condition_]( - score::message_passing::IClientConnection::State new_state) noexcept { - { - std::lock_guard callback_lock(state_mutex); - state = new_state; - } - condition.notify_all(); - }; + // Suppress "AUTOSAR C++14 A5-1-4" rule finding: "A lambda expression object shall not outlive any of its + // reference-captured objects.". + // The lambda is stored in sender_ and its lifetime is bounded by sender_'s lifetime. The Shutdown() method + // calls sender_.reset() which invokes the ClientConnection destructor. That destructor calls Stop() and + // waits for state_ == kStopped before returning, guaranteeing all callbacks complete before sender_ is destroyed. + // Therefore, the lambda cannot outlive the captured 'this' pointer. + auto state_callback = [this](score::message_passing::IClientConnection::State new_state) noexcept { + { + std::lock_guard callback_lock(sender_state_change_mutex_); + sender_state_ = new_state; + } + state_condition_.notify_all(); + }; + // coverity[autosar_cpp14_a5_1_4_violation]: See justification above sender_->Start(state_callback, score::message_passing::IClientConnection::NotifyCallback{}); return {}; } diff --git a/score/mw/log/detail/data_router/data_router_message_client_test.cpp b/score/mw/log/detail/data_router/data_router_message_client_test.cpp index 7011706c..38704437 100644 --- a/score/mw/log/detail/data_router/data_router_message_client_test.cpp +++ b/score/mw/log/detail/data_router/data_router_message_client_test.cpp @@ -268,9 +268,10 @@ class DatarouterMessageClientFixture : public ::testing::Test { EXPECT_CALL(*receiver_mock, Destruct()); } - void ExpectSendAcquireResponse(score::message_passing::ClientConnectionMock* sender_ptr, - ReadAcquireResult expected_content, - score::cpp::expected_blank result = score::cpp::expected_blank{}) + void ExpectSendAcquireResponse( + score::message_passing::ClientConnectionMock* sender_ptr, + ReadAcquireResult expected_content, + score::cpp::expected_blank result = score::cpp::expected_blank{}) { EXPECT_CALL(*sender_ptr, Send(Matcher>(_))) .WillOnce( diff --git a/score/mw/log/detail/utils/signal_handling/BUILD b/score/mw/log/detail/utils/signal_handling/BUILD index e2f495e1..0087d191 100644 --- a/score/mw/log/detail/utils/signal_handling/BUILD +++ b/score/mw/log/detail/utils/signal_handling/BUILD @@ -11,7 +11,7 @@ # SPDX-License-Identifier: Apache-2.0 # ******************************************************************************* -load("@rules_cc//cc:defs.bzl", "cc_library") +load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load("@score_baselibs//:bazel/unit_tests.bzl", "cc_unit_test_suites_for_host_and_qnx") load("@score_baselibs//score/quality/clang_tidy:extra_checks.bzl", "clang_tidy_extra_checks") diff --git a/score/mw/log/detail/utils/signal_handling/signal_handling.h b/score/mw/log/detail/utils/signal_handling/signal_handling.h index 5f84aef0..d2a34660 100644 --- a/score/mw/log/detail/utils/signal_handling/signal_handling.h +++ b/score/mw/log/detail/utils/signal_handling/signal_handling.h @@ -46,6 +46,7 @@ class SignalHandling static auto WithSigTermBlocked(score::os::Signal& signal, Func&& func) noexcept -> decltype(func()) { const auto block_result = PThreadBlockSigTerm(signal); + std::ignore = block_result; auto result = func(); const auto unblock_result = PThreadUnblockSigTerm(signal); std::ignore = unblock_result; diff --git a/score/mw/log/flags/BUILD b/score/mw/log/flags/BUILD index 0adc3125..776af6c9 100644 --- a/score/mw/log/flags/BUILD +++ b/score/mw/log/flags/BUILD @@ -46,6 +46,23 @@ config_setting( ], ) +bool_flag( + name = "shm_dma_enabled", + build_setting_default = False, +) + +config_setting( + name = "config_use_shm_dma_enabled", + flag_values = { + ":KRemote_Logging": "True", + ":shm_dma_enabled": "True", + }, + visibility = [ + "//score/mw/log:__subpackages__", + "@score_baselibs//score/mw/log:__subpackages__", + ], +) + cc_library( name = "unfilled", )