1 /* Copyright (c) 2015-2023. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #include "src/mc/transition/TransitionObjectAccess.hpp"
7 #include "xbt/asserts.h"
9 #include <xbt/string.hpp>
11 namespace simgrid::mc {
13 ObjectAccessTransition::ObjectAccessTransition(aid_t issuer, int times_considered, std::stringstream& stream)
14 : Transition(Type::OBJECT_ACCESS, issuer, times_considered)
17 xbt_assert(stream >> s >> objaddr_ >> objname_ >> file_ >> line_);
18 access_type_ = static_cast<simgrid::mc::ObjectAccessType>(s);
20 std::string ObjectAccessTransition::to_string(bool verbose) const
23 if (access_type_ == ObjectAccessType::ENTER)
24 res = std::string("BeginObjectAccess(");
25 else if (access_type_ == ObjectAccessType::EXIT)
26 res = std::string("EndObjectAccess(");
28 res = std::string("ObjectAccess(");
30 if (not xbt_log_no_loc)
31 res += std::string(" @ ") + file_ + ":" + std::to_string(line_);
32 res += std::string(")");
35 bool ObjectAccessTransition::depends(const Transition* o) const
38 return o->depends(this);
40 // Actions executed by the same actor are always dependent
44 if (const auto* other = dynamic_cast<const ObjectAccessTransition*>(o))
45 return objaddr_ == other->objaddr_; // dependent only if it's an access to the same object
49 bool ObjectAccessTransition::reversible_race(const Transition* other) const
52 case Type::OBJECT_ACCESS:
53 return true; // Object access is always enabled
55 xbt_die("Unexpected transition type %s", to_c_str(type_));
59 } // namespace simgrid::mc