static void tp_dwarf_ranges(void) { Dwarf_Debug dbg; Dwarf_Ranges *ranges; Dwarf_Signed range_cnt; Dwarf_Unsigned byte_cnt; Dwarf_Off off; Dwarf_Error de; int fd, r_ranges, i; result = TET_UNRESOLVED; TS_DWARF_INIT(dbg, fd, de); off = 0; for (;;) { tet_printf("check ranges at offset(%ju):\n", (uintmax_t) off); r_ranges = dwarf_get_ranges_a(dbg, off, NULL, &ranges, &range_cnt, &byte_cnt, &de); if (r_ranges != DW_DLV_OK) break; TS_CHECK_INT(range_cnt); TS_CHECK_UINT(byte_cnt); off += byte_cnt; for (i = 0; i < range_cnt; i++) { tet_printf("check range %d:\n", i); TS_CHECK_INT(ranges[i].dwr_type); TS_CHECK_UINT(ranges[i].dwr_addr1); TS_CHECK_UINT(ranges[i].dwr_addr2); } } /* * SGI libdwarf return DW_DLV_ERROR when provided offset is out of * range, instead of DW_DLV_NO_ENTRY as stated in the SGI libdwarf * documentation. elftoolchain libdwarf follows the SGI libdwarf * documentation. */ #if 0 if (r_ranges == DW_DLV_ERROR) { tet_printf("dwarf_get_ranges failed: %s\n", dwarf_errmsg(de)); result = TET_FAIL; } #endif if (result == TET_UNRESOLVED) result = TET_PASS; done: TS_DWARF_FINISH(dbg, de); TS_RESULT(result); }
int dwarf_get_ranges(Dwarf_Debug dbg, Dwarf_Off rangesoffset, Dwarf_Ranges ** rangesbuf, Dwarf_Signed * listlen, Dwarf_Unsigned * bytecount, Dwarf_Error * error) { Dwarf_Die die = 0; int res = dwarf_get_ranges_a(dbg,rangesoffset,die, rangesbuf,listlen,bytecount,error); return res; }
/* Now that we are at the end of the CU, check the range lists */ void check_range_array_info(Dwarf_Debug dbg) { if (range_array && range_array_count) { /* Traverse the range array and for each entry: Load the ranges Check for any outside conditions */ Dwarf_Off original_off = 0; Dwarf_Off die_off = 0; Dwarf_Unsigned index = 0; Dwarf_Die cu_die; int res; /* In case of errors, the correct DIE offset should be displayed. At this point we are at the end of the PU */ Dwarf_Off DIE_overall_offset_bak = DIE_overall_offset; for (index = 0; index < range_array_count; ++index) { Dwarf_Ranges *rangeset = 0; Dwarf_Signed rangecount = 0; Dwarf_Unsigned bytecount = 0; /* Get a range info record */ die_off = range_array[index].die_off; original_off = range_array[index].range_off; res = dwarf_offdie(dbg,die_off,&cu_die,&err); if (res != DW_DLV_OK) { print_error(dbg,"dwarf_offdie",res,err); } res = dwarf_get_ranges_a(dbg,original_off,cu_die, &rangeset,&rangecount,&bytecount,&err); if (res == DW_DLV_OK) { check_ranges_list(dbg,die_off,cu_die,original_off, rangeset,rangecount,bytecount); } dwarf_dealloc(dbg,cu_die,DW_DLA_DIE); }; reset_range_array_info(); /* Point back to the end of the PU */ DIE_overall_offset = DIE_overall_offset_bak; } }