use of com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceType in project graal by oracle.
the class DITypeExtractor method visit.
@Override
public void visit(MDCompositeType mdType) {
final long size = mdType.getSize();
final long align = mdType.getAlign();
final long offset = mdType.getOffset();
final LLVMSourceLocation location = scopeBuilder.buildLocation(mdType);
switch(mdType.getTag()) {
case DW_TAG_VECTOR_TYPE:
case DW_TAG_ARRAY_TYPE:
{
final boolean isVector = mdType.getTag() == MDType.DwarfTag.DW_TAG_VECTOR_TYPE;
final LLVMSourceArrayLikeType type = new LLVMSourceArrayLikeType(size, align, offset, location);
parsedTypes.put(mdType, type);
LLVMSourceType baseType = resolve(mdType.getBaseType());
final List<LLVMSourceType> members = new ArrayList<>(1);
getElements(mdType.getMembers(), members, false);
for (int i = members.size() - 1; i > 0; i--) {
final long length = extractLength(members.get(i));
final long tmpSize = length * baseType.getSize();
final LLVMSourceArrayLikeType tmp = new LLVMSourceArrayLikeType(tmpSize >= 0 ? tmpSize : 0, align, 0L, location);
setAggregateProperties(isVector, tmp, length, baseType);
baseType = tmp;
}
setAggregateProperties(isVector, type, extractLength(members.get(0)), baseType);
break;
}
case DW_TAG_CLASS_TYPE:
{
String name = MDNameExtractor.getName(mdType.getName());
final LLVMSourceClassLikeType type = new LLVMSourceClassLikeType(name, size, align, offset, location);
parsedTypes.put(mdType, type);
final List<LLVMSourceType> members = new ArrayList<>();
getElements(mdType.getMembers(), members, false);
for (final LLVMSourceType member : members) {
if (member instanceof LLVMSourceMemberType) {
type.addDynamicMember((LLVMSourceMemberType) member);
} else if (member instanceof LLVMSourceStaticMemberType) {
type.addStaticMember((LLVMSourceStaticMemberType) member);
}
}
MDBaseNode mdMembers = mdType.getMembers();
if (mdMembers instanceof MDNode) {
final MDNode elemListNode = (MDNode) mdMembers;
for (MDBaseNode elemNode : elemListNode) {
if (elemNode instanceof MDSubprogram) {
MDSubprogram mdSubprogram = (MDSubprogram) elemNode;
final String methodName = ((MDString) mdSubprogram.getName()).getString();
if (mdSubprogram.getLinkageName() instanceof MDString) {
final String methodLinkageName = ((MDString) mdSubprogram.getLinkageName()).getString();
final LLVMSourceFunctionType llvmSourceFunctionType = (LLVMSourceFunctionType) parsedTypes.get(mdSubprogram);
final long virtualIndex = mdSubprogram.getVirtuality() > 0 ? mdSubprogram.getVirtualIndex() : -1L;
if (llvmSourceFunctionType != null) {
type.addMethod(methodName, methodLinkageName, llvmSourceFunctionType, virtualIndex);
}
} else {
/*
* mdSubprogram does not have an MDString as (linkage)name, or
* function could not be found. In this case, just do not add the
* given mdSubprogram as a class method.
*/
}
}
}
}
break;
}
case DW_TAG_UNION_TYPE:
case DW_TAG_STRUCTURE_TYPE:
{
String name = MDNameExtractor.getName(mdType.getName());
if (mdType.getTag() == MDType.DwarfTag.DW_TAG_STRUCTURE_TYPE) {
name = String.format("struct %s", name);
} else if (mdType.getTag() == MDType.DwarfTag.DW_TAG_UNION_TYPE) {
name = String.format("union %s", name);
}
final LLVMSourceStructLikeType type = new LLVMSourceStructLikeType(name, size, align, offset, location);
parsedTypes.put(mdType, type);
final List<LLVMSourceType> members = new ArrayList<>();
getElements(mdType.getMembers(), members, false);
for (final LLVMSourceType member : members) {
if (member instanceof LLVMSourceMemberType) {
type.addDynamicMember((LLVMSourceMemberType) member);
} else if (member instanceof LLVMSourceStaticMemberType) {
type.addStaticMember((LLVMSourceStaticMemberType) member);
}
}
break;
}
case DW_TAG_ENUMERATION_TYPE:
{
final String name = String.format("enum %s", MDNameExtractor.getName(mdType.getName()));
final LLVMSourceEnumLikeType type = new LLVMSourceEnumLikeType(() -> name, size, align, offset, location);
parsedTypes.put(mdType, type);
final List<LLVMSourceType> members = new ArrayList<>();
getElements(mdType.getMembers(), members, false);
for (final LLVMSourceType member : members) {
type.addValue((int) member.getOffset(), member.getName());
}
break;
}
default:
{
parsedTypes.put(mdType, LLVMSourceType.UNKNOWN);
}
}
}
use of com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceType in project graal by oracle.
the class DITypeExtractor method visit.
@Override
public void visit(MDGlobalVariableExpression mdGlobalExpression) {
final LLVMSourceType type = resolve(mdGlobalExpression.getGlobalVariable());
parsedTypes.put(mdGlobalExpression, type);
}
Aggregations