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 MC_OBJECT_INFO_H
12 #define MC_OBJECT_INFO_H
16 #include <simgrid_config.h>
18 #include <xbt/dynar.h>
20 #include "mc_forward.h"
21 #include "mc_location.h"
27 typedef int e_dw_type_type;
31 Dwarf_Off id; /* Offset in the section (in hexadecimal form) */
32 char *name; /* Name of the type */
33 int byte_size; /* Size in bytes */
34 int element_count; /* Number of elements for array type */
35 char *dw_type_id; /* DW_AT_type id */
36 xbt_dynar_t members; /* if DW_TAG_structure_type, DW_TAG_class_type, DW_TAG_union_type*/
39 // Location (for members) is either of:
40 struct s_mc_expression location;
43 dw_type_t subtype; // DW_AT_type
44 dw_type_t full_type; // The same (but more complete) type
47 void dw_type_free(dw_type_t t);
48 void dw_variable_free(dw_variable_t v);
49 void dw_variable_free_voidp(void *t);
53 enum mc_object_info_flags {
54 MC_OBJECT_INFO_NONE = 0,
55 MC_OBJECT_INFO_EXECUTABLE = 1
58 struct s_mc_object_info {
59 enum mc_object_info_flags flags;
61 char *start_exec, *end_exec; // Executable segment
62 char *start_rw, *end_rw; // Read-write segment
63 char *start_ro, *end_ro; // read-only segment
64 xbt_dict_t subprograms; // xbt_dict_t<origin as hexadecimal string, dw_frame_t>
65 xbt_dynar_t global_variables; // xbt_dynar_t<dw_variable_t>
66 xbt_dict_t types; // xbt_dict_t<origin as hexadecimal string, dw_type_t>
67 xbt_dict_t full_types_by_name; // xbt_dict_t<name, dw_type_t> (full defined type only)
69 // Here we sort the minimal information for an efficient (and cache-efficient)
70 // lookup of a function given an instruction pointer.
71 // The entries are sorted by low_pc and a binary search can be used to look them up.
72 xbt_dynar_t functions_index;
75 /** Find the DWARF offset for this ELF object
77 * An offset is applied to address found in DWARF:
80 * <li>for an executable obejct, addresses are virtual address
81 * (there is no offset) i.e. \f$\text{virtual address} = \{dwarf address}\f$;</li>
82 * <li>for a shared object, the addreses are offset from the begining
83 * of the shared object (the base address of the mapped shared
84 * object must be used as offset
85 * i.e. \f$\text{virtual address} = \text{shared object base address}
86 * + \text{dwarf address}\f$.</li>
89 void* MC_object_base_address(mc_object_info_t info);
91 mc_object_info_t MC_new_object_info(void);
92 mc_object_info_t MC_find_object_info(memory_map_t maps, char* name, int executable);
93 void MC_free_object_info(mc_object_info_t* p);
95 void MC_post_process_object_info(mc_object_info_t info);
97 void MC_dwarf_get_variables(mc_object_info_t info);
98 void MC_dwarf_get_variables_libdw(mc_object_info_t info);
99 const char* MC_dwarf_attrname(int attr);
100 const char* MC_dwarf_tagname(int tag);
103 char* get_type_description(mc_object_info_t info, char *type_name);
105 extern mc_object_info_t mc_libsimgrid_info;
106 extern mc_object_info_t mc_binary_info;
107 extern mc_object_info_t mc_object_infos[2];
108 extern size_t mc_object_infos_size;
110 void* mc_member_resolve(const void* base, dw_type_t type, dw_type_t member, mc_snapshot_t snapshot, int process_index);
112 struct s_dw_variable{
113 Dwarf_Off dwarf_offset; /* Global offset of the field. */
120 s_mc_location_list_t locations;
124 mc_object_info_t object_info;
133 s_mc_location_list_t frame_base;
134 xbt_dynar_t /* <dw_variable_t> */ variables; /* Cannot use dict, there may be several variables with the same name (in different lexical blocks)*/
135 unsigned long int id; /* DWARF offset of the subprogram */
136 xbt_dynar_t /* <dw_frame_t> */ scopes;
137 Dwarf_Off abstract_origin_id;
138 mc_object_info_t object_info;
141 struct s_mc_function_index_item {
142 void* low_pc, *high_pc;
146 void mc_frame_free(dw_frame_t freme);