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 type_ = static_cast<simgrid::mc::ObjectAccessType>(s);
20 std::string ObjectAccessTransition::to_string(bool verbose) const
22 if (type_ == ObjectAccessType::ENTER)
23 return xbt::string_printf("BeginObjectAccess(%s @ %s:%d)", objname_.c_str(), file_.c_str(), line_);
24 if (type_ == ObjectAccessType::EXIT)
25 return xbt::string_printf("EndObjectAccess(%s @ %s:%d)", objname_.c_str(), file_.c_str(), line_);
26 return xbt::string_printf("ObjectAccess(%s @ %s:%d)", objname_.c_str(), file_.c_str(), line_);
28 bool ObjectAccessTransition::depends(const Transition* o) const
30 if (const auto* other = dynamic_cast<const ObjectAccessTransition*>(o))
31 return objaddr_ == other->objaddr_; // dependent only if it's an access to the same object
35 } // namespace simgrid::mc