use of com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceArrayLikeType in project graal by oracle.
the class DebugExprType method getTypeFromSymbolTableMetaObject.
@TruffleBoundary
public static DebugExprType getTypeFromSymbolTableMetaObject(Object metaObj) {
if (metaObj instanceof LLVMSourceBasicType) {
LLVMSourceBasicType basicType = (LLVMSourceBasicType) metaObj;
LLVMSourceBasicType.Kind typeKind = basicType.getKind();
long typeSize = basicType.getSize();
switch(typeKind) {
case BOOLEAN:
return DebugExprType.getIntType(1, false);
case SIGNED:
return DebugExprType.getIntType(typeSize, true);
case UNSIGNED:
return DebugExprType.getIntType(typeSize, false);
case SIGNED_CHAR:
return DebugExprType.getIntType(8, true);
case UNSIGNED_CHAR:
return DebugExprType.getIntType(8, false);
case FLOATING:
return DebugExprType.getFloatType(typeSize);
default:
return DebugExprType.getVoidType();
}
} else if (metaObj instanceof LLVMSourceArrayLikeType) {
LLVMSourceArrayLikeType arrayType = (LLVMSourceArrayLikeType) metaObj;
DebugExprType innerType = getTypeFromSymbolTableMetaObject(arrayType.getElementType(0));
return new DebugExprType(Kind.ARRAY, innerType, arrayType.getElementCount());
} else if (metaObj instanceof LLVMSourceDecoratorType) {
return getTypeFromSymbolTableMetaObject(((LLVMSourceDecoratorType) metaObj).getActualType());
} else if (metaObj instanceof LLVMSourceStructLikeType) {
return new DebugExprType(Kind.STRUCT, null);
} else if (metaObj instanceof LLVMSourcePointerType) {
LLVMSourcePointerType pointerType = (LLVMSourcePointerType) metaObj;
DebugExprType baseType = getTypeFromSymbolTableMetaObject(pointerType.getBaseType());
return new DebugExprType(Kind.POINTER, baseType);
} else {
return DebugExprType.getVoidType();
}
}
use of com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceArrayLikeType 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);
}
}
}
Aggregations