set(MC_SRC
src/mc/AddressSpace.hpp
src/mc/AddressSpace.cpp
+ src/mc/Frame.hpp
+ src/mc/ModelChecker.hpp
+ src/mc/ModelChecker.cpp
+ src/mc/ObjectInformation.hpp
+ src/mc/ObjectInformation.cpp
+ src/mc/PageStore.hpp
+ src/mc/PageStore.cpp
+ src/mc/RegionSnapshot.cpp
+ src/mc/RegionSnapshot.hpp
+ src/mc/Type.hpp
+ src/mc/Variable.hpp
+
src/mc/mc_forward.h
src/mc/mc_forward.hpp
src/mc/mc_process.h
src/mc/mc_unw.cpp
src/mc/mc_unw_vmread.cpp
src/mc/mc_mmalloc.h
- src/mc/ModelChecker.hpp
- src/mc/ModelChecker.cpp
src/mc/mc_object_info.h
src/mc/mc_object_info.cpp
src/mc/mc_checkpoint.cpp
src/mc/mc_snapshot.h
src/mc/mc_snapshot.cpp
- src/mc/RegionSnapshot.cpp
- src/mc/RegionSnapshot.hpp
- src/mc/PageStore.hpp
- src/mc/PageStore.cpp
src/mc/mc_page_snapshot.cpp
src/mc/mc_comm_pattern.h
src/mc/mc_comm_pattern.cpp
--- /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. */
+
+#ifndef SIMGRID_MC_FRAME_HPP
+#define SIMGRID_MC_FRAME_HPP
+
+#include <string>
+
+#include "mc_forward.h"
+#include "mc_location.h"
+
+namespace simgrid {
+namespace mc {
+
+class Frame {
+public:
+ Frame();
+
+ int tag;
+ std::string name;
+ void *low_pc;
+ void *high_pc;
+ simgrid::mc::LocationList frame_base;
+ std::vector<Variable> variables;
+ unsigned long int id; /* DWARF offset of the subprogram */
+ std::vector<Frame> scopes;
+ unsigned long int abstract_origin_id;
+ simgrid::mc::ObjectInformation* object_info;
+};
+
+}
+}
+
+#endif
--- /dev/null
+#include "mc/Frame.hpp"
+#include "mc/ObjectInformation.hpp"
+#include "mc/Variable.hpp"
+
+namespace simgrid {
+namespace mc {
+
+ObjectInformation::ObjectInformation()
+{
+ this->flags = 0;
+ this->start = nullptr;
+ this->end = nullptr;
+ this->start_exec = nullptr;
+ this->end_exec = nullptr;
+ this->start_rw = nullptr;
+ this->end_rw = nullptr;
+ this->start_ro = nullptr;
+ this->end_ro = nullptr;
+}
+
+/** Find the DWARF offset for this ELF object
+ *
+ * An offset is applied to address found in DWARF:
+ *
+ * * for an executable obejct, addresses are virtual address
+ * (there is no offset) i.e.
+ * \f$\text{virtual address} = \{dwarf address}\f$;
+ *
+ * * for a shared object, the addreses are offset from the begining
+ * of the shared object (the base address of the mapped shared
+ * object must be used as offset
+ * i.e. \f$\text{virtual address} = \text{shared object base address}
+ * + \text{dwarf address}\f$.
+ */
+void *ObjectInformation::base_address() const
+{
+ if (this->executable())
+ return nullptr;
+
+ void *result = this->start_exec;
+ if (this->start_rw != NULL && result > (void *) this->start_rw)
+ result = this->start_rw;
+ if (this->start_ro != NULL && result > (void *) this->start_ro)
+ result = this->start_ro;
+ return result;
+}
+
+/* Find a function by instruction pointer */
+simgrid::mc::Frame* ObjectInformation::find_function(const void *ip) const
+{
+ /* This is implemented by binary search on a sorted array.
+ *
+ * We do quite a lot ot those so we want this to be cache efficient.
+ * We pack the only information we need in the index entries in order
+ * to successfully do the binary search. We do not need the high_pc
+ * during the binary search (only at the end) so it is not included
+ * in the index entry. We could use parallel arrays as well.
+ *
+ * We cannot really use the std:: alogrithm for this.
+ * We could use std::binary_search by including the high_pc inside
+ * the FunctionIndexEntry.
+ */
+ const simgrid::mc::FunctionIndexEntry* base =
+ this->functions_index.data();
+ int i = 0;
+ int j = this->functions_index.size() - 1;
+ while (j >= i) {
+ int k = i + ((j - i) / 2);
+
+ /* In most of the search, we do not dereference the base[k].function.
+ * This way the memory accesses are located in the base[k] array. */
+ if (ip < base[k].low_pc)
+ j = k - 1;
+ else if (k < j && ip >= base[k + 1].low_pc)
+ i = k + 1;
+
+ /* At this point, the search is over.
+ * Either we have found the correct function or we do not know
+ * any function corresponding to this instruction address.
+ * Only at the point do we derefernce the function pointer. */
+ else if (ip < base[k].function->high_pc)
+ return base[k].function;
+ else
+ return nullptr;
+ }
+ return nullptr;
+}
+
+simgrid::mc::Variable* ObjectInformation::find_variable(const char* name) const
+{
+ for (simgrid::mc::Variable& variable : this->global_variables)
+ if(variable.name == name)
+ return &variable;
+ return nullptr;
+}
+
+}
+}
\ No newline at end of file
--- /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. */
+
+#ifndef SIMGRID_MC_OBJECT_INFORMATION_HPP
+#define SIMGRID_MC_OBJECT_INFORMATION_HPP
+
+#include <string>
+#include <unordered_map>
+#include <vector>
+
+#include "mc/mc_forward.h"
+#include "mc/Type.hpp"
+#include "mc/Frame.hpp"
+
+#include "smpi/private.h"
+
+namespace simgrid {
+namespace mc {
+
+/** An entry in the functions index
+ *
+ * See the code of ObjectInformation::find_function.
+ */
+struct FunctionIndexEntry {
+ void* low_pc;
+ simgrid::mc::Frame* function;
+};
+
+/** Information about an (ELF) executable/sharedobject
+ *
+ * This contain sall the information we have at runtime about an
+ * executable/shared object in the target (modelchecked) process:
+ * - where it is located in the virtual address space;
+ * - where are located it's different memory mapping in the the
+ * virtual address space ;
+ * - all the debugging (DWARF) information,
+ * - location of the functions,
+ * - types
+ * - etc.
+ *
+ * It is not copyable because we are taking pointers to Types/Frames.
+ * We'd have to update/rebuild some data structures in order to copy
+ * successfully.
+ */
+
+class ObjectInformation {
+public:
+ ObjectInformation();
+
+ // Not copyable:
+ ObjectInformation(ObjectInformation const&) = delete;
+ ObjectInformation& operator=(ObjectInformation const&) = delete;
+
+ // Flag:
+ static const int Executable = 1;
+
+ /** Bitfield of flags */
+ int flags;
+ std::string file_name;
+ const void* start;
+ const void *end;
+ char *start_exec;
+ char *end_exec; // Executable segment
+ char *start_rw;
+ char *end_rw; // Read-write segment
+ char *start_ro;
+ char *end_ro; // read-only segment
+ std::unordered_map<std::uint64_t, simgrid::mc::Frame> subprograms;
+ // TODO, remove the mutable (to remove it we'll have to add a lot of const everywhere)
+ mutable std::vector<simgrid::mc::Variable> global_variables;
+ std::unordered_map<std::uint64_t, simgrid::mc::Type> types;
+ std::unordered_map<std::string, simgrid::mc::Type*> full_types_by_name;
+
+ /** Index of functions by IP
+ *
+ * The entries are sorted by low_pc and a binary search can be used to look
+ * them up. Should we used a binary tree instead?
+ */
+ std::vector<FunctionIndexEntry> functions_index;
+
+ bool executable() const
+ {
+ return this->flags & simgrid::mc::ObjectInformation::Executable;
+ }
+
+ bool privatized() const
+ {
+ return this->executable() && smpi_privatize_global_variables;
+ }
+
+ void* base_address() const;
+
+ simgrid::mc::Frame* find_function(const void *ip) const;
+ simgrid::mc::Variable* find_variable(const char* name) const;
+
+};
+
+}
+}
+
+#endif
--- /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. */
+
+#ifndef SIMGRID_MC_TYPE_HPP
+#define SIMGRID_MC_TYPE_HPP
+
+#include <vector>
+#include <string>
+
+#include "mc_forward.h"
+#include "mc_location.h"
+
+namespace simgrid {
+namespace mc {
+
+/** Represents a type in the program
+ *
+ * It is currently used to represent members of structs and unions as well.
+ */
+class Type {
+public:
+ Type();
+ Type(Type const& type) = default;
+ Type& operator=(Type const&) = default;
+ Type(Type&& type) = default;
+ Type& operator=(Type&&) = default;
+
+ /** The DWARF TAG of the type (e.g. DW_TAG_array_type) */
+ int type;
+ unsigned id; /* Offset in the section (in hexadecimal form) */
+ std::string name; /* Name of the type */
+ int byte_size; /* Size in bytes */
+ int element_count; /* Number of elements for array type */
+ unsigned type_id; /* DW_AT_type id */
+ std::vector<Type> members; /* if DW_TAG_structure_type, DW_TAG_class_type, DW_TAG_union_type*/
+ int is_pointer_type;
+
+ // Location (for members) is either of:
+ simgrid::mc::DwarfExpression location_expression;
+
+ simgrid::mc::Type* subtype; // DW_AT_type
+ simgrid::mc::Type* full_type; // The same (but more complete) type
+
+ bool has_offset_location() const
+ {
+ return location_expression.size() == 1 &&
+ location_expression[0].atom == DW_OP_plus_uconst;
+ }
+
+ // TODO, check if this shortcut is really necessary
+ int offset() const
+ {
+ xbt_assert(this->has_offset_location());
+ return this->location_expression[0].number;
+ }
+
+ void offset(int new_offset)
+ {
+ Dwarf_Op op;
+ op.atom = DW_OP_plus_uconst;
+ op.number = new_offset;
+ this->location_expression = { op };
+ }
+};
+
+}
+}
+
+#endif
--- /dev/null
+/* Copyright (c) 2007-2014. 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. */
+
+#ifndef SIMGRID_MC_VARIABLE_HPP
+#define SIMGRID_MC_VARIABLE_HPP
+
+#include <string>
+
+#include "mc_forward.h"
+#include "mc_location.h"
+
+namespace simgrid {
+namespace mc {
+
+class Variable {
+public:
+ Variable();
+
+ unsigned dwarf_offset; /* Global offset of the field. */
+ int global;
+ std::string name;
+ unsigned type_id;
+ simgrid::mc::Type* type;
+
+ // Use either of:
+ simgrid::mc::LocationList location_list;
+ void* address;
+
+ size_t start_scope;
+ simgrid::mc::ObjectInformation* object_info;
+};
+
+}
+}
+
+#endif
#include "mc_smx.h"
#include "mc_hash.hpp"
+#include "mc/ObjectInformation.hpp"
+#include "mc/Frame.hpp"
+#include "mc/Variable.hpp"
+
using simgrid::mc::remote;
extern "C" {
#include "mc_private.h"
#include "mc_smx.h"
+#include "mc/Frame.hpp"
+#include "mc/ObjectInformation.hpp"
+#include "mc/Variable.hpp"
+
#ifdef HAVE_SMPI
#include "smpi/private.h"
#endif
#include "mc/datatypes.h"
#include "mc/mc_private.h"
#include "mc/mc_snapshot.h"
+#include "mc/Type.hpp"
using simgrid::mc::remote;
#include "mc_object_info.h"
#include "mc_private.h"
+#include "mc_process.h"
+
+#include "mc/ObjectInformation.hpp"
+#include "mc/Variable.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_dwarf, mc, "DWARF processing");
#include "mc_object_info.h"
#include "mc_private.h"
+#include "mc_location.h"
+#include "mc/AddressSpace.hpp"
+#include "mc/Frame.hpp"
+#include "mc/ObjectInformation.hpp"
using simgrid::mc::remote;
/* Warning: autogenerated, do not edit! */
#include <dwarf.h>
+#include <elfutils/libdw.h>
#include <xbt/base.h>
#include "mc_object_info.h"
#include "mc_object_info.h"
#include "mc_private.h"
+#include "mc/Type.hpp"
/** Resolve snapshot in the process address space
*
#include "mc_object_info.h"
#include "mc_private.h"
+#include "mc/Frame.hpp"
+#include "mc/Type.hpp"
+#include "mc/Variable.hpp"
namespace simgrid {
namespace mc {
this->object_info = nullptr;
}
-// ObjectInformations
-
-ObjectInformation::ObjectInformation()
-{
- this->flags = 0;
- this->start = nullptr;
- this->end = nullptr;
- this->start_exec = nullptr;
- this->end_exec = nullptr;
- this->start_rw = nullptr;
- this->end_rw = nullptr;
- this->start_ro = nullptr;
- this->end_ro = nullptr;
-}
-
-/** Find the DWARF offset for this ELF object
- *
- * An offset is applied to address found in DWARF:
- *
- * * for an executable obejct, addresses are virtual address
- * (there is no offset) i.e.
- * \f$\text{virtual address} = \{dwarf address}\f$;
- *
- * * for a shared object, the addreses are offset from the begining
- * of the shared object (the base address of the mapped shared
- * object must be used as offset
- * i.e. \f$\text{virtual address} = \text{shared object base address}
- * + \text{dwarf address}\f$.
- */
-void *ObjectInformation::base_address() const
-{
- if (this->executable())
- return nullptr;
-
- void *result = this->start_exec;
- if (this->start_rw != NULL && result > (void *) this->start_rw)
- result = this->start_rw;
- if (this->start_ro != NULL && result > (void *) this->start_ro)
- result = this->start_ro;
- return result;
-}
-
-/* Find a function by instruction pointer */
-simgrid::mc::Frame* ObjectInformation::find_function(const void *ip) const
-{
- /* This is implemented by binary search on a sorted array.
- *
- * We do quite a lot ot those so we want this to be cache efficient.
- * We pack the only information we need in the index entries in order
- * to successfully do the binary search. We do not need the high_pc
- * during the binary search (only at the end) so it is not included
- * in the index entry. We could use parallel arrays as well.
- *
- * We cannot really use the std:: alogrithm for this.
- * We could use std::binary_search by including the high_pc inside
- * the FunctionIndexEntry.
- */
- const simgrid::mc::FunctionIndexEntry* base =
- this->functions_index.data();
- int i = 0;
- int j = this->functions_index.size() - 1;
- while (j >= i) {
- int k = i + ((j - i) / 2);
-
- /* In most of the search, we do not dereference the base[k].function.
- * This way the memory accesses are located in the base[k] array. */
- if (ip < base[k].low_pc)
- j = k - 1;
- else if (k < j && ip >= base[k + 1].low_pc)
- i = k + 1;
-
- /* At this point, the search is over.
- * Either we have found the correct function or we do not know
- * any function corresponding to this instruction address.
- * Only at the point do we derefernce the function pointer. */
- else if (ip < base[k].function->high_pc)
- return base[k].function;
- else
- return nullptr;
- }
- return nullptr;
-}
-
-simgrid::mc::Variable* ObjectInformation::find_variable(const char* name) const
-{
- for (simgrid::mc::Variable& variable : this->global_variables)
- if(variable.name == name)
- return &variable;
- return nullptr;
-}
-
}
}
\ No newline at end of file
/* 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. */
-/** file
- * Debug information for the MC.
- */
-
#ifndef SIMGRID_MC_OBJECT_INFO_H
#define SIMGRID_MC_OBJECT_INFO_H
-#include <cstdint>
-
-#include <string>
#include <vector>
-#include <unordered_map>
-
-#include <simgrid_config.h>
-#include <xbt/dict.h>
-#include <xbt/dynar.h>
+#include <memory>
-#include <elfutils/libdw.h>
+#include <xbt/base.h>
#include "mc_forward.hpp"
-#include "mc_location.h"
-#include "mc_process.h"
-#include "../smpi/private.h"
-
-// ***** Type
-
-namespace simgrid {
-namespace mc {
-
-/** Represents a type in the program
- *
- * It is currently used to represent members of structs and unions as well.
- */
-class Type {
-public:
- Type();
- Type(Type const& type) = default;
- Type& operator=(Type const&) = default;
- Type(Type&& type) = default;
- Type& operator=(Type&&) = default;
-
- /** The DWARF TAG of the type (e.g. DW_TAG_array_type) */
- int type;
- Dwarf_Off id; /* Offset in the section (in hexadecimal form) */
- std::string name; /* Name of the type */
- int byte_size; /* Size in bytes */
- int element_count; /* Number of elements for array type */
- std::uint64_t type_id; /* DW_AT_type id */
- std::vector<Type> members; /* if DW_TAG_structure_type, DW_TAG_class_type, DW_TAG_union_type*/
- int is_pointer_type;
-
- // Location (for members) is either of:
- simgrid::mc::DwarfExpression location_expression;
-
- simgrid::mc::Type* subtype; // DW_AT_type
- simgrid::mc::Type* full_type; // The same (but more complete) type
-
- bool has_offset_location() const
- {
- return location_expression.size() == 1 &&
- location_expression[0].atom == DW_OP_plus_uconst;
- }
-
- // TODO, check if this shortcut is really necessary
- int offset() const
- {
- xbt_assert(this->has_offset_location());
- return this->location_expression[0].number;
- }
-
- void offset(int new_offset)
- {
- Dwarf_Op op;
- op.atom = DW_OP_plus_uconst;
- op.number = new_offset;
- this->location_expression = { op };
- }
-};
-
-}
-}
-
-// ***** Object info
-
-namespace simgrid {
-namespace mc {
-
-class Variable {
-public:
- Variable();
-
- Dwarf_Off dwarf_offset; /* Global offset of the field. */
- int global;
- std::string name;
- std::uint64_t type_id;
- simgrid::mc::Type* type;
-
- // Use either of:
- simgrid::mc::LocationList location_list;
- void* address;
-
- size_t start_scope;
- simgrid::mc::ObjectInformation* object_info;
-};
-
-class Frame {
-public:
- Frame();
-
- int tag;
- std::string name;
- void *low_pc;
- void *high_pc;
- simgrid::mc::LocationList frame_base;
- std::vector<Variable> variables;
- unsigned long int id; /* DWARF offset of the subprogram */
- std::vector<Frame> scopes;
- Dwarf_Off abstract_origin_id;
- simgrid::mc::ObjectInformation* object_info;
-};
-
-/** An entry in the functions index
- *
- * See the code of ObjectInformation::find_function.
- */
-struct FunctionIndexEntry {
- void* low_pc;
- simgrid::mc::Frame* function;
-};
-
-/** Information about an (ELF) executable/sharedobject
- *
- * This contain sall the information we have at runtime about an
- * executable/shared object in the target (modelchecked) process:
- * - where it is located in the virtual address space;
- * - where are located it's different memory mapping in the the
- * virtual address space ;
- * - all the debugging (DWARF) information,
- * - location of the functions,
- * - types
- * - etc.
- *
- * It is not copyable because we are taking pointers to Types/Frames.
- * We'd have to update/rebuild some data structures in order to copy
- * successfully.
- */
-
-class ObjectInformation {
-public:
- ObjectInformation();
-
- // Not copyable:
- ObjectInformation(ObjectInformation const&) = delete;
- ObjectInformation& operator=(ObjectInformation const&) = delete;
-
- // Flag:
- static const int Executable = 1;
-
- /** Bitfield of flags */
- int flags;
- std::string file_name;
- const void* start;
- const void *end;
- char *start_exec;
- char *end_exec; // Executable segment
- char *start_rw;
- char *end_rw; // Read-write segment
- char *start_ro;
- char *end_ro; // read-only segment
- std::unordered_map<std::uint64_t, simgrid::mc::Frame> subprograms;
- // TODO, remove the mutable (to remove it we'll have to add a lot of const everywhere)
- mutable std::vector<simgrid::mc::Variable> global_variables;
- std::unordered_map<std::uint64_t, simgrid::mc::Type> types;
- std::unordered_map<std::string, simgrid::mc::Type*> full_types_by_name;
-
- /** Index of functions by IP
- *
- * The entries are sorted by low_pc and a binary search can be used to look
- * them up. Should we used a binary tree instead?
- */
- std::vector<FunctionIndexEntry> functions_index;
-
- bool executable() const
- {
- return this->flags & simgrid::mc::ObjectInformation::Executable;
- }
-
- bool privatized() const
- {
- return this->executable() && smpi_privatize_global_variables;
- }
-
- void* base_address() const;
-
- simgrid::mc::Frame* find_function(const void *ip) const;
- simgrid::mc::Variable* find_variable(const char* name) const;
-
-};
-
-}
-}
-
+#include "mc_memory_map.h"
XBT_INTERNAL std::shared_ptr<simgrid::mc::ObjectInformation> MC_find_object_info(
std::vector<simgrid::mc::VmMap> const& maps, const char* name, int executable);
XBT_INTERNAL void MC_dwarf_get_variables(simgrid::mc::ObjectInformation* info);
XBT_INTERNAL void MC_dwarf_get_variables_libdw(simgrid::mc::ObjectInformation* info);
+
XBT_INTERNAL const char* MC_dwarf_attrname(int attr);
XBT_INTERNAL const char* MC_dwarf_tagname(int tag);
#include "mc_process.h"
#include "mc_object_info.h"
-#include "AddressSpace.hpp"
#include "mc_unw.h"
#include "mc_snapshot.h"
#include "mc_ignore.h"
#include "mc_smx.h"
#include "mc_server.h"
+#include "mc/AddressSpace.hpp"
+#include "mc/ObjectInformation.hpp"
+#include "mc/Variable.hpp"
+
using simgrid::mc::remote;
extern "C" {
#include "mc_object_info.h"
#include "mc_process.h"
#include "mc_unw.h"
+#include "mc/Frame.hpp"
using simgrid::mc::remote;
#include "mc/mc_protocol.h"
#include "mc/mc_client.h"
+#include "mc/Frame.hpp"
+#include "mc/Variable.hpp"
+#include "mc/ObjectInformation.hpp"
+
extern "C" {
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mcer_ignore, mc,
#include <xbt.h>
#include <mc/mc.h>
-#include "../../src/include/mc/datatypes.h"
-#include "../../src/mc/mc_object_info.h"
-#include "../../src/mc/mc_private.h"
+#include "mc/datatypes.h"
+#include "mc/mc_object_info.h"
+#include "mc/mc_private.h"
+#include "mc/mc_process.h"
+
+#include "mc/Type.hpp"
+#include "mc/ObjectInformation.hpp"
+#include "mc/Variable.hpp"
int test_some_array[4][5][6];
struct some_struct { int first; int second[4][5]; } test_some_struct;
#include <assert.h>
#include <stdlib.h>
-#include "../src/mc/mc_private.h"
-#include "../src/mc/mc_object_info.h"
+#include "mc/mc_process.h"
+#include "mc/mc_private.h"
+#include "mc/mc_object_info.h"
+
+#include "mc/Type.hpp"
+#include "mc/ObjectInformation.hpp"
+#include "mc/Variable.hpp"
static simgrid::mc::Process* process;
/* Warning: autogenerated, do not edit! */
#include <dwarf.h>
+#include <elfutils/libdw.h>
#include <xbt/base.h>
#include "mc_object_info.h"