Search in sources :

Example 11 with IAttributeValueMap

use of com.ibm.dtfj.javacore.parser.j9.IAttributeValueMap in project openj9 by eclipse.

the class ThreadSectionParser method parseStackTrace.

/**
 * @param results from parsing the threadinfo tag
 * @throws ParserException
 */
private void parseStackTrace(JavaThread javaThread, int currentFileLineNumber, boolean buildModel) throws ParserException {
    /*
		 * Consume data from buffer even if there is no valid java thread in which
		 * to add the stack frames.
		 */
    IAttributeValueMap stackTraceResults = null;
    currentFileLineNumber = getCurrentFileLineNumber();
    processTagLineOptional(T_3XMTHREADINFO3);
    while ((stackTraceResults = processTagLineOptional(T_4XESTACKTRACE)) != null) {
        if (javaThread != null) {
            addStackTrace(stackTraceResults, javaThread, currentFileLineNumber);
            currentFileLineNumber = getCurrentFileLineNumber();
        }
    }
    /*
		 * Sov hook (i.e., for Sov 1.4.2 javacores, there is additional information after
		 * the last 4XESTACKTRACE tag of a 3XMTHREADINFO tag.
		 */
    sovOnlyRules(T_3XMTHREADINFO);
}
Also used : IAttributeValueMap(com.ibm.dtfj.javacore.parser.j9.IAttributeValueMap)

Example 12 with IAttributeValueMap

use of com.ibm.dtfj.javacore.parser.j9.IAttributeValueMap in project openj9 by eclipse.

the class EnvironmentSectionParser method parseEnvironmentVars.

/**
 * Parse the user args information (1CIUSERARGS and 2CIUSERARG lines)
 * @throws ParserException
 */
private void parseEnvironmentVars() throws ParserException {
    IAttributeValueMap results = null;
    results = processTagLineOptional(T_1CIENVVARS);
    if (results != null) {
        while ((results = processTagLineOptional(T_2CIENVVAR)) != null) {
            String env_name = results.getTokenValue(ENV_NAME);
            String env_value = results.getTokenValue(ENV_VALUE);
            if (env_name != null && env_value != null) {
                fImageProcessBuilder.addEnvironmentVariable(env_name, env_value);
            }
        }
    }
}
Also used : IAttributeValueMap(com.ibm.dtfj.javacore.parser.j9.IAttributeValueMap)

Example 13 with IAttributeValueMap

use of com.ibm.dtfj.javacore.parser.j9.IAttributeValueMap in project openj9 by eclipse.

the class EnvironmentSectionParser method parseVersion.

/**
 * Parse the version information (1CIJAVAVERSION, and lines)
 * @throws ParserException
 */
private void parseVersion() throws ParserException {
    IAttributeValueMap results = null;
    // Process the version lines
    if ((results = processTagLineOptional(T_1CIJAVAVERSION)) != null) {
        int pointerSize = results.getIntValue(ICommonTypes.POINTER_SIZE);
        if (pointerSize != IBuilderData.NOT_AVAILABLE) {
            fImageProcessBuilder.setPointerSize(pointerSize);
        }
        String javaversion = results.getTokenValue(ARG_STRING);
        String checkString = "j2re 1.";
        // check that the core we are processing is from Java 5 or later
        if ((javaversion.toLowerCase().startsWith(checkString)) && (javaversion.length() > (checkString.length() + 1))) {
            String number = javaversion.substring(checkString.length(), javaversion.indexOf('.', checkString.length() + 1));
            try {
                int version = Integer.parseInt(number);
                if (version <= 4) {
                    throw new ParserException("Javacore files earlier than 1.5.0 are not supported");
                }
            } catch (NumberFormatException e) {
                handleError("Error determining Java version", e);
            }
        }
        results = processTagLineOptional(T_1CIVMVERSION);
        if (results != null) {
            javaversion = buildVersionString(javaversion, results);
        }
        results = processTagLineOptional(T_1CIJITVERSION);
        if (results != null) {
            javaversion = buildVersionString(javaversion, results);
        }
        results = processTagLineOptional(T_1CIGCVERSION);
        if (results != null) {
            javaversion = buildVersionString(javaversion, results);
        }
        if (javaversion != null) {
            fRuntimeBuilder.setJavaVersion(javaversion);
        }
    } else {
        processTagLineOptional(T_1CIVMVERSION);
        processTagLineOptional(T_1CIJITVERSION);
        processTagLineOptional(T_1CIGCVERSION);
    }
    results = processTagLineOptional(T_1CIJITMODES);
    if (results != null) {
        IParserToken token = results.getToken(JIT_MODE);
        if (token != null) {
            String value = token.getValue().trim();
            if (value.toLowerCase().startsWith("unavailable")) {
                // JIT was disabled with -Xint
                fRuntimeBuilder.setJITEnabled(false);
            } else {
                // JIT was operational but still could be disabled if -Xnojit was specified
                fRuntimeBuilder.setJITEnabled(true);
                String[] props = value.split(",");
                for (int i = 0; i < props.length; i++) {
                    // trim any white space
                    String item = props[i].trim();
                    int index = item.indexOf(' ');
                    if (index == -1) {
                        fRuntimeBuilder.addJITProperty(props[i], "<default value>");
                    } else {
                        String name = item.substring(0, index);
                        String pvalue = item.substring(index + 1);
                        fRuntimeBuilder.addJITProperty(name, pvalue);
                    }
                }
            }
        }
    }
    processTagLineOptional(T_1CIRUNNINGAS);
    // 1CISTARTTIME   JVM start time: 2015/07/17 at 13:31:04:547
    if ((results = processTagLineOptional(T_1CISTARTTIME)) != null) {
        String dateTimeString = results.getTokenValue(START_TIME);
        if (dateTimeString != null) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd 'at' HH:mm:ss:SSS");
            Date startDate = sdf.parse(dateTimeString, new ParsePosition(0));
            if (startDate != null) {
                fRuntimeBuilder.setStartTime(startDate.getTime());
            }
        }
    }
    // 1CISTARTNANO   JVM start nanotime: 3534023113503
    if ((results = processTagLineOptional(T_1CISTARTNANO)) != null) {
        String nanoTimeString = results.getTokenValue(START_NANO);
        if (nanoTimeString != null) {
            fRuntimeBuilder.setStartTimeNanos(Long.parseLong(nanoTimeString));
        }
    }
    if ((results = processTagLineOptional(T_1CIPROCESSID)) != null) {
        String pidStr = results.getTokenValue(PID_STRING);
        if (pidStr != null) {
            fImageBuilder.getCurrentAddressSpaceBuilder().getCurrentImageProcessBuilder().setID(pidStr);
        }
    }
    String cmdLine = null;
    if ((results = processTagLineOptional(T_1CICMDLINE)) != null) {
        cmdLine = results.getTokenValue(CMD_LINE);
        if ("[not available]".equals(cmdLine)) {
            cmdLine = null;
        } else {
            fImageProcessBuilder.setCommandLine(cmdLine);
        }
    }
    String home = null;
    if ((results = processTagLineOptional(T_1CIJAVAHOMEDIR)) != null) {
        ;
        home = results.getTokenValue(ARG_STRING);
    }
    String dlldir = null;
    if ((results = processTagLineOptional(T_1CIJAVADLLDIR)) != null) {
        ;
        dlldir = results.getTokenValue(ARG_STRING);
    }
    if (cmdLine != null) {
        if (dlldir != null) {
            // See if the command line starts with part of Java directory - if so add rest of path
            // Find position of first path separator
            int min1 = cmdLine.indexOf('/') + 1;
            if (min1 == 0)
                min1 = cmdLine.length();
            int min2 = cmdLine.indexOf('\\') + 1;
            if (min2 == 0)
                min2 = cmdLine.length();
            int min = Math.min(min1, min2);
            for (int i = cmdLine.length(); i > min; --i) {
                String prefix = cmdLine.substring(0, i);
                int j = dlldir.indexOf(prefix);
                if (j >= 0) {
                    cmdLine = dlldir.substring(0, j) + cmdLine;
                    break;
                }
            }
        }
        // Allow for spaces in the path by skipping over spaces in javadlldir
        int i = 0;
        if (dlldir != null) {
            for (i = dlldir.length(); i >= 0; --i) {
                if (cmdLine.startsWith(dlldir.substring(0, i))) {
                    break;
                }
            }
        }
        // Look for the rest of the command line
        int sp = cmdLine.indexOf(' ', i);
        String exec;
        if (sp >= 0) {
            exec = cmdLine.substring(0, sp);
        } else {
            exec = cmdLine;
        }
        ImageModule execMod = fImageProcessBuilder.addLibrary(exec);
        fImageProcessBuilder.setExecutable(execMod);
    }
    processTagLineOptional(T_1CISYSCP);
}
Also used : ParserException(com.ibm.dtfj.javacore.parser.framework.parser.ParserException) IAttributeValueMap(com.ibm.dtfj.javacore.parser.j9.IAttributeValueMap) IParserToken(com.ibm.dtfj.javacore.parser.framework.scanner.IParserToken) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) ImageModule(com.ibm.dtfj.image.ImageModule) ParsePosition(java.text.ParsePosition)

Example 14 with IAttributeValueMap

use of com.ibm.dtfj.javacore.parser.j9.IAttributeValueMap in project openj9 by eclipse.

the class ClassLoaderSectionParser method classLoaderLibraries.

/**
 * Loaded libraries data may not be found in Sovereign VMs, therefore make
 * it optional, even though it is a standard tag in later J9 VMs.
 * @throws ParserException
 */
private void classLoaderLibraries() throws ParserException {
    if (matchOptional(T_1CLTEXTCLLIB)) {
        consume();
        /*
			 * Consume whatever other data is in the same line, as it's just header data.
			 */
        IParserToken token = lookAhead(1);
        if (token != null && token.getType().equals(IGeneralTokenTypes.UNPARSED_STRING)) {
            consume();
        }
        IAttributeValueMap results = null;
        if ((results = processTagLineRequired(T_2CLTEXTCLLIB)) != null) {
            processLibraryLoader(results);
            while ((results = processTagLineOptional(T_2CLTEXTCLLIB)) != null) {
                processLibraryLoader(results);
            }
        }
    }
}
Also used : IAttributeValueMap(com.ibm.dtfj.javacore.parser.j9.IAttributeValueMap) IParserToken(com.ibm.dtfj.javacore.parser.framework.scanner.IParserToken)

Example 15 with IAttributeValueMap

use of com.ibm.dtfj.javacore.parser.j9.IAttributeValueMap in project openj9 by eclipse.

the class ClassLoaderSectionParser method classLoaderSummaries.

/**
 * @throws ParserException
 */
private void classLoaderSummaries() throws ParserException {
    /*
		 * 1CLTEXTCLLOS and 1CLTEXTCLLSS contain no meaningful data. Process and ignore.
		 */
    processTagLineRequired(T_1CLTEXTCLLOS);
    processTagLineRequired(T_1CLTEXTCLLSS);
    IAttributeValueMap results = null;
    if ((results = processTagLineRequired(T_2CLTEXTCLLOADER)) != null) {
        processClassLoaderStats(results);
        while ((results = processTagLineOptional(T_2CLTEXTCLLOADER)) != null) {
            processClassLoaderStats(results);
        }
    }
}
Also used : IAttributeValueMap(com.ibm.dtfj.javacore.parser.j9.IAttributeValueMap)

Aggregations

IAttributeValueMap (com.ibm.dtfj.javacore.parser.j9.IAttributeValueMap)25 BuilderFailureException (com.ibm.dtfj.javacore.builder.BuilderFailureException)4 ImageModule (com.ibm.dtfj.image.ImageModule)3 IParserToken (com.ibm.dtfj.javacore.parser.framework.scanner.IParserToken)3 JavaThread (com.ibm.dtfj.java.JavaThread)2 ParserException (com.ibm.dtfj.javacore.parser.framework.parser.ParserException)2 ParsePosition (java.text.ParsePosition)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 ImageSection (com.ibm.dtfj.image.ImageSection)1 ImageThread (com.ibm.dtfj.image.ImageThread)1 JavaRuntimeMemoryCategory (com.ibm.dtfj.java.JavaRuntimeMemoryCategory)1 IImageProcessBuilder (com.ibm.dtfj.javacore.builder.IImageProcessBuilder)1 IJavaRuntimeBuilder (com.ibm.dtfj.javacore.builder.IJavaRuntimeBuilder)1 InetAddress (java.net.InetAddress)1 UnknownHostException (java.net.UnknownHostException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 LinkedHashMap (java.util.LinkedHashMap)1