1 /* Copyright (c) 2007-2014. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
8 * Debug information for the MC.
11 #ifndef SIMGRID_MC_OBJECT_INFO_H
12 #define SIMGRID_MC_OBJECT_INFO_H
17 #include <simgrid_config.h>
19 #include <xbt/dynar.h>
21 #include "mc_forward.h"
22 #include "mc_location.h"
23 #include "mc_process.h"
24 #include "../smpi/private.h"
28 typedef int e_dw_type_type;
35 Dwarf_Off id; /* Offset in the section (in hexadecimal form) */
36 char *name; /* Name of the type */
37 int byte_size; /* Size in bytes */
38 int element_count; /* Number of elements for array type */
39 char *dw_type_id; /* DW_AT_type id */
40 xbt_dynar_t members; /* if DW_TAG_structure_type, DW_TAG_class_type, DW_TAG_union_type*/
43 // Location (for members) is either of:
44 struct s_mc_expression location;
47 dw_type_t subtype; // DW_AT_type
48 dw_type_t full_type; // The same (but more complete) type
51 XBT_INTERNAL void dw_variable_free(dw_variable_t v);
52 XBT_INTERNAL void dw_variable_free_voidp(void *t);
56 /** Bit field of options */
57 typedef int mc_object_info_flags;
58 #define MC_OBJECT_INFO_NONE 0
59 #define MC_OBJECT_INFO_EXECUTABLE 1
64 class ObjectInformation {
68 ObjectInformation(ObjectInformation const&) = delete;
69 ObjectInformation& operator=(ObjectInformation const&) = delete;
71 mc_object_info_flags flags;
76 char *end_exec; // Executable segment
78 char *end_rw; // Read-write segment
80 char *end_ro; // read-only segment
81 xbt_dict_t subprograms; // xbt_dict_t<origin as hexadecimal string, dw_frame_t>
82 xbt_dynar_t global_variables; // xbt_dynar_t<dw_variable_t>
83 xbt_dict_t types; // xbt_dict_t<origin as hexadecimal string, dw_type_t>
84 xbt_dict_t full_types_by_name; // xbt_dict_t<name, dw_type_t> (full defined type only)
86 // Here we sort the minimal information for an efficient (and cache-efficient)
87 // lookup of a function given an instruction pointer.
88 // The entries are sorted by low_pc and a binary search can be used to look them up.
89 xbt_dynar_t functions_index;
91 bool executable() const
93 return this->flags & MC_OBJECT_INFO_EXECUTABLE;
96 bool privatized() const
98 return this->executable() && smpi_privatize_global_variables;
101 void* base_address() const;
103 dw_frame_t find_function(const void *ip) const;
104 dw_variable_t find_variable(const char* name) const;
111 XBT_INTERNAL std::shared_ptr<s_mc_object_info_t> MC_find_object_info(
112 std::vector<simgrid::mc::VmMap> const& maps, const char* name, int executable);
113 XBT_INTERNAL void MC_post_process_object_info(mc_process_t process, mc_object_info_t info);
115 XBT_INTERNAL void MC_dwarf_get_variables(mc_object_info_t info);
116 XBT_INTERNAL void MC_dwarf_get_variables_libdw(mc_object_info_t info);
117 XBT_INTERNAL const char* MC_dwarf_attrname(int attr);
118 XBT_INTERNAL const char* MC_dwarf_tagname(int tag);
120 XBT_INTERNAL void* mc_member_resolve(const void* base, dw_type_t type, dw_type_t member, mc_address_space_t snapshot, int process_index);
122 struct s_dw_variable{
123 Dwarf_Off dwarf_offset; /* Global offset of the field. */
130 s_mc_location_list_t locations;
134 mc_object_info_t object_info;
143 s_mc_location_list_t frame_base;
144 xbt_dynar_t /* <dw_variable_t> */ variables; /* Cannot use dict, there may be several variables with the same name (in different lexical blocks)*/
145 unsigned long int id; /* DWARF offset of the subprogram */
146 xbt_dynar_t /* <dw_frame_t> */ scopes;
147 Dwarf_Off abstract_origin_id;
148 mc_object_info_t object_info;
151 struct s_mc_function_index_item {
152 void* low_pc, *high_pc;
156 XBT_INTERNAL void mc_frame_free(dw_frame_t freme);