X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/5f32263569ffe21e013c081a922778e4cb785d7f..c4f1fe5c9bd8fa83fd0cdf873f27634930e02d95:/src/mc/DwarfExpression.cpp diff --git a/src/mc/DwarfExpression.cpp b/src/mc/DwarfExpression.cpp index ddb3799488..ecedcb2da5 100644 --- a/src/mc/DwarfExpression.cpp +++ b/src/mc/DwarfExpression.cpp @@ -10,27 +10,21 @@ #include #include -#include "mc_object_info.h" -#include "mc_private.h" -#include "mc/LocationList.hpp" -#include "mc/AddressSpace.hpp" -#include "mc/Frame.hpp" -#include "mc/ObjectInformation.hpp" -#include "mc/DwarfExpression.hpp" -#include "mc_dwarf.hpp" +#include "src/mc/mc_object_info.h" +#include "src/mc/mc_private.h" +#include "src/mc/LocationList.hpp" +#include "src/mc/AddressSpace.hpp" +#include "src/mc/Frame.hpp" +#include "src/mc/ObjectInformation.hpp" +#include "src/mc/DwarfExpression.hpp" +#include "src/mc/mc_dwarf.hpp" using simgrid::mc::remote; namespace simgrid { namespace dwarf { -evaluation_error::~evaluation_error() {} - -} -} - -namespace simgrid { -namespace dwarf { +evaluation_error::~evaluation_error() noexcept(true) {} void execute( const Dwarf_Op* ops, std::size_t n, @@ -89,9 +83,17 @@ void execute( // Push the CFA (Canonical Frame Addresse): case DW_OP_call_frame_cfa: { - // UNW_X86_64_CFA does not return the CFA DWARF expects - // (it is a synonym for UNW_X86_64_RSP) so copy the cursor, - // unwind it once in order to find the parent SP: + /* See 6.4 of DWARF4 (http://dwarfstd.org/doc/DWARF4.pdf#page=140): + * + * > Typically, the CFA is defined to be the value of the stack + * > pointer at the call site in the previous frame (which may be + * > different from its value on entry to the current frame). + * + * We need to unwind the frame in order to get the SP of the parent + * frame. + * + * Warning: the CFA returned by libunwind (UNW_X86_64_RSP, etc.) + * is the SP of the *current* frame. */ if (!context.cursor) throw evaluation_error("Missint cursor"); @@ -267,39 +269,3 @@ void execute( } } - -extern "C" { - -void mc_dwarf_location_list_init( - simgrid::dwarf::LocationList* list, simgrid::mc::ObjectInformation* info, - Dwarf_Die * die, Dwarf_Attribute * attr) -{ - list->clear(); - - std::ptrdiff_t offset = 0; - Dwarf_Addr base, start, end; - Dwarf_Op *ops; - std::size_t len; - - while (1) { - - offset = dwarf_getlocations(attr, offset, &base, &start, &end, &ops, &len); - if (offset == 0) - return; - 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 = info->base_address(); - // If start == 0, this is not a location list: - entry.lowpc = start == 0 ? NULL : (char *) base + start; - entry.highpc = start == 0 ? NULL : (char *) base + end; - - list->push_back(std::move(entry)); - } - -} - -}