X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d4cffd7edd2269eb55baf61bee016bd7cb4a107d..2f6b0aa5c5a2fada81b8593c0ba9d930a7ce41d2:/src/mc/LocationList.cpp diff --git a/src/mc/LocationList.cpp b/src/mc/LocationList.cpp index 34e55e4b2e..8bb46615c4 100644 --- a/src/mc/LocationList.cpp +++ b/src/mc/LocationList.cpp @@ -1,12 +1,20 @@ -/* Copyright (c) 2004-2015. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2004-2017. 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 "mc_dwarf.hpp" -#include -#include +#include +#include +#include + +#include "xbt/asserts.h" +#include "xbt/sysdep.h" + +#include + +#include "src/mc/mc_dwarf.hpp" +#include "src/mc/ObjectInformation.hpp" +#include "src/mc/LocationList.hpp" namespace simgrid { namespace dwarf { @@ -26,13 +34,9 @@ Location resolve( context.object_info = object_info; context.process_index = process_index; - if (!expression.empty() - && expression[0].atom >= DW_OP_reg0 - && expression[0].atom <= DW_OP_reg31) { + if (not expression.empty() && expression[0].atom >= DW_OP_reg0 && expression[0].atom <= DW_OP_reg31) { int dwarf_register = expression[0].atom - DW_OP_reg0; - xbt_assert(c, - "Missing frame context for register operation DW_OP_reg%i", - dwarf_register); + xbt_assert(c, "Missing frame context for register operation DW_OP_reg%i", dwarf_register); return Location(dwarf_register_to_libunwind(dwarf_register)); } @@ -47,7 +51,7 @@ static simgrid::dwarf::DwarfExpression const* find_expression( { for (simgrid::dwarf::LocationListEntry const& entry : locations) if (entry.valid_for_ip(ip)) - return &entry.expression; + return &entry.expression(); return nullptr; } @@ -64,51 +68,46 @@ Location resolve( xbt_die("Could not resolve IP"); simgrid::dwarf::DwarfExpression const* expression = find_expression(locations, ip); - if (!expression) + if (not expression) xbt_die("Could not resolve location"); return simgrid::dwarf::resolve( *expression, object_info, c, frame_pointer_address, address_space, process_index); } -simgrid::dwarf::LocationList location_list( +LocationList location_list( simgrid::mc::ObjectInformation& info, Dwarf_Attribute& attr) { - simgrid::dwarf::LocationList locations; + LocationList locations; std::ptrdiff_t offset = 0; while (1) { - - Dwarf_Addr base, start, end; + Dwarf_Addr base; + Dwarf_Addr start; + Dwarf_Addr end; Dwarf_Op *ops; std::size_t len; - offset = dwarf_getlocations( - &attr, offset, &base, &start, &end, &ops, &len); + offset = dwarf_getlocations(&attr, offset, &base, &start, &end, &ops, &len); if (offset == 0) - return std::move(locations); + break; else if (offset == -1) xbt_die("Error while loading location list"); - simgrid::dwarf::LocationListEntry entry; - entry.expression = simgrid::dwarf::DwarfExpression(ops, ops + len); - - void *base_address = info.base_address(); + std::uint64_t base_address = (std::uint64_t) info.base_address(); - // If start == 0, this is not a location list: - if (start == 0) { - entry.lowpc = nullptr; - entry.highpc = nullptr; - } else { - entry.lowpc = (char *) base_address + start; - entry.highpc = (char *) base_address + end; - } + LocationListEntry::range_type range; + if (start == 0) + // If start == 0, this is not a location list: + range = { 0, UINT64_MAX }; + else + range = { base_address + start, base_address + end }; - locations.push_back(std::move(entry)); + locations.push_back({ DwarfExpression(ops, ops+len), range }); } -} - + return locations; +} +} } -} \ No newline at end of file