X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/7da2926d0733ff0683f31aeea176ce71e127264f..0a82e90d4cfdd7e27e1b946d22aff74a5abdda99:/src/mc/mc_member.cpp diff --git a/src/mc/mc_member.cpp b/src/mc/mc_member.cpp index 2dc276b690..8ce5366117 100644 --- a/src/mc/mc_member.cpp +++ b/src/mc/mc_member.cpp @@ -4,21 +4,22 @@ /* 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( +void *resolve_member( const void *base, simgrid::mc::Type* type, simgrid::mc::Member* member, simgrid::mc::AddressSpace* address_space, int process_index) { @@ -26,20 +27,17 @@ void *mc_member_resolve( 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(); +} + +} }