X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/5a97de8c98502af9f74cfceb924fa02e0fd80925..4b6ea22affbf2fb45a2e80779c789047121ceff6:/src/mc/mc_location.h diff --git a/src/mc/mc_location.h b/src/mc/mc_location.h index 45657f4551..7f603281a8 100644 --- a/src/mc/mc_location.h +++ b/src/mc/mc_location.h @@ -4,36 +4,50 @@ /* 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. */ -#ifndef MC_OBJECT_LOCATION_H -#define MC_OBJECT_LOCATION_H +#ifndef SIMGRID_MC_OBJECT_LOCATION_H +#define SIMGRID_MC_OBJECT_LOCATION_H #include -#define UNW_LOCAL_ONLY +#include + #include #include #include #include -#include "mc_interface.h" -#include "mc_object_info.h" +#include "mc_base.h" #include "mc_forward.h" +#include "AddressSpace.hpp" -SG_BEGIN_DECL() +namespace simgrid { +namespace mc { + +typedef std::vector DwarfExpression; -/** \brief a DWARF expression with optional validity contraints */ -typedef struct s_mc_expression { - size_t size; - Dwarf_Op* ops; - // Optional validity: + +/** \brief A DWARF expression with optional validity contraints */ +class LocationListEntry { +public: + DwarfExpression expression; void* lowpc, *highpc; -} s_mc_expression_t, *mc_expression_t; -/** A location list (list of location expressions) */ -typedef struct s_mc_location_list { - size_t size; - mc_expression_t locations; -} s_mc_location_list_t, *mc_location_list_t; + LocationListEntry() : lowpc(nullptr), highpc(nullptr) {} + + bool valid_for_ip(unw_word_t ip) + { + return (this->lowpc == nullptr && this->highpc == nullptr) + || (ip >= (unw_word_t) this->lowpc + && ip < (unw_word_t) this->highpc); + } +}; + +typedef std::vector LocationList; + +} +} + +SG_BEGIN_DECL() /** A location is either a location in memory of a register location * @@ -76,16 +90,20 @@ enum mc_location_type mc_get_location_type(mc_location_t location) { } } -void mc_dwarf_resolve_location(mc_location_t location, mc_expression_t expression, mc_object_info_t object_info, unw_cursor_t* c, void* frame_pointer_address, mc_snapshot_t snapshot, int process_index); -void mc_dwarf_resolve_locations(mc_location_t location, mc_location_list_t locations, mc_object_info_t object_info, unw_cursor_t* c, void* frame_pointer_address, mc_snapshot_t snapshot, int process_index); - -void mc_dwarf_expression_clear(mc_expression_t expression); -void mc_dwarf_expression_init(mc_expression_t expression, size_t len, Dwarf_Op* ops); - -void mc_dwarf_location_list_clear(mc_location_list_t list); - -void mc_dwarf_location_list_init_from_expression(mc_location_list_t target, size_t len, Dwarf_Op* ops); -void mc_dwarf_location_list_init(mc_location_list_t target, mc_object_info_t info, Dwarf_Die* die, Dwarf_Attribute* attr); +XBT_INTERNAL void mc_dwarf_resolve_location( + mc_location_t location, simgrid::mc::DwarfExpression* expression, + mc_object_info_t object_info, unw_cursor_t* c, + void* frame_pointer_address, mc_address_space_t address_space, + int process_index); +MC_SHOULD_BE_INTERNAL void mc_dwarf_resolve_locations( + mc_location_t location, simgrid::mc::LocationList* locations, + mc_object_info_t object_info, unw_cursor_t* c, + void* frame_pointer_address, mc_address_space_t address_space, + int process_index); + +XBT_INTERNAL void mc_dwarf_location_list_init( + simgrid::mc::LocationList*, mc_object_info_t info, Dwarf_Die* die, + Dwarf_Attribute* attr); #define MC_EXPRESSION_STACK_SIZE 64 @@ -103,15 +121,30 @@ typedef struct s_mc_expression_state { unw_cursor_t* cursor; void* frame_base; - mc_snapshot_t snapshot; + mc_address_space_t address_space; mc_object_info_t object_info; int process_index; } s_mc_expression_state_t, *mc_expression_state_t; -int mc_dwarf_execute_expression(size_t n, const Dwarf_Op* ops, mc_expression_state_t state); +MC_SHOULD_BE_INTERNAL int mc_dwarf_execute_expression( + size_t n, const Dwarf_Op* ops, mc_expression_state_t state); -void* mc_find_frame_base(dw_frame_t frame, mc_object_info_t object_info, unw_cursor_t* unw_cursor); +MC_SHOULD_BE_INTERNAL void* mc_find_frame_base( + mc_frame_t frame, mc_object_info_t object_info, unw_cursor_t* unw_cursor); SG_END_DECL() +namespace simgrid { +namespace mc { + +inline +int execute(DwarfExpression const& expression, mc_expression_state_t state) +{ + return mc_dwarf_execute_expression( + expression.size(), expression.data(), state); +} + +} +} + #endif