use of com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceDecoratorType 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.LLVMSourceDecoratorType in project graal by oracle.
the class DITypeExtractor method visit.
@Override
public void visit(MDDerivedType 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_MEMBER:
{
final String name = MDNameExtractor.getName(mdType.getName());
if (Flags.STATIC_MEMBER.isSetIn(mdType.getFlags())) {
final LLVMSourceStaticMemberType type = new LLVMSourceStaticMemberType(name, size, align, location);
parsedTypes.put(mdType, type);
final LLVMSourceType baseType = resolve(mdType.getBaseType());
type.setElementType(baseType);
if (mdType.getExtraData() instanceof MDValue) {
staticMembers.put(type, ((MDValue) mdType.getExtraData()).getValue());
}
break;
}
final LLVMSourceMemberType type = new LLVMSourceMemberType(name, size, align, offset, location);
parsedTypes.put(mdType, type);
LLVMSourceType baseType = resolve(mdType.getBaseType());
if (Flags.BITFIELD.isSetIn(mdType.getFlags()) || (baseType != UNKNOWN && baseType.getSize() != size)) {
final LLVMSourceDecoratorType decorator = new LLVMSourceDecoratorType(size, align, offset, Function.identity(), location);
decorator.setBaseType(baseType);
baseType = decorator;
}
type.setElementType(baseType);
break;
}
case DW_TAG_REFERENCE_TYPE:
case DW_TAG_POINTER_TYPE:
{
final boolean isSafeToDereference = Flags.OBJECT_POINTER.isSetIn(mdType.getFlags());
final boolean isReference = mdType.getTag() == MDType.DwarfTag.DW_TAG_REFERENCE_TYPE;
final LLVMSourcePointerType type = new LLVMSourcePointerType(size, align, offset, isSafeToDereference, isReference, location);
parsedTypes.put(mdType, type);
// LLVM does not specify a void type, if this is indicated, the reference is simply
// null
final LLVMSourceType baseType = resolve(mdType.getBaseType(), LLVMSourceType.VOID);
type.setBaseType(baseType);
type.setName(() -> {
final String baseName = baseType.getName();
final String sym = isReference ? " &" : "*";
if (!baseType.isPointer() && baseName.contains(" ")) {
return String.format("(%s)%s", baseName, sym);
} else {
return String.format("%s%s", baseName, sym);
}
});
break;
}
case DW_TAG_TYPEDEF:
case DW_TAG_VOLATILE_TYPE:
case DW_TAG_CONST_TYPE:
{
final Function<String, String> decorator;
switch(mdType.getTag()) {
case DW_TAG_VOLATILE_TYPE:
decorator = s -> String.format("volatile %s", s);
break;
case DW_TAG_CONST_TYPE:
decorator = s -> String.format("const %s", s);
break;
case DW_TAG_TYPEDEF:
{
final String name = MDNameExtractor.getName(mdType.getName());
decorator = s -> name;
break;
}
default:
decorator = Function.identity();
}
final LLVMSourceDecoratorType type = new LLVMSourceDecoratorType(size, align, offset, decorator, location);
parsedTypes.put(mdType, type);
final LLVMSourceType baseType = resolve(mdType.getBaseType());
type.setBaseType(baseType);
type.setSize(baseType.getSize());
break;
}
case DW_TAG_INHERITANCE:
{
final LLVMSourceInheritanceType inheritanceType = new LLVMSourceInheritanceType("super", size, align, offset, location);
parsedTypes.put(mdType, inheritanceType);
final LLVMSourceType baseType = resolve(mdType.getBaseType());
inheritanceType.setElementType(baseType);
inheritanceType.setName(() -> String.format("super (%s)", baseType.getName()));
inheritanceType.setVirtual(Flags.VIRTUAL.isSetIn(mdType.getFlags()));
break;
}
default:
{
parsedTypes.put(mdType, LLVMSourceType.UNKNOWN);
}
}
}
Aggregations