in core/src/main/java/org/adoptopenjdk/jitwatch/core/TagProcessor.java [177:304]
private Tag processValidLine(String line, int indexEndName, boolean selfClosing)
{
if (DEBUG_LOGGING_TAGPROCESSOR)
{
logger.debug("processValidLine(line:{}, indexEndName:{}, selfClosing:{})", line, indexEndName, selfClosing);
}
Tag result = null;
String name = line.substring(1, indexEndName);
String attributeString = line.substring(indexEndName);
Map<String, String> attrs = StringUtil.attributeStringToMap(attributeString);
Tag nextTag;
if (JITWatchConstants.TAG_TASK.equals(name))
{
nextTag = new Task(attributeString, selfClosing);
}
else
{
nextTag = new Tag(name, attributeString, selfClosing);
}
if (DEBUG_LOGGING_TAGPROCESSOR)
{
logger.debug("top: {}", topTag);
}
if (DEBUG_LOGGING_TAGPROCESSOR)
{
logger.debug("currentTag: {}", currentTag);
}
if (DEBUG_LOGGING_TAGPROCESSOR)
{
logger.debug("t: {}", nextTag);
}
if (currentTag == null)
{
if (name.equals(S_FRAGMENT))
{
logger.warn(
"Found a {} in the HotSpot log. The VM exited before the hotspot log was fully written. JIT information may have been lost.",
TAG_OPEN_FRAGMENT);
fragmentSeen = true;
return null;
}
else
{
// new tag at top level
currentTag = nextTag;
topTag = nextTag;
}
}
else
{
currentTag.addChild(nextTag);
}
if (topTag instanceof Task)
{
switch (name)
{
case JITWatchConstants.TAG_TYPE:
((Task) topTag).addDictionaryType(attrs.get(JITWatchConstants.ATTR_ID), nextTag);
break;
case JITWatchConstants.TAG_METHOD:
((Task) topTag).addDictionaryMethod(attrs.get(JITWatchConstants.ATTR_ID), nextTag);
break;
case JITWatchConstants.TAG_KLASS:
((Task) topTag).addDictionaryKlass(attrs.get(JITWatchConstants.ATTR_ID), nextTag);
break;
case JITWatchConstants.TAG_PARSE:
String currentMethodID = attrs.get(JITWatchConstants.ATTR_METHOD);
methodIDStack.push(currentMethodID);
break;
case JITWatchConstants.TAG_BC:
String bci = attrs.get(JITWatchConstants.ATTR_BCI);
String code = attrs.get(JITWatchConstants.ATTR_CODE);
try
{
int bciValue = Integer.parseInt(bci);
int codeValue = Integer.parseInt(code);
Opcode opcode = Opcode.getByCode(codeValue);
((Task) topTag).addBCIOpcodeMapping(methodIDStack.peek(), bciValue, opcode);
//logger.info("{} got bc tag {}", methodIDStack.peek(), nextTag.toString(false));
}
catch (NumberFormatException nfe)
{
logger.error("Couldn't parse bc tag {}", nextTag);
}
break;
default:
break;
}
}
if (selfClosing)
{
if (name.equals(currentTag.getName()))
{
if (currentTag.getParent() == null)
{
result = currentTag;
}
}
}
else
{
// not closed
currentTag = nextTag;
}
return result;
}