X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/ea9cce21b6d3f37823143217f1ca183bb2f0c9ac..debe4e5871c0c3d1c714bbb1bd28ba7147454aa5:/src/mc/mc_member.cpp diff --git a/src/mc/mc_member.cpp b/src/mc/mc_member.cpp index a75a9afdb5..c92ab41a9b 100644 --- a/src/mc/mc_member.cpp +++ b/src/mc/mc_member.cpp @@ -1,47 +1,38 @@ -/* Copyright (c) 2014. The SimGrid Team. +/* Copyright (c) 2014-2019. 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 +#include "src/mc/Type.hpp" +#include "src/mc/mc_dwarf.hpp" +#include "src/mc/mc_private.hpp" -#include "mc_object_info.h" -#include "mc_private.h" - -extern "C" { +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, dw_type_t type, dw_type_t member, - mc_address_space_t 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) { - if (!member->location.size) { - 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 (mc_dwarf_execute_expression - (member->location.size, member->location.ops, &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(); } } +}