Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
sthread: Add a way to verify accesses to non-reentrant data structures
[simgrid.git] / src / mc / transition / TransitionObjectAccess.cpp
1 /* Copyright (c) 2015-2023. The SimGrid Team. All rights reserved.          */
2
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. */
5
6 #include "src/mc/transition/TransitionObjectAccess.hpp"
7 #include "xbt/asserts.h"
8 #include "xbt/log.h"
9 #include <xbt/string.hpp>
10
11 namespace simgrid::mc {
12
13 ObjectAccessTransition::ObjectAccessTransition(aid_t issuer, int times_considered, std::stringstream& stream)
14     : Transition(Type::OBJECT_ACCESS, issuer, times_considered)
15 {
16   short s;
17   xbt_assert(stream >> s >> objaddr_ >> objname_ >> file_ >> line_);
18   type_ = static_cast<simgrid::mc::ObjectAccessType>(s);
19 }
20 std::string ObjectAccessTransition::to_string(bool verbose) const
21 {
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_);
27 }
28 bool ObjectAccessTransition::depends(const Transition* o) const
29 {
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
32   return false;
33 }
34
35 } // namespace simgrid::mc