in analysis/gc-log/src/main/java/org/eclipse/jifa/gclog/parser/AbstractPreUnifiedGCLogParser.java [749:812]
private void doAssemble() {
if (checkNextToken(TOKEN_LINE_FULL_SENTENCE)) {
parser.pushSentenceToParse(List.of(lastToken));
}
while (!endOfLine()) {
if (checkNextToken(TOKEN_EMBEDDED_SENTENCE)) {
parser.pushSentenceToParse(List.of(lastToken));
continue;
}
List<GCLogToken> sentence = null;
for (GCLogTokenType tokenType : GC_TRACETIME_BEGIN_TOKEN_TYPES) {
if (sentence == null && tokenType == TOKEN_GCID) {
// at least one of -XX:+PrintGCDateStamps and -XX:+PrintGCTimeStamps is needed, gcid can not
// occur at beginning
continue;
}
if (checkNextToken(tokenType)) {
if (sentence == null) {
sentence = new ArrayList<>();
}
sentence.add(lastToken);
}
}
if (sentence != null) {
parser.pushSentenceToAssemble(sentence);
parser.pushSentenceToParse(sentence);
continue;
}
for (GCLogTokenType tokenType : GC_TRACETIME_END_TOKEN_TYPES) {
if (!checkNextToken(tokenType)) {
continue;
}
if (sentence == null) {
if (tokenType == TOKEN_SAFEPOINT || tokenType == TOKEN_REFERENCE_GC) {
// They are always printed together with timestamp
sentence = parser.pollSentenceToAssemble();
} else {
// Filter out some invalid sentence. This may be useful when
// the log is using unsupported options
do {
sentence = parser.pollSentenceToAssemble();
} while (sentence != null &&
sentence.get(sentence.size() - 1).getType() != TOKEN_GC_TRACETIME_TITLE);
}
if (sentence == null) {
break; // log is incomplete?
}
}
sentence.add(lastToken);
}
if (sentence != null) {
continue;
}
if (checkNextToken(TOKEN_COLON_SPACE)) {
// HACK: when we find ": " and this can not match any other token type, it is likely
// that we meet a concurrent problem of gclog parsing. Just swallow this token.
continue;
}
// some logs like -XX:+PrintTenuringDistribution, -XX:+PrintHeapAtGC are ignored
break;
}
}