src/mc/mc_dwarf_attrnames.h
src/mc/mc_dwarf_expression.cpp
src/mc/mc_dwarf_tagnames.h
+ src/mc/mc_hash.hpp
src/mc/mc_hash.cpp
src/mc/mc_ignore.cpp
src/mc/mcer_ignore.cpp
#include "mc_unw.h"
#include "mc_protocol.h"
#include "mc_smx.h"
+#include "mc_hash.hpp"
using simgrid::mc::remote;
s_mc_snapshot_stack::~s_mc_snapshot_stack()
{
xbt_dynar_free(&(this->stack_frames));
- mc_unw_destroy_context(this->context);
+ if (this->context)
+ mc_unw_destroy_context(this->context);
xbt_free(this->context);
}
return result;
};
-static xbt_dynar_t MC_take_snapshot_stacks(mc_snapshot_t * snapshot)
+static std::vector<s_mc_snapshot_stack_t> MC_take_snapshot_stacks(mc_snapshot_t * snapshot)
{
-
- xbt_dynar_t res =
- xbt_dynar_new(sizeof(s_mc_snapshot_stack_t),
- MC_snapshot_stack_free_voidp);
+ std::vector<s_mc_snapshot_stack_t> res;
unsigned int cursor = 0;
stack_region_t current_stack;
// FIXME, cross-process support (stack_areas)
xbt_dynar_foreach(stacks_areas, cursor, current_stack) {
- mc_snapshot_stack_t st = new s_mc_snapshot_stack();
+ s_mc_snapshot_stack_t st;
// Read the context from remote process:
unw_context_t context;
mc_model_checker->process().read_bytes(
&context, sizeof(context), remote(current_stack->context));
- st->context = xbt_new0(s_mc_unw_context_t, 1);
- if (mc_unw_init_context(st->context, &mc_model_checker->process(),
+ st.context = xbt_new0(s_mc_unw_context_t, 1);
+ if (mc_unw_init_context(st.context, &mc_model_checker->process(),
&context) < 0) {
xbt_die("Could not initialise the libunwind context.");
}
+ st.stack_frames = MC_unwind_stack_frames(st.context);
+ st.local_variables = MC_get_local_variables_values(st.stack_frames, current_stack->process_index);
+ st.process_index = current_stack->process_index;
- st->stack_frames = MC_unwind_stack_frames(st->context);
- st->local_variables = MC_get_local_variables_values(st->stack_frames, current_stack->process_index);
- st->process_index = current_stack->process_index;
+ unw_word_t sp = xbt_dynar_get_as(st.stack_frames, 0, mc_stack_frame_t)->sp;
- unw_word_t sp = xbt_dynar_get_as(st->stack_frames, 0, mc_stack_frame_t)->sp;
+ res.push_back(std::move(st));
- xbt_dynar_push(res, &st);
size_t stack_size =
(char*) current_stack->address + current_stack->size - (char*) sp;
(*snapshot)->stack_sizes.push_back(stack_size);
}
- return res;
+ return std::move(res);
}
if (_sg_mc_visited > 0 || strcmp(_sg_mc_property_file, "")) {
snapshot->stacks =
MC_take_snapshot_stacks(&snapshot);
- if (_sg_mc_hash && snapshot->stacks != NULL) {
+ if (_sg_mc_hash && !snapshot->stacks.empty()) {
snapshot->hash = mc_hash_processes_state(num_state, snapshot->stacks);
} else {
snapshot->hash = 0;
int is_diff = 0;
/* Compare size of stacks */
- while (i < xbt_dynar_length(s1->stacks)) {
+ while (i < s1->stacks.size()) {
size_used1 = s1->stack_sizes[i];
size_used2 = s2->stack_sizes[i];
if (size_used1 != size_used2) {
is_diff = 0;
#endif
mc_snapshot_stack_t stack1, stack2;
- while (cursor < xbt_dynar_length(s1->stacks)) {
- stack1 =
- (mc_snapshot_stack_t) xbt_dynar_get_as(s1->stacks, cursor,
- mc_snapshot_stack_t);
- stack2 =
- (mc_snapshot_stack_t) xbt_dynar_get_as(s2->stacks, cursor,
- mc_snapshot_stack_t);
+ while (cursor < s1->stacks.size()) {
+ stack1 = &s1->stacks[cursor];
+ stack2 = &s1->stacks[cursor];
if (stack1->process_index != stack2->process_index) {
diff_local = 1;
#include "mc_private.h"
#include "mc/datatypes.h"
#include <mc/mc.h>
-
-extern "C" {
+#include "mc_hash.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_hash, mc, "Logging specific to mc_hash");
}
#endif
-uint64_t mc_hash_processes_state(int num_state, xbt_dynar_t stacks)
+uint64_t mc_hash_processes_state(int num_state, std::vector<s_mc_snapshot_stack_t> const& stacks)
{
XBT_DEBUG("START hash %i", num_state);
XBT_DEBUG("END hash %i", num_state);
return hash;
}
-
-}
--- /dev/null
+/* Copyright (c) 2007-2015. The SimGrid Team.
+ * All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include <stdio.h>
+#include <stdint.h>
+
+#include <vector>
+
+#include "xbt/misc.h"
+#include "mc_snapshot.h"
+
+#ifndef SIMGRID_MC_HASH_HPP
+#define SIMGRID_MC_HASH_HPP
+
+/** \brief Hash the current state
+ * \param num_state number of states
+ * \param stacks stacks (mc_snapshot_stak_t) used fot the stack unwinding informations
+ * \result resulting hash
+ * */
+XBT_INTERNAL uint64_t mc_hash_processes_state(
+ int num_state, std::vector<s_mc_snapshot_stack_t> const& stacks);
+
+/** @brief Dump the stacks of the application processes
+ *
+ * This functions is currently not used but it is quite convenient
+ * to call from the debugger.
+ *
+ * Does not work when an application thread is running.
+ */
+
+#endif
/********************************** Miscellaneous **********************************/
-/* *********** Hash *********** */
-
-/** \brief Hash the current state
- * \param num_state number of states
- * \param stacks stacks (mc_snapshot_stak_t) used fot the stack unwinding informations
- * \result resulting hash
- * */
-XBT_INTERNAL uint64_t mc_hash_processes_state(int num_state, xbt_dynar_t stacks);
-
-/** @brief Dump the stacks of the application processes
- *
- * This functions is currently not used but it is quite convenient
- * to call from the debugger.
- *
- * Does not work when an application thread is running.
- */
XBT_INTERNAL void MC_dump_stacks(FILE* file);
XBT_INTERNAL void MC_report_assertion_error(void);
heap_bytes_used(0),
enabled_processes(),
privatization_index(0),
- stack_sizes(),
- stacks(nullptr),
hash(0)
{
Snapshot::~Snapshot()
{
- xbt_dynar_free(&(this->stacks));
+
}
const void* Snapshot::read_bytes(void* buffer, std::size_t size,
xbt_dynar_t stack_frames; // mc_stack_frame_t
int process_index;
+ s_mc_snapshot_stack()
+ : context(nullptr), stack_frames(nullptr), process_index(0)
+ {}
~s_mc_snapshot_stack();
+ s_mc_snapshot_stack(s_mc_snapshot_stack& p) = delete;
+ s_mc_snapshot_stack& operator=(s_mc_snapshot_stack&) = delete;
+
+ s_mc_snapshot_stack(s_mc_snapshot_stack&& that)
+ {
+ *this = std::move(that);
+ }
+ s_mc_snapshot_stack& operator=(s_mc_snapshot_stack&& that)
+ {
+ this->local_variables = std::move(that.local_variables);
+ this->context = std::move(that.context);
+ that.context = nullptr;
+ this->stack_frames = std::move(that.stack_frames);
+ that.stack_frames = nullptr;
+ this->process_index = that.process_index;
+ that.process_index = 0;
+ return *this;
+ }
+
}s_mc_snapshot_stack_t, *mc_snapshot_stack_t;
typedef struct s_mc_global_t {
std::set<pid_t> enabled_processes;
int privatization_index;
std::vector<size_t> stack_sizes;
- xbt_dynar_t stacks;
+ std::vector<s_mc_snapshot_stack_t> stacks;
std::vector<s_mc_heap_ignore_region_t> to_ignore;
uint64_t hash;
std::vector<s_mc_snapshot_ignored_data> ignored_data;