Skip to content

Commit

Permalink
Fixes for gprof multiple file reading.
Browse files Browse the repository at this point in the history
git-svn-id: file:///mnt/fast/tau2git/svnroot/trunk/tau2@7181 a8e31b63-e6ca-409b-a01b-2eec1b506579
  • Loading branch information
amorris committed May 6, 2009
1 parent 132f62f commit 521c2d7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
Binary file modified tools/src/perfdmf/bin/perfdmf.jar
Binary file not shown.
38 changes: 27 additions & 11 deletions tools/src/perfdmf/src/GprofDataSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class GprofDataSource extends DataSource {
private int linenumber = 0;
private boolean fixLengths = true;

private String currentFile;

public GprofDataSource(File[] files, boolean fixNames) {
super();
this.fixNames = fixNames;
Expand Down Expand Up @@ -57,6 +59,7 @@ public void load() throws FileNotFoundException, IOException {

for (int fIndex = 0; fIndex < files.length; fIndex++) {
File file = files[fIndex];
currentFile = files[fIndex].toString();

//System.out.println("Processing " + file + ", please wait ......");
FileInputStream fileIn = new FileInputStream(file);
Expand All @@ -77,6 +80,7 @@ public void load() throws FileNotFoundException, IOException {
LineData self = null;
Vector children = new Vector();

fixLengths = true;
linenumber = 1;
while ((inputString = br.readLine()) != null) {
if (inputString.startsWith("gmon") && linenumber == 1) {
Expand Down Expand Up @@ -204,13 +208,14 @@ public void load() throws FileNotFoundException, IOException {

private void getFieldLengths(String string) {

System.out.println("FIELD LENGTHS@!!!!");

/*
* parse a line that looks like: index %time self childen
* called+self name index ...or... index % time self children called
* name index [xxxx] 100.0 xxxx.xx xxxxxxxx.xx xxxxxxx+xxxxxxx ssssss...
*/
StringTokenizer st = new StringTokenizer(string, " \t\n\r");
System.out.println(string);
String index = st.nextToken();
String percent = st.nextToken();
if (percent.compareTo("%") == 0)
Expand Down Expand Up @@ -333,8 +338,10 @@ private LineData getSelfLineData(String string) {
}

private LineData getParentChildLineData(String string) {
//System.out.println("string = " + string);

LineData lineData = new LineData();
StringTokenizer st1 = new StringTokenizer(string, " \t\n\r");
StringTokenizer st = new StringTokenizer(string, " \t\n\r");

// unlike the other line parsers, this function assumed a fixed
// location for values. That may be erroneous, but I think that
Expand Down Expand Up @@ -373,34 +380,43 @@ private LineData getParentChildLineData(String string) {
*/

String tmpStr = string.substring(selfStart, descendantsStart).trim();
if (tmpStr.length() > 0)
//String tmpStr = st.nextToken();
if (tmpStr.length() > 0) {
lineData.d0 = 1000000.0 * Double.parseDouble(tmpStr);
else
} else {
lineData.d0 = 0.0;
}

System.err.println("Error parsing file: " + currentFile + ", line: " + linenumber);
System.err.println("selfStart: " + selfStart);
System.err.println("descendantsStart: " + descendantsStart);
System.err.println("calledStart: " + calledStart);

try {
tmpStr = string.substring(descendantsStart, calledStart).trim();
if (tmpStr.length() > 0)
//tmpStr = st.nextToken();
if (tmpStr.length() > 0) {
lineData.d1 = 1000000.0 * Double.parseDouble(tmpStr);
else
} else {
lineData.d1 = 0.0;
}
} catch (Exception e) {
System.err.println("Error parsing file, line: " + linenumber);
System.err.println("Error parsing file: " + currentFile + ", line: " + linenumber);
System.err.println("selfStart: " + selfStart);
System.err.println("descendantsStart: " + descendantsStart);
System.err.println("calledStart: " + calledStart);
System.err.println(e.getMessage());
e.printStackTrace();
System.exit(0);
throw new DataSourceException(e, currentFile);
}

// check if the counts 'spill' into the name field.
String spillTest = string.substring(calledStart, string.length()).trim();
int space = spillTest.indexOf(" ");
if (space > (nameStart - calledStart))
if (space > (nameStart - calledStart)) {
tmpStr = spillTest.substring(0, space).trim();
else
} else {
tmpStr = string.substring(calledStart, nameStart).trim();
}
// check for a ratio
if (tmpStr.indexOf("/") >= 0) {
StringTokenizer st2 = new StringTokenizer(tmpStr, "/");
Expand Down

0 comments on commit 521c2d7

Please sign in to comment.