aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Grunberg2011-08-30 14:53:35 -0400
committerRoland Grunberg2011-08-30 17:29:51 -0400
commitcd019986ddf7104bfbc858c19e4e5daba34c0917 (patch)
treed4211d17750505ef104c7491bc818c4a869efced
parent04a6df7c8d543fe03743efcac5a36bac2c46c21d (diff)
downloadorg.eclipse.linuxtools-cd019986ddf7104bfbc858c19e4e5daba34c0917.zip
org.eclipse.linuxtools-cd019986ddf7104bfbc858c19e4e5daba34c0917.tar.gz
org.eclipse.linuxtools-cd019986ddf7104bfbc858c19e4e5daba34c0917.tar.xz
Modify classes to support viewing of sample data in timer mode.
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.core/ChangeLog10
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/linux/OpxmlRunner.java31
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/info/InfoAdapter.java18
-rw-r--r--oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/modeldata/ModelDataAdapter.java16
4 files changed, 61 insertions, 14 deletions
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/ChangeLog b/oprofile/org.eclipse.linuxtools.oprofile.core/ChangeLog
index f01f7c1..1f767ea 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.core/ChangeLog
+++ b/oprofile/org.eclipse.linuxtools.oprofile.core/ChangeLog
@@ -5,6 +5,16 @@
(InfoAdapter): Check for timer-mode before running ophelp.
(createDOM): Minor change to support creating a DOM without ophelp XML.
(process): Don't attempt to find events if we are in timer-mode.
+ (checkTimerSupport): New Method - Actual check for timer support
+ (hasTimerSupport): Cached check for timer support.
+ * src/org/eclipse/linuxtools/oprofile/core/linux/OpxmlRunner.java
+ (handleModelData): Determine what flags to give ophelp depending on whether
+ we are in timer-mode.
+ (getEventNames): Determine what elements to check in ophelp XML depending on
+ whether we are in timer-mode.
+ (run): Check for timer-mode support here.
+ * src/org/eclipse/linuxtools/oprofile/core/opxml/modeldata/ModelDataAdapter.java
+ (createXML): We do not need to set any event count in timer-mode.
2011-08-29 Roland Grunberg <rgrunber@redhat.com>
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/linux/OpxmlRunner.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/linux/OpxmlRunner.java
index 9b775d1..a6919ab 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/linux/OpxmlRunner.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/linux/OpxmlRunner.java
@@ -21,6 +21,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -87,6 +88,9 @@ public class OpxmlRunner {
reader.setContentHandler(_handler);
reader.setErrorHandler(_handler);
+ // Check for timer support
+ InfoAdapter.checkTimerSupport();
+
// Run opxml
try {
File file = constructFile(args);
@@ -178,8 +182,15 @@ public class OpxmlRunner {
private boolean handleModelData (String [] args){
Process p;
try {
- String cmd[] = {"opreport", "-X", "--details", "event:" + args[1]};
- p = Runtime.getRuntime().exec(cmd); //$NON-NLS-1$
+ ArrayList<String> cmd = new ArrayList<String>();
+ cmd.add("opreport"); //$NON-NLS-1$
+ cmd.add("-X"); //$NON-NLS-1$
+ cmd.add("--details"); //$NON-NLS-1$
+ if (!InfoAdapter.hasTimerSupport()){
+ cmd.add("event:" + args[1]); //$NON-NLS-1$
+ }
+ String [] a = {};
+ p = Runtime.getRuntime().exec(cmd.toArray(a));
StringBuilder output = new StringBuilder();
StringBuilder errorOutput = new StringBuilder();
@@ -316,14 +327,26 @@ public class OpxmlRunner {
Document doc = builder.parse(is);
Element root = (Element) doc.getElementsByTagName(ModelDataAdapter.PROFILE).item(0);
+ String eventOrTimerSetup;
+ String eventOrTimerName;
+
+ // Determine if we are in timer-mode or not as the XML will vary
+ if (!InfoAdapter.hasTimerSupport()){
+ eventOrTimerSetup = ModelDataAdapter.EVENT_SETUP;
+ eventOrTimerName = ModelDataAdapter.EVENT_NAME;
+ }else{
+ eventOrTimerSetup = ModelDataAdapter.TIMER_SETUP;
+ eventOrTimerName = ModelDataAdapter.RTC_INTERRUPTS;
+ }
+
Element setupTag = (Element) root.getElementsByTagName(ModelDataAdapter.SETUP).item(0);
- NodeList eventSetupList = setupTag.getElementsByTagName(ModelDataAdapter.EVENT_SETUP);
+ NodeList eventSetupList = setupTag.getElementsByTagName(eventOrTimerSetup);
// get the event names for the current session
ret = new String[eventSetupList.getLength()];
for (int i = 0; i < eventSetupList.getLength(); i++) {
Element elm = (Element) eventSetupList.item(i);
- ret[i] = elm.getAttribute(ModelDataAdapter.EVENT_NAME);
+ ret[i] = elm.getAttribute(eventOrTimerName);
}
}
} catch (IOException e) {
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/info/InfoAdapter.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/info/InfoAdapter.java
index 9cfff42..9c4bf27 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/info/InfoAdapter.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/info/InfoAdapter.java
@@ -74,6 +74,8 @@ public class InfoAdapter extends AbstractDataAdapter{
private Element oldRoot; // the root of the document with data from ophelp
private Element newRoot; // the root of the document we intent to build
+ private static boolean hasTimerSupport;
+
public InfoAdapter (){
try {
if (hasTimerSupport()){
@@ -183,7 +185,14 @@ public class InfoAdapter extends AbstractDataAdapter{
* Determine whether the cpu supports timer mode
* @return true if it is true, and false otherwise
*/
- private boolean hasTimerSupport() {
+ public static boolean hasTimerSupport() {
+ return hasTimerSupport;
+ }
+
+ /**
+ * Set whether the cpu supports timer mode
+ */
+ public static void checkTimerSupport() {
File file = new File(CPUTYPE);
try {
@@ -191,19 +200,18 @@ public class InfoAdapter extends AbstractDataAdapter{
String cpuType = bi.readLine();
bi.close();
if (cpuType.equals(TIMER)) {
- return true;
+ hasTimerSupport = true;
} else {
- return false;
+ hasTimerSupport = false;
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
-
- return false;
}
+
/**
* Get the system's cpu frequency
* @return the system's cpu frequency
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/modeldata/ModelDataAdapter.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/modeldata/ModelDataAdapter.java
index 2daffb1..8ac5d4b 100644
--- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/modeldata/ModelDataAdapter.java
+++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/oprofile/core/opxml/modeldata/ModelDataAdapter.java
@@ -14,6 +14,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.eclipse.linuxtools.oprofile.core.opxml.AbstractDataAdapter;
+import org.eclipse.linuxtools.oprofile.core.opxml.info.InfoAdapter;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -43,8 +44,10 @@ public class ModelDataAdapter extends AbstractDataAdapter {
public final static String SETUP = "setup"; //$NON-NLS-1$
public final static String EVENT_SETUP = "eventsetup"; //$NON-NLS-1$
+ public final static String TIMER_SETUP = "timersetup"; //$NON-NLS-1$
public final static String SETUP_COUNT = "setupcount"; //$NON-NLS-1$
public final static String EVENT_NAME = "eventname"; //$NON-NLS-1$
+ public final static String RTC_INTERRUPTS = "rtcinterrupts"; //$NON-NLS-1$
public final static String PROFILE = "profile"; //$NON-NLS-1$
public final static String MODEL_DATA = "model-data"; //$NON-NLS-1$
@@ -112,11 +115,14 @@ public class ModelDataAdapter extends AbstractDataAdapter {
String imageCount = countTag.getTextContent().trim();
newImage.setAttribute(COUNT, imageCount);
- // get the count that was used to profile
- Element setupTag = (Element) oldRoot.getElementsByTagName(SETUP).item(0);
- Element eventSetupTag = (Element) setupTag.getElementsByTagName(EVENT_SETUP).item(0);
- String setupcount = eventSetupTag.getAttribute(SETUP_COUNT);
- newImage.setAttribute(SETUP_COUNT, setupcount);
+ // There is no setup count in timer mode
+ if (!InfoAdapter.hasTimerSupport()){
+ // get the count that was used to profile
+ Element setupTag = (Element) oldRoot.getElementsByTagName(SETUP).item(0);
+ Element eventSetupTag = (Element) setupTag.getElementsByTagName(EVENT_SETUP).item(0);
+ String setupcount = eventSetupTag.getAttribute(SETUP_COUNT);
+ newImage.setAttribute(SETUP_COUNT, setupcount);
+ }
newRoot.appendChild(newImage);