instead of using Type (which is now only used for types).
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 {
+/** Represent a member of a structure (or inheritance) */
+class Member {
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;
+ Member() : inheritance(false), byte_size(0), type_id(0) {}
- // Location (for members) is either of:
+ bool inheritance;
+ std::string name;
simgrid::mc::DwarfExpression location_expression;
-
- simgrid::mc::Type* subtype; // DW_AT_type
- simgrid::mc::Type* full_type; // The same (but more complete) type
+ std::size_t byte_size; // Do we really need this?
+ unsigned type_id;
+ simgrid::mc::Type* type;
bool has_offset_location() const
{
}
};
+/** 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<Member> members; /* if DW_TAG_structure_type, DW_TAG_class_type, DW_TAG_union_type*/
+ int is_pointer_type;
+
+ simgrid::mc::Type* subtype; // DW_AT_type
+ simgrid::mc::Type* full_type; // The same (but more complete) type
+};
+
inline
Type::Type()
{
#include "mc_liveness.h"
#include "mc_private.h"
#include "mc_smx.h"
+#include "mc_dwarf.hpp"
#include "mc/Frame.hpp"
#include "mc/ObjectInformation.hpp"
}
case DW_TAG_structure_type:
case DW_TAG_class_type:
- for(simgrid::mc::Type& member : type->members) {
+ for(simgrid::mc::Member& member : type->members) {
void *member1 =
mc_member_resolve(real_area1, type, &member, snapshot1, process_index);
void *member2 =
compare_areas_with_type(state, process_index,
member1, snapshot1, subregion1,
member2, snapshot2, subregion2,
- member.subtype, pointer_level);
+ member.type, pointer_level);
if (res == 1)
return res;
}
#include "mc/datatypes.h"
#include "mc/mc_private.h"
#include "mc/mc_snapshot.h"
+#include "mc/mc_dwarf.hpp"
#include "mc/Type.hpp"
using simgrid::mc::remote;
return -1;
}
} else {
- for(simgrid::mc::Type& member : type->members) {
+ for(simgrid::mc::Member& member : type->members) {
// TODO, optimize this? (for the offset case)
void *real_member1 =
mc_member_resolve(real_area1, type, &member, (simgrid::mc::AddressSpace*) snapshot1, process_index);
res =
compare_heap_area_with_type(state, process_index, real_member1, real_member2,
snapshot1, snapshot2,
- previous, member.subtype, -1,
+ previous, member.type, -1,
check_ignore, 0);
if (res == 1) {
return res;
else
return NULL;
} else {
- for(simgrid::mc::Type& member : type->members) {
+ for(simgrid::mc::Member& member : type->members) {
if (member.has_offset_location()) {
// We have the offset, use it directly (shortcut):
if (member.offset() == offset)
- return member.subtype;
+ return member.type;
} else {
void *real_member =
mc_member_resolve(real_base_address, type, &member,
snapshot, process_index);
if ((char*) real_member - (char *) real_base_address == offset)
- return member.subtype;
+ return member.type;
}
}
* \param member the member of the type
* \param child DIE of the member (DW_TAG_member)
*/
-static void MC_dwarf_fill_member_location(simgrid::mc::Type* type, simgrid::mc::Type* member,
- Dwarf_Die * child)
+static void MC_dwarf_fill_member_location(
+ simgrid::mc::Type* type, simgrid::mc::Member* member, Dwarf_Die * child)
{
if (dwarf_hasattr(child, DW_AT_data_bit_offset))
xbt_die("Can't groke DW_AT_data_bit_offset.");
continue;
// TODO, we should use another type (because is is not a type but a member)
- simgrid::mc::Type member;
- member.type = tag;
-
- // Global Offset:
- member.id = dwarf_dieoffset(&child);
+ simgrid::mc::Member member;
+ member.inheritance = tag == DW_TAG_inheritance;
const char *name = MC_dwarf_attr_integrate_string(&child, DW_AT_name);
if (name)
member.name = name;
member.byte_size =
MC_dwarf_attr_integrate_uint(&child, DW_AT_byte_size, 0);
- member.element_count = -1;
member.type_id = MC_dwarf_at_type(&child);
if (dwarf_hasattr(&child, DW_AT_data_bit_offset))
}
-/** \brief Fill/lookup the "subtype" field.
- */
-static void MC_resolve_subtype(simgrid::mc::ObjectInformation* info, simgrid::mc::Type* type)
+static
+simgrid::mc::Type* MC_resolve_type(
+ simgrid::mc::ObjectInformation* info, unsigned type_id)
{
- if (!type->type_id)
- return;
- type->subtype = simgrid::util::find_map_ptr(info->types, type->type_id);
- if (type->subtype == nullptr)
- return;
- if (type->subtype->byte_size != 0)
- return;
- if (type->subtype->name.empty())
- return;
+ if (!type_id)
+ return nullptr;
+ simgrid::mc::Type* type = simgrid::util::find_map_ptr(info->types, type_id);
+ if (type == nullptr)
+ return nullptr;
+
+ // We already have the information on the type:
+ if (type->byte_size != 0)
+ return type;
+
+ // Don't have a name, we can't find a more complete version:
+ if (type->name.empty())
+ return type;
+
// Try to find a more complete description of the type:
// We need to fix in order to support C++.
simgrid::mc::Type** subtype = simgrid::util::find_map_ptr(
- info->full_types_by_name, type->subtype->name);
+ info->full_types_by_name, type->name);
if (subtype)
- type->subtype = *subtype;
+ type = *subtype;
+ return type;
}
static void MC_post_process_types(simgrid::mc::ObjectInformation* info)
{
// Lookup "subtype" field:
for(auto& i : info->types) {
- MC_resolve_subtype(info, &(i.second));
- for (simgrid::mc::Type& member : i.second.members)
- MC_resolve_subtype(info, &member);
+ i.second.subtype = MC_resolve_type(info, i.second.type_id);
+ for (simgrid::mc::Member& member : i.second.members)
+ member.type = MC_resolve_type(info, member.type_id);
}
}
XBT_PRIVATE const char* MC_dwarf_tagname(int tag);
XBT_PRIVATE void* mc_member_resolve(
- const void* base, simgrid::mc::Type* type, simgrid::mc::Type* member,
+ const void* base, simgrid::mc::Type* type, simgrid::mc::Member* member,
simgrid::mc::AddressSpace* snapshot, int process_index);
#endif
class Process;
class Snapshot;
class ObjectInformation;
+class Member;
class Type;
class Variable;
class Frame;
* @param snapshot Snapshot (or NULL)
* @return Process address of the given member of the 'object' struct/class
*/
-void *mc_member_resolve(const void *base, simgrid::mc::Type* type, simgrid::mc::Type* member,
- simgrid::mc::AddressSpace* address_space, int process_index)
+void *mc_member_resolve(
+ const void *base, simgrid::mc::Type* type, simgrid::mc::Member* member,
+ simgrid::mc::AddressSpace* address_space, int process_index)
{
// TODO, get rid of this?
if (!member->has_offset_location())
XBT_PRIVATE const char* MC_dwarf_attrname(int attr);
XBT_PRIVATE const char* MC_dwarf_tagname(int tag);
-XBT_PRIVATE void* mc_member_resolve(
- const void* base, simgrid::mc::Type* type, simgrid::mc::Type* member,
- simgrid::mc::AddressSpace* snapshot, int process_index);
-
#endif
return variable;
}
-static simgrid::mc::Type* find_member(simgrid::mc::ObjectInformation* info, const char* name, simgrid::mc::Type* type)
+static simgrid::mc::Member* find_member(simgrid::mc::Type& type, const char* name)
{
- for (simgrid::mc::Type& member : type->members)
+ for (simgrid::mc::Member& member : type.members)
if(member.name == name)
return &member;
return nullptr;
i = process->binary_info->types.find(var->type_id);
xbt_assert(i != process->binary_info->types.end(), "Missing type");
type = &i->second;
- assert(find_member(process->binary_info.get(), "first", type)->offset() == 0);
- assert(find_member(process->binary_info.get(), "second", type)->offset()
+
+ assert(type);
+ assert(find_member(*type, "first")->offset() == 0);
+ assert(find_member(*type, "second")->offset()
== ((const char*)&test_some_struct.second) - (const char*)&test_some_struct);
unw_context_t context;