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"
22 #include "mc_process.h"
28 typedef int e_dw_type_type;
32 Dwarf_Off id; /* Offset in the section (in hexadecimal form) */
33 char *name; /* Name of the type */
34 int byte_size; /* Size in bytes */
35 int element_count; /* Number of elements for array type */
36 char *dw_type_id; /* DW_AT_type id */
37 xbt_dynar_t members; /* if DW_TAG_structure_type, DW_TAG_class_type, DW_TAG_union_type*/
40 // Location (for members) is either of:
41 struct s_mc_expression location;
44 dw_type_t subtype; // DW_AT_type
45 dw_type_t full_type; // The same (but more complete) type
48 void dw_type_free(dw_type_t t);
49 void dw_variable_free(dw_variable_t v);
50 void dw_variable_free_voidp(void *t);
54 enum mc_object_info_flags {
55 MC_OBJECT_INFO_NONE = 0,
56 MC_OBJECT_INFO_EXECUTABLE = 1
59 struct s_mc_object_info {
60 enum mc_object_info_flags flags;
62 char *start_exec, *end_exec; // Executable segment
63 char *start_rw, *end_rw; // Read-write segment
64 char *start_ro, *end_ro; // read-only segment
65 xbt_dict_t subprograms; // xbt_dict_t<origin as hexadecimal string, dw_frame_t>
66 xbt_dynar_t global_variables; // xbt_dynar_t<dw_variable_t>
67 xbt_dict_t types; // xbt_dict_t<origin as hexadecimal string, dw_type_t>
68 xbt_dict_t full_types_by_name; // xbt_dict_t<name, dw_type_t> (full defined type only)
70 // Here we sort the minimal information for an efficient (and cache-efficient)
71 // lookup of a function given an instruction pointer.
72 // The entries are sorted by low_pc and a binary search can be used to look them up.
73 xbt_dynar_t functions_index;
76 /** Find the DWARF offset for this ELF object
78 * An offset is applied to address found in DWARF:
81 * <li>for an executable obejct, addresses are virtual address
82 * (there is no offset) i.e. \f$\text{virtual address} = \{dwarf address}\f$;</li>
83 * <li>for a shared object, the addreses are offset from the begining
84 * of the shared object (the base address of the mapped shared
85 * object must be used as offset
86 * i.e. \f$\text{virtual address} = \text{shared object base address}
87 * + \text{dwarf address}\f$.</li>
90 void* MC_object_base_address(mc_object_info_t info);
92 mc_object_info_t MC_new_object_info(void);
93 mc_object_info_t MC_find_object_info(memory_map_t maps, const char* name, int executable);
94 void MC_free_object_info(mc_object_info_t* p);
96 dw_frame_t MC_file_object_info_find_function(mc_object_info_t info, void *ip);
98 void MC_post_process_object_info(mc_process_t process, mc_object_info_t info);
100 void MC_dwarf_get_variables(mc_object_info_t info);
101 void MC_dwarf_get_variables_libdw(mc_object_info_t info);
102 const char* MC_dwarf_attrname(int attr);
103 const char* MC_dwarf_tagname(int tag);
106 char* get_type_description(mc_object_info_t info, char *type_name);
108 void* mc_member_resolve(const void* base, dw_type_t type, dw_type_t member, mc_snapshot_t snapshot, int process_index);
110 struct s_dw_variable{
111 Dwarf_Off dwarf_offset; /* Global offset of the field. */
118 s_mc_location_list_t locations;
122 mc_object_info_t object_info;
131 s_mc_location_list_t frame_base;
132 xbt_dynar_t /* <dw_variable_t> */ variables; /* Cannot use dict, there may be several variables with the same name (in different lexical blocks)*/
133 unsigned long int id; /* DWARF offset of the subprogram */
134 xbt_dynar_t /* <dw_frame_t> */ scopes;
135 Dwarf_Off abstract_origin_id;
136 mc_object_info_t object_info;
139 struct s_mc_function_index_item {
140 void* low_pc, *high_pc;
144 void mc_frame_free(dw_frame_t freme);