예제 #1
0
static void
tp_dwarf_lineno_sanity(void)
{
	Dwarf_Debug dbg;
	Dwarf_Error de;
	Dwarf_Line *linebuf;
	Dwarf_Signed linecount;
	Dwarf_Signed srccount;
	char **srcfiles;
	int fd;

	result = TET_UNRESOLVED;

	TS_DWARF_INIT(dbg, fd, de);

	if (dwarf_srclines(NULL, &linebuf, &linecount, &de) !=
	    DW_DLV_ERROR) {
		tet_infoline("dwarf_srclines didn't return DW_DLV_ERROR"
		    " when called with NULL arguments");
		result = TET_FAIL;
	}

	if (dwarf_srcfiles(NULL, &srcfiles, &srccount, &de) !=
	    DW_DLV_ERROR) {
		tet_infoline("dwarf_srcfiles didn't return DW_DLV_ERROR"
		    " when called with NULL arguments");
		result = TET_FAIL;
	}

	if (result == TET_UNRESOLVED)
		result = TET_PASS;
done:
	TS_DWARF_FINISH(dbg, de);
	TS_RESULT(result);
}
예제 #2
0
static void
tp_dwarf_die_offset_given_cu(void)
{
	Dwarf_Debug dbg;
	Dwarf_Error de;
	Dwarf_Off cu_offset, cu_dieoff;
	Dwarf_Unsigned cu_next_offset;
	int fd;
	
	result = TET_UNRESOLVED;

	TS_DWARF_INIT(dbg, fd, de);

	cu_offset = 0;
	TS_DWARF_CU_FOREACH(dbg, cu_next_offset, de) {
		if (dwarf_get_cu_die_offset_given_cu_header_offset(dbg,
		    cu_offset, &cu_dieoff, &de) != DW_DLV_OK) {
			tet_printf("dwarf_get_cu_die_offset_given_cu_header"
			    "_offset failed: %s", dwarf_errmsg(de));
			result = TET_FAIL;
			goto done;
		}
		TS_CHECK_INT(cu_dieoff);
		cu_offset = cu_next_offset;
	}

	if (result == TET_UNRESOLVED)
		result = TET_PASS;

done:
	TS_DWARF_FINISH(dbg, de);
	TS_RESULT(result);
}
static void
tp_dwarf_next_cu_header(void)
{
	Dwarf_Debug dbg;
	Dwarf_Error de;
	Dwarf_Unsigned cu_header_length;
	Dwarf_Half cu_version;
	Dwarf_Off cu_abbrev_offset;
	Dwarf_Half cu_pointer_size;
	Dwarf_Unsigned cu_next_offset;
	int fd, result;

	result = TET_UNRESOLVED;

	TS_DWARF_INIT(dbg, fd, de);

	while (dwarf_next_cu_header(dbg, &cu_header_length, &cu_version,
	    &cu_abbrev_offset, &cu_pointer_size, &cu_next_offset, &de) ==
	    DW_DLV_OK) {
		TS_CHECK_UINT(cu_header_length);
		TS_CHECK_UINT(cu_version);
		TS_CHECK_INT(cu_abbrev_offset);
		TS_CHECK_UINT(cu_pointer_size);
		TS_CHECK_UINT(cu_next_offset);
	}

	if (result == TET_UNRESOLVED)
		result = TET_PASS;

done:
	TS_DWARF_FINISH(dbg, de);
	TS_RESULT(result);
}
static void
tp_dwarf_next_cu_header_loop(void)
{
	Dwarf_Debug dbg;
	Dwarf_Error de;
	int i, r, fd, result;
	Dwarf_Unsigned cu_next_offset;

	result = TET_UNRESOLVED;

	TS_DWARF_INIT(dbg, fd, de);

	for (i = 0; i < _LOOP_COUNT; i++) {
		tet_printf("dwarf_next_cu_header loop(%d)\n", i);
		r = dwarf_next_cu_header(dbg, NULL, NULL, NULL, NULL,
		    &cu_next_offset, &de);
		TS_CHECK_INT(r);
	}

	if (result == TET_UNRESOLVED)
		result = TET_PASS;

done:
	TS_DWARF_FINISH(dbg, de);
	TS_RESULT(result);
}
예제 #5
0
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);
}
예제 #6
0
static void
tp_dwarf_die_offset_sanity(void)
{
	Dwarf_Debug dbg;
	Dwarf_Die die;
	Dwarf_Error de;
	Dwarf_Off rel_off, die_off, cu_off, cu_len;
	Dwarf_Unsigned cu_next_offset;
	int fd;

	result = TET_UNRESOLVED;

	TS_DWARF_INIT(dbg, fd, de);

	TS_DWARF_CU_FOREACH(dbg, cu_next_offset, de) {
		if (dwarf_siblingof(dbg, NULL, &die, &de) == DW_DLV_ERROR) {
			tet_printf("dwarf_siblingof failed: %s\n",
			    dwarf_errmsg(de));
			result = TET_FAIL;
			goto done;
		}
		if (dwarf_die_CU_offset(NULL, &rel_off, &de) != DW_DLV_ERROR) {
			tet_infoline("dwarf_die_CU_offset didn't return"
			    " DW_DLV_ERROR when called with NULL arguments");
			result = TET_FAIL;
			goto done;
		}
		if (dwarf_die_CU_offset_range(NULL, &cu_off, &cu_len, &de) !=
		    DW_DLV_ERROR) {
			tet_infoline("dwarf_die_CU_offset_range didn't return"
			    " DW_DLV_ERROR when called with NULL arguments");
			result = TET_FAIL;
			goto done;
		}
		if (dwarf_dieoffset(NULL, &die_off, &de) != DW_DLV_ERROR) {
			tet_infoline("dwarf_dieoffset didn't return DW_DLV_ERROR"
			    " when called with NULL arguments");
			result = TET_FAIL;
			goto done;
		}
	}

	if (result == TET_UNRESOLVED)
		result = TET_PASS;

done:
	TS_DWARF_FINISH(dbg, de);
	TS_RESULT(result);
}
예제 #7
0
static void
tp_dwarf_srcfiles(void)
{
	Dwarf_Debug dbg;
	Dwarf_Error de;
	int fd;
	result = TET_UNRESOLVED;

	TS_DWARF_INIT(dbg, fd, de);

	TS_DWARF_DIE_TRAVERSE(dbg, _dwarf_srcfiles);

	if (result == TET_UNRESOLVED)
		result = TET_PASS;

done:
	TS_DWARF_FINISH(dbg, de);
	TS_RESULT(result);
}
예제 #8
0
static void
tp_dwarf_attr_sanity(void)
{
	Dwarf_Debug dbg;
	Dwarf_Error de;
	Dwarf_Bool has_attr;
	Dwarf_Half attr;
	Dwarf_Attribute at;
	int fd;

	result = TET_UNRESOLVED;

	TS_DWARF_INIT(dbg, fd, de);

	if (dwarf_hasattr(NULL, DW_AT_name, &has_attr, &de) != DW_DLV_ERROR) {
		tet_infoline("dwarf_hasattr didn't return DW_DLV_ERROR"
		    " when called with NULL arguments");
		result = TET_FAIL;
		goto done;
	}

	if (dwarf_attr(NULL, DW_AT_name, &at, &de) != DW_DLV_ERROR) {
		tet_infoline("dwarf_attr didn't return DW_DLV_ERROR"
		    " when called with NULL arguments");
		result = TET_FAIL;
		goto done;
	}

	if (dwarf_whatattr(NULL, &attr, &de) != DW_DLV_ERROR) {
		tet_infoline("dwarf_whatattr didn't return DW_DLV_ERROR"
		    " when called with NULL arguments");
		result = TET_FAIL;
		goto done;
	}

	if (result == TET_UNRESOLVED)
		result = TET_PASS;

done:
	TS_DWARF_FINISH(dbg, de);
	TS_RESULT(result);
}
static void
tp_dwarf_get_address_size(void)
{
	Dwarf_Debug dbg;
	Dwarf_Error de;
	Dwarf_Half addr_size;
	int fd, result;

	dbg = NULL;
	result = TET_UNRESOLVED;

	if (dwarf_get_address_size(NULL, &addr_size, &de) != DW_DLV_ERROR) {
		tet_infoline("dwarf_get_adderss_size NULL 'dbg' test failed");
		result = TET_FAIL;
		goto done;
	}

	TS_DWARF_INIT(dbg, fd, de);

	if (dwarf_get_address_size(dbg, NULL, &de) != DW_DLV_ERROR) {
		tet_infoline("dwarf_get_adderss_size NULL 'addr_size' test "
		    "failed");
		result = TET_FAIL;
		goto done;
	}

	if (dwarf_get_address_size(dbg, &addr_size, &de) != DW_DLV_OK) {
		tet_printf("dwarf_get_address_size failed: %s",
		    dwarf_errmsg(de));
		result = TET_FAIL;
		goto done;
	}

	TS_CHECK_UINT(addr_size);

	if (result == TET_UNRESOLVED)
		result = TET_PASS;

done:
	TS_DWARF_FINISH(dbg, de);
	TS_RESULT(result);
}
예제 #10
0
static void
tp_dwarf_frame3(void)
{
	Dwarf_Debug dbg;
	Dwarf_Error de;
	int fd;

	result = TET_UNRESOLVED;

	TS_DWARF_INIT(dbg, fd, de);

	_dwarf_cie_fde_test(dbg, 0, _frame3_test);
	_dwarf_cie_fde_test(dbg, 1, _frame3_test);

	if (result == TET_UNRESOLVED)
		result = TET_PASS;
done:
	TS_DWARF_FINISH(dbg, de);
	TS_RESULT(result);
}
예제 #11
0
static void
tp_dwarf_init(void)
{
	Dwarf_Debug dbg;
	Dwarf_Error de;
	int fd, result;

	result = TET_UNRESOLVED;

	assert(_cur_file != NULL);
	dbg = NULL;
	if ((fd = open(_cur_file, O_RDONLY)) < 0) {
		tet_printf("open %s failed: %s", _cur_file, strerror(errno));
		result = TET_FAIL;
		goto done;
	}

	if (dwarf_init(fd, DW_DLC_READ, NULL, NULL, &dbg, &de) != DW_DLV_OK) {
		tet_printf("dwarf_init failed: %s", dwarf_errmsg(de));
		result = TET_FAIL;
		goto done;
	}

	if (dwarf_init(-1, DW_DLC_READ, NULL, NULL, &dbg, &de) != DW_DLV_ERROR) {
		tet_infoline("dwarf_init didn't return DW_DLV_ERROR when"
		    " called with fd(-1)");
		result = TET_FAIL;
		goto done;
	}

	if (result == TET_UNRESOLVED)
		result = TET_PASS;

done:
	TS_DWARF_FINISH(dbg, de);
	TS_RESULT(result);
}
예제 #12
0
static void
tp_dwarf_arange(void)
{
	Dwarf_Debug dbg;
	Dwarf_Arange *aranges;
	Dwarf_Arange arange;
	Dwarf_Signed arange_cnt;
	Dwarf_Off cu_die_offset, cu_die_offset2, cu_header_offset;
	Dwarf_Addr start;
	Dwarf_Unsigned length;
	Dwarf_Error de;
	int fd, i, r_aranges, r_arange;

	result = TET_UNRESOLVED;

	TS_DWARF_INIT(dbg, fd, de);

	r_aranges = dwarf_get_aranges(dbg, &aranges, &arange_cnt, &de);
	TS_CHECK_INT(r_aranges);
	if (r_aranges == DW_DLV_ERROR) {
		tet_printf("dwarf_get_aranges failed: %s\n", dwarf_errmsg(de));
		result = TET_FAIL;
		goto done;
	}
	if (r_aranges == DW_DLV_OK) {
		for (i = 0; i < arange_cnt; i++) {
			if (dwarf_get_cu_die_offset(aranges[i], &cu_die_offset,
			    &de) != DW_DLV_OK) {
				tet_printf("dwarf_get_cu_die_offset failed:"
				    " %s\n", dwarf_errmsg(de));
				result = TET_FAIL;
				continue;
			}
			TS_CHECK_INT(cu_die_offset);
			if (dwarf_get_arange_cu_header_offset(aranges[i],
			    &cu_header_offset, &de) != DW_DLV_OK) {
				tet_printf("dwarf_get_arange_cu_header_offset"
				    "failed: %s\n", dwarf_errmsg(de));
				result = TET_FAIL;
				continue;
			}
			TS_CHECK_INT(cu_header_offset);
			if (dwarf_get_arange_info(aranges[i], &start, &length,
			    &cu_die_offset2, &de) != DW_DLV_OK) {
				tet_printf("dwarf_get_arange_info failed:%s\n",
				    dwarf_errmsg(de));
				result = TET_FAIL;
				continue;
			}
			TS_CHECK_UINT(start);
			TS_CHECK_UINT(length);
			TS_CHECK_UINT(cu_die_offset2);
			r_arange = dwarf_get_arange(aranges, arange_cnt, start,
			    &arange, &de);
			TS_CHECK_INT(r_arange);
			r_arange = dwarf_get_arange(aranges, arange_cnt,
			    start + 1, &arange, &de);
			TS_CHECK_INT(r_arange);
			r_arange = dwarf_get_arange(aranges, arange_cnt,
			    start + length, &arange, &de);
			TS_CHECK_INT(r_arange);
			r_arange = dwarf_get_arange(aranges, arange_cnt,
			    start + length + 1, &arange, &de);
			TS_CHECK_INT(r_arange);
			r_arange = dwarf_get_arange(aranges, arange_cnt,
			    start + length - 1, &arange, &de);
			TS_CHECK_INT(r_arange);
		}
	}


	if (result == TET_UNRESOLVED)
		result = TET_PASS;

done:
	TS_DWARF_FINISH(dbg, de);
	TS_RESULT(result);
}