Search in sources :

Example 16 with IAttributeValueMap

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

the class MemorySectionParser method memInfo.

/**
 * Parse the memory section and segment information
 * @throws ParserException
 */
private void memInfo() throws ParserException {
    IAttributeValueMap results = null;
    // Heap information
    results = processTagLineOptional(T_1STHEAPALLOC);
    results = processTagLineOptional(T_1STHEAPFREE);
    while ((results = processTagLineOptional(T_1STSEGTYPE)) != null) {
        // The segment type
        String segName = results.getTokenValue(MEMORY_SEGMENT_NAME);
        // Each segment
        while ((results = processTagLineOptional(T_1STSEGMENT)) != null) {
            long id = results.getLongValue(MEMORY_SEGMENT_ID);
            String name;
            if (id != IBuilderData.NOT_AVAILABLE) {
                name = segName + " segment 0x" + Long.toHexString(id);
            } else {
                name = segName;
            }
            long head = results.getLongValue(MEMORY_SEGMENT_HEAD);
            long size = results.getLongValue(MEMORY_SEGMENT_SIZE);
            long free = results.getLongValue(MEMORY_SEGMENT_FREE);
            long tail = results.getLongValue(MEMORY_SEGMENT_TAIL);
            if (head != IBuilderData.NOT_AVAILABLE) {
                if (free != IBuilderData.NOT_AVAILABLE) {
                    long headSize = free - head;
                    if (headSize != 0) {
                        fImageAddressSpaceBuilder.addImageSection(name + " head", head, headSize);
                    }
                }
            }
            if (free != IBuilderData.NOT_AVAILABLE) {
                if (tail != IBuilderData.NOT_AVAILABLE) {
                    long freeSize = tail - free;
                    if (freeSize != 0) {
                        fImageAddressSpaceBuilder.addImageSection(name + " free", free, freeSize);
                    }
                }
            }
            if (head != IBuilderData.NOT_AVAILABLE) {
                if (tail != IBuilderData.NOT_AVAILABLE) {
                    if (size != IBuilderData.NOT_AVAILABLE) {
                        long tailSize = head + size - tail;
                        if (tailSize != 0) {
                            fImageAddressSpaceBuilder.addImageSection(name + " tail", tail, tailSize);
                        }
                    }
                }
            }
        }
    }
}
Also used : IAttributeValueMap(com.ibm.dtfj.javacore.parser.j9.IAttributeValueMap)

Example 17 with IAttributeValueMap

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

the class MonitorSectionParser method waitOnNotifyOrEnter.

/**
 * This handles both wait on notify and wait on enter threads for a given java monitor.
 * <br><br>
 * If either a wait on notify or wait on enter header tag is parsed (3LKNOTIFYQ or 3LKWAITNOTIFY, respectively),
 * its corresponding data tag (3LKWAITNOTIFY and 3LKWAITER, respectively) is parsed iteratively.
 * For each of the data tags, a valid threadID must be parsed. If not, an exception is thrown and
 * the thread is not added to the monitor wait notify/wait enter thread list.However, the process
 * will continue regardless of whether errors are encountered or not, as long as the error handler permits it to
 * do so.
 * <br>
 * A valid thread ID must be parsed for each 3LKWAITNOTIFY or 3LKWAITER encountered, or error handler is invoked.
 * @throws ParserException
 */
private void waitOnNotifyOrEnter(JavaMonitor monitor) throws ParserException {
    boolean waitOnNotify = false;
    String tagName = null;
    while ((waitOnNotify = matchOptional(tagName = T_3LKNOTIFYQ)) || matchOptional(T_3LKWAITERQ)) {
        // Consume header tag
        consume();
        // Consume any unnecessary data contained in the same header tag line:
        IParserToken token = lookAhead(1);
        if (token != null && token.getType().equals(IGeneralTokenTypes.UNPARSED_STRING)) {
            consume();
        }
        tagName = (waitOnNotify) ? T_3LKWAITNOTIFY : T_3LKWAITER;
        IAttributeValueMap results = null;
        // This must match at least once. Subsequent matches are optional.
        if ((results = processTagLineRequired(tagName)) != null) {
            processNotifyOrEnterThreads(monitor, results, waitOnNotify);
            while ((results = processTagLineOptional(tagName)) != null) {
                processNotifyOrEnterThreads(monitor, results, waitOnNotify);
            }
        }
    }
}
Also used : IAttributeValueMap(com.ibm.dtfj.javacore.parser.j9.IAttributeValueMap) IParserToken(com.ibm.dtfj.javacore.parser.framework.scanner.IParserToken)

Example 18 with IAttributeValueMap

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

the class NativeMemorySectionParser method topLevelRule.

protected void topLevelRule() throws ParserException {
    IImageProcessBuilder fImageProcessBuilder = fImageBuilder.getCurrentAddressSpaceBuilder().getCurrentImageProcessBuilder();
    IJavaRuntimeBuilder fRuntimeBuilder = fImageProcessBuilder.getCurrentJavaRuntimeBuilder();
    IAttributeValueMap results = null;
    Stack categoryStack = new Stack();
    processTagLineOptional(T_0MEMUSER);
    while ((results = processMemUserLine()) != null) {
        String name = results.getTokenValue(A_NAME);
        /* If no name available, this is a spacing line */
        if (name == null) {
            continue;
        }
        int depth = results.getIntValue(A_DEPTH);
        while (categoryStack.size() >= depth) {
            categoryStack.pop();
        }
        long deepBytes = parseCommaDelimitedLong(results.getTokenValue(A_DEEP_BYTES));
        long deepAllocations = parseCommaDelimitedLong(results.getTokenValue(A_DEEP_ALLOCATIONS));
        JavaRuntimeMemoryCategory parent = null;
        if (categoryStack.size() > 0) {
            parent = (JavaRuntimeMemoryCategory) categoryStack.peek();
        }
        if (name.equals(OTHER_CATEGORY)) {
            if (parent == null) {
                throw new ParserException("Parse error: Unexpected NULL parent category for \"Other\" memory category");
            }
            fRuntimeBuilder.setShallowCountersForCategory(parent, deepBytes, deepAllocations);
        } else {
            JavaRuntimeMemoryCategory category = fRuntimeBuilder.addMemoryCategory(name, deepBytes, deepAllocations, parent);
            categoryStack.push(category);
        }
    }
}
Also used : ParserException(com.ibm.dtfj.javacore.parser.framework.parser.ParserException) IAttributeValueMap(com.ibm.dtfj.javacore.parser.j9.IAttributeValueMap) JavaRuntimeMemoryCategory(com.ibm.dtfj.java.JavaRuntimeMemoryCategory) IJavaRuntimeBuilder(com.ibm.dtfj.javacore.builder.IJavaRuntimeBuilder) IImageProcessBuilder(com.ibm.dtfj.javacore.builder.IImageProcessBuilder) Stack(java.util.Stack)

Example 19 with IAttributeValueMap

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

the class StackSectionParser method parseStackLine.

/**
 * Parse the native stack line information
 * @throws ParserException
 */
private void parseStackLine() throws ParserException {
    IAttributeValueMap results = null;
    // Process the version lines
    while ((results = processTagLineOptional(T_BTTHREADID)) != null) {
        long threadID = results.getLongValue(STACK_THREAD);
        while ((results = processTagLineOptional(T_1BTSTACKENT)) != null) {
            String module = results.getTokenValue(STACK_MODULE);
            String routine = results.getTokenValue(STACK_ROUTINE);
            long address = results.getLongValue(STACK_PROC_ADDRESS);
            long routine_address = results.getLongValue(STACK_ROUTINE_ADDRESS);
            long offset = results.getLongValue(STACK_OFFSET);
            String file = results.getTokenValue(STACK_FILE);
            int line = results.getIntValue(STACK_LINE);
            // Allow for missing data
            if (routine_address == IBuilderData.NOT_AVAILABLE && address != IBuilderData.NOT_AVAILABLE && offset != IBuilderData.NOT_AVAILABLE) {
                routine_address = address - offset;
            } else if (offset == IBuilderData.NOT_AVAILABLE && address != IBuilderData.NOT_AVAILABLE && routine_address != IBuilderData.NOT_AVAILABLE) {
                offset = address - routine_address;
            } else if (address == IBuilderData.NOT_AVAILABLE && offset != IBuilderData.NOT_AVAILABLE && routine_address != IBuilderData.NOT_AVAILABLE) {
                address = routine_address + offset;
            }
            String name;
            if (module != null) {
                name = module;
            } else {
                name = "";
            }
            if (file != null) {
                name = name + "(" + file;
                if (line != IBuilderData.NOT_AVAILABLE) {
                    name = name + ":" + line;
                }
                name = name + ")";
            }
            if (module != null) {
                ImageModule mod = fImageProcessBuilder.addLibrary(module);
                if (routine != null && address != IBuilderData.NOT_AVAILABLE && offset != IBuilderData.NOT_AVAILABLE && routine_address != IBuilderData.NOT_AVAILABLE) {
                    fImageProcessBuilder.addRoutine(mod, routine, routine_address);
                    name = name + "::" + routine + (offset >= 0 ? "+" : "-") + offset;
                } else {
                    if (offset != IBuilderData.NOT_AVAILABLE) {
                        name = name + (offset >= 0 ? "+" : "-") + offset;
                    } else {
                        if (address != IBuilderData.NOT_AVAILABLE) {
                            name = name + "::0x" + Long.toHexString(address);
                        }
                    }
                }
            } else {
                if (routine != null) {
                    if (offset != IBuilderData.NOT_AVAILABLE) {
                        name = "::" + routine + (offset >= 0 ? "+" : "-") + offset;
                    } else {
                        name = "::" + routine;
                    }
                } else {
                    if (address != IBuilderData.NOT_AVAILABLE) {
                        name = "::0x" + Long.toHexString(address);
                    } else {
                        name = null;
                    }
                }
            }
            fImageProcessBuilder.addImageStackFrame(threadID, name, 0, address);
        }
    }
}
Also used : IAttributeValueMap(com.ibm.dtfj.javacore.parser.j9.IAttributeValueMap) ImageModule(com.ibm.dtfj.image.ImageModule)

Example 20 with IAttributeValueMap

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

the class PlatformSectionParser method hostInfo.

/**
 * Parse the OS and CPU information (2XHOSLEVEL,2XHCPUARCH and 2XHCPUS lines)
 * @throws ParserException
 */
private void hostInfo() throws ParserException {
    IAttributeValueMap results = null;
    // Operating system information
    results = processTagLineOptional(T_2XHHOSTNAME);
    if (results != null) {
        // store the host name and address
        String host_name = results.getTokenValue(PL_HOST_NAME);
        String host_addr = results.getTokenValue(PL_HOST_ADDR);
        if (host_name != null) {
            fImageBuilder.setHostName(host_name);
        }
        if (host_addr != null) {
            try {
                InetAddress addr = InetAddress.getByName(host_addr);
                fImageBuilder.addHostAddr(addr);
            } catch (UnknownHostException e) {
            }
        }
    }
    // Operating system information
    results = processTagLineRequired(T_2XHOSLEVEL);
    if (results != null) {
        // store the OS name and version - two strings
        String os_name = results.getTokenValue(PL_OS_NAME);
        String os_version = results.getTokenValue(PL_OS_VERSION);
        fImageBuilder.setOSType(os_name);
        fImageBuilder.setOSSubType(os_version);
    }
    // Process and ignore the 2XHCPUS line - no useful information in there
    processTagLineRequired(T_2XHCPUS);
    // Host processor information - CPU architecture
    results = processTagLineRequired(T_3XHCPUARCH);
    if (results != null) {
        String cpu_arch = results.getTokenValue(PL_CPU_ARCH);
        fImageBuilder.setcpuType(cpu_arch);
    }
    // Host processor information - CPU count
    results = processTagLineRequired(T_3XHNUMCPUS);
    if (results != null) {
        int cpu_count = results.getIntValue(PL_CPU_COUNT);
        fImageBuilder.setcpuCount(cpu_count);
    }
    processTagLineOptional(T_3XHNUMASUP);
}
Also used : UnknownHostException(java.net.UnknownHostException) IAttributeValueMap(com.ibm.dtfj.javacore.parser.j9.IAttributeValueMap) InetAddress(java.net.InetAddress)

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