int result = 1;
Dwarf_Die child;
- int res;
- for (res = dwarf_child(die, &child); res == 0; res = dwarf_siblingof(&child, &child)) {
+ for (int res = dwarf_child(die, &child); res == 0; res = dwarf_siblingof(&child, &child)) {
int child_tag = dwarf_tag(&child);
if (child_tag == DW_TAG_subrange_type || child_tag == DW_TAG_enumeration_type)
result *= MC_dwarf_subrange_element_count(&child, unit);
static void MC_dwarf_add_members(const simgrid::mc::ObjectInformation* /*info*/, Dwarf_Die* die,
const Dwarf_Die* /*unit*/, simgrid::mc::Type* type)
{
- int res;
Dwarf_Die child;
xbt_assert(type->members.empty());
- for (res = dwarf_child(die, &child); res == 0; res = dwarf_siblingof(&child, &child)) {
+ for (int res = dwarf_child(die, &child); res == 0; res = dwarf_siblingof(&child, &child)) {
int tag = dwarf_tag(&child);
if (tag == DW_TAG_member || tag == DW_TAG_inheritance) {
// Skip declarations:
// No location: do not add it ?
return nullptr;
- std::unique_ptr<simgrid::mc::Variable> variable = std::unique_ptr<simgrid::mc::Variable>(new simgrid::mc::Variable());
- variable->id = dwarf_dieoffset(die);
- variable->global = frame == nullptr; // Can be override base on DW_AT_location
- variable->object_info = info;
+ auto variable = std::make_unique<simgrid::mc::Variable>();
+ variable->id = dwarf_dieoffset(die);
+ variable->global = frame == nullptr; // Can be override base on DW_AT_location
+ variable->object_info = info;
const char* name = MC_dwarf_attr_integrate_string(die, DW_AT_name);
if (name)
if (len == 1 && expr[0].atom == DW_OP_addr) {
variable->global = true;
- uintptr_t offset = (uintptr_t)expr[0].number;
- uintptr_t base = (uintptr_t)info->base_address();
- variable->address = (void*)(base + offset);
+ auto offset = static_cast<uintptr_t>(expr[0].number);
+ auto base = reinterpret_cast<uintptr_t>(info->base_address());
+ variable->address = reinterpret_cast<void*>(base + offset);
} else
variable->location_list = {
simgrid::dwarf::LocationListEntry(simgrid::dwarf::DwarfExpression(expr, expr + len))};
// This is the base address for DWARF addresses.
// Relocated addresses are offset from this base address.
// See DWARF4 spec 7.5
- std::uint64_t base = (std::uint64_t)info->base_address();
+ auto base = reinterpret_cast<std::uint64_t>(info->base_address());
// TODO, support DW_AT_ranges
uint64_t low_pc = MC_dwarf_attr_integrate_addr(die, DW_AT_low_pc);
{
// For each child DIE:
Dwarf_Die child;
- int res;
- for (res = dwarf_child(die, &child); res == 0; res = dwarf_siblingof(&child, &child))
+ for (int res = dwarf_child(die, &child); res == 0; res = dwarf_siblingof(&child, &child))
MC_dwarf_handle_die(info, &child, unit, frame, ns);
}
/** @brief Finds information about a given shared object/executable */
std::shared_ptr<ObjectInformation> createObjectInformation(std::vector<xbt::VmMap> const& maps, const char* name)
{
- std::shared_ptr<ObjectInformation> result = std::make_shared<ObjectInformation>();
- result->file_name = name;
+ auto result = std::make_shared<ObjectInformation>();
+ result->file_name = name;
simgrid::mc::find_object_address(maps, result.get());
MC_load_dwarf(result.get());
MC_post_process_variables(result.get());