X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b3b356352e87ae00a20f737c48e19b0c8413455a..4b95f054f8e620b68676f19b9db38002889538c6:/src/mc/mc_member.cpp diff --git a/src/mc/mc_member.cpp b/src/mc/mc_member.cpp index 29fe1f5193..8ce5366117 100644 --- a/src/mc/mc_member.cpp +++ b/src/mc/mc_member.cpp @@ -4,41 +4,40 @@ /* 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 +#include "src/mc/mc_private.h" +#include "src/mc/Type.hpp" +#include "src/mc/mc_dwarf.hpp" -#include "mc_object_info.h" -#include "mc_private.h" -#include "mc/Type.hpp" +namespace simgrid { +namespace dwarf { /** Resolve snapshot in the process address space * * @param object Process address of the struct/class * @param type Type of the struct/class * @param member Member description - * @param snapshot Snapshot (or NULL) + * @param snapshot Snapshot (or nullptr) * @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 *resolve_member( + 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()) return ((char *) base) + member->offset(); - s_mc_expression_state_t state; - memset(&state, 0, sizeof(s_mc_expression_state_t)); - state.frame_base = NULL; - state.cursor = NULL; + ExpressionContext state; + state.frame_base = nullptr; + state.cursor = nullptr; state.address_space = address_space; - state.stack_size = 1; - state.stack[0] = (uintptr_t) base; state.process_index = process_index; - if (simgrid::mc::execute( - member->location_expression, &state)) - xbt_die("Error evaluating DWARF expression"); - if (state.stack_size == 0) - xbt_die("No value on the stack"); - else - return (void *) state.stack[state.stack_size - 1]; + ExpressionStack stack; + stack.push((ExpressionStack::value_type) base); + simgrid::dwarf::execute(member->location_expression, state, stack); + return (void*) stack.top(); +} + +} }