*/
static std::uint64_t MC_dwarf_at_type(Dwarf_Die * die);
-/** \brief A class of DWARF tags (DW_TAG_*)
- */
-typedef enum mc_tag_class {
- mc_tag_unknown,
- mc_tag_type,
- mc_tag_subprogram,
- mc_tag_variable,
- mc_tag_scope,
- mc_tag_namespace
-} mc_tag_class;
-
-static mc_tag_class MC_dwarf_tag_classify(int tag)
+namespace simgrid {
+namespace dwarf {
+
+enum class TagClass {
+ Unknown,
+ Type,
+ Subprogram,
+ Variable,
+ Scope,
+ Namespace
+};
+
+namespace {
+
+TagClass classify_tag(int tag)
{
switch (tag) {
case DW_TAG_interface_type:
case DW_TAG_unspecified_type:
case DW_TAG_shared_type:
- return mc_tag_type;
+ return TagClass::Type;
case DW_TAG_subprogram:
- return mc_tag_subprogram;
+ return TagClass::Subprogram;
case DW_TAG_variable:
case DW_TAG_formal_parameter:
- return mc_tag_variable;
+ return TagClass::Variable;
case DW_TAG_lexical_block:
case DW_TAG_try_block:
case DW_TAG_catch_block:
case DW_TAG_inlined_subroutine:
case DW_TAG_with_stmt:
- return mc_tag_scope;
+ return TagClass::Scope;
case DW_TAG_namespace:
- return mc_tag_namespace;
+ return TagClass::Namespace;
default:
- return mc_tag_unknown;
-
+ return TagClass::Unknown;
}
}
+}
+}
+}
+
#define MC_DW_CLASS_UNKNOWN 0
#define MC_DW_CLASS_ADDRESS 1 // Location in the address space of the program
#define MC_DW_CLASS_BLOCK 2 // Arbitrary block of bytes
{
// TODO, handle DW_TAG_type/DW_TAG_location for DW_TAG_with_stmt
int tag = dwarf_tag(die);
- mc_tag_class klass = MC_dwarf_tag_classify(tag);
+ simgrid::dwarf::TagClass klass = simgrid::dwarf::classify_tag(tag);
// (Template) Subprogram declaration:
- if (klass == mc_tag_subprogram
+ if (klass == simgrid::dwarf::TagClass::Subprogram
&& MC_dwarf_attr_flag(die, DW_AT_declaration, false))
return;
- if (klass == mc_tag_scope)
+ if (klass == simgrid::dwarf::TagClass::Scope)
xbt_assert(parent_frame, "No parent scope for this scope");
simgrid::mc::Frame frame;
frame.id = dwarf_dieoffset(die);
frame.object_info = info;
- if (klass == mc_tag_subprogram) {
+ if (klass == simgrid::dwarf::TagClass::Subprogram) {
const char *name = MC_dwarf_attr_integrate_string(die, DW_AT_name);
if(ns)
frame.name = std::string(ns) + "::" + name;
}
}
- if (klass == mc_tag_subprogram) {
+ if (klass == simgrid::dwarf::TagClass::Subprogram) {
Dwarf_Attribute attr_frame_base;
if (dwarf_attr_integrate(die, DW_AT_frame_base, &attr_frame_base))
mc_dwarf_location_list_init(&frame.frame_base, info, die,
MC_compare_variable);
// Register it:
- if (klass == mc_tag_subprogram)
+ if (klass == simgrid::dwarf::TagClass::Subprogram)
info->subprograms[frame.id] = frame;
- else if (klass == mc_tag_scope)
+ else if (klass == simgrid::dwarf::TagClass::Scope)
parent_frame->scopes.push_back(std::move(frame));
}
const char *ns)
{
int tag = dwarf_tag(die);
- mc_tag_class klass = MC_dwarf_tag_classify(tag);
+ simgrid::dwarf::TagClass klass = simgrid::dwarf::classify_tag(tag);
switch (klass) {
// Type:
- case mc_tag_type:
+ case simgrid::dwarf::TagClass::Type:
MC_dwarf_handle_type_die(info, die, unit, frame, ns);
break;
// Subprogram or scope:
- case mc_tag_subprogram:
- case mc_tag_scope:
+ case simgrid::dwarf::TagClass::Subprogram:
+ case simgrid::dwarf::TagClass::Scope:
MC_dwarf_handle_scope_die(info, die, unit, frame, ns);
return;
// Variable:
- case mc_tag_variable:
+ case simgrid::dwarf::TagClass::Variable:
MC_dwarf_handle_variable_die(info, die, unit, frame, ns);
break;
- case mc_tag_namespace:
+ case simgrid::dwarf::TagClass::Namespace:
mc_dwarf_handle_namespace_die(info, die, unit, frame, ns);
break;
#include "mc/Variable.hpp"
#include "mc/mc_memory_map.h"
-/** \brief A class of DWARF tags (DW_TAG_*)
- */
-typedef enum mc_tag_class {
- mc_tag_unknown,
- mc_tag_type,
- mc_tag_subprogram,
- mc_tag_variable,
- mc_tag_scope,
- mc_tag_namespace
-} mc_tag_class;
-
-static mc_tag_class MC_dwarf_tag_classify(int tag)
-{
- switch (tag) {
-
- case DW_TAG_array_type:
- case DW_TAG_class_type:
- case DW_TAG_enumeration_type:
- case DW_TAG_typedef:
- case DW_TAG_pointer_type:
- case DW_TAG_reference_type:
- case DW_TAG_rvalue_reference_type:
- case DW_TAG_string_type:
- case DW_TAG_structure_type:
- case DW_TAG_subroutine_type:
- case DW_TAG_union_type:
- case DW_TAG_ptr_to_member_type:
- case DW_TAG_set_type:
- case DW_TAG_subrange_type:
- case DW_TAG_base_type:
- case DW_TAG_const_type:
- case DW_TAG_file_type:
- case DW_TAG_packed_type:
- case DW_TAG_volatile_type:
- case DW_TAG_restrict_type:
- case DW_TAG_interface_type:
- case DW_TAG_unspecified_type:
- case DW_TAG_shared_type:
- return mc_tag_type;
-
- case DW_TAG_subprogram:
- return mc_tag_subprogram;
-
- case DW_TAG_variable:
- case DW_TAG_formal_parameter:
- return mc_tag_variable;
-
- case DW_TAG_lexical_block:
- case DW_TAG_try_block:
- case DW_TAG_catch_block:
- case DW_TAG_inlined_subroutine:
- case DW_TAG_with_stmt:
- return mc_tag_scope;
-
- case DW_TAG_namespace:
- return mc_tag_namespace;
-
- default:
- return mc_tag_unknown;
-
- }
-}
-
-#define MC_DW_CLASS_UNKNOWN 0
-#define MC_DW_CLASS_ADDRESS 1 // Location in the address space of the program
-#define MC_DW_CLASS_BLOCK 2 // Arbitrary block of bytes
-#define MC_DW_CLASS_CONSTANT 3
-#define MC_DW_CLASS_STRING 3 // String
-#define MC_DW_CLASS_FLAG 4 // Boolean
-#define MC_DW_CLASS_REFERENCE 5 // Reference to another DIE
-#define MC_DW_CLASS_EXPRLOC 6 // DWARF expression/location description
-#define MC_DW_CLASS_LINEPTR 7
-#define MC_DW_CLASS_LOCLISTPTR 8
-#define MC_DW_CLASS_MACPTR 9
-#define MC_DW_CLASS_RANGELISTPTR 10
-
-/** \brief Find the DWARF data class for a given DWARF data form
- *
- * This mapping is defined in the DWARF spec.
- *
- * \param form The form (values taken from the DWARF spec)
- * \return An internal representation for the corresponding class
- * */
-static int MC_dwarf_form_get_class(int form)
-{
- switch (form) {
- case DW_FORM_addr:
- return MC_DW_CLASS_ADDRESS;
- case DW_FORM_block2:
- case DW_FORM_block4:
- case DW_FORM_block:
- case DW_FORM_block1:
- return MC_DW_CLASS_BLOCK;
- case DW_FORM_data1:
- case DW_FORM_data2:
- case DW_FORM_data4:
- case DW_FORM_data8:
- case DW_FORM_udata:
- case DW_FORM_sdata:
- return MC_DW_CLASS_CONSTANT;
- case DW_FORM_string:
- case DW_FORM_strp:
- return MC_DW_CLASS_STRING;
- case DW_FORM_ref_addr:
- case DW_FORM_ref1:
- case DW_FORM_ref2:
- case DW_FORM_ref4:
- case DW_FORM_ref8:
- case DW_FORM_ref_udata:
- return MC_DW_CLASS_REFERENCE;
- case DW_FORM_flag:
- case DW_FORM_flag_present:
- return MC_DW_CLASS_FLAG;
- case DW_FORM_exprloc:
- return MC_DW_CLASS_EXPRLOC;
- // TODO sec offset
- // TODO indirect
- default:
- return MC_DW_CLASS_UNKNOWN;
- }
-}
-
-/** \brief Find the default lower bound for a given language
- *
- * The default lower bound of an array (when DW_TAG_lower_bound
- * is missing) depends on the language of the compilation unit.
- *
- * \param lang Language of the compilation unit (values defined in the DWARF spec)
- * \return Default lower bound of an array in this compilation unit
- * */
-static inline
-uint64_t MC_dwarf_default_lower_bound(int lang)
-{
- switch (lang) {
- case DW_LANG_C:
- case DW_LANG_C89:
- case DW_LANG_C99:
- case DW_LANG_C_plus_plus:
- case DW_LANG_D:
- case DW_LANG_Java:
- case DW_LANG_ObjC:
- case DW_LANG_ObjC_plus_plus:
- case DW_LANG_Python:
- case DW_LANG_UPC:
- return 0;
- case DW_LANG_Ada83:
- case DW_LANG_Ada95:
- case DW_LANG_Fortran77:
- case DW_LANG_Fortran90:
- case DW_LANG_Fortran95:
- case DW_LANG_Modula2:
- case DW_LANG_Pascal83:
- case DW_LANG_PL1:
- case DW_LANG_Cobol74:
- case DW_LANG_Cobol85:
- return 1;
- default:
- xbt_die("No default DW_TAG_lower_bound for language %i and none given",
- lang);
- return 0;
- }
-}
-
-/** Sort the variable by name and address.
- *
- * We could use boost::container::flat_set instead.
- */
-static inline
-bool MC_compare_variable(
- simgrid::mc::Variable const& a, simgrid::mc::Variable const& b)
-{
- int cmp = a.name.compare(b.name);
- if (cmp < 0)
- return true;
- else if (cmp > 0)
- return false;
- else
- return a.address < b.address;
-}
-
XBT_PRIVATE std::shared_ptr<simgrid::mc::ObjectInformation> MC_find_object_info(
std::vector<simgrid::mc::VmMap> const& maps, const char* name, int executable);
XBT_PRIVATE void MC_post_process_object_info(simgrid::mc::Process* process, simgrid::mc::ObjectInformation* info);