|  |  
 |   |   
 NAME
 LIBRARYDWARF Access Library (libdwarf, -ldwarf) SYNOPSIS
 int
   int
   DESCRIPTIONFunction
     Argument dbg should reference a DWARF debug context allocated using dwarf_init(3). Argument offset is an offset, relative to
    the “.debug_ranges” section, to the start of the desired list
    of address ranges. The offset of an address ranges list is indicated by the
     Argument die
    (function
     Argument ranges should point to a location that will be set to a pointer to an array of Dwarf_Ranges descriptors. Argument cnt should point to a location that will be set to the number of entries returned. If argument byte_cnt is not NULL, it will be set to the number of bytes occupied by the returned entries in the “.debug_ranges” section. If argument err is not NULL, it will be used to store error information in case of an error. Dwarf_Ranges descriptors are defined in the
    header file  
 Memory ManagementThe memory area used for the array of
    Dwarf_Ranges descriptors returned in argument
    ranges is owned by the DWARF Access
    Library (libdwarf, -ldwarf). The application should not attempt to
    directly free this pointer. Portable code should instead use
     RETURN VALUESThese functions return  EXAMPLESTo retrieve the address range list associated with a debugging information entry, use: Dwarf_Debug dbg;
Dwarf_Die die;
Dwarf_Error de;
Dwarf_Addr base;
Dwarf_Attribute *attr_list;
Dwarf_Ranges *ranges;
Dwarf_Signed cnt;
Dwarf_Unsigned off, attr_count, bytecnt;
int i, j;
if ((ret = dwarf_attrlist(die, &attr_list, &attr_count, &de)) !=
    DW_DLV_OK)
	errx(EXIT_FAILURE, "dwarf_attrlist failed: %s",
	    dwarf_errmsg(de));
for (i = 0; (Dwarf_Unsigned) i < attr_count; i++) {
	if (dwarf_whatattr(attr_list[i], &attr, &de) != DW_DLV_OK) {
		warnx("dwarf_whatattr failed: %s",
		    dwarf_errmsg(de));
		continue;
	}
	if (attr != DW_AT_ranges)
		continue;
	if (dwarf_formudata(attr_list[i], &off, &de) != DW_DLV_OK) {
		warnx("dwarf_formudata failed: %s",
		    dwarf_errmsg(de));
		continue;
	}
	if (dwarf_get_ranges(dbg, (Dwarf_Off) off, &ranges, &cnt,
	    &bytecnt, &de) != DW_DLV_OK)
		continue;
	for (j = 0; j < cnt; j++) {
		if (ranges[j].dwr_type == DW_RANGES_END)
			break;
		else if (ranges[j].dwr_type ==
		    DW_RANGES_ADDRESS_SELECTION)
			base = ranges[j].dwr_addr2;
		else {
			/*
			 * DW_RANGES_ENTRY entry.
			 * .. Use dwr_addr1 and dwr_addr2 ..
			 */
		}
	}
}COMPATIBILITYFunction  ERRORSThese function can fail with: 
 SEE ALSO
 
 |