use of com.ibm.dtfj.javacore.parser.j9.IAttributeValueMap in project openj9 by eclipse.
the class EnvironmentSectionParser method parseUserArgs.
/**
* Parse the user args information (1CIUSERARGS and 2CIUSERARG lines)
* @throws ParserException
*/
private void parseUserArgs() throws ParserException {
IAttributeValueMap results = null;
if ((results = processTagLineRequired(T_1CIUSERARGS)) != null) {
boolean added = false;
while ((results = processTagLineOptional(T_2CIUSERARG)) != null) {
if (!added) {
// Delay creating init args until we find some args
added = true;
try {
fRuntimeBuilder.addVMInitArgs();
} catch (BuilderFailureException e) {
handleError("Failed to add JavaVMInitArgs to builder: ", e);
}
}
String argString = results.getTokenValue(ARG_STRING);
long extraInfo = results.getLongValue(ARG_EXTRA);
try {
if (extraInfo == IBuilderData.NOT_AVAILABLE) {
if (argString != null) {
fRuntimeBuilder.addVMOption(argString);
}
} else {
fRuntimeBuilder.addVMOption(argString, extraInfo);
}
} catch (BuilderFailureException e) {
handleError("Failed to add VM option to builder: " + argString + " ", e);
}
}
}
}
use of com.ibm.dtfj.javacore.parser.j9.IAttributeValueMap in project openj9 by eclipse.
the class NativeMemorySectionParser method processMemUserLine.
/**
* The XMEMUSER tag can occur in almost any order. processMemUserLine
* looks for any of the XMEMUSER tags
* @return
* @throws ParserException
*/
private IAttributeValueMap processMemUserLine() throws ParserException {
for (int i = 0; i < T_MEMUSERS.length; i++) {
String tag = T_MEMUSERS[i];
IAttributeValueMap results = processTagLineOptional(tag);
if (results != null) {
return results;
}
}
return null;
}
use of com.ibm.dtfj.javacore.parser.j9.IAttributeValueMap in project openj9 by eclipse.
the class ThreadSectionParser method allThreadInfoSubsection.
/**
* @param scanner
*/
protected void allThreadInfoSubsection() throws ParserException {
processTagLineRequired(T_1XMTHDINFO);
IAttributeValueMap results = processTagLineOptional(T_2XMFULLTHDDUMP);
if (results != null) {
int pointerSize = results.getIntValue(ICommonTypes.POINTER_SIZE);
fImageProcessBuilder.setPointerSize(pointerSize);
}
threadInfo(true, false);
}
use of com.ibm.dtfj.javacore.parser.j9.IAttributeValueMap in project openj9 by eclipse.
the class ThreadSectionParser method parseNativeStackTrace.
/**
* Parse the native stack line information
* @throws ParserException
*/
private void parseNativeStackTrace(long threadID, boolean buildModel) throws ParserException {
IAttributeValueMap results = null;
// Process the version lines
processTagLineOptional(T_3XMTHREADINFO3);
while ((results = processTagLineOptional(T_4XENATIVESTACK)) != null) {
if (!buildModel)
continue;
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 routine_offset = results.getLongValue(STACK_ROUTINE_OFFSET);
long module_offset = results.getLongValue(STACK_MODULE_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 && routine_offset != IBuilderData.NOT_AVAILABLE) {
routine_address = address - routine_offset;
} else if (routine_offset == IBuilderData.NOT_AVAILABLE && address != IBuilderData.NOT_AVAILABLE && routine_address != IBuilderData.NOT_AVAILABLE) {
routine_offset = address - routine_address;
} else if (address == IBuilderData.NOT_AVAILABLE && routine_offset != IBuilderData.NOT_AVAILABLE && routine_address != IBuilderData.NOT_AVAILABLE) {
address = routine_address + routine_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 (address != IBuilderData.NOT_AVAILABLE && module_offset != IBuilderData.NOT_AVAILABLE) {
String modAddress = "0x" + Long.toHexString(address - module_offset);
fImageProcessBuilder.addProperty(mod, "Load address", modAddress);
}
if (routine != null && address != IBuilderData.NOT_AVAILABLE && routine_offset != IBuilderData.NOT_AVAILABLE && routine_address != IBuilderData.NOT_AVAILABLE) {
fImageProcessBuilder.addRoutine(mod, routine, routine_address);
name = name + "::" + routine + (routine_offset >= 0 ? "+" : "-") + routine_offset;
} else {
if (routine_offset != IBuilderData.NOT_AVAILABLE) {
name = name + (routine_offset >= 0 ? "+" : "-") + routine_offset;
} else {
if (address != IBuilderData.NOT_AVAILABLE) {
name = name + "::0x" + Long.toHexString(address);
}
}
}
} else {
if (routine != null) {
if (routine_offset != IBuilderData.NOT_AVAILABLE) {
name = "::" + routine + (routine_offset >= 0 ? "+" : "-") + routine_offset;
} else {
name = "::" + routine;
}
} else {
if (address != IBuilderData.NOT_AVAILABLE) {
name = "::0x" + Long.toHexString(address);
} else {
name = null;
}
}
}
fImageProcessBuilder.addImageStackFrame(threadID, name, 0, address);
}
}
use of com.ibm.dtfj.javacore.parser.j9.IAttributeValueMap in project openj9 by eclipse.
the class ThreadSectionParser method addThread.
/**
* @param javaThreadResults
* @param nativeStacks list of attributes of the native stacks
* @param currentFileLineNumber
* @return java thread
* @throws ParserException if error handler decides to throw it due java thread or image thread error creation
*/
private JavaThread addThread(IAttributeValueMap javaThreadResults, IAttributeValueMap nativeResults, List nativeStacks, IAttributeValueMap blockerInfo, IAttributeValueMap cpuTimes, int currentFileLineNumber) throws ParserException {
long imageThreadID = (nativeResults != null) ? nativeResults.getLongValue(NATIVE_THREAD_ID) : javaThreadResults.getLongValue(NATIVE_THREAD_ID);
long tid = javaThreadResults.getLongValue(VM_THREAD_ID);
if (imageThreadID == IBuilderData.NOT_AVAILABLE) {
imageThreadID = tid;
}
ImageThread imageThread = null;
JavaThread javaThread = null;
// CMVC 158108 : fixed so that if the thread name is not present then it is not subsequently parsed
String threadName = javaThreadResults.getTokenValue(JAVA_THREAD_NAME);
if (threadName != null && threadName.length() >= 2) {
// remove quotes
threadName = threadName.substring(1, threadName.length() - 1);
}
String threadState = javaThreadResults.getTokenValue(JAVA_STATE);
int threadPriority = javaThreadResults.getIntValue(VM_THREAD_PRIORITY);
long abstractThreadID = javaThreadResults.getLongValue(ABSTRACT_THREAD_ID);
Properties properties = new Properties();
if (abstractThreadID != IBuilderData.NOT_AVAILABLE) {
addAsProperty(properties, ABSTRACT_THREAD_ID, "0x" + Long.toHexString(abstractThreadID));
}
if (nativeResults != null) {
addAsProperty(properties, NATIVE_THREAD_PRIORITY, nativeResults.getTokenValue(NATIVE_THREAD_PRIORITY));
addAsProperty(properties, NATIVE_THREAD_POLICY, nativeResults.getTokenValue(NATIVE_THREAD_POLICY));
addAsProperty(properties, SCOPE, nativeResults.getTokenValue(SCOPE));
addAsProperty(properties, VM_STATE, nativeResults.getTokenValue(VM_STATE));
addAsProperty(properties, VM_FLAGS, nativeResults.getTokenValue(VM_FLAGS));
}
if (cpuTimes != null) {
addAsProperty(properties, CPU_TIME_TOTAL, cpuTimes.getTokenValue(CPU_TIME_TOTAL));
addAsProperty(properties, CPU_TIME_USER, cpuTimes.getTokenValue(CPU_TIME_USER));
addAsProperty(properties, CPU_TIME_SYSTEM, cpuTimes.getTokenValue(CPU_TIME_SYSTEM));
}
String blockerObjectClassName = null;
// CMVC 180977 : the parser expects missing data to be represented by a -ve number, so change the default address from 0 to IBuilderData.NOT_AVAILABLE (currently -1)
// this parser check will break on a sufficiently large 64bit number, but fixing that is beyond the scope of this defect.
long blockerObjectAddress = IBuilderData.NOT_AVAILABLE;
if (blockerInfo != null) {
blockerObjectClassName = blockerInfo.getTokenValue(BLOCKER_OBJECT_FULL_JAVA_NAME);
blockerObjectAddress = blockerInfo.getLongValue(BLOCKER_OBJECT_ADDRESS);
}
long javaObjID = javaThreadResults.getLongValue(JAVA_THREAD_OBJ);
if (javaObjID == IBuilderData.NOT_AVAILABLE && nativeResults == null) {
String vmthread = javaThreadResults.getTokenValue(VM_THREAD_ID);
// Java 5.0 vmthreads tend to start with 0x0, and are not Java objects
if (vmthread != null && !vmthread.startsWith("0x0"))
javaObjID = tid;
}
try {
imageThread = fImageProcessBuilder.addImageThread(imageThreadID, abstractThreadID, properties);
if (threadName != null || tid != IBuilderData.NOT_AVAILABLE) {
javaThread = fRuntimeBuilder.addJavaThread(imageThread, threadName, tid, abstractThreadID, javaObjID, IBuilderData.NOT_AVAILABLE, threadState, threadPriority, blockerObjectAddress, blockerObjectClassName);
}
} catch (BuilderFailureException e) {
handleErrorAtLineNumber(currentFileLineNumber, "Failed to add thread: " + threadName + " " + imageThreadID, e);
}
for (Iterator it = nativeStacks.iterator(); it.hasNext(); ) {
IAttributeValueMap stackInfo = (IAttributeValueMap) it.next();
long from = stackInfo.getLongValue(NATIVE_STACK_FROM);
long to = stackInfo.getLongValue(NATIVE_STACK_TO);
long size = stackInfo.getLongValue(NATIVE_STACK_SIZE);
if (from != IBuilderData.NOT_AVAILABLE && size != IBuilderData.NOT_AVAILABLE) {
ImageSection section = fImageAddressSpaceBuilder.addImageSection("Native stack section", from, size);
fImageProcessBuilder.addImageStackSection(imageThread, section);
}
}
return javaThread;
}
Aggregations