MainWindowpublic class MainWindow extends org.eclipse.jface.window.ApplicationWindow
Fields Summary |
---|
private static final String | PING_NAME | private static final String | PING_VERSION | private TraceReader | mReader | private String | mTraceName | public static HashMap | sStringCache |
Constructors Summary |
---|
public MainWindow(String traceName, TraceReader reader)
super(null);
mReader = reader;
mTraceName = traceName;
|
Methods Summary |
---|
protected void | configureShell(org.eclipse.swt.widgets.Shell shell)
super.configureShell(shell);
shell.setText("Traceview: " + mTraceName);
shell.setBounds(100, 10, 1282, 900);
| protected org.eclipse.swt.widgets.Control | createContents(org.eclipse.swt.widgets.Composite parent)
ColorController.assignMethodColors(parent.getDisplay(), mReader.getMethods());
SelectionController selectionController = new SelectionController();
GridLayout gridLayout = new GridLayout(1, false);
gridLayout.marginWidth = 0;
gridLayout.marginHeight = 0;
gridLayout.horizontalSpacing = 0;
gridLayout.verticalSpacing = 0;
parent.setLayout(gridLayout);
Display display = parent.getDisplay();
Color darkGray = display.getSystemColor(SWT.COLOR_DARK_GRAY);
// Create a sash form to separate the timeline view (on top)
// and the profile view (on bottom)
SashForm sashForm1 = new SashForm(parent, SWT.VERTICAL);
sashForm1.setBackground(darkGray);
sashForm1.SASH_WIDTH = 3;
GridData data = new GridData(GridData.FILL_BOTH);
sashForm1.setLayoutData(data);
// Create the timeline view
new TimeLineView(sashForm1, mReader, selectionController);
// Create the profile view
new ProfileView(sashForm1, mReader, selectionController);
return sashForm1;
| public static void | main(java.lang.String[] args)
TraceReader reader = null;
boolean regression = false;
// ping the usage server
SdkStatsService.ping(PING_NAME, PING_VERSION);
// Process command line arguments
int argc = 0;
int len = args.length;
while (argc < len) {
String arg = args[argc];
if (arg.charAt(0) != '-") {
break;
}
if (arg.equals("-r")) {
regression = true;
} else {
break;
}
argc++;
}
if (argc != len - 1) {
System.out.printf("Usage: java %s [-r] trace%n", MainWindow.class.getName());
System.out.printf(" -r regression only%n");
return;
}
String traceName = args[len - 1];
File file = new File(traceName);
if (file.exists() && file.isDirectory()) {
System.out.printf("Qemu trace files not supported yet.\n");
System.exit(1);
// reader = new QtraceReader(traceName);
} else {
// If the filename as given doesn't exist...
if (!file.exists()) {
// Try appending .trace.
if (new File(traceName + ".trace").exists()) {
traceName = traceName + ".trace";
// Next, see if it is the old two-file trace.
} else if (new File(traceName + ".data").exists()
&& new File(traceName + ".key").exists()) {
try {
traceName = makeTempTraceFile(traceName);
} catch (IOException e) {
System.err.printf("cannot convert old trace file '%s'\n", traceName);
System.exit(1);
}
// Otherwise, give up.
} else {
System.err.printf("trace file '%s' not found\n", traceName);
System.exit(1);
}
}
reader = new DmTraceReader(traceName, regression);
}
reader.getTraceUnits().setTimeScale(TraceUnits.TimeScale.MilliSeconds);
new MainWindow(traceName, reader).run();
| private static java.lang.String | makeTempTraceFile(java.lang.String base)Convert the old two-file format into the current concatenated one.
// Make a temporary file that will go away on exit and prepare to
// write into it.
File temp = File.createTempFile(base, ".trace");
temp.deleteOnExit();
FileChannel dstChannel = new FileOutputStream(temp).getChannel();
// First copy the contents of the key file into our temp file.
FileChannel srcChannel = new FileInputStream(base + ".key").getChannel();
long size = dstChannel.transferFrom(srcChannel, 0, srcChannel.size());
srcChannel.close();
// Then concatenate the data file.
srcChannel = new FileInputStream(base + ".data").getChannel();
dstChannel.transferFrom(srcChannel, size, srcChannel.size());
// Clean up.
srcChannel.close();
dstChannel.close();
// Return the path of the temp file.
return temp.getPath();
| public void | run()
setBlockOnOpen(true);
open();
Display.getCurrent().dispose();
|
|