else if (type == simgrid::mc::RegionType::Heap)
xbt_assert(!object_info, "Unexpected object info for heap region.");
- const bool privatization_aware = MC_object_info_is_privatized(object_info);
+ const bool privatization_aware = object_info && object_info->privatized();
simgrid::mc::RegionSnapshot region;
if (privatization_aware && MC_smpi_process_count())
}
}
-// Not used:
-char *get_type_description(mc_object_info_t info, char *type_name)
-{
-
- xbt_dict_cursor_t dict_cursor;
- char *type_origin;
- dw_type_t type;
-
- xbt_dict_foreach(info->types, dict_cursor, type_origin, type) {
- if (type->name && (strcmp(type->name, type_name) == 0)
- && type->byte_size > 0) {
- xbt_dict_cursor_free(&dict_cursor);
- return type_origin;
- }
- }
-
- xbt_dict_cursor_free(&dict_cursor);
- return NULL;
-}
-
-
#ifndef max
#define max( a, b ) ( ((a) > (b)) ? (a) : (b) )
#endif
if (len == 1 && expr[0].atom == DW_OP_addr) {
variable->global = 1;
uintptr_t offset = (uintptr_t) expr[0].number;
- uintptr_t base = (uintptr_t) MC_object_base_address(info);
+ uintptr_t base = (uintptr_t) info->base_address();
variable->address = (void *) (base + offset);
} else {
mc_dwarf_location_list_init_from_expression(&variable->locations, len,
// This is the base address for DWARF addresses.
// Relocated addresses are offset from this base address.
// See DWARF4 spec 7.5
- void *base = MC_object_base_address(info);
+ void *base = info->base_address();
// Variables are filled in the (recursive) call of MC_dwarf_handle_children:
frame->variables =
// ***** object_info
-s_mc_object_info::s_mc_object_info()
+namespace simgrid {
+namespace mc {
+
+ObjectInformation::ObjectInformation()
{
this->flags = 0;
this->file_name = nullptr;
this->functions_index = nullptr;
}
-s_mc_object_info::~s_mc_object_info()
+ObjectInformation::~ObjectInformation()
{
xbt_free(this->file_name);
xbt_dict_free(&this->subprograms);
xbt_dynar_free(&this->functions_index);
}
-// ***** Helpers
-
-void *MC_object_base_address(mc_object_info_t info)
+/** Find the DWARF offset for this ELF object
+ *
+ * An offset is applied to address found in DWARF:
+ *
+ * <ul>
+ * <li>for an executable obejct, addresses are virtual address
+ * (there is no offset) i.e. \f$\text{virtual address} = \{dwarf address}\f$;</li>
+ * <li>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$.</li>
+ *
+ */
+void *ObjectInformation::base_address() const
{
- if (info->flags & MC_OBJECT_INFO_EXECUTABLE)
- return 0;
- void *result = info->start_exec;
- if (info->start_rw != NULL && result > (void *) info->start_rw)
- result = info->start_rw;
- if (info->start_ro != NULL && result > (void *) info->start_ro)
- result = info->start_ro;
+ 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;
}
+}
+}
+
+// ***** Helpers
+
// ***** Functions index
static int MC_compare_frame_index_items(mc_function_index_item_t a,
if (state->stack_size == MC_EXPRESSION_STACK_SIZE)
return MC_EXPRESSION_E_STACK_OVERFLOW;
Dwarf_Off addr = (Dwarf_Off) (uintptr_t)
- MC_object_base_address(state->object_info) + op->number;
+ state->object_info->base_address() + op->number;
error = mc_dwarf_push_value(state, addr);
break;
}
expression->ops = NULL;
mc_dwarf_expression_init(expression, len, ops);
- void *base =
- info->
- flags & MC_OBJECT_INFO_EXECUTABLE ? 0 : MC_object_base_address(info);
+ void *base = info->base_address();
// If start == 0, this is not a location list:
expression->lowpc = start == 0 ? NULL : (char *) base + start;
expression->highpc = start == 0 ? NULL : (char *) base + end;
class AddressSpace;
class Process;
class Snapshot;
+class ObjectInformation;
}
}
typedef ::simgrid::mc::AddressSpace s_mc_address_space_t;
typedef ::simgrid::mc::Process s_mc_process_t;
typedef ::simgrid::mc::Snapshot s_mc_snapshot_t;
+typedef ::simgrid::mc::ObjectInformation s_mc_object_info_t;
#else
typedef struct _s_mc_address_space_t s_mc_address_space_t;
typedef struct _s_mc_process_t s_mc_process_t;
typedef struct _s_mc_snapshot_t s_mc_snapshot_t;
+typedef struct _s_mc_object_info_t s_mc_object_info_t;
#endif
-typedef struct s_mc_object_info s_mc_object_info_t, *mc_object_info_t;
+
typedef struct s_dw_type s_dw_type_t, *dw_type_t;
typedef struct s_memory_map s_memory_map_t, *memory_map_t;
typedef struct s_dw_variable s_dw_variable_t, *dw_variable_t;
typedef s_mc_address_space_t *mc_address_space_t;
typedef s_mc_process_t *mc_process_t;
typedef s_mc_snapshot_t *mc_snapshot_t;
+typedef s_mc_object_info_t *mc_object_info_t;
SG_BEGIN_DECL()
extern mc_model_checker_t mc_model_checker;
#include "mc_object_info.h"
#include "mc_private.h"
-dw_frame_t MC_file_object_info_find_function(mc_object_info_t info, const void *ip)
+namespace simgrid {
+namespace mc {
+
+dw_frame_t ObjectInformation::find_function(const void *ip) const
{
- xbt_dynar_t dynar = info->functions_index;
+ xbt_dynar_t dynar = this->functions_index;
mc_function_index_item_t base =
(mc_function_index_item_t) xbt_dynar_get_ptr(dynar, 0);
int i = 0;
return base[k].function;
}
}
- return NULL;
+ return nullptr;
}
-dw_variable_t MC_file_object_info_find_variable_by_name(mc_object_info_t info, const char* name)
+dw_variable_t ObjectInformation::find_variable(const char* name) const
{
unsigned int cursor = 0;
dw_variable_t variable;
- xbt_dynar_foreach(info->global_variables, cursor, variable){
+ xbt_dynar_foreach(this->global_variables, cursor, variable){
if(!strcmp(name, variable->name))
return variable;
}
- return NULL;
+ return nullptr;
+}
+
}
+}
\ No newline at end of file
#define MC_OBJECT_INFO_NONE 0
#define MC_OBJECT_INFO_EXECUTABLE 1
-struct s_mc_object_info {
- s_mc_object_info();
- ~s_mc_object_info();
- s_mc_object_info(s_mc_object_info const&) = delete;
- s_mc_object_info& operator=(s_mc_object_info const&) = delete;
+namespace simgrid {
+namespace mc {
+
+class ObjectInformation {
+public:
+ ObjectInformation();
+ ~ObjectInformation();
+ ObjectInformation(ObjectInformation const&) = delete;
+ ObjectInformation& operator=(ObjectInformation const&) = delete;
mc_object_info_flags flags;
char* file_name;
// lookup of a function given an instruction pointer.
// The entries are sorted by low_pc and a binary search can be used to look them up.
xbt_dynar_t functions_index;
-};
-static inline __attribute__ ((always_inline))
-bool MC_object_info_executable(mc_object_info_t info)
-{
- return info->flags & MC_OBJECT_INFO_EXECUTABLE;
-}
+ bool executable() const
+ {
+ return this->flags & MC_OBJECT_INFO_EXECUTABLE;
+ }
-static inline __attribute__ ((always_inline))
-bool MC_object_info_is_privatized(mc_object_info_t info)
-{
- return info && MC_object_info_executable(info) && smpi_privatize_global_variables;
-}
+ bool privatized() const
+ {
+ return this->executable() && smpi_privatize_global_variables;
+ }
-/** Find the DWARF offset for this ELF object
- *
- * An offset is applied to address found in DWARF:
- *
- * <ul>
- * <li>for an executable obejct, addresses are virtual address
- * (there is no offset) i.e. \f$\text{virtual address} = \{dwarf address}\f$;</li>
- * <li>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$.</li>
- *
- */
-XBT_INTERNAL void* MC_object_base_address(mc_object_info_t info);
+ void* base_address() const;
-XBT_INTERNAL std::shared_ptr<s_mc_object_info_t> MC_find_object_info(
- std::vector<simgrid::mc::VmMap> const& maps, const char* name, int executable);
+ dw_frame_t find_function(const void *ip) const;
+ dw_variable_t find_variable(const char* name) const;
-XBT_INTERNAL void MC_free_object_info(mc_object_info_t* p);
+};
-XBT_INTERNAL dw_frame_t MC_file_object_info_find_function(mc_object_info_t info, const void *ip);
-MC_SHOULD_BE_INTERNAL dw_variable_t MC_file_object_info_find_variable_by_name(mc_object_info_t info, const char* name);
+}
+}
+XBT_INTERNAL std::shared_ptr<s_mc_object_info_t> MC_find_object_info(
+ std::vector<simgrid::mc::VmMap> const& maps, const char* name, int executable);
XBT_INTERNAL void MC_post_process_object_info(mc_process_t process, mc_object_info_t info);
XBT_INTERNAL void MC_dwarf_get_variables(mc_object_info_t info);
XBT_INTERNAL const char* MC_dwarf_attrname(int attr);
XBT_INTERNAL const char* MC_dwarf_tagname(int tag);
-// Not used:
-XBT_INTERNAL char* get_type_description(mc_object_info_t info, char *type_name);
-
XBT_INTERNAL void* mc_member_resolve(const void* base, dw_type_t type, dw_type_t member, mc_address_space_t snapshot, int process_index);
struct s_dw_variable{
return NULL;
}
-std::shared_ptr<s_mc_object_info_t> Process::find_object_info_exec(remote_ptr<void> addr) const
+std::shared_ptr<ObjectInformation> Process::find_object_info_exec(remote_ptr<void> addr) const
{
- for (std::shared_ptr<s_mc_object_info> const& info : this->object_infos) {
+ for (std::shared_ptr<ObjectInformation> const& info : this->object_infos) {
if (addr.address() >= (std::uint64_t) info->start_exec
&& addr.address() <= (std::uint64_t) info->end_exec) {
return info;
return nullptr;
}
-std::shared_ptr<s_mc_object_info_t> Process::find_object_info_rw(remote_ptr<void> addr) const
+std::shared_ptr<ObjectInformation> Process::find_object_info_rw(remote_ptr<void> addr) const
{
- for (std::shared_ptr<s_mc_object_info> const& info : this->object_infos) {
+ for (std::shared_ptr<ObjectInformation> const& info : this->object_infos) {
if (addr.address() >= (std::uint64_t)info->start_rw
&& addr.address() <= (std::uint64_t)info->end_rw) {
return info;
dw_frame_t Process::find_function(remote_ptr<void> ip) const
{
std::shared_ptr<s_mc_object_info_t> info = this->find_object_info_exec(ip);
- if (!info)
- return nullptr;
- else
- return MC_file_object_info_find_function(info.get(), (void*) ip.address());
+ return info ? info->find_function((void*) ip.address()) : nullptr;
}
/** Find (one occurence of) the named variable definition
// We need to look up the variable in the execvutable first.
if (this->binary_info) {
std::shared_ptr<s_mc_object_info_t> const& info = this->binary_info;
- dw_variable_t var = MC_file_object_info_find_variable_by_name(info.get(), name);
+ dw_variable_t var = info->find_variable(name);
if (var)
return var;
}
for (std::shared_ptr<s_mc_object_info_t> const& info : this->object_infos) {
- dw_variable_t var = MC_file_object_info_find_variable_by_name(info.get(), name);
+ dw_variable_t var = info->find_variable(name);
if (var)
return var;
}
std::shared_ptr<s_mc_object_info_t> const& info =
this->find_object_info_rw((void*)address.address());
// Segment overlap is not handled.
- if (MC_object_info_is_privatized(info.get())) {
+ if (info.get() && info.get()->privatized()) {
if (process_index < 0)
xbt_die("Missing process index");
if (process_index >= (int) MC_smpi_process_count())
static dw_variable_t test_global_variable(mc_process_t process, mc_object_info_t info, const char* name, void* address, long byte_size) {
- dw_variable_t variable = MC_file_object_info_find_variable_by_name(info, name);
+ dw_variable_t variable = info->find_variable(name);
xbt_assert(variable, "Global variable %s was not found", name);
xbt_assert(!strcmp(variable->name, name), "Name mismatch for %s", name);
xbt_assert(variable->global, "Variable %s is not global", name);