-/** \brief Create a location list from a given attribute
- *
- * \param die the DIE
- * \param attr the attribute
- * \return MC specific representation of the location list represented by the given attribute
- * of the given die
- */
-static dw_location_t MC_dwarf_get_location_list(Dwarf_Die* die, Dwarf_Attribute* attr) {
-
- dw_location_t location = xbt_new0(s_dw_location_t, 1);
- location->type = e_dw_loclist;
- xbt_dynar_t loclist = xbt_dynar_new(sizeof(dw_location_entry_t), NULL);
- location->location.loclist = loclist;
-
- ptrdiff_t offset = 0;
- Dwarf_Addr base, start, end;
- Dwarf_Op *expr;
- size_t len;
-
- while (1) {
-
- offset = dwarf_getlocations(attr, offset, &base, &start, &end, &expr, &len);
- if (offset==0)
- return location;
- else if (offset==-1)
- xbt_die("Error while loading location list");
-
- dw_location_entry_t new_entry = xbt_new0(s_dw_location_entry_t, 1);
- new_entry->lowpc = start;
- new_entry->highpc = end;
- new_entry->location = MC_dwarf_get_expression(expr, len);
-
- xbt_dynar_push(loclist, &new_entry);
-
- }
-}
-
-/** \brief Get the location expression or location list from an attribute
- *
- * Processes direct expressions as well as location lists.
- *
- * \param die the DIE
- * \param attr the attribute
- * \return MC specific representation of the location represented by the given attribute
- * of the given die
- */
-static dw_location_t MC_dwarf_get_location(Dwarf_Die* die, Dwarf_Attribute* attr) {
- int form = dwarf_whatform(attr);
- switch (form) {
-
- // The attribute is an DWARF location expression:
- case DW_FORM_exprloc:
- case DW_FORM_block1: // not in the spec
- case DW_FORM_block2:
- case DW_FORM_block4:
- case DW_FORM_block:
- {
- Dwarf_Op* expr;
- size_t len;
- if (dwarf_getlocation(attr, &expr, &len))
- xbt_die("Could not read location expression");
- return MC_dwarf_get_expression(expr, len);
- }
-
- // The attribute is a reference to a location list entry:
- case DW_FORM_sec_offset:
- case DW_FORM_data2:
- case DW_FORM_data4:
- case DW_FORM_data8:
- {
- return MC_dwarf_get_location_list(die, attr);
- }
- break;
-
- default:
- xbt_die("Unexpected form %i list for location in attribute %s of <%p>%s",
- form,
- MC_dwarf_attrname(attr->code),
- (void*) dwarf_dieoffset(die),
- MC_dwarf_attr_string(die, DW_AT_name));
- return NULL;
- }
-}
-
-/** \brief Get the location expression or location list from an attribute
- *
- * Processes direct expressions as well as location lists.
- *
- * \param die the DIE
- * \param attribute the attribute code
- * \return MC specific representation of the location represented by the given attribute
- * of the given die
- */
-static dw_location_t MC_dwarf_at_location(Dwarf_Die* die, int attribute) {
- if(!dwarf_hasattr_integrate(die, attribute))
- return xbt_new0(s_dw_location_t, 1);
-
- Dwarf_Attribute attr;
- dwarf_attr_integrate(die, attribute, &attr);
- return MC_dwarf_get_location(die, &attr);
-}
-