Beispiel #1
0
static void
cleanUnknownDies(Dwarf_Die die)
{
	Dwarf_Die previousSibling = NULL;
	while (NULL != die) {
		if (DW_TAG_unknown == die->_tag) {
			Dwarf_Die toDelete = die;
			Dwarf_Die nextDie = NULL;
			if (NULL != die->_child) {
				Dwarf_Die child = die->_child;
				for (; NULL != child->_sibling; child = child->_sibling) {
					child->_parent = toDelete->_parent;
				}
				child->_parent = toDelete->_parent;
				child->_sibling = toDelete->_sibling;
				nextDie = toDelete->_child;
			} else {
				nextDie = toDelete->_sibling;
			}
			if (NULL == previousSibling) {
				toDelete->_parent->_child = nextDie;
			} else {
				previousSibling->_sibling = nextDie;
			}
			die = nextDie;
			toDelete->_child = NULL;
			toDelete->_sibling = NULL;
			deleteDie(toDelete);
		} else {
			cleanUnknownDies(die->_child);
			previousSibling = die;
			die = die->_sibling;
		}
	}
}
Beispiel #2
0
static void
deleteDie(Dwarf_Die die)
{
	/* Free the Die's attributes. */
	Dwarf_Attribute attr = die->_attribute;
	while (NULL != attr) {
		Dwarf_Attribute next = attr->_nextAttr;
		if (NULL != attr->_stringdata) {
			free(attr->_stringdata);
		}
		delete attr;
		attr = next;
	}

	/* Free the Die's siblings and children. */
	if (NULL != die->_sibling) {
		deleteDie(die->_sibling);
	}
	if (NULL != die->_child) {
		deleteDie(die->_child);
	}
	delete die;
}
Beispiel #3
0
int
dwarf_finish(Dwarf_Debug dbg, Dwarf_Error *error)
{
	/* Free all Dies and Attributes created in dwarf_init(). */
	Dwarf_CU_Context::_currentCU = Dwarf_CU_Context::_firstCU;
	while (NULL != Dwarf_CU_Context::_currentCU) {
		Dwarf_CU_Context *nextCU = Dwarf_CU_Context::_currentCU->_nextCU;
		if (NULL != Dwarf_CU_Context::_currentCU->_die) {
			deleteDie(Dwarf_CU_Context::_currentCU->_die);
		}
		delete Dwarf_CU_Context::_currentCU;
		Dwarf_CU_Context::_currentCU = nextCU;
	}
	Dwarf_CU_Context::_fileList.clear();
	Dwarf_CU_Context::_currentCU = NULL;
	Dwarf_CU_Context::_firstCU = NULL;
	return DW_DLV_OK;
}