Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OTF2: Create generic class representing a SystemTreeNode
Added a generic class representing system tree nodes. This class can be inherited by the different OTF2 analyzes that use the system architecture. With this class, some recurrent functions related to system tree nodes do not need to be duplicated in these analyzes. Also changed the callstack state provider so it makes use of this new class. Signed-off-by: yoann-heitz <yoann.heitz@polymtl.ca> Change-Id: Ic62bc6ed55dd180adf7f92922d93996446e2c5cc Reviewed-on: https://git.eclipse.org/r/c/tracecompass.incubator/org.eclipse.tracecompass.incubator/+/190902 Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org> Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com> Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com> Reviewed-by: Marco Miller <marco.miller@ericsson.com>
- Loading branch information
1 parent
a4f2697
commit dc98dab
Showing
4 changed files
with
173 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
....core/src/org/eclipse/tracecompass/incubator/internal/otf2/core/trace/SystemTreeNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 École Polytechnique de Montréal | ||
* | ||
* All rights reserved. This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 which accompanies | ||
* this distribution, and is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*******************************************************************************/ | ||
|
||
package org.eclipse.tracecompass.incubator.internal.otf2.core.trace; | ||
|
||
import static org.eclipse.tracecompass.incubator.internal.otf2.core.analysis.IOtf2Constants.OTF2_UNKNOWN_STRING; | ||
import static org.eclipse.tracecompass.incubator.internal.otf2.core.analysis.IOtf2Constants.OTF2_UNKNOWN_SYSTEM_TREE_NODE; | ||
|
||
import java.util.Map; | ||
|
||
import org.eclipse.tracecompass.incubator.internal.otf2.core.analysis.IOtf2Constants; | ||
import org.eclipse.tracecompass.incubator.internal.otf2.core.analysis.IOtf2Fields; | ||
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; | ||
import org.eclipse.tracecompass.tmf.core.event.ITmfEventField; | ||
|
||
/** | ||
* A generic class representing an OTF2 system tree node (it may be a cluster or | ||
* a physical node for example). | ||
* | ||
* @author Yoann Heitz | ||
*/ | ||
public class SystemTreeNode { | ||
|
||
private static final String WHITESPACE = " "; //$NON-NLS-1$ | ||
|
||
private final long fId; | ||
private final long fParentId; | ||
private final long fNameId; | ||
private final long fClassNameId; | ||
|
||
/** | ||
* Constructs an instance of a SystemTreeNode based on an ITmfEvent | ||
* | ||
* @param event | ||
* the event that will be parsed | ||
*/ | ||
public SystemTreeNode(ITmfEvent event) { | ||
ITmfEventField content = event.getContent(); | ||
Long id = content.getFieldValue(Long.class, IOtf2Fields.OTF2_SELF); | ||
fId = id == null ? OTF2_UNKNOWN_SYSTEM_TREE_NODE : id; | ||
|
||
Long parentId = content.getFieldValue(Long.class, IOtf2Fields.OTF2_SYSTEM_TREE_PARENT); | ||
fParentId = parentId == null ? OTF2_UNKNOWN_SYSTEM_TREE_NODE : parentId; | ||
|
||
Long nameId = content.getFieldValue(Long.class, IOtf2Fields.OTF2_NAME); | ||
fNameId = nameId == null ? OTF2_UNKNOWN_STRING : nameId; | ||
|
||
Long classNameId = content.getFieldValue(Long.class, IOtf2Fields.OTF2_CLASS_NAME); | ||
fClassNameId = classNameId == null ? OTF2_UNKNOWN_STRING : classNameId; | ||
} | ||
|
||
/** | ||
* A method to get the complete name for this system tree node | ||
* | ||
* @param stringIdMap | ||
* a map containing the associations between the string IDs and | ||
* their actual values | ||
* @return the full name of this system tree node | ||
*/ | ||
public String getFullName(Map<Integer, String> stringIdMap) { | ||
String name = stringIdMap.get((int) fNameId); | ||
String className = stringIdMap.get((int) fClassNameId); | ||
return className + WHITESPACE + name; | ||
} | ||
|
||
/** | ||
* Gets the ID of the system tree node | ||
* | ||
* @return the ID of this system tree node | ||
*/ | ||
public long getId() { | ||
return fId; | ||
} | ||
|
||
/** | ||
* Gets the ID of the parent of the system tree node | ||
* | ||
* @return the ID of the parent of this system tree node | ||
*/ | ||
public long getParentId() { | ||
return fParentId; | ||
} | ||
|
||
/** | ||
* Tests if this node is at the root of the system tree | ||
* | ||
* @return true if this node is root, false else. | ||
*/ | ||
public boolean isRootNode() { | ||
return getParentId() == IOtf2Constants.OTF2_UNDEFINED_SYSTEM_TREE_NODE; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...f2.core/src/org/eclipse/tracecompass/incubator/internal/otf2/core/trace/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 École Polytechnique de Montréal | ||
* | ||
* All rights reserved. This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 which accompanies | ||
* this distribution, and is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*******************************************************************************/ | ||
|
||
@org.eclipse.jdt.annotation.NonNullByDefault | ||
package org.eclipse.tracecompass.incubator.internal.otf2.core.trace; |