com.apple.internal.jobjc.generator.model.Struct Java Examples

The following examples show how to use com.apple.internal.jobjc.generator.model.Struct. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StructClassFile.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private void writeField(final Struct.Field field, final PrintStream out){
    if(field.type.type32 instanceof NBitfield){
        out.format("\t// Skipping bitfield '%1$s'\n", field.name);
        return;
    }
    String privName = field.name + "__";
    String offsetName = field.name.toUpperCase() + "_OFFSET";
    JType jtype = field.type.getJType();
    String retType = jtype.getJavaReturnTypeName();
    CoderDescriptor cdesc = jtype.getCoderDescriptor();
    out.println();
    out.println("\tprivate static final int " + offsetName + " = " + JObjCRuntime.class.getName()
            + ".IS64 ? " + field.field64.offset64() + " : " + field.field32.offset32() + ";");

    out.println("\t//" + cdesc.getClass().toString());
    out.println("\tpublic " + retType + " " + getterName(field) + "(){");
    out.println(jtype.createPopAddr("getRuntime()", "this.raw.bufferPtr + " + offsetName));
    out.println(jtype.createReturn());
    out.println("\t}");
    out.println();
    out.println("\tpublic void " + setterName(field.name) + "(final " + retType + " " + privName + "){");
    out.println("\t\t" + cdesc.getPushAddrStatementFor("getRuntime()", "this.raw.bufferPtr + " + offsetName, privName));
    out.println("\t}");
}
 
Example #2
Source File: StructClassFile.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private void writeField(final Struct.Field field, final PrintStream out){
    if(field.type.type32 instanceof NBitfield){
        out.format("\t// Skipping bitfield '%1$s'\n", field.name);
        return;
    }
    String privName = field.name + "__";
    String offsetName = field.name.toUpperCase() + "_OFFSET";
    JType jtype = field.type.getJType();
    String retType = jtype.getJavaReturnTypeName();
    CoderDescriptor cdesc = jtype.getCoderDescriptor();
    out.println();
    out.println("\tprivate static final int " + offsetName + " = " + JObjCRuntime.class.getName()
            + ".IS64 ? " + field.field64.offset64() + " : " + field.field32.offset32() + ";");

    out.println("\t//" + cdesc.getClass().toString());
    out.println("\tpublic " + retType + " " + getterName(field) + "(){");
    out.println(jtype.createPopAddr("getRuntime()", "this.raw.bufferPtr + " + offsetName));
    out.println(jtype.createReturn());
    out.println("\t}");
    out.println();
    out.println("\tpublic void " + setterName(field.name) + "(final " + retType + " " + privName + "){");
    out.println("\t\t" + cdesc.getPushAddrStatementFor("getRuntime()", "this.raw.bufferPtr + " + offsetName, privName));
    out.println("\t}");
}
 
Example #3
Source File: StructClassFile.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private void writeField(final Struct.Field field, final PrintStream out){
    if(field.type.type32 instanceof NBitfield){
        out.format("\t// Skipping bitfield '%1$s'\n", field.name);
        return;
    }
    String privName = field.name + "__";
    String offsetName = field.name.toUpperCase() + "_OFFSET";
    JType jtype = field.type.getJType();
    String retType = jtype.getJavaReturnTypeName();
    CoderDescriptor cdesc = jtype.getCoderDescriptor();
    out.println();
    out.println("\tprivate static final int " + offsetName + " = " + JObjCRuntime.class.getName()
            + ".IS64 ? " + field.field64.offset64() + " : " + field.field32.offset32() + ";");

    out.println("\t//" + cdesc.getClass().toString());
    out.println("\tpublic " + retType + " " + getterName(field) + "(){");
    out.println(jtype.createPopAddr("getRuntime()", "this.raw.bufferPtr + " + offsetName));
    out.println(jtype.createReturn());
    out.println("\t}");
    out.println();
    out.println("\tpublic void " + setterName(field.name) + "(final " + retType + " " + privName + "){");
    out.println("\t\t" + cdesc.getPushAddrStatementFor("getRuntime()", "this.raw.bufferPtr + " + offsetName, privName));
    out.println("\t}");
}
 
Example #4
Source File: StructClassFile.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private void writeField(final Struct.Field field, final PrintStream out){
    if(field.type.type32 instanceof NBitfield){
        out.format("\t// Skipping bitfield '%1$s'\n", field.name);
        return;
    }
    String privName = field.name + "__";
    String offsetName = field.name.toUpperCase() + "_OFFSET";
    JType jtype = field.type.getJType();
    String retType = jtype.getJavaReturnTypeName();
    CoderDescriptor cdesc = jtype.getCoderDescriptor();
    out.println();
    out.println("\tprivate static final int " + offsetName + " = " + JObjCRuntime.class.getName()
            + ".IS64 ? " + field.field64.offset64() + " : " + field.field32.offset32() + ";");

    out.println("\t//" + cdesc.getClass().toString());
    out.println("\tpublic " + retType + " " + getterName(field) + "(){");
    out.println(jtype.createPopAddr("getRuntime()", "this.raw.bufferPtr + " + offsetName));
    out.println(jtype.createReturn());
    out.println("\t}");
    out.println();
    out.println("\tpublic void " + setterName(field.name) + "(final " + retType + " " + privName + "){");
    out.println("\t\t" + cdesc.getPushAddrStatementFor("getRuntime()", "this.raw.bufferPtr + " + offsetName, privName));
    out.println("\t}");
}
 
Example #5
Source File: StructClassFile.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private void writeStructField(final Struct.Field field, final PrintStream out){
    if(field.type.getJType() == null || !(field.type.getJType() instanceof JStruct)){
        out.println("\t// Found bad JavaType (" + field.type.getJType() + ") for field (" + field.name + ") of type (" + field.type + ")");
        return;
    }
    String privName = field.name + "__";
    String offsetName = field.name.toUpperCase() + "_OFFSET";
    JStruct jstype = (JStruct) field.type.getJType();
    String retTypeName = jstype.getJavaReturnTypeName();
    out.println();
    out.println("\tprivate static final int " + offsetName + " = " + JObjCRuntime.class.getName() + ".IS64"
            + " ? " + field.field64.offset64() + " : " + field.field32.offset32() + ";");

    out.println("\tprivate " + retTypeName + " " + privName + " = null;");
    out.println("\tpublic " + retTypeName + " " + getterName(field) + "(){");
    out.println("\t\tif(null==" + privName + "){");
    out.println("\t\t\tthis.raw.position(" + offsetName + ");");
    out.println("\t\t\t" + privName + " = " + RootJObjCClass.runtimeFrameworkInstR(struct.parent.name) + ".make" + jstype.struct.name + "(this.raw.slice());");
    out.println("\t\t}");
    out.println("\t\treturn " + privName + ";");
    out.println("\t}");
}
 
Example #6
Source File: StructClassFile.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private void writeStructField(final Struct.Field field, final PrintStream out){
    if(field.type.getJType() == null || !(field.type.getJType() instanceof JStruct)){
        out.println("\t// Found bad JavaType (" + field.type.getJType() + ") for field (" + field.name + ") of type (" + field.type + ")");
        return;
    }
    String privName = field.name + "__";
    String offsetName = field.name.toUpperCase() + "_OFFSET";
    JStruct jstype = (JStruct) field.type.getJType();
    String retTypeName = jstype.getJavaReturnTypeName();
    out.println();
    out.println("\tprivate static final int " + offsetName + " = " + JObjCRuntime.class.getName() + ".IS64"
            + " ? " + field.field64.offset64() + " : " + field.field32.offset32() + ";");

    out.println("\tprivate " + retTypeName + " " + privName + " = null;");
    out.println("\tpublic " + retTypeName + " " + getterName(field) + "(){");
    out.println("\t\tif(null==" + privName + "){");
    out.println("\t\t\tthis.raw.position(" + offsetName + ");");
    out.println("\t\t\t" + privName + " = " + RootJObjCClass.runtimeFrameworkInstR(struct.parent.name) + ".make" + jstype.struct.name + "(this.raw.slice());");
    out.println("\t\t}");
    out.println("\t\treturn " + privName + ";");
    out.println("\t}");
}
 
Example #7
Source File: StructClassFile.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private void writeField(final Struct.Field field, final PrintStream out){
    if(field.type.type32 instanceof NBitfield){
        out.format("\t// Skipping bitfield '%1$s'\n", field.name);
        return;
    }
    String privName = field.name + "__";
    String offsetName = field.name.toUpperCase() + "_OFFSET";
    JType jtype = field.type.getJType();
    String retType = jtype.getJavaReturnTypeName();
    CoderDescriptor cdesc = jtype.getCoderDescriptor();
    out.println();
    out.println("\tprivate static final int " + offsetName + " = " + JObjCRuntime.class.getName()
            + ".IS64 ? " + field.field64.offset64() + " : " + field.field32.offset32() + ";");

    out.println("\t//" + cdesc.getClass().toString());
    out.println("\tpublic " + retType + " " + getterName(field) + "(){");
    out.println(jtype.createPopAddr("getRuntime()", "this.raw.bufferPtr + " + offsetName));
    out.println(jtype.createReturn());
    out.println("\t}");
    out.println();
    out.println("\tpublic void " + setterName(field.name) + "(final " + retType + " " + privName + "){");
    out.println("\t\t" + cdesc.getPushAddrStatementFor("getRuntime()", "this.raw.bufferPtr + " + offsetName, privName));
    out.println("\t}");
}
 
Example #8
Source File: StructClassFile.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private void writeField(final Struct.Field field, final PrintStream out){
    if(field.type.type32 instanceof NBitfield){
        out.format("\t// Skipping bitfield '%1$s'\n", field.name);
        return;
    }
    String privName = field.name + "__";
    String offsetName = field.name.toUpperCase() + "_OFFSET";
    JType jtype = field.type.getJType();
    String retType = jtype.getJavaReturnTypeName();
    CoderDescriptor cdesc = jtype.getCoderDescriptor();
    out.println();
    out.println("\tprivate static final int " + offsetName + " = " + JObjCRuntime.class.getName()
            + ".IS64 ? " + field.field64.offset64() + " : " + field.field32.offset32() + ";");

    out.println("\t//" + cdesc.getClass().toString());
    out.println("\tpublic " + retType + " " + getterName(field) + "(){");
    out.println(jtype.createPopAddr("getRuntime()", "this.raw.bufferPtr + " + offsetName));
    out.println(jtype.createReturn());
    out.println("\t}");
    out.println();
    out.println("\tpublic void " + setterName(field.name) + "(final " + retType + " " + privName + "){");
    out.println("\t\t" + cdesc.getPushAddrStatementFor("getRuntime()", "this.raw.bufferPtr + " + offsetName, privName));
    out.println("\t}");
}
 
Example #9
Source File: StructClassFile.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private void writeStructField(final Struct.Field field, final PrintStream out){
    if(field.type.getJType() == null || !(field.type.getJType() instanceof JStruct)){
        out.println("\t// Found bad JavaType (" + field.type.getJType() + ") for field (" + field.name + ") of type (" + field.type + ")");
        return;
    }
    String privName = field.name + "__";
    String offsetName = field.name.toUpperCase() + "_OFFSET";
    JStruct jstype = (JStruct) field.type.getJType();
    String retTypeName = jstype.getJavaReturnTypeName();
    out.println();
    out.println("\tprivate static final int " + offsetName + " = " + JObjCRuntime.class.getName() + ".IS64"
            + " ? " + field.field64.offset64() + " : " + field.field32.offset32() + ";");

    out.println("\tprivate " + retTypeName + " " + privName + " = null;");
    out.println("\tpublic " + retTypeName + " " + getterName(field) + "(){");
    out.println("\t\tif(null==" + privName + "){");
    out.println("\t\t\tthis.raw.position(" + offsetName + ");");
    out.println("\t\t\t" + privName + " = " + RootJObjCClass.runtimeFrameworkInstR(struct.parent.name) + ".make" + jstype.struct.name + "(this.raw.slice());");
    out.println("\t\t}");
    out.println("\t\treturn " + privName + ";");
    out.println("\t}");
}
 
Example #10
Source File: StructClassFile.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
private void writeField(final Struct.Field field, final PrintStream out){
    if(field.type.type32 instanceof NBitfield){
        out.format("\t// Skipping bitfield '%1$s'\n", field.name);
        return;
    }
    String privName = field.name + "__";
    String offsetName = field.name.toUpperCase() + "_OFFSET";
    JType jtype = field.type.getJType();
    String retType = jtype.getJavaReturnTypeName();
    CoderDescriptor cdesc = jtype.getCoderDescriptor();
    out.println();
    out.println("\tprivate static final int " + offsetName + " = " + JObjCRuntime.class.getName()
            + ".IS64 ? " + field.field64.offset64() + " : " + field.field32.offset32() + ";");

    out.println("\t//" + cdesc.getClass().toString());
    out.println("\tpublic " + retType + " " + getterName(field) + "(){");
    out.println(jtype.createPopAddr("getRuntime()", "this.raw.bufferPtr + " + offsetName));
    out.println(jtype.createReturn());
    out.println("\t}");
    out.println();
    out.println("\tpublic void " + setterName(field.name) + "(final " + retType + " " + privName + "){");
    out.println("\t\t" + cdesc.getPushAddrStatementFor("getRuntime()", "this.raw.bufferPtr + " + offsetName, privName));
    out.println("\t}");
}
 
Example #11
Source File: StructClassFile.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private void writeStructField(final Struct.Field field, final PrintStream out){
    if(field.type.getJType() == null || !(field.type.getJType() instanceof JStruct)){
        out.println("\t// Found bad JavaType (" + field.type.getJType() + ") for field (" + field.name + ") of type (" + field.type + ")");
        return;
    }
    String privName = field.name + "__";
    String offsetName = field.name.toUpperCase() + "_OFFSET";
    JStruct jstype = (JStruct) field.type.getJType();
    String retTypeName = jstype.getJavaReturnTypeName();
    out.println();
    out.println("\tprivate static final int " + offsetName + " = " + JObjCRuntime.class.getName() + ".IS64"
            + " ? " + field.field64.offset64() + " : " + field.field32.offset32() + ";");

    out.println("\tprivate " + retTypeName + " " + privName + " = null;");
    out.println("\tpublic " + retTypeName + " " + getterName(field) + "(){");
    out.println("\t\tif(null==" + privName + "){");
    out.println("\t\t\tthis.raw.position(" + offsetName + ");");
    out.println("\t\t\t" + privName + " = " + RootJObjCClass.runtimeFrameworkInstR(struct.parent.name) + ".make" + jstype.struct.name + "(this.raw.slice());");
    out.println("\t\t}");
    out.println("\t\treturn " + privName + ";");
    out.println("\t}");
}
 
Example #12
Source File: StructClassFile.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private void writeField(final Struct.Field field, final PrintStream out){
    if(field.type.type32 instanceof NBitfield){
        out.format("\t// Skipping bitfield '%1$s'\n", field.name);
        return;
    }
    String privName = field.name + "__";
    String offsetName = field.name.toUpperCase() + "_OFFSET";
    JType jtype = field.type.getJType();
    String retType = jtype.getJavaReturnTypeName();
    CoderDescriptor cdesc = jtype.getCoderDescriptor();
    out.println();
    out.println("\tprivate static final int " + offsetName + " = " + JObjCRuntime.class.getName()
            + ".IS64 ? " + field.field64.offset64() + " : " + field.field32.offset32() + ";");

    out.println("\t//" + cdesc.getClass().toString());
    out.println("\tpublic " + retType + " " + getterName(field) + "(){");
    out.println(jtype.createPopAddr("getRuntime()", "this.raw.bufferPtr + " + offsetName));
    out.println(jtype.createReturn());
    out.println("\t}");
    out.println();
    out.println("\tpublic void " + setterName(field.name) + "(final " + retType + " " + privName + "){");
    out.println("\t\t" + cdesc.getPushAddrStatementFor("getRuntime()", "this.raw.bufferPtr + " + offsetName, privName));
    out.println("\t}");
}
 
Example #13
Source File: StructClassFile.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private void writeStructField(final Struct.Field field, final PrintStream out){
    if(field.type.getJType() == null || !(field.type.getJType() instanceof JStruct)){
        out.println("\t// Found bad JavaType (" + field.type.getJType() + ") for field (" + field.name + ") of type (" + field.type + ")");
        return;
    }
    String privName = field.name + "__";
    String offsetName = field.name.toUpperCase() + "_OFFSET";
    JStruct jstype = (JStruct) field.type.getJType();
    String retTypeName = jstype.getJavaReturnTypeName();
    out.println();
    out.println("\tprivate static final int " + offsetName + " = " + JObjCRuntime.class.getName() + ".IS64"
            + " ? " + field.field64.offset64() + " : " + field.field32.offset32() + ";");

    out.println("\tprivate " + retTypeName + " " + privName + " = null;");
    out.println("\tpublic " + retTypeName + " " + getterName(field) + "(){");
    out.println("\t\tif(null==" + privName + "){");
    out.println("\t\t\tthis.raw.position(" + offsetName + ");");
    out.println("\t\t\t" + privName + " = " + RootJObjCClass.runtimeFrameworkInstR(struct.parent.name) + ".make" + jstype.struct.name + "(this.raw.slice());");
    out.println("\t\t}");
    out.println("\t\treturn " + privName + ";");
    out.println("\t}");
}
 
Example #14
Source File: StructClassFile.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private void writeStructField(final Struct.Field field, final PrintStream out){
    if(field.type.getJType() == null || !(field.type.getJType() instanceof JStruct)){
        out.println("\t// Found bad JavaType (" + field.type.getJType() + ") for field (" + field.name + ") of type (" + field.type + ")");
        return;
    }
    String privName = field.name + "__";
    String offsetName = field.name.toUpperCase() + "_OFFSET";
    JStruct jstype = (JStruct) field.type.getJType();
    String retTypeName = jstype.getJavaReturnTypeName();
    out.println();
    out.println("\tprivate static final int " + offsetName + " = " + JObjCRuntime.class.getName() + ".IS64"
            + " ? " + field.field64.offset64() + " : " + field.field32.offset32() + ";");

    out.println("\tprivate " + retTypeName + " " + privName + " = null;");
    out.println("\tpublic " + retTypeName + " " + getterName(field) + "(){");
    out.println("\t\tif(null==" + privName + "){");
    out.println("\t\t\tthis.raw.position(" + offsetName + ");");
    out.println("\t\t\t" + privName + " = " + RootJObjCClass.runtimeFrameworkInstR(struct.parent.name) + ".make" + jstype.struct.name + "(this.raw.slice());");
    out.println("\t\t}");
    out.println("\t\treturn " + privName + ";");
    out.println("\t}");
}
 
Example #15
Source File: StructOffsetResolver.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
protected void processLine(String ln, Collection<Framework> fws, Width arch) throws Exception{
        System.out.println("\tSOR '" + ln + "'");
        if(ln.trim().length() == 0) return;
        Pattern stinfo = Pattern.compile("^(.*) (.*):(\\d+).*$");
        Matcher m = stinfo.matcher(ln);
        if(!m.matches()) throw new RuntimeException("Failed to parse line from exec: " + ln);
        String fwname = m.group(1);
        String stname = m.group(2);
        int stsize = Integer.parseInt(m.group(3));

        Framework fw = findFrameworkByName(fws, fwname);

        Struct st = fw.getStructByName(stname);
        NStruct nst = wget(arch, st.type.type32, st.type.type64);
        nst.sizeof.put(arch, stsize);

//        System.out.println(st.name + " : " + stsize);

        Pattern finfo = Pattern.compile(" (-?\\d+)");
        Matcher fm = finfo.matcher(ln);
        int fi = 0;
        while(fm.find()){
            NField sf = nst.fields.get(fi++);
            sf.offset.put(arch, Integer.parseInt(fm.group(1)));
//            System.out.println("\t" + sf.name + " : " + off);
        }

        TypeCache.inst().pingType(st.type);
    }
 
Example #16
Source File: StructOffsetResolver.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
static void printStructInfos(Framework fw, Width arch, PrintWriter out){
    for(Struct st : fw.structs){
        NStruct nst = wget(arch, st.type.type32, st.type.type64);
        out.println("std::cout << \"" + fw.name + " " + st.name + "\" << ':' << sizeof("+st.name+")");
        for(NField sf : nst.fields){
            out.print("\t<< ' ' << ");
            out.println(sf.type instanceof NType.NBitfield
                      ? "-1"
                      : "offsetof("+st.name+","+sf.name+")");
        }
        out.println("\t<< std::endl;");
    }
}
 
Example #17
Source File: StructClassFile.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override public void writeBody(final PrintStream out) {
    for(Struct.Field field : struct.fields){
        if(field.type.type64 instanceof NStruct && field.type.type32 instanceof NStruct)
            writeStructField(field, out);
        else
            writeField(field, out);
    }
}
 
Example #18
Source File: StructClassFile.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override public void writeBody(final PrintStream out) {
    for(Struct.Field field : struct.fields){
        if(field.type.type64 instanceof NStruct && field.type.type32 instanceof NStruct)
            writeStructField(field, out);
        else
            writeField(field, out);
    }
}
 
Example #19
Source File: StructOffsetResolver.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
protected void processLine(String ln, Collection<Framework> fws, Width arch) throws Exception{
        System.out.println("\tSOR '" + ln + "'");
        if(ln.trim().length() == 0) return;
        Pattern stinfo = Pattern.compile("^(.*) (.*):(\\d+).*$");
        Matcher m = stinfo.matcher(ln);
        if(!m.matches()) throw new RuntimeException("Failed to parse line from exec: " + ln);
        String fwname = m.group(1);
        String stname = m.group(2);
        int stsize = Integer.parseInt(m.group(3));

        Framework fw = findFrameworkByName(fws, fwname);

        Struct st = fw.getStructByName(stname);
        NStruct nst = wget(arch, st.type.type32, st.type.type64);
        nst.sizeof.put(arch, stsize);

//        System.out.println(st.name + " : " + stsize);

        Pattern finfo = Pattern.compile(" (-?\\d+)");
        Matcher fm = finfo.matcher(ln);
        int fi = 0;
        while(fm.find()){
            NField sf = nst.fields.get(fi++);
            sf.offset.put(arch, Integer.parseInt(fm.group(1)));
//            System.out.println("\t" + sf.name + " : " + off);
        }

        TypeCache.inst().pingType(st.type);
    }
 
Example #20
Source File: StructOffsetResolver.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
static void printStructInfos(Framework fw, Width arch, PrintWriter out){
    for(Struct st : fw.structs){
        NStruct nst = wget(arch, st.type.type32, st.type.type64);
        out.println("std::cout << \"" + fw.name + " " + st.name + "\" << ':' << sizeof("+st.name+")");
        for(NField sf : nst.fields){
            out.print("\t<< ' ' << ");
            out.println(sf.type instanceof NType.NBitfield
                      ? "-1"
                      : "offsetof("+st.name+","+sf.name+")");
        }
        out.println("\t<< std::endl;");
    }
}
 
Example #21
Source File: StructOffsetResolver.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void printStructInfos(Framework fw, Width arch, PrintWriter out){
    for(Struct st : fw.structs){
        NStruct nst = wget(arch, st.type.type32, st.type.type64);
        out.println("std::cout << \"" + fw.name + " " + st.name + "\" << ':' << sizeof("+st.name+")");
        for(NField sf : nst.fields){
            out.print("\t<< ' ' << ");
            out.println(sf.type instanceof NType.NBitfield
                      ? "-1"
                      : "offsetof("+st.name+","+sf.name+")");
        }
        out.println("\t<< std::endl;");
    }
}
 
Example #22
Source File: StructClassFile.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override public void writeBody(final PrintStream out) {
    for(Struct.Field field : struct.fields){
        if(field.type.type64 instanceof NStruct && field.type.type32 instanceof NStruct)
            writeStructField(field, out);
        else
            writeField(field, out);
    }
}
 
Example #23
Source File: StructOffsetResolver.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
static void printStructInfos(Framework fw, Width arch, PrintWriter out){
    for(Struct st : fw.structs){
        NStruct nst = wget(arch, st.type.type32, st.type.type64);
        out.println("std::cout << \"" + fw.name + " " + st.name + "\" << ':' << sizeof("+st.name+")");
        for(NField sf : nst.fields){
            out.print("\t<< ' ' << ");
            out.println(sf.type instanceof NType.NBitfield
                      ? "-1"
                      : "offsetof("+st.name+","+sf.name+")");
        }
        out.println("\t<< std::endl;");
    }
}
 
Example #24
Source File: StructOffsetResolver.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
protected void processLine(String ln, Collection<Framework> fws, Width arch) throws Exception{
        System.out.println("\tSOR '" + ln + "'");
        if(ln.trim().length() == 0) return;
        Pattern stinfo = Pattern.compile("^(.*) (.*):(\\d+).*$");
        Matcher m = stinfo.matcher(ln);
        if(!m.matches()) throw new RuntimeException("Failed to parse line from exec: " + ln);
        String fwname = m.group(1);
        String stname = m.group(2);
        int stsize = Integer.parseInt(m.group(3));

        Framework fw = findFrameworkByName(fws, fwname);

        Struct st = fw.getStructByName(stname);
        NStruct nst = wget(arch, st.type.type32, st.type.type64);
        nst.sizeof.put(arch, stsize);

//        System.out.println(st.name + " : " + stsize);

        Pattern finfo = Pattern.compile(" (-?\\d+)");
        Matcher fm = finfo.matcher(ln);
        int fi = 0;
        while(fm.find()){
            NField sf = nst.fields.get(fi++);
            sf.offset.put(arch, Integer.parseInt(fm.group(1)));
//            System.out.println("\t" + sf.name + " : " + off);
        }

        TypeCache.inst().pingType(st.type);
    }
 
Example #25
Source File: StructOffsetResolver.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
static void printStructInfos(Framework fw, Width arch, PrintWriter out){
    for(Struct st : fw.structs){
        NStruct nst = wget(arch, st.type.type32, st.type.type64);
        out.println("std::cout << \"" + fw.name + " " + st.name + "\" << ':' << sizeof("+st.name+")");
        for(NField sf : nst.fields){
            out.print("\t<< ' ' << ");
            out.println(sf.type instanceof NType.NBitfield
                      ? "-1"
                      : "offsetof("+st.name+","+sf.name+")");
        }
        out.println("\t<< std::endl;");
    }
}
 
Example #26
Source File: StructClassFile.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override public void writeBody(final PrintStream out) {
    for(Struct.Field field : struct.fields){
        if(field.type.type64 instanceof NStruct && field.type.type32 instanceof NStruct)
            writeStructField(field, out);
        else
            writeField(field, out);
    }
}
 
Example #27
Source File: StructOffsetResolver.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
static void printStructInfos(Framework fw, Width arch, PrintWriter out){
    for(Struct st : fw.structs){
        NStruct nst = wget(arch, st.type.type32, st.type.type64);
        out.println("std::cout << \"" + fw.name + " " + st.name + "\" << ':' << sizeof("+st.name+")");
        for(NField sf : nst.fields){
            out.print("\t<< ' ' << ");
            out.println(sf.type instanceof NType.NBitfield
                      ? "-1"
                      : "offsetof("+st.name+","+sf.name+")");
        }
        out.println("\t<< std::endl;");
    }
}
 
Example #28
Source File: StructClassFile.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override public void writeBody(final PrintStream out) {
    for(Struct.Field field : struct.fields){
        if(field.type.type64 instanceof NStruct && field.type.type32 instanceof NStruct)
            writeStructField(field, out);
        else
            writeField(field, out);
    }
}
 
Example #29
Source File: StructOffsetResolver.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
static void printStructInfos(Framework fw, Width arch, PrintWriter out){
    for(Struct st : fw.structs){
        NStruct nst = wget(arch, st.type.type32, st.type.type64);
        out.println("std::cout << \"" + fw.name + " " + st.name + "\" << ':' << sizeof("+st.name+")");
        for(NField sf : nst.fields){
            out.print("\t<< ' ' << ");
            out.println(sf.type instanceof NType.NBitfield
                      ? "-1"
                      : "offsetof("+st.name+","+sf.name+")");
        }
        out.println("\t<< std::endl;");
    }
}
 
Example #30
Source File: StructOffsetResolver.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
protected void processLine(String ln, Collection<Framework> fws, Width arch) throws Exception{
        System.out.println("\tSOR '" + ln + "'");
        if(ln.trim().length() == 0) return;
        Pattern stinfo = Pattern.compile("^(.*) (.*):(\\d+).*$");
        Matcher m = stinfo.matcher(ln);
        if(!m.matches()) throw new RuntimeException("Failed to parse line from exec: " + ln);
        String fwname = m.group(1);
        String stname = m.group(2);
        int stsize = Integer.parseInt(m.group(3));

        Framework fw = findFrameworkByName(fws, fwname);

        Struct st = fw.getStructByName(stname);
        NStruct nst = wget(arch, st.type.type32, st.type.type64);
        nst.sizeof.put(arch, stsize);

//        System.out.println(st.name + " : " + stsize);

        Pattern finfo = Pattern.compile(" (-?\\d+)");
        Matcher fm = finfo.matcher(ln);
        int fi = 0;
        while(fm.find()){
            NField sf = nst.fields.get(fi++);
            sf.offset.put(arch, Integer.parseInt(fm.group(1)));
//            System.out.println("\t" + sf.name + " : " + off);
        }

        TypeCache.inst().pingType(st.type);
    }