Skip to content

Commit 658d017

Browse files
crimson11devendrapatil
authored andcommitted
use typed-mem feature flag
To decide, whether typed-mem should be used in case of IPC-tracing, now the corresponding feature flag is consulted.
1 parent e4add2a commit 658d017

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

‎score/mw/com/impl/bindings/lola/BUILD‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,10 @@ cc_library(
303303
":sample_ptr",
304304
"//score/mw/com/impl/bindings/lola/tracing:tracing_runtime",
305305
],
306+
local_defines = select({
307+
"@score_baselibs//score/analysis/tracing/generic_trace_library/flags:require_typed_memory": ["REQUIRE_TYPED_MEMORY"],
308+
"//conditions:default": [],
309+
}),
306310
tags = ["FFI"],
307311
visibility = [
308312
"//score/mw/com/impl/bindings/lola/test:__pkg__",

‎score/mw/com/impl/bindings/lola/skeleton_memory_manager.cpp‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,13 @@ bool SkeletonMemoryManager::CreateSharedMemoryForData(
646646
}
647647

648648
const auto path = shm_path_builder_.GetDataChannelShmName(lola_instance_id_);
649+
#ifdef REQUIRE_TYPED_MEMORY
650+
// We only use "typed memory", if REQUIRE_TYPED_MEMORY (set by the GTL) and IPC tracing is enabled/configured, which
651+
// we can deduce from register_shm_object_trace_callback being set.
649652
const bool use_typed_memory = register_shm_object_trace_callback.has_value();
653+
#else
654+
constexpr bool use_typed_memory = false;
655+
#endif
650656
const memory::shared::SharedMemoryFactory::UserPermissions user_permissions =
651657
((permissions.empty()) && (!lola_service_instance_deployment.strict_permissions_))
652658
? memory::shared::SharedMemoryFactory::WorldReadable{}
@@ -664,17 +670,17 @@ bool SkeletonMemoryManager::CreateSharedMemoryForData(
664670
return false;
665671
}
666672
data_storage_path_ = path;
667-
if (register_shm_object_trace_callback.has_value() && memory_resource->IsShmInTypedMemory())
673+
const auto is_tracing_enabled_for_shm_object = register_shm_object_trace_callback.has_value();
674+
const auto is_typed_memory_required_and_successful_allocated =
675+
use_typed_memory && memory_resource->IsShmInTypedMemory();
676+
if (is_tracing_enabled_for_shm_object && (is_typed_memory_required_and_successful_allocated || !use_typed_memory))
668677
{
669-
// only if the memory_resource could be successfully allocated in typed-memory, we call back the
670-
// register_shm_object_trace_callback, because only then the shm-object can be accessed by tracing
671-
// subsystem.
672678
// Since LoLa creates shm-objects on the granularity of whole service-instances (including ALL its service
673679
// elements), we call register_shm_object_trace_callback once and hand over a dummy element name/type!
674680
// Other bindings, which might create shm-objects per service-element would call
675681
// register_shm_object_trace_callback for each service-element and then use their "real" name and type ...
676-
// Suppress "AUTOSAR C++14 A15-4-2" rule finding. This rule states: "I a function is declared to be
677-
// , (true) or (<true condition>), then it shall not exit with an exception"
682+
// Suppress "AUTOSAR C++14 A15-4-2" rule finding. This rule states: "If a function is declared to be
683+
// noexcept, noexcept(true) or noexcept(<true condition>), then it shall not exit with an exception"
678684
// we can't add to score::cpp::callback signature.
679685
// coverity[autosar_cpp14_a15_4_2_violation]
680686
register_shm_object_trace_callback.value()(

0 commit comments

Comments
 (0)