void parseDeadLocks()

in analysis/thread-dump/src/main/java/org/eclipse/jifa/tda/parser/JStackParser.java [295:376]


        void parseDeadLocks() throws Exception {
            String line = input.currentLine();
            if (line == null) {
                return;
            }
            int dlCount = 0;
            while (line.equals(PATTERNS.DEAD_LOCK_HEAD)) {
                dlCount++;
                if (snapshot.getDeadLockThreads() == null) {
                    snapshot.setDeadLockThreads(new ArrayList<>());
                }
                List<JavaThread> threads = new ArrayList<>();
                // skip ====
                input.readLine();
                step();

                line = input.currentLine();
                Matcher matcher;

                int tCount = 0;
                do {
                    matcher = PATTERNS.DEAD_LOCK_THREAD.matcher(line);
                    if (!matcher.matches()) {
                        throw new ParserException("Illegal dead lock thread name");
                    }
                    JavaThread thread = new JavaThread();
                    String name = matcher.group("name");
                    threads.add(thread);
                    tCount++;

                    thread.setName(snapshot.getSymbols().add(name));
                    thread.setType(ThreadType.JAVA);
                    // wait and held info
                    input.readLine();
                    input.readLine();

                    line = input.readLine();

                } while (line.startsWith("\""));

                step();
                line = input.currentLine();

                if (!line.equals(PATTERNS.DEAD_LOCK_STACK_HEAD)) {
                    throw new ParserException("Illegal dead lock stack head");
                }
                // skip ====
                input.readLine();

                line = input.readLine();
                for (int i = 0; i < tCount; i++) {
                    matcher = PATTERNS.DEAD_LOCK_THREAD.matcher(line);
                    if (!matcher.matches()) {
                        throw new ParserException("Illegal dead lock thread name");
                    }
                    List<String> stackTraces = new ArrayList<>();
                    while (true) {
                        line = input.readLine();
                        if (line != null && !line.startsWith("\"") && !line.isBlank() && !line.startsWith("Found")) {
                            stackTraces.add(line);
                        } else {
                            Trace trace = parseStackTrace(threads.get(i), true, stackTraces);
                            threads.get(i).setTrace(snapshot.getTraces().add(trace));
                            break;
                        }
                    }
                }
                snapshot.getDeadLockThreads().add(threads);
            }

            if (dlCount > 0) {
                step();
                line = input.currentLine();
                Matcher matcher = PATTERNS.DEAD_FOUND.matcher(line);
                if (!matcher.matches()) {
                    throw new ParserException("Missing Dead lock found line");
                }
                if (Integer.parseInt(matcher.group("count")) != dlCount) {
                    throw new ParserException("Dead lock count mismatched");
                }
            }
        }