{
int iRdyitPortNumber = 17883;
if (m_fileRampBinaryDir == null)
{
throw new RampException("Path to RAMP binaries is not set");
}
ArrayList<String> arrProgramCmdArgs = new ArrayList<String>();
//cmdargs.add("-Dpid=$$");
arrProgramCmdArgs.add("-noverify");
arrProgramCmdArgs.add("-agentpath:" + getRampLibPath()+"/librvmti.so");
/*
* BUGBUG: here we store the log file in the RAM disk mounted at /mnt/tmpfs
*/
File fnm = new File(m_fileProjectDir, RampFileNames.strMainRdyitLogFile);
//File fnm = new File("/mnt/tmpfs", RampFileNames.strMainRdyitLogFile);
File fileDiskPatch = new File(m_fileCommonDir.getPath(), RampFileNames.strDiskPatch);
File fileNetPatch = new File(m_fileCommonDir.getPath(), RampFileNames.strSocketPatch);
File fileProgramPatch = new File(m_fileProjectDir, RampFileNames.strMainPatch);
String strProgramPatchPath = fileProgramPatch.getPath().trim();
//arrProgramCmdArgs.add("-javaagent:" + getRampNBPath() + "/rdyit/dist/rdyit.jar=OUTPUT=" + fnm.getPath() + ":SPEC=" + strProgramPatchPath + ":IO=" + fileDiskPatch.getPath() + ":NET=" + fileNetPatch.getPath());
File fileLibSet = new File(m_fileProjectDir, RampFileNames.strLibraryProbesSet);
if (fileLibSet.exists())
{
arrProgramCmdArgs.add("-javaagent:" + getRampNBPath() + "/rdyit/dist/rdyit.jar=OUTPUT=" + fnm.getPath() + ":SPEC=" + strProgramPatchPath + ":IO=" + fileDiskPatch.getPath() + ":NET=" + fileNetPatch.getPath()+":LIBSET="+fileLibSet.getPath());
}else
{
arrProgramCmdArgs.add("-javaagent:" + getRampNBPath() + "/rdyit/dist/rdyit.jar=OUTPUT=" + fnm.getPath() + ":SPEC=" + strProgramPatchPath + ":IO=" + fileDiskPatch.getPath() + ":NET=" + fileNetPatch.getPath());
}
arrProgramCmdArgs.add("-Xbootclasspath/a:" + getASMLibraryPath() + ":" + getRampNBPath() + "/rdyit/dist/rdyit.jar");
StringBuilder strRdyitCP = new StringBuilder();
strRdyitCP.append("java -cp ");
strRdyitCP.append(getRampBinClassPath());
strRdyitCP.append(File.pathSeparator);
strRdyitCP.append(getASMLibraryPath());
/*
strRdyitCP.append(m_fileRampBinaryDir.getAbsolutePath());
strRdyitCP.append("/lib/rampasm.jar");
strRdyitCP.append(File.pathSeparator);
strRdyitCP.append(m_fileRampBinaryDir.getAbsolutePath());
strRdyitCP.append("/lib/sprasm.jar");
*/
//strRdyitCP.append(File.pathSeparator);
strRdyitCP.append(" edu.brown.cs.ramp.rdyit.RdyitMain -p ").append(iRdyitPortNumber);
strRdyitCP.append(" -s ").append(m_fileProjectDir.getAbsolutePath()).append("/mainpatch.xml");
strRdyitCP.append(" -s ").append(this.m_fileCommonDir.getAbsolutePath()).append("/diskpatch.xml");
strRdyitCP.append(" -s ").append(this.m_fileCommonDir.getAbsolutePath()).append("/socketpath.xml");
strRdyitCP.append(" -w ").append(m_fileProjectDir.getAbsolutePath()).append("/wrappers.xml");
IvyExec exServer = null;
//String cmd = "/research/people/spr/ramp/bin/rdynserver " + f.getPath();
//String cmdServer = getRampHome() + "/bin/rdyitserver " + m_fileProjectDir.getPath();
try
{
//Create and run the rdyitserver so we could instrument
//native/synchronized methods
exServer = new IvyExec(strRdyitCP.toString());
try
{
Thread.sleep(10000);
} catch (InterruptedException e)
{
}
if (exServer == null)
{
throw new RampException("Failed to run the RDYIT server");
}
/*
System.out.println("Command line for the application to run:");
for (String str:arrProgramCmdArgs)
{
System.out.print(str);
System.out.print(" ");
}
System.out.println();
*/
//Run the instrumented program
Process p = m_rampProject.run(arrProgramCmdArgs);
if (p == null)
{
throw new RampException("Failed to run the instrumented program");
}
//Write out its stdout/stderr
InputStream stderr = p.getErrorStream();
InputStream stdout = p.getInputStream();