use of com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceStaticMemberType in project graal by oracle.
the class DITypeExtractor method visit.
@Override
public void visit(MDGlobalVariable mdGlobal) {
final LLVMSourceType type = resolve(mdGlobal.getType());
parsedTypes.put(mdGlobal, type);
if (mdGlobal.getStaticMemberDeclaration() != MDVoidNode.INSTANCE && mdGlobal.getVariable() instanceof MDValue) {
final LLVMSourceType declType = resolve(mdGlobal.getStaticMemberDeclaration());
final SymbolImpl symbol = ((MDValue) mdGlobal.getVariable()).getValue();
if (declType instanceof LLVMSourceStaticMemberType) {
staticMembers.put((LLVMSourceStaticMemberType) declType, symbol);
}
}
}
use of com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceStaticMemberType in project graal by oracle.
the class DebugInfoModuleProcessor method processSymbols.
private static void processSymbols(List<? extends GlobalValueSymbol> list, DebugInfoCache cache, ModelModule irModel) {
for (GlobalValueSymbol global : list) {
MDBaseNode mdGlobal = getDebugInfo(global);
if (mdGlobal != null) {
final boolean isGlobal = !(mdGlobal instanceof MDLocalVariable);
final LLVMSourceSymbol symbol = cache.getSourceSymbol(mdGlobal, isGlobal);
if (symbol != null) {
irModel.getSourceGlobals().put(symbol, global);
global.setSourceSymbol(symbol);
}
if (mdGlobal instanceof MDGlobalVariableExpression) {
mdGlobal = ((MDGlobalVariableExpression) mdGlobal).getGlobalVariable();
}
if (mdGlobal instanceof MDGlobalVariable) {
final MDBaseNode declaration = ((MDGlobalVariable) mdGlobal).getStaticMemberDeclaration();
if (declaration != MDVoidNode.INSTANCE) {
final LLVMSourceType sourceType = cache.parseType(declaration);
if (sourceType instanceof LLVMSourceStaticMemberType) {
irModel.getSourceStaticMembers().put((LLVMSourceStaticMemberType) sourceType, global);
}
}
}
}
}
}
use of com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceStaticMemberType 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);
}
}
}
use of com.oracle.truffle.llvm.runtime.debug.type.LLVMSourceStaticMemberType 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