Search in sources :

Example 6 with IParserToken

use of com.ibm.dtfj.javacore.parser.framework.scanner.IParserToken in project openj9 by eclipse.

the class LineRule method internalAddToken.

/**
 * Used internally for adding a token to the token list.
 *
 * <br><br>
 * If the token type already exists in the token map, it overwrites the value with the new token.
 *
 * @param type
 * @param matcher
 * @param offset
 * @return matched token or null otherwise
 */
private IParserToken internalAddToken(String type, Matcher matcher) {
    String value = null;
    IParserToken token = null;
    int offset = fOffSet;
    if ((value = matchAndConsumeValue(matcher)) != null) {
        token = TokenManager.getToken(value.length(), offset, fLineNumber, type, value);
        fTokenList.put(token.getType(), token);
    }
    return token;
}
Also used : IParserToken(com.ibm.dtfj.javacore.parser.framework.scanner.IParserToken)

Example 7 with IParserToken

use of com.ibm.dtfj.javacore.parser.framework.scanner.IParserToken in project openj9 by eclipse.

the class StackTagParser method initTagAttributeRules.

/**
 * Initialize parser with rules for lines in the environment (CI) section in
 * the javacore
 */
protected void initTagAttributeRules() {
    ILineRule lineRule = new LineRule() {

        public void processLine(String source, int startingOffset) {
            // version is on a single line, can include whitespace, separators etc
            consumeUntilFirstMatch(CommonPatternMatchers.colon);
            addPrefixedHexToken(STACK_THREAD);
        }
    };
    addTag(T_BTTHREADID, lineRule);
    lineRule = new LineRule() {

        // Consider all the possibilities
        // Linux
        // 1BTSTACKENT          /home/vmfarm/pxa6460sr6/ibm-java-x86_64-60/jre/lib/amd64/default/libj9dyn24.so(j9bcutil_createRomClass+0x40) [0x2a99e1be00]
        // 1BTSTACKENT          /home/vmfarm/pxa6460sr6/ibm-java-x86_64-60/jre/lib/amd64/default/libj9dyn24.so [0x2a99e1be00]
        // 1BTSTACKENT          [0x2a99e1be00]
        // AIX
        // 1BTSTACKENT          0x3076AB84
        // 1BTSTACKENT          /data/AIX/testjava/java6-32/sdk/jre/lib/ppc/libj9vm24.so:0xD538DDB4 [0xD5363000 +0x0002ADB4]
        // z/OS
        // 1BTSTACKENT          MM_ConcurrentSweepScheme::workThreadFindMinimumSizeFreeEntry(MM_EnvironmentModron*,MM_Memor...:0x2C280D0C [0x2C280840 +0x000004CC]
        // 1BTSTACKENT          :0x2C284192 [0x2C283FF0 +0x000001A2]
        // 1BTSTACKENT          thread_wrapper:0x2B697FBA [0x2B697B48 +0x00000472]
        // 1BTSTACKENT          CEEVROND:0x0F7E1AE8 [0x0F7E1198 +0x00000950]
        public void processLine(String source, int startingOffset) {
            consumeUntilFirstMatch(CommonPatternMatchers.whitespace);
            if (indexOfLast(LINUXADDRESS) >= 0) {
                IParserToken token = addAllCharactersAsTokenAndConsumeFirstMatch(STACK_MODULE, CommonPatternMatchers.open_paren);
                if (token != null) {
                    addAllCharactersAsTokenAndConsumeFirstMatch(STACK_ROUTINE, Pattern.compile("[+-]").matcher(""));
                    addPrefixedHexToken(STACK_OFFSET);
                } else {
                    addAllCharactersAsTokenAndConsumeFirstMatch(STACK_MODULE, CommonPatternMatchers.whitespace);
                }
                addPrefixedHexToken(STACK_PROC_ADDRESS);
            } else {
                int lastColon = indexOfLast(CommonPatternMatchers.colon);
                if (lastColon >= 0) {
                    String name = consumeCharacters(0, lastColon);
                    if (name.indexOf("/") != -1) {
                        addToken(STACK_MODULE, name);
                    } else {
                        addToken(STACK_ROUTINE, name);
                    }
                }
                addPrefixedHexToken(STACK_PROC_ADDRESS);
                addPrefixedHexToken(STACK_ROUTINE_ADDRESS);
                addPrefixedHexToken(STACK_OFFSET);
            }
        }
    };
    addTag(T_1BTSTACKENT, lineRule);
}
Also used : LineRule(com.ibm.dtfj.javacore.parser.framework.tag.LineRule) ILineRule(com.ibm.dtfj.javacore.parser.framework.tag.ILineRule) IParserToken(com.ibm.dtfj.javacore.parser.framework.scanner.IParserToken) ILineRule(com.ibm.dtfj.javacore.parser.framework.tag.ILineRule)

Example 8 with IParserToken

use of com.ibm.dtfj.javacore.parser.framework.scanner.IParserToken in project openj9 by eclipse.

the class LineRule method addAllCharactersAsTokenUntilIndex.

/**
 * Copies all characters from start to endIndex - 1. Also gives the option to strip trailing whitespace.
 * <br><br>
 * If the token type already exists in the token map, it overwrites the value with the new token.
 * @param type token type
 * @param endIndex
 * @param stripTrailingWhitespace if whitespace starting from endIndex - 1 to n, where n >=0 && n < endIndex.
 * @throws IndexOutOfBoundsException if endIndex > source buffer length || endIndex <= 0
 * @return generated token
 */
protected IParserToken addAllCharactersAsTokenUntilIndex(String type, int endIndex, boolean stripTrailingWhitespace) {
    if (endIndex > fSource.length() || endIndex < 0) {
        throw new IndexOutOfBoundsException(endIndex + ":" + fSource.length());
    }
    int adjustedEndIndex = endIndex - 1;
    if (stripTrailingWhitespace) {
        int i = adjustedEndIndex;
        for (; i >= 0 && Character.isWhitespace(fSource.charAt(i)); i--) ;
        adjustedEndIndex = i;
    }
    fCharSubSet.delete(0, fCharSubSet.length());
    for (int i = 0; i <= adjustedEndIndex; i++) {
        fCharSubSet.append(fSource.charAt(i));
    }
    fSource.delete(0, endIndex);
    IParserToken token = TokenManager.getToken(fCharSubSet.length(), fOffSet, fLineNumber, type, fCharSubSet.toString());
    addToken(token);
    return token;
}
Also used : IParserToken(com.ibm.dtfj.javacore.parser.framework.scanner.IParserToken)

Example 9 with IParserToken

use of com.ibm.dtfj.javacore.parser.framework.scanner.IParserToken in project openj9 by eclipse.

the class LineRule method addNonPrefixedHexToken.

/**
 * Matches the first hexadecimal match encountered that is not prefixed by "0x" as a token. The latter
 * is then prefixed to the value of the token before generating the token.
 *
 * <br><br>
 * If the token type already exists in the token map, it overwrites the value with the new token.
 *
 * @param type of token to be generated
 * @return generated token if hexadecimal match found, or null otherwise.
 */
protected IParserToken addNonPrefixedHexToken(String type) {
    Matcher matcher = CommonPatternMatchers.hex;
    matcher.reset(fSource);
    IParserToken token = null;
    if (matcher.find()) {
        fCharSubSet.delete(0, fCharSubSet.length());
        int startIndex = matcher.start();
        int endIndex = matcher.end();
        fCharSubSet.append('0');
        fCharSubSet.append('x');
        for (int i = startIndex; i < endIndex; i++) {
            fCharSubSet.append(fSource.charAt(i));
        }
        String value = fCharSubSet.toString();
        fSource.delete(0, endIndex);
        token = addToken(type, value);
    }
    return token;
}
Also used : Matcher(java.util.regex.Matcher) IParserToken(com.ibm.dtfj.javacore.parser.framework.scanner.IParserToken)

Example 10 with IParserToken

use of com.ibm.dtfj.javacore.parser.framework.scanner.IParserToken in project openj9 by eclipse.

the class LineRule method addToken.

/**
 * Adds a token of the type specified to the internal token list and assigns it the value specified by the argument.
 * Returns the generated token.
 *
 * <br><br>
 * If the token type already exists in the token map, it overwrites the value with the new token.
 *
 * @param type of the token
 * @param value of the token
 * @return generated token.
 */
protected IParserToken addToken(String type, String value) {
    IParserToken token = TokenManager.getToken(value.length(), fOffSet, fLineNumber, type, value);
    addToken(token);
    return token;
}
Also used : IParserToken(com.ibm.dtfj.javacore.parser.framework.scanner.IParserToken)

Aggregations

IParserToken (com.ibm.dtfj.javacore.parser.framework.scanner.IParserToken)19 IAttributeValueMap (com.ibm.dtfj.javacore.parser.j9.IAttributeValueMap)3 ParserException (com.ibm.dtfj.javacore.parser.framework.parser.ParserException)2 ImageModule (com.ibm.dtfj.image.ImageModule)1 BuilderFailureException (com.ibm.dtfj.javacore.builder.BuilderFailureException)1 IImageBuilder (com.ibm.dtfj.javacore.builder.IImageBuilder)1 ILookAheadBuffer (com.ibm.dtfj.javacore.parser.framework.parser.ILookAheadBuffer)1 ISectionParser (com.ibm.dtfj.javacore.parser.framework.parser.ISectionParser)1 ScannerException (com.ibm.dtfj.javacore.parser.framework.scanner.ScannerException)1 ILineRule (com.ibm.dtfj.javacore.parser.framework.tag.ILineRule)1 LineRule (com.ibm.dtfj.javacore.parser.framework.tag.LineRule)1 IOException (java.io.IOException)1 ParsePosition (java.text.ParsePosition)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 Iterator (java.util.Iterator)1 Matcher (java.util.regex.Matcher)1