private final List<ICalledFunction> fChildren = new ArrayList<>();
private final @Nullable ICalledFunction fParent;
protected long fSelfTime = 0;
+ private final int fProcessId;
- public AbstractCalledFunction(long start, long end, int depth, @Nullable ICalledFunction parent) {
+ public AbstractCalledFunction(long start, long end, int depth, int processId, @Nullable ICalledFunction parent) {
if (start > end) {
throw new IllegalArgumentException(Messages.TimeError + "[" + start + "," + end + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
fParent = parent;
// It'll be modified once we add a child to it
fSelfTime = fEnd - fStart;
+ fProcessId = processId;
}
@Override
return fDepth;
}
+ @Override
+ public int getProcessId() {
+ return fProcessId;
+ }
+
@Override
public int compareTo(@Nullable ISegment o) {
if (o == null) {
private final AggregatedCalledFunctionStatistics fStatistics;
private long fDuration;
private long fSelfTime;
+ private final int fProcessId;
/**
* Constructor, parent is not null
fDuration = calledFunction.getLength();
fSelfTime = calledFunction.getLength();
fDepth = calledFunction.getDepth();
+ fProcessId = calledFunction.getProcessId();
fMaxDepth = parent.getMaxDepth();
fParent = parent;
fStatistics = new AggregatedCalledFunctionStatistics(calledFunction, calledFunction);
fDuration = calledFunction.getLength();
fSelfTime = calledFunction.getLength();
fDepth = calledFunction.getDepth();
+ fProcessId = calledFunction.getProcessId();
fMaxDepth = maxDepth;
fParent = null;
fStatistics = new AggregatedCalledFunctionStatistics(calledFunction, calledFunction);
fSelfTime += selfTime;
}
+ /**
+ * The process ID of the trace application.
+ * @return The process Id
+ */
+ public int getProcessId() {
+ return fProcessId;
+ }
+
/**
* Returns whether the function has callees.
*
}
List<Integer> processQuarks = ss.getQuarks(processesPattern);
for (int processQuark : processQuarks) {
+ int processId = getProcessId(ss, processQuark, ss.getCurrentEndTime());
for (int threadQuark : ss.getQuarks(processQuark, threadsPattern)) {
- if (!iterateOverQuark(ss, threadQuark, callStackPath, monitor)) {
+ if (!iterateOverQuark(ss, processId, threadQuark, callStackPath, monitor)) {
return false;
}
}
*
* @param stateSystem
* The state system
- * @param quark
- * The quark
+ * @param processId
+ * The process ID of the traced application
+ * @param threadQuark
+ * The thread quark
* @param subAttributePath
* sub-Attributes path
* @param monitor
* The monitor
* @return Boolean
*/
- private boolean iterateOverQuark(ITmfStateSystem stateSystem, int quark, String[] subAttributePath, IProgressMonitor monitor) {
- String threadName = stateSystem.getAttributeName(quark);
+ private boolean iterateOverQuark(ITmfStateSystem stateSystem, int processId, int threadQuark, String[] subAttributePath, IProgressMonitor monitor) {
+ String threadName = stateSystem.getAttributeName(threadQuark);
long threadId = -1;
ITmfStateInterval interval = null;
try {
- interval = stateSystem.querySingleState(stateSystem.getStartTime(), quark);
+ interval = stateSystem.querySingleState(stateSystem.getStartTime(), threadQuark);
ITmfStateValue threadStateValue = interval.getStateValue();
if (threadStateValue.getType() == Type.LONG || threadStateValue.getType() == Type.INTEGER) {
threadId = threadStateValue.unboxLong();
try {
long curTime = stateSystem.getStartTime();
long limit = stateSystem.getCurrentEndTime();
- AbstractCalledFunction initSegment = CalledFunctionFactory.create(0, 0, 0, threadName, null);
+ AbstractCalledFunction initSegment = CalledFunctionFactory.create(0, 0, 0, threadName, processId, null);
ThreadNode init = new ThreadNode(initSegment, 0, threadId);
while (curTime < limit) {
if (monitor.isCanceled()) {
return false;
}
- int callStackQuark = stateSystem.getQuarkRelative(quark, subAttributePath);
+ int callStackQuark = stateSystem.getQuarkRelative(threadQuark, subAttributePath);
fCurrentQuarks = stateSystem.getSubAttributes(callStackQuark, false);
if (fCurrentQuarks.isEmpty()) {
return false;
long intervalStart = interval.getStartTime();
long intervalEnd = interval.getEndTime();
// Create the segment for the first call event.
- AbstractCalledFunction segment = CalledFunctionFactory.create(intervalStart, intervalEnd + 1, depth, stateValue, null);
+ AbstractCalledFunction segment = CalledFunctionFactory.create(intervalStart, intervalEnd + 1, depth, stateValue, processId, null);
fRootFunctions.add(segment);
AggregatedCalledFunction firstNode = new AggregatedCalledFunction(segment, fCurrentQuarks.size());
- if (!findChildren(segment, depth, stateSystem, fCurrentQuarks.size() + fCurrentQuarks.get(depth), firstNode, monitor)) {
+ if (!findChildren(segment, depth, stateSystem, fCurrentQuarks.size() + fCurrentQuarks.get(depth), firstNode, processId, monitor)) {
return false;
}
init.addChild(firstNode);
* The quark of the segment parent ss The actual state system
* @param maxQuark
* The last quark in the state system
- * @param AggregatedCalledFunction
+ * @param aggregatedCalledFunction
* A node in the aggregation tree
+ * @param processId
+ * The process ID of the traced application
* @param monitor
* The progress monitor The progress monitor TODO: if stack size
* is an issue, convert to a stack instead of recursive function
*/
- private boolean findChildren(AbstractCalledFunction node, int depth, ITmfStateSystem ss, int maxQuark, AggregatedCalledFunction aggregatedCalledFunction, IProgressMonitor monitor) {
+ private boolean findChildren(AbstractCalledFunction node, int depth, ITmfStateSystem ss, int maxQuark, AggregatedCalledFunction aggregatedCalledFunction, int processId, IProgressMonitor monitor) {
fStore.add(node);
long curTime = node.getStart();
long limit = node.getEnd();
if (intervalStart < node.getStart() || intervalEnd > limit) {
return true;
}
- AbstractCalledFunction segment = CalledFunctionFactory.create(intervalStart, intervalEnd + 1, node.getDepth() + 1, stateValue, node);
+ AbstractCalledFunction segment = CalledFunctionFactory.create(intervalStart, intervalEnd + 1, node.getDepth() + 1, stateValue, processId, node);
AggregatedCalledFunction childNode = new AggregatedCalledFunction(segment, aggregatedCalledFunction);
// Search for the children with the next quark.
- findChildren(segment, depth + 1, ss, maxQuark, childNode, monitor);
+ findChildren(segment, depth + 1, ss, maxQuark, childNode, processId, monitor);
aggregatedCalledFunction.addChild(childNode);
node.addChild(segment);
}
return ImmutableList.copyOf(fThreadNodes);
}
+ private static int getProcessId(ITmfStateSystem ss, int processQuark, long curTime) {
+ int processId = -1;
+ if (processQuark != ITmfStateSystem.ROOT_ATTRIBUTE) {
+ try {
+ ITmfStateInterval interval = ss.querySingleState(curTime, processQuark);
+ String processName = ss.getAttributeName(processQuark);
+ ITmfStateValue processStateValue = interval.getStateValue();
+ if (processStateValue.getType() == Type.INTEGER) {
+ processId = processStateValue.unboxInt();
+ } else {
+ try {
+ processId = Integer.parseInt(processName);
+ } catch (NumberFormatException e) {
+ /* use default processId */
+ }
+ }
+ } catch (StateSystemDisposedException e) {
+ // ignore
+ }
+ }
+ return processId;
+ }
}
\ No newline at end of file
* The symbol of the call stack function
* @param depth
* The depth in the call stack of a function
+ * @param processId
+ * The process ID of the traced application
* @param parent
* The caller, can be null for root elements
*/
- protected CalledFunction(long start, long end, long symbol, int depth, @Nullable ICalledFunction parent) {
- super(start, end, depth, parent);
+ protected CalledFunction(long start, long end, long symbol, int depth, int processId, @Nullable ICalledFunction parent) {
+ super(start, end, depth, processId, parent);
fSymbol = symbol;
}
* the depth
* @param stateValue
* the symbol
+ * @param processId
+ * The process ID of the traced application
* @param parent
* the parent node
- * @return an ICalledFunction with the specified propertiess
+ * @return an ICalledFunction with the specified properties
*/
- public static AbstractCalledFunction create(long start, long end, int depth, ITmfStateValue stateValue, @Nullable ICalledFunction parent) {
+ public static AbstractCalledFunction create(long start, long end, int depth, ITmfStateValue stateValue, int processId, @Nullable ICalledFunction parent) {
switch (stateValue.getType()) {
case CUSTOM:
throw new IllegalArgumentException(ERROR_MSG + stateValue.getType() + SEPARATOR + stateValue.toString());
case DOUBLE:
throw new IllegalArgumentException(ERROR_MSG + stateValue.getType() + SEPARATOR + stateValue.toString());
case INTEGER:
- return create(start, end, depth, stateValue.unboxInt(), parent);
+ return create(start, end, depth, stateValue.unboxInt(), processId, parent);
case LONG:
- return create(start, end, depth, stateValue.unboxLong(), parent);
+ return create(start, end, depth, stateValue.unboxLong(), processId, parent);
case NULL:
throw new IllegalArgumentException(ERROR_MSG + stateValue.getType() + SEPARATOR + stateValue.toString());
case STRING:
- return create(start, end, depth, stateValue.unboxStr(), parent);
+ return create(start, end, depth, stateValue.unboxStr(), processId, parent);
default:
throw new IllegalArgumentException(ERROR_MSG + stateValue.getType() + SEPARATOR + stateValue.toString());
}
* the depth
* @param value
* the symbol
+ * @param processId
+ * The process ID of the traced application
* @param parent
* the parent node
* @return an ICalledFunction with the specified propertiess
*/
- private static CalledFunction create(long start, long end, int depth, long value, @Nullable ICalledFunction parent) {
+ private static CalledFunction create(long start, long end, int depth, long value, int processId, @Nullable ICalledFunction parent) {
if (start > end) {
throw new IllegalArgumentException(Messages.TimeError + '[' + start + ',' + end + ']');
}
- return new CalledFunction(start, end, value, depth, parent);
+ return new CalledFunction(start, end, value, depth, processId, parent);
}
/**
* the depth
* @param value
* the symbol
+ * @param processId
+ * The process ID of the traced application
* @param parent
* the parent node
* @return an ICalledFunction with the specified properties
*/
- public static CalledStringFunction create(long start, long end, int depth, String value, @Nullable ICalledFunction parent) {
+ public static CalledStringFunction create(long start, long end, int depth, String value, int processId, @Nullable ICalledFunction parent) {
if (start > end) {
throw new IllegalArgumentException(Messages.TimeError + '[' + start + ',' + end + ']');
}
- return new CalledStringFunction(start, end, value, depth, parent);
+ return new CalledStringFunction(start, end, value, depth, processId, parent);
}
}
* The symbol of the call stack function
* @param depth
* The depth in the call stack of a function
+ * @param processId
+ * The process ID of the traced application
* @param parent
* The caller, can be null for root elements
*/
- protected CalledStringFunction(long start, long end, String symbol, int depth, @Nullable ICalledFunction parent) {
- super(start, end, depth, parent);
+ protected CalledStringFunction(long start, long end, String symbol, int depth, int processId, @Nullable ICalledFunction parent) {
+ super(start, end, depth, processId, parent);
fSymbol = symbol;
}
*/
int getDepth();
+ /**
+ * The process ID of the traced application
+ *
+ * @return The process ID
+ */
+ int getProcessId();
+
}
\ No newline at end of file
if (symbolText == null) {
return "0x" + Long.toHexString(longAddress); //$NON-NLS-1$
}
+ // take the start time in the query for the symbol name
+ long time = segment.getStart();
+ int pid = calledFunction.getProcessId();
+ if (pid > 0) {
+ String text = provider.getSymbolText(pid, time, longAddress);
+ if (text != null) {
+ return text;
+ }
+ }
return symbolText;
}
return String.valueOf(symbol);
if (funcSymbol == null) {
return "0x" + Long.toHexString(longAddress); //$NON-NLS-1$
}
+ // take time of max segment for time a query the symbol name
+ long time = event.getStatistics().getMaxSegment().getStart();
+ int pid = event.getProcessId();
+ if (pid > 0) {
+ String text = symbolProvider.getSymbolText(pid, time, longAddress);
+ if (text != null) {
+ return text;
+ }
+ }
} else {
return event.getSymbol().toString();
}
private final Object fSymbol;
private final long fSelfTime;
+ private final int fProcessId;
private final AggregatedCalledFunctionStatistics fStatistics;
/**
super(source, beginTime, aggregatedFunction.getDuration(), String.valueOf(aggregatedFunction.getSymbol()).hashCode() % MODULO + MODULO);
fSymbol = aggregatedFunction.getSymbol();
fStatistics = aggregatedFunction.getFunctionStatistics();
+ fProcessId = aggregatedFunction.getProcessId();
fSelfTime = aggregatedFunction.getSelfTime();
}
public long getSelfTime() {
return fSelfTime;
}
+
+ /**
+ * The process ID of the traced application
+ *
+ * @return process id
+ */
+ public int getProcessId() {
+ return fProcessId;
+ }
}