Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Various sonar cleanups
[simgrid.git] / src / mc / transition / TransitionObjectAccess.cpp
index 144107d..f32e459 100644 (file)
@@ -15,21 +15,42 @@ ObjectAccessTransition::ObjectAccessTransition(aid_t issuer, int times_considere
 {
   short s;
   xbt_assert(stream >> s >> objaddr_ >> objname_ >> file_ >> line_);
-  type_ = static_cast<simgrid::mc::ObjectAccessType>(s);
+  access_type_ = static_cast<simgrid::mc::ObjectAccessType>(s);
 }
 std::string ObjectAccessTransition::to_string(bool verbose) const
 {
-  if (type_ == ObjectAccessType::ENTER)
-    return xbt::string_printf("BeginObjectAccess(%s @ %s:%d)", objname_.c_str(), file_.c_str(), line_);
-  if (type_ == ObjectAccessType::EXIT)
-    return xbt::string_printf("EndObjectAccess(%s @ %s:%d)", objname_.c_str(), file_.c_str(), line_);
-  return xbt::string_printf("ObjectAccess(%s @ %s:%d)", objname_.c_str(), file_.c_str(), line_);
+  std::string res;
+  if (access_type_ == ObjectAccessType::ENTER)
+    res = std::string("BeginObjectAccess(");
+  else if (access_type_ == ObjectAccessType::EXIT)
+    res = std::string("EndObjectAccess(");
+  else
+    res = std::string("ObjectAccess(");
+  res += objname_;
+  if (not xbt_log_no_loc)
+    res += std::string(" @ ") + file_ + ":" + std::to_string(line_);
+  res += std::string(")");
+  return res;
 }
 bool ObjectAccessTransition::depends(const Transition* o) const
 {
+  if (o->type_ < type_)
+    return o->depends(this);
+
+  // Actions executed by the same actor are always dependent
+  if (o->aid_ == aid_)
+    return true;
+
   if (const auto* other = dynamic_cast<const ObjectAccessTransition*>(o))
     return objaddr_ == other->objaddr_; // dependent only if it's an access to the same object
   return false;
 }
 
+bool ObjectAccessTransition::reversible_race(const Transition* other) const
+{
+  xbt_assert(type_ == Type::OBJECT_ACCESS, "Unexpected transition type %s", to_c_str(type_));
+
+  return true; // Object access is always enabled
+}
+
 } // namespace simgrid::mc