From 9b4ac8fd04e749d0737479e3b02074be4ad3f2ab Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Mon, 16 Dec 2019 09:42:22 +0100 Subject: [PATCH] mornign cleanups --- src/bindings/java/jmsg_host.cpp | 5 +- src/instr/jedule/jedule_platform.cpp | 7 +- src/kernel/activity/ExecImpl.cpp | 1 - src/kernel/routing/DijkstraZone.cpp | 10 +-- src/kernel/routing/FatTreeZone.cpp | 1 - src/kernel/routing/RoutedZone.cpp | 11 ++- src/kernel/routing/TorusZone.cpp | 8 +- src/mc/checker/LivenessChecker.cpp | 9 +- src/mc/checker/SafetyChecker.cpp | 95 +++++++++----------- src/mc/compare.cpp | 124 +++++++++++---------------- src/mc/inspect/mc_dwarf.cpp | 16 ++-- src/msg/msg_comm.cpp | 1 - src/simgrid/util.hpp | 4 +- src/surf/sg_platf.cpp | 2 - src/xbt/log.cpp | 1 - 15 files changed, 119 insertions(+), 176 deletions(-) diff --git a/src/bindings/java/jmsg_host.cpp b/src/bindings/java/jmsg_host.cpp index cea9d2230a..b21688065e 100644 --- a/src/bindings/java/jmsg_host.cpp +++ b/src/bindings/java/jmsg_host.cpp @@ -53,8 +53,8 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Host_nativeInit(JNIEnv *env, jclass "Native initialization of msg/Host failed. Please report that bug"); } -JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_getByName(JNIEnv * env, jclass cls, jstring jname) { - +JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_getByName(JNIEnv* env, jclass cls, jstring jname) +{ /* get the C string from the java string */ if (jname == nullptr) { jxbt_throw_null(env, "No host can have a null name"); @@ -297,7 +297,6 @@ JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_getStorageContent(JNIEn JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_Host_all(JNIEnv * env, jclass cls_arg) { - xbt_dynar_t table = MSG_hosts_as_dynar(); int count = xbt_dynar_length(table); diff --git a/src/instr/jedule/jedule_platform.cpp b/src/instr/jedule/jedule_platform.cpp index 891b31aef4..fd248982e9 100644 --- a/src/instr/jedule/jedule_platform.cpp +++ b/src/instr/jedule/jedule_platform.cpp @@ -53,7 +53,6 @@ void Container::add_resources(std::vector hosts) void Container::create_hierarchy(sg_netzone_t from_as) { - if (from_as->get_children().empty()) { // I am no AS // add hosts to jedule platform @@ -71,7 +70,6 @@ void Container::create_hierarchy(sg_netzone_t from_as) std::vector Container::get_hierarchy() { if(this->parent != nullptr ) { - if (not this->parent->children.empty()) { // we are in the last level return this->parent->get_hierarchy(); @@ -150,8 +148,8 @@ void Container::print(FILE* jed_file) fprintf(jed_file, " \n"); } -} -} +} // namespace jedule +} // namespace simgrid static void add_subsets_to(std::vector& subset_list, std::vector hostgroup, jed_container_t parent) @@ -193,7 +191,6 @@ static void add_subsets_to(std::vector& subset_list, st pos = i; } } - } void get_resource_selection_by_hosts(std::vector& subset_list, diff --git a/src/kernel/activity/ExecImpl.cpp b/src/kernel/activity/ExecImpl.cpp index 76b136ff85..5846ac383f 100644 --- a/src/kernel/activity/ExecImpl.cpp +++ b/src/kernel/activity/ExecImpl.cpp @@ -257,7 +257,6 @@ void ExecImpl::finish() } switch (state_) { - case State::DONE: /* do nothing, synchro done */ XBT_DEBUG("ExecImpl::finish(): execution successful"); diff --git a/src/kernel/routing/DijkstraZone.cpp b/src/kernel/routing/DijkstraZone.cpp index 1b6902fd1b..a5ad4b57ad 100644 --- a/src/kernel/routing/DijkstraZone.cpp +++ b/src/kernel/routing/DijkstraZone.cpp @@ -57,7 +57,6 @@ void DijkstraZone::seal() /* Add the loopback if needed */ if (network_model_->loopback_ && hierarchy_ == RoutingMode::base) { - xbt_dynar_foreach (xbt_graph_get_nodes(route_graph_), cursor, node) { bool found = false; xbt_edge_t edge = nullptr; @@ -119,7 +118,6 @@ void DijkstraZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationAr /* if the src and dst are the same */ if (src_node_id == dst_node_id) { - xbt_node_t node_s_v = xbt_dynar_get_as(nodes, src_node_id, xbt_node_t); xbt_node_t node_e_v = xbt_dynar_get_as(nodes, dst_node_id, xbt_node_t); xbt_edge_t edge = xbt_graph_get_edge(route_graph_, node_s_v, node_e_v); @@ -250,7 +248,7 @@ void DijkstraZone::add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, Net new_edge(dst->id(), src->id(), new_extended_route(hierarchy_, dst, src, gw_dst, gw_src, link_list, symmetrical, 0)); } -void DijkstraZone::new_edge(int src_id, int dst_id, simgrid::kernel::routing::RouteCreationArgs* route) +void DijkstraZone::new_edge(int src_id, int dst_id, RouteCreationArgs* route) { XBT_DEBUG("Create Route from '%d' to '%d'", src_id, dst_id); @@ -277,6 +275,6 @@ void DijkstraZone::new_edge(int src_id, int dst_id, simgrid::kernel::routing::Ro // Finally add it xbt_graph_new_edge(route_graph_, src, dst, route); } -} -} -} // namespace +} // namespace routing +} // namespace kernel +} // namespace simgrid diff --git a/src/kernel/routing/FatTreeZone.cpp b/src/kernel/routing/FatTreeZone.cpp index 8a551eac5f..475e034431 100644 --- a/src/kernel/routing/FatTreeZone.cpp +++ b/src/kernel/routing/FatTreeZone.cpp @@ -61,7 +61,6 @@ bool FatTreeZone::is_in_sub_tree(FatTreeNode* root, FatTreeNode* node) void FatTreeZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) { - if (dst->is_router() || src->is_router()) return; diff --git a/src/kernel/routing/RoutedZone.cpp b/src/kernel/routing/RoutedZone.cpp index 090085d5eb..dff7174aaf 100644 --- a/src/kernel/routing/RoutedZone.cpp +++ b/src/kernel/routing/RoutedZone.cpp @@ -25,7 +25,6 @@ static const char* instr_node_name(xbt_node_t node) xbt_node_t new_xbt_graph_node(xbt_graph_t graph, const char* name, std::map* nodes) { - auto elm = nodes->find(name); if (elm == nodes->end()) { xbt_node_t ret = xbt_graph_new_node(graph, xbt_strdup(name)); @@ -67,7 +66,7 @@ RoutedZone::RoutedZone(NetZoneImpl* father, const std::string& name, resource::N void RoutedZone::get_graph(xbt_graph_t graph, std::map* nodes, std::map* edges) { - std::vector vertices = get_vertices(); + std::vector vertices = get_vertices(); for (auto const& my_src : vertices) { for (auto const& my_dst : vertices) { @@ -203,8 +202,8 @@ void RoutedZone::add_route_check_params(NetPoint* src, NetPoint* dst, NetPoint* dstName, gw_dst->get_cname()); } - simgrid::s4u::NetZone::on_route_creation(symmetrical, src, dst, gw_src, gw_dst, link_list); -} -} -} + s4u::NetZone::on_route_creation(symmetrical, src, dst, gw_src, gw_dst, link_list); } +} // namespace routing +} // namespace kernel +} // namespace simgrid diff --git a/src/kernel/routing/TorusZone.cpp b/src/kernel/routing/TorusZone.cpp index 971fd4c5e4..c6012b1ac3 100644 --- a/src/kernel/routing/TorusZone.cpp +++ b/src/kernel/routing/TorusZone.cpp @@ -83,7 +83,6 @@ void TorusZone::parse_specific_arguments(ClusterCreationArgs* cluster) void TorusZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* route, double* lat) { - XBT_VERB("torus getLocalRoute from '%s'[%u] to '%s'[%u]", src->get_cname(), src->id(), dst->get_cname(), dst->id()); if (dst->is_router() || src->is_router()) @@ -134,7 +133,6 @@ void TorusZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* const unsigned cur_dim = dimensions_[j]; // current_node/dim_product = position in current dimension if ((current_node / dim_product) % cur_dim != (dst->id() / dim_product) % cur_dim) { - if ((targetCoords[j] > myCoords[j] && targetCoords[j] <= myCoords[j] + cur_dim / 2) // Is the target node on the right, without the wrap-around? || (myCoords[j] > cur_dim / 2 && @@ -190,6 +188,6 @@ void TorusZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* delete[] myCoords; delete[] targetCoords; } -} -} -} // namespace +} // namespace routing +} // namespace kernel +} // namespace simgrid diff --git a/src/mc/checker/LivenessChecker.cpp b/src/mc/checker/LivenessChecker.cpp index 9b9b937020..0e3d3ef4f1 100644 --- a/src/mc/checker/LivenessChecker.cpp +++ b/src/mc/checker/LivenessChecker.cpp @@ -23,7 +23,7 @@ namespace mc { VisitedPair::VisitedPair(int pair_num, xbt_automaton_state_t automaton_state, std::shared_ptr> atomic_propositions, - std::shared_ptr graph_state) + std::shared_ptr graph_state) : num(pair_num), automaton_state(automaton_state) { RemoteClient* process = &(mc_model_checker->process()); @@ -164,9 +164,7 @@ void LivenessChecker::replay() mc_model_checker->executed_transitions++; depth++; - } - XBT_DEBUG("**** End Replay ****"); } @@ -382,7 +380,7 @@ void LivenessChecker::run() this->previous_request_.clear(); } this->previous_pair_ = current_pair->num; - this->previous_request_ = simgrid::mc::request_get_dot_output(req, req_num); + this->previous_request_ = request_get_dot_output(req, req_num); if (current_pair->search_cycle) fprintf(dot_output, "%d [shape=doublecircle];\n", current_pair->num); fflush(dot_output); @@ -415,11 +413,10 @@ void LivenessChecker::run() if (evaluate_label(transition_succ->label, *prop_values)) exploration_stack_.push_back(this->create_pair(current_pair.get(), transition_succ->dst, prop_values)); } - } XBT_INFO("No property violation found."); - simgrid::mc::session->log_state(); + mc::session->log_state(); } Checker* createLivenessChecker(Session& s) diff --git a/src/mc/checker/SafetyChecker.cpp b/src/mc/checker/SafetyChecker.cpp index c08ecaa23b..22a868cb8b 100644 --- a/src/mc/checker/SafetyChecker.cpp +++ b/src/mc/checker/SafetyChecker.cpp @@ -26,12 +26,12 @@ #include "src/xbt/mmalloc/mmprivate.h" -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_safety, mc, - "Logging specific to MC safety verification "); +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_safety, mc, "Logging specific to MC safety verification "); + namespace simgrid { namespace mc { -void SafetyChecker::check_non_termination(simgrid::mc::State* current_state) +void SafetyChecker::check_non_termination(State* current_state) { for (auto state = stack_.rbegin(); state != stack_.rend(); ++state) if (snapshot_equal((*state)->system_state.get(), current_state->system_state.get())) { @@ -42,10 +42,10 @@ void SafetyChecker::check_non_termination(simgrid::mc::State* current_state) XBT_INFO("Counter-example execution trace:"); for (auto const& s : mc_model_checker->getChecker()->get_textual_trace()) XBT_INFO(" %s", s.c_str()); - simgrid::mc::dumpRecordPath(); - simgrid::mc::session->log_state(); + dumpRecordPath(); + session->log_state(); - throw simgrid::mc::TerminationError(); + throw TerminationError(); } } @@ -64,8 +64,7 @@ std::vector SafetyChecker::get_textual_trace() // override int value = state->transition_.argument_; smx_simcall_t req = &state->executed_req_; if (req) - trace.push_back(simgrid::mc::request_to_string( - req, value, simgrid::mc::RequestType::executed)); + trace.push_back(request_to_string(req, value, RequestType::executed)); } return trace; } @@ -84,9 +83,8 @@ void SafetyChecker::run() * This allows one to explore the call stack at will. */ while (not stack_.empty()) { - /* Get current state */ - simgrid::mc::State* state = stack_.back().get(); + State* state = stack_.back().get(); XBT_DEBUG("**************************************************"); XBT_VERB("Exploration depth=%zu (state=%p, num %d)(%zu interleave)", stack_.size(), state, state->num_, @@ -125,13 +123,11 @@ void SafetyChecker::run() // If there are processes to interleave and the maximum depth has not been // reached then perform one step of the exploration algorithm. - XBT_DEBUG( - "Execute: %s", - simgrid::mc::request_to_string(req, state->transition_.argument_, simgrid::mc::RequestType::simix).c_str()); + XBT_DEBUG("Execute: %s", request_to_string(req, state->transition_.argument_, RequestType::simix).c_str()); std::string req_str; if (dot_output != nullptr) - req_str = simgrid::mc::request_get_dot_output(req, state->transition_.argument_); + req_str = request_get_dot_output(req, state->transition_.argument_); mc_model_checker->executed_transitions++; @@ -139,8 +135,7 @@ void SafetyChecker::run() this->get_session().execute(state->transition_); /* Create the new expanded state (copy the state of MCed into our MCer data) */ - std::unique_ptr next_state = - std::unique_ptr(new simgrid::mc::State(++expanded_states_count_)); + std::unique_ptr next_state = std::unique_ptr(new State(++expanded_states_count_)); if (_sg_mc_termination) this->check_non_termination(next_state.get()); @@ -155,9 +150,9 @@ void SafetyChecker::run() /* Get an enabled process and insert it in the interleave set of the next state */ for (auto& remoteActor : mc_model_checker->process().actors()) { auto actor = remoteActor.copy.get_buffer(); - if (simgrid::mc::actor_is_enabled(actor)) { + if (actor_is_enabled(actor)) { next_state->add_interleaving_set(actor); - if (reductionMode_ == simgrid::mc::ReductionMode::dpor) + if (reductionMode_ == ReductionMode::dpor) break; // With DPOR, we take the first enabled transition } } @@ -174,7 +169,7 @@ void SafetyChecker::run() } XBT_INFO("No property violation found."); - simgrid::mc::session->log_state(); + session->log_state(); } void SafetyChecker::backtrack() @@ -184,39 +179,35 @@ void SafetyChecker::backtrack() /* Check for deadlocks */ if (mc_model_checker->checkDeadlock()) { MC_show_deadlock(); - throw simgrid::mc::DeadlockError(); + throw DeadlockError(); } - /* Traverse the stack backwards until a state with a non empty interleave - set is found, deleting all the states that have it empty in the way. - For each deleted state, check if the request that has generated it - (from it's predecessor state), depends on any other previous request - executed before it. If it does then add it to the interleave set of the - state that executed that previous request. */ + /* Traverse the stack backwards until a state with a non empty interleave set is found, deleting all the states that + * have it empty in the way. For each deleted state, check if the request that has generated it (from its + * predecessor state), depends on any other previous request executed before it. If it does then add it to the + * interleave set of the state that executed that previous request. */ while (not stack_.empty()) { - std::unique_ptr state = std::move(stack_.back()); + std::unique_ptr state = std::move(stack_.back()); stack_.pop_back(); - if (reductionMode_ == simgrid::mc::ReductionMode::dpor) { + if (reductionMode_ == ReductionMode::dpor) { smx_simcall_t req = &state->internal_req; if (req->call_ == SIMCALL_MUTEX_LOCK || req->call_ == SIMCALL_MUTEX_TRYLOCK) xbt_die("Mutex is currently not supported with DPOR, use --cfg=model-check/reduction:none"); const smx_actor_t issuer = MC_smx_simcall_get_issuer(req); for (auto i = stack_.rbegin(); i != stack_.rend(); ++i) { - simgrid::mc::State* prev_state = i->get(); - if (simgrid::mc::request_depend(req, &prev_state->internal_req)) { + State* prev_state = i->get(); + if (request_depend(req, &prev_state->internal_req)) { if (XBT_LOG_ISENABLED(mc_safety, xbt_log_priority_debug)) { XBT_DEBUG("Dependent Transitions:"); int value = prev_state->transition_.argument_; smx_simcall_t prev_req = &prev_state->executed_req_; - XBT_DEBUG("%s (state=%d)", - simgrid::mc::request_to_string(prev_req, value, simgrid::mc::RequestType::internal).c_str(), + XBT_DEBUG("%s (state=%d)", simgrid::mc::request_to_string(prev_req, value, RequestType::internal).c_str(), prev_state->num_); value = state->transition_.argument_; prev_req = &state->executed_req_; - XBT_DEBUG("%s (state=%d)", - simgrid::mc::request_to_string(prev_req, value, simgrid::mc::RequestType::executed).c_str(), + XBT_DEBUG("%s (state=%d)", simgrid::mc::request_to_string(prev_req, value, RequestType::executed).c_str(), state->num_); } @@ -224,17 +215,12 @@ void SafetyChecker::backtrack() prev_state->add_interleaving_set(issuer); else XBT_DEBUG("Process %p is in done set", req->issuer_); - break; - } else if (req->issuer_ == prev_state->internal_req.issuer_) { - XBT_DEBUG("Simcall %s and %s with same issuer", SIMIX_simcall_name(req->call_), SIMIX_simcall_name(prev_state->internal_req.call_)); break; - } else { - const smx_actor_t previous_issuer = MC_smx_simcall_get_issuer(&prev_state->internal_req); XBT_DEBUG("Simcall %s, process %ld (state %d) and simcall %s, process %ld (state %d) are independent", SIMIX_simcall_name(req->call_), issuer->get_pid(), state->num_, @@ -259,17 +245,17 @@ void SafetyChecker::backtrack() void SafetyChecker::restore_state() { /* Intermediate backtracking */ - simgrid::mc::State* last_state = stack_.back().get(); + State* last_state = stack_.back().get(); if (last_state->system_state) { last_state->system_state->restore(&mc_model_checker->process()); return; } /* Restore the initial state */ - simgrid::mc::session->restore_initial_state(); + session->restore_initial_state(); /* Traverse the stack from the state at position start and re-execute the transitions */ - for (std::unique_ptr const& state : stack_) { + for (std::unique_ptr const& state : stack_) { if (state == stack_.back()) break; session->execute(state->transition_); @@ -281,33 +267,32 @@ void SafetyChecker::restore_state() SafetyChecker::SafetyChecker(Session& s) : Checker(s) { - reductionMode_ = simgrid::mc::reduction_mode; + reductionMode_ = reduction_mode; if (_sg_mc_termination) - reductionMode_ = simgrid::mc::ReductionMode::none; - else if (reductionMode_ == simgrid::mc::ReductionMode::unset) - reductionMode_ = simgrid::mc::ReductionMode::dpor; + reductionMode_ = ReductionMode::none; + else if (reductionMode_ == ReductionMode::unset) + reductionMode_ = ReductionMode::dpor; if (_sg_mc_termination) XBT_INFO("Check non progressive cycles"); else XBT_INFO("Check a safety property. Reduction is: %s.", - (reductionMode_ == simgrid::mc::ReductionMode::none ? "none": - (reductionMode_ == simgrid::mc::ReductionMode::dpor ? "dpor": "unknown"))); - simgrid::mc::session->initialize(); + (reductionMode_ == ReductionMode::none ? "none" + : (reductionMode_ == ReductionMode::dpor ? "dpor" : "unknown"))); + session->initialize(); XBT_DEBUG("Starting the safety algorithm"); - std::unique_ptr initial_state = - std::unique_ptr(new simgrid::mc::State(++expanded_states_count_)); + std::unique_ptr initial_state = std::unique_ptr(new State(++expanded_states_count_)); XBT_DEBUG("**************************************************"); XBT_DEBUG("Initial state"); /* Get an enabled actor and insert it in the interleave set of the initial state */ for (auto& actor : mc_model_checker->process().actors()) - if (simgrid::mc::actor_is_enabled(actor.copy.get_buffer())) { + if (actor_is_enabled(actor.copy.get_buffer())) { initial_state->add_interleaving_set(actor.copy.get_buffer()); - if (reductionMode_ != simgrid::mc::ReductionMode::none) + if (reductionMode_ != ReductionMode::none) break; } @@ -319,5 +304,5 @@ Checker* createSafetyChecker(Session& s) return new SafetyChecker(s); } -} -} +} // namespace mc +} // namespace simgrid diff --git a/src/mc/compare.cpp b/src/mc/compare.cpp index 4bf2cb2888..159d83c374 100644 --- a/src/mc/compare.cpp +++ b/src/mc/compare.cpp @@ -55,12 +55,12 @@ public: class ProcessComparisonState { public: - const std::vector* to_ignore = nullptr; + const std::vector* to_ignore = nullptr; std::vector equals_to; - std::vector types; + std::vector types; std::size_t heapsize = 0; - void initHeapInformation(xbt_mheap_t heap, const std::vector& i); + void initHeapInformation(xbt_mheap_t heap, const std::vector& i); }; class StateComparator { @@ -77,8 +77,8 @@ public: compared_pointers.clear(); } - int initHeapInformation(xbt_mheap_t heap1, xbt_mheap_t heap2, const std::vector& i1, - const std::vector& i2); + int initHeapInformation(xbt_mheap_t heap1, xbt_mheap_t heap2, const std::vector& i1, + const std::vector& i2); template HeapArea& equals_to_(std::size_t i, std::size_t j) { @@ -126,8 +126,8 @@ public: void match_equals(HeapLocationPairs* list); }; -} -} +} // namespace mc +} // namespace simgrid /************************************************************************************/ @@ -175,16 +175,16 @@ void StateComparator::match_equals(HeapLocationPairs* list) { for (auto const& pair : *list) { if (pair[0].fragment_ != -1) { - this->equals_to_<1>(pair[0].block_, pair[0].fragment_) = simgrid::mc::HeapArea(pair[1].block_, pair[1].fragment_); - this->equals_to_<2>(pair[1].block_, pair[1].fragment_) = simgrid::mc::HeapArea(pair[0].block_, pair[0].fragment_); + this->equals_to_<1>(pair[0].block_, pair[0].fragment_) = HeapArea(pair[1].block_, pair[1].fragment_); + this->equals_to_<2>(pair[1].block_, pair[1].fragment_) = HeapArea(pair[0].block_, pair[0].fragment_); } else { - this->equals_to_<1>(pair[0].block_, 0) = simgrid::mc::HeapArea(pair[1].block_, pair[1].fragment_); - this->equals_to_<2>(pair[1].block_, 0) = simgrid::mc::HeapArea(pair[0].block_, pair[0].fragment_); + this->equals_to_<1>(pair[0].block_, 0) = HeapArea(pair[1].block_, pair[1].fragment_); + this->equals_to_<2>(pair[1].block_, 0) = HeapArea(pair[0].block_, pair[0].fragment_); } } } -void ProcessComparisonState::initHeapInformation(xbt_mheap_t heap, const std::vector& i) +void ProcessComparisonState::initHeapInformation(xbt_mheap_t heap, const std::vector& i) { auto heaplimit = heap->heaplimit; this->heapsize = heap->heapsize; @@ -193,9 +193,8 @@ void ProcessComparisonState::initHeapInformation(xbt_mheap_t heap, const std::ve this->types.assign(heaplimit * MAX_FRAGMENT_PER_BLOCK, nullptr); } -int StateComparator::initHeapInformation(xbt_mheap_t heap1, xbt_mheap_t heap2, - const std::vector& i1, - const std::vector& i2) +int StateComparator::initHeapInformation(xbt_mheap_t heap1, xbt_mheap_t heap2, const std::vector& i1, + const std::vector& i2) { if ((heap1->heaplimit != heap2->heaplimit) || (heap1->heapsize != heap2->heapsize)) return -1; @@ -210,7 +209,7 @@ int StateComparator::initHeapInformation(xbt_mheap_t heap1, xbt_mheap_t heap2, static inline Region* MC_get_heap_region(const Snapshot& snapshot) { for (auto const& region : snapshot.snapshot_regions_) - if (region->region_type() == simgrid::mc::RegionType::Heap) + if (region->region_type() == RegionType::Heap) return region.get(); xbt_die("No heap region"); } @@ -218,10 +217,9 @@ static inline Region* MC_get_heap_region(const Snapshot& snapshot) static bool heap_area_differ(StateComparator& state, const void* area1, const void* area2, const Snapshot& snapshot1, const Snapshot& snapshot2, HeapLocationPairs* previous, Type* type, int pointer_level); -static bool mmalloc_heap_differ(simgrid::mc::StateComparator& state, const simgrid::mc::Snapshot& snapshot1, - const simgrid::mc::Snapshot& snapshot2) +static bool mmalloc_heap_differ(StateComparator& state, const Snapshot& snapshot1, const Snapshot& snapshot2) { - const simgrid::mc::RemoteClient& process = mc_model_checker->process(); + const RemoteClient& process = mc_model_checker->process(); /* Check busy blocks */ size_t i1 = 1; @@ -230,8 +228,8 @@ static bool mmalloc_heap_differ(simgrid::mc::StateComparator& state, const simgr malloc_info heapinfo_temp2; malloc_info heapinfo_temp2b; - simgrid::mc::Region* heap_region1 = MC_get_heap_region(snapshot1); - simgrid::mc::Region* heap_region2 = MC_get_heap_region(snapshot2); + Region* heap_region1 = MC_get_heap_region(snapshot1); + Region* heap_region2 = MC_get_heap_region(snapshot2); // This is the address of std_heap->heapinfo in the application process: void* heapinfo_address = &((xbt_mheap_t)process.heap_address)->heapinfo; @@ -317,7 +315,6 @@ static bool mmalloc_heap_differ(simgrid::mc::StateComparator& state, const simgr equal = true; i1 += heapinfo1->busy_block.size; } - i2++; } @@ -325,11 +322,8 @@ static bool mmalloc_heap_differ(simgrid::mc::StateComparator& state, const simgr XBT_DEBUG("Block %zu not found (size_used = %zu, addr = %p)", i1, heapinfo1->busy_block.busy_size, addr_block1); return true; } - - } else { /* Fragmented block */ - + } else { /* Fragmented block */ for (size_t j1 = 0; j1 < (size_t)(BLOCKSIZE >> heapinfo1->type); j1++) { - if (heapinfo1->busy_frag.frag_size[j1] == -1) /* Free fragment_ */ continue; @@ -381,7 +375,6 @@ static bool mmalloc_heap_differ(simgrid::mc::StateComparator& state, const simgr break; } } - i2++; } @@ -391,7 +384,6 @@ static bool mmalloc_heap_differ(simgrid::mc::StateComparator& state, const simgr return true; } } - i1++; } } @@ -436,7 +428,6 @@ static bool mmalloc_heap_differ(simgrid::mc::StateComparator& state, const simgr return true; } } - return false; } @@ -452,14 +443,13 @@ static bool mmalloc_heap_differ(simgrid::mc::StateComparator& state, const simgr * @param check_ignore * @return true when different, false otherwise (same or unknown) */ -static bool heap_area_differ_without_type(simgrid::mc::StateComparator& state, const void* real_area1, - const void* real_area2, const simgrid::mc::Snapshot& snapshot1, - const simgrid::mc::Snapshot& snapshot2, HeapLocationPairs* previous, int size, - int check_ignore) +static bool heap_area_differ_without_type(StateComparator& state, const void* real_area1, const void* real_area2, + const Snapshot& snapshot1, const Snapshot& snapshot2, + HeapLocationPairs* previous, int size, int check_ignore) { - const simgrid::mc::RemoteClient& process = mc_model_checker->process(); - simgrid::mc::Region* heap_region1 = MC_get_heap_region(snapshot1); - simgrid::mc::Region* heap_region2 = MC_get_heap_region(snapshot2); + const RemoteClient& process = mc_model_checker->process(); + Region* heap_region1 = MC_get_heap_region(snapshot1); + Region* heap_region2 = MC_get_heap_region(snapshot2); for (int i = 0; i < size; ) { if (check_ignore > 0) { @@ -496,13 +486,10 @@ static bool heap_area_differ_without_type(simgrid::mc::StateComparator& state, c i = pointer_align + sizeof(void *); continue; } - return true; } - i++; } - return false; } @@ -520,10 +507,10 @@ static bool heap_area_differ_without_type(simgrid::mc::StateComparator& state, c * @param pointer_level * @return true when different, false otherwise (same or unknown) */ -static bool heap_area_differ_with_type(simgrid::mc::StateComparator& state, const void* real_area1, - const void* real_area2, const simgrid::mc::Snapshot& snapshot1, - const simgrid::mc::Snapshot& snapshot2, HeapLocationPairs* previous, - simgrid::mc::Type* type, int area_size, int check_ignore, int pointer_level) +static bool heap_area_differ_with_type(StateComparator& state, const void* real_area1, const void* real_area2, + const Snapshot& snapshot1, const Snapshot& snapshot2, + HeapLocationPairs* previous, Type* type, int area_size, int check_ignore, + int pointer_level) { // HACK: This should not happen but in practice, there are some // DW_TAG_typedef without an associated DW_AT_type: @@ -543,14 +530,14 @@ static bool heap_area_differ_with_type(simgrid::mc::StateComparator& state, cons return false; } - simgrid::mc::Type* subtype; - simgrid::mc::Type* subsubtype; + Type* subtype; + Type* subsubtype; int elm_size; const void* addr_pointed1; const void* addr_pointed2; - simgrid::mc::Region* heap_region1 = MC_get_heap_region(snapshot1); - simgrid::mc::Region* heap_region2 = MC_get_heap_region(snapshot2); + Region* heap_region1 = MC_get_heap_region(snapshot1); + Region* heap_region2 = MC_get_heap_region(snapshot2); switch (type->type) { case DW_TAG_unspecified_type: @@ -667,8 +654,8 @@ static bool heap_area_differ_with_type(simgrid::mc::StateComparator& state, cons } else { for (simgrid::mc::Member& member : type->members) { // TODO, optimize this? (for the offset case) - void* real_member1 = simgrid::dwarf::resolve_member(real_area1, type, &member, &snapshot1); - void* real_member2 = simgrid::dwarf::resolve_member(real_area2, type, &member, &snapshot2); + void* real_member1 = dwarf::resolve_member(real_area1, type, &member, &snapshot1); + void* real_member2 = dwarf::resolve_member(real_area2, type, &member, &snapshot2); if (heap_area_differ_with_type(state, real_member1, real_member2, snapshot1, snapshot2, previous, member.type, -1, check_ignore, 0)) return true; @@ -695,8 +682,7 @@ static bool heap_area_differ_with_type(simgrid::mc::StateComparator& state, cons * @param area_size * @return DWARF type ID for given offset */ -static simgrid::mc::Type* get_offset_type(void* real_base_address, simgrid::mc::Type* type, int offset, int area_size, - const simgrid::mc::Snapshot& snapshot) +static Type* get_offset_type(void* real_base_address, Type* type, int offset, int area_size, const Snapshot& snapshot) { // Beginning of the block, the inferred variable type if the type of the block: if (offset == 0) @@ -720,7 +706,7 @@ static simgrid::mc::Type* get_offset_type(void* real_base_address, simgrid::mc:: if (member.offset() == offset) return member.type; } else { - void* real_member = simgrid::dwarf::resolve_member(real_base_address, type, &member, &snapshot); + void* real_member = dwarf::resolve_member(real_base_address, type, &member, &snapshot); if ((char*)real_member - (char*)real_base_address == offset) return member.type; } @@ -744,9 +730,8 @@ static simgrid::mc::Type* get_offset_type(void* real_base_address, simgrid::mc:: * @param pointer_level * @return true when different, false otherwise (same or unknown) */ -static bool heap_area_differ(simgrid::mc::StateComparator& state, const void* area1, const void* area2, - const simgrid::mc::Snapshot& snapshot1, const simgrid::mc::Snapshot& snapshot2, - HeapLocationPairs* previous, simgrid::mc::Type* type, int pointer_level) +static bool heap_area_differ(StateComparator& state, const void* area1, const void* area2, const Snapshot& snapshot1, + const Snapshot& snapshot2, HeapLocationPairs* previous, Type* type, int pointer_level) { const simgrid::mc::RemoteClient& process = mc_model_checker->process(); @@ -761,8 +746,8 @@ static bool heap_area_differ(simgrid::mc::StateComparator& state, const void* ar int new_size1 = -1; int new_size2 = -1; - simgrid::mc::Type* new_type1 = nullptr; - simgrid::mc::Type* new_type2 = nullptr; + Type* new_type1 = nullptr; + Type* new_type2 = nullptr; bool match_pairs = false; @@ -881,8 +866,7 @@ static bool heap_area_differ(simgrid::mc::StateComparator& state, const void* ar return false; } - if (heapinfo1->busy_block.ignore > 0 - && heapinfo2->busy_block.ignore == heapinfo1->busy_block.ignore) + if (heapinfo1->busy_block.ignore > 0 && heapinfo2->busy_block.ignore == heapinfo1->busy_block.ignore) check_ignore = heapinfo1->busy_block.ignore; } else if ((heapinfo1->type > 0) && (heapinfo2->type > 0)) { /* Fragmented block */ @@ -962,7 +946,6 @@ static bool heap_area_differ(simgrid::mc::StateComparator& state, const void* ar } if (new_type1 != nullptr && new_type2 != nullptr && new_type1 != new_type2) { - type = new_type1; while (type->byte_size == 0 && type->subtype != nullptr) type = type->subtype; @@ -1001,7 +984,6 @@ static bool heap_area_differ(simgrid::mc::StateComparator& state, const void* ar if ((heapinfo1->busy_frag.ignore[frag1] > 0) && (heapinfo2->busy_frag.ignore[frag2] == heapinfo1->busy_frag.ignore[frag1])) check_ignore = heapinfo1->busy_frag.ignore[frag1]; - } else return true; @@ -1017,9 +999,8 @@ static bool heap_area_differ(simgrid::mc::StateComparator& state, const void* ar state.match_equals(previous); return false; } - -} -} +} // namespace mc +} // namespace simgrid /************************** Snapshot comparison *******************************/ /******************************************************************************/ @@ -1245,12 +1226,10 @@ bool snapshot_equal(const Snapshot* s1, const Snapshot* s2) } /* Init heap information used in heap comparison algorithm */ - xbt_mheap_t heap1 = - static_cast(s1->read_bytes(alloca(sizeof(struct mdesc)), sizeof(struct mdesc), - remote(process.heap_address), simgrid::mc::ReadOptions::lazy())); - xbt_mheap_t heap2 = - static_cast(s2->read_bytes(alloca(sizeof(struct mdesc)), sizeof(struct mdesc), - remote(process.heap_address), simgrid::mc::ReadOptions::lazy())); + xbt_mheap_t heap1 = static_cast(s1->read_bytes(alloca(sizeof(struct mdesc)), sizeof(struct mdesc), + remote(process.heap_address), ReadOptions::lazy())); + xbt_mheap_t heap2 = static_cast(s2->read_bytes(alloca(sizeof(struct mdesc)), sizeof(struct mdesc), + remote(process.heap_address), ReadOptions::lazy())); if (state_comparator.initHeapInformation(heap1, heap2, s1->to_ignore_, s2->to_ignore_) == -1) { XBT_VERB("(%d - %d) Different heap information", s1->num_state_, s2->num_state_); return false; @@ -1301,6 +1280,5 @@ bool snapshot_equal(const Snapshot* s1, const Snapshot* s2) return true; } - -} -} +} // namespace mc +} // namespace simgrid diff --git a/src/mc/inspect/mc_dwarf.cpp b/src/mc/inspect/mc_dwarf.cpp index e3a6d25e48..74b9f4740f 100644 --- a/src/mc/inspect/mc_dwarf.cpp +++ b/src/mc/inspect/mc_dwarf.cpp @@ -123,7 +123,6 @@ enum class FormClass { static TagClass classify_tag(int tag) { switch (tag) { - case DW_TAG_array_type: case DW_TAG_class_type: case DW_TAG_enumeration_type: @@ -224,7 +223,7 @@ static FormClass classify_form(int form) */ inline XBT_PRIVATE const char* tagname(Dwarf_Die* die) { - return simgrid::dwarf::tagname(dwarf_tag(die)); + return tagname(dwarf_tag(die)); } } // namespace dwarf @@ -1192,11 +1191,10 @@ namespace simgrid { namespace mc { /** @brief Finds informations about a given shared object/executable */ -std::shared_ptr createObjectInformation(std::vector const& maps, - const char* name) +std::shared_ptr createObjectInformation(std::vector const& maps, const char* name) { - std::shared_ptr result = std::make_shared(); - result->file_name = name; + std::shared_ptr result = std::make_shared(); + result->file_name = name; simgrid::mc::find_object_address(maps, result.get()); MC_load_dwarf(result.get()); MC_post_process_variables(result.get()); @@ -1209,11 +1207,11 @@ std::shared_ptr createObjectInformation(std::vec /*************************************************************************/ -void postProcessObjectInformation(simgrid::mc::RemoteClient* process, simgrid::mc::ObjectInformation* info) +void postProcessObjectInformation(RemoteClient* process, ObjectInformation* info) { for (auto& t : info->types) { - simgrid::mc::Type* type = &(t.second); - simgrid::mc::Type* subtype = type; + Type* type = &(t.second); + Type* subtype = type; while (subtype->type == DW_TAG_typedef || subtype->type == DW_TAG_volatile_type || subtype->type == DW_TAG_const_type) if (subtype->subtype) diff --git a/src/msg/msg_comm.cpp b/src/msg/msg_comm.cpp index 463619d61b..e706353c0d 100644 --- a/src/msg/msg_comm.cpp +++ b/src/msg/msg_comm.cpp @@ -207,7 +207,6 @@ int MSG_comm_waitany(xbt_dynar_t comms) */ msg_error_t MSG_comm_get_status(msg_comm_t comm) { - return comm->get_status(); } diff --git a/src/simgrid/util.hpp b/src/simgrid/util.hpp index 4526a663a7..2d28f9dbd1 100644 --- a/src/simgrid/util.hpp +++ b/src/simgrid/util.hpp @@ -35,7 +35,7 @@ typename C::mapped_type const* find_map_ptr(C const& c, K const& k) return &i->second; } -} -} +} // namespace util +} // namespace simgrid #endif diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index 630032819a..31f1a9b7c2 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -277,7 +277,6 @@ void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* cluster //Make the backbone if ((cluster->bb_bw > 0) || (cluster->bb_lat > 0)) { - simgrid::kernel::routing::LinkCreationArgs link; link.id = std::string(cluster->id)+ "_backbone"; link.bandwidths.push_back(cluster->bb_bw); @@ -463,7 +462,6 @@ void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor) host->pimpl_->add_actor_at_boot(arg); if (start_time > SIMIX_get_clock()) { - arg = new simgrid::kernel::actor::ProcessArg(actor_name, code, nullptr, host, kill_time, properties, auto_restart); XBT_DEBUG("Process %s@%s will be started at time %f", arg->name.c_str(), arg->host->get_cname(), start_time); diff --git a/src/xbt/log.cpp b/src/xbt/log.cpp index a72858e6ac..17cc12c71c 100644 --- a/src/xbt/log.cpp +++ b/src/xbt/log.cpp @@ -180,7 +180,6 @@ void _xbt_log_event_log(xbt_log_event_t ev, const char *fmt, ...) if (done) { appender->do_append(appender, buff); } else { - /* The static buffer was too small, use a dynamically expanded one */ ev->buffer_size = XBT_LOG_DYNAMIC_BUFFER_SIZE; ev->buffer = static_cast(xbt_malloc(ev->buffer_size)); -- 2.20.1