Commit f9dccac4 authored by Andrey Filippov's avatar Andrey Filippov

Restored broken playback of log files

parent bf9e34c8
......@@ -240,7 +240,7 @@ public class LaunchCore {
logBuildStamp);
if (VDTLaunchUtil.getRunner().getRunningBuilds().isAlreadyOpen(tool.getName())){
// System.out.println("LaunchCore:launch() tool="+tool.getName()+" was already open! Ignoring... ");
// return;
return;
}
// System.out.println("DebugUITools.launch() tool="+tool.getName()+" project="+project.getName()+" resource="+resource.toString()+" logBuildStamp="+logBuildStamp);
DebugUITools.launch(launchConfig, ILaunchManager.RUN_MODE);
......
......@@ -99,9 +99,14 @@ public class RunningBuilds {
}
public void addMonListener(IConsole parserConsole, IStreamMonitor monitor, IStreamListener listener){
synchronized (parserListeners){
parserListeners.put(parserConsole, new MonListener(monitor, listener));
if (parserListeners==null){
MessageUI.error("BUG in addMonListener(): parserListeners=null - enable breakpoints");
System.out.println("BUG in addMonListener(): parserListeners=null");
return;
}
// synchronized (parserListeners){
parserListeners.put(parserConsole, new MonListener(monitor, listener)); // java.lang.NullPointerException
// }
}
private void removeMonListener(IConsole parserConsole){
MonListener monListener;
......@@ -209,7 +214,7 @@ public class RunningBuilds {
while (iter.hasNext()) {
String consoleName=iter.next();
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.print(i+": "+consoleName);
System.out.println((i++)+": "+consoleName);
}
}
......@@ -295,13 +300,30 @@ public class RunningBuilds {
if (toolName.equals(runConfig.getToolName())){
Tool tool=ToolsCore.getTool(runConfig.getToolName());
// tool.setRunning(false);
System.out.println("RunningBuilds#isAlreadyOpen("+toolName+"), state="+tool.getState()+" threadID="+Thread.currentThread().getId());
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.println("RunningBuilds#isAlreadyOpen("+toolName+"), state="+tool.getState()+" consoleName="+
consoleName+" threadID="+Thread.currentThread().getId()); // Reused old VDTRunner()
for (String key:unfinishedBuilds.keySet()){
System.out.println("Unfinished build: "+key);
}
}
tool.setMode(TOOL_MODE.STOP);
tool.toolFinished();
if (tool.getState()==TOOL_STATE.KEPT_OPEN) {
MessageUI.error("Termninal that starts by this tool ("+toolName+") is already open in console \""+consoleName+"\"");
MessageUI.error("Termninal that starts by this tool ("+toolName+") is already open in console \""+consoleName+"\". You may close it manually.");
tool.toolFinished();
return true;
}
MessageUI.error("Something is wrong in RunningBuilds#isAlreadyOpen as the console for the specified tool "+tool.getName()+" is already open");
tool.setState(TOOL_STATE.FAILURE);
tool.toolFinished();
return true;
}
}
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) {
System.out.println("RunningBuilds#isAlreadyOpen("+toolName+"), no match threadID="+Thread.currentThread().getId());
for (String key:unfinishedBuilds.keySet()){
System.out.println("Unfinished build: "+key+" tool "+unfinishedBuilds.get(key).getToolName());
}
}
return false;
......
......@@ -125,6 +125,7 @@ public class ToolLogFile {
* @param buildStamp if null - write log mode, "" - read link (latest) file, else - read that build stamp file
*/
public ToolLogFile(
boolean writeMode,
String logDir,
String logTool,
String logName,
......@@ -141,7 +142,7 @@ public class ToolLogFile {
targetOutIFile=null;
targetErrIFile=null;
debugPrint=VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING);
boolean writeMode=(buildStamp==null);
// boolean writeMode=(buildStamp==null);
if (!hasOut && !hasErr){
return; // nothing to do
}
......@@ -181,7 +182,7 @@ public class ToolLogFile {
targetErrIFile = singleFile? targetOutIFile : iLogFolder.getFile(baseNameErr+buildStampWithSep+ext);
if (writeMode) {
outBytes=0; // jsut for debugging
outBytes=0; // just for debugging
errBytes=0;
byte [] emptyBA={};
......
......@@ -95,6 +95,7 @@ public class VDTConsolePlayback{
// Open logfiles for reading (if available)
boolean twoFiles=(stdoutParser!=null) && (stderrParser!=null);
ToolLogFile toolLogFile=new ToolLogFile (
false,
runConfig.getLogDir(),
runConfig.getToolName(),
buildParamsItem.getLogName(),
......
......@@ -202,6 +202,7 @@ public class VDTConsoleRunner{
String timeStamp=ToolsCore.getTool(runConfig.getToolName()).getTimeStamp();
toolLogFile=(((fSendOutputToStreamProxy!=null) || (fSendErrorsToStreamProxy!=null)))?
(new ToolLogFile (
true,
runConfig.getLogDir(),
runConfig.getToolName(),
buildParamsItem.getLogName(),
......@@ -259,11 +260,12 @@ public class VDTConsoleRunner{
}
}
};
if (processOut!=null) VDTLaunchUtil.getRunner().getRunningBuilds().addMonListener( // to remove listener when parser is terminated
if (processOut!=null) VDTLaunchUtil.getRunner().getRunningBuilds().addMonListener( // to remove listener when parser is terminated null pointer
DebugUITools.getConsole(processOut), //IConsole parserConsole,
consoleOutStreamMonitor,
outputListener);
consoleOutStreamMonitor.addListener(outputListener );
consoleOutStreamMonitor.addListener(outputListener ); // got frozen here
// }
// Problems occurred when invoking code from plug-in: "org.eclipse.ui.console".
// Exception occurred during console property change notification.
......@@ -375,6 +377,7 @@ public class VDTConsoleRunner{
try {
Thread.sleep(VDTLaunchUtil.CLOSE_INPUT_STREAM_DELAY);
} catch (InterruptedException e) {
System.out.println("Failed Thread.sleep for "+ VDTLaunchUtil.CLOSE_INPUT_STREAM_DELAY);
}
stdoutStreamProxy.closeInputStream();
} catch (IOException e) {
......
......@@ -118,7 +118,7 @@ public class VDTLaunchConfigurationDelegate implements ILaunchConfigurationDeleg
// String consoleName=VDTRunner.renderProcessLabel(runConfig.getToolName());
final String consoleName=runConfig.getOriginalConsoleName();
runner.getRunningBuilds().saveUnfinished(consoleName, runConfig );
runner.getRunningBuilds().saveUnfinished(consoleName, runConfig ); // has to remove it after playback!!! (others are removed by closing consoles)
String playBackStamp=VDTLaunchUtil.getLogBuildStamp(configuration); // got null
runConfig.setPlayBackStamp(playBackStamp); // null
......
......@@ -297,7 +297,7 @@ public class VDTRunner {
// tool.setTimeStamp(); //will set at start
if ((tool.getState()==TOOL_STATE.SUCCESS) && runConfig.isKeptOpen()) {
tool.setState(TOOL_STATE.KEPT_OPEN);
} else { // failure on not
} else { // failure or not
runningBuilds.removeConfiguration(consoleName);
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING))
System.out.println("VDTRunner#doResumeLaunch("+consoleName+") - removed configuartion, tool="+tool.getName()+" "+tool.toString()+" state="+tool.getState()+" threadID="+Thread.currentThread().getId());
......@@ -362,8 +362,10 @@ public class VDTRunner {
}
if (debugPrint) System.out.println("Skipping program runner as playback is not implemented, arguments were "+argumentsItemsArray[numItem].getNameAsParser());
} //for (;numItem<argumentsItemsArray.length;numItem++){
getRunningBuilds().removeConfiguration(consoleName); // normal tool launch removes it by console listener (when console is closed)
if (debugPrint) System.out.println("All playbacks finished");
monitor.done();
// remove configuration!!
// ToolsCore.getTool(runConfig.getToolName()).setRunning(false);
ToolsCore.getTool(runConfig.getToolName()).setMode(TOOL_MODE.STOP);
ToolsCore.getTool(runConfig.getToolName()).toolFinished();
......@@ -423,11 +425,13 @@ public class VDTRunner {
}
public static String renderProcessLabel(String[] commandLine) {
String timestamp= DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM).format(new Date(System.currentTimeMillis()));
// String timestamp= DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM).format(new Date(System.currentTimeMillis()));
String timestamp= DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG).format(new Date(System.currentTimeMillis()));
return Txt.s("Launch.Process.LabelFormat", new String[] {commandLine[0], timestamp});
}
public static String renderProcessLabel(String toolName) {
String timestamp= DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM).format(new Date(System.currentTimeMillis()));
// String timestamp= DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM).format(new Date(System.currentTimeMillis()));
String timestamp= DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG).format(new Date(System.currentTimeMillis()));
return Txt.s("Launch.Process.LabelFormat", new String[] {toolName, timestamp});
}
} // class VDTRunner
......@@ -182,7 +182,8 @@ public class VDTRunnerConfiguration {
}
public int getPrevBuildStep(){
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING))
System.out.println("getPrevBuildStep(): prevBuildStep=" +prevBuildStep+ ", nextBuildStep=" +nextBuildStep.get());
System.out.println("getPrevBuildStep(): prevBuildStep=" +prevBuildStep+ ", nextBuildStep=" +
((nextBuildStep==null)?null:nextBuildStep.get()));
return prevBuildStep;
}
......@@ -190,7 +191,8 @@ public class VDTRunnerConfiguration {
public int getAndIncBuildStep(){
prevBuildStep=nextBuildStep.getAndIncrement();
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING))
System.out.println("getAndIncBuildStep(): prevBuildStep=" +prevBuildStep+ ", nextBuildStep=" +nextBuildStep.get());
System.out.println("getAndIncBuildStep(): prevBuildStep=" +prevBuildStep+ ", nextBuildStep=" +
((nextBuildStep==null)?null:nextBuildStep.get()));
return prevBuildStep;
}
......@@ -198,7 +200,8 @@ public class VDTRunnerConfiguration {
nextBuildStep=new AtomicInteger(0);
prevBuildStep=0;
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING))
System.out.println("resetBuildStep(): prevBuildStep=" +prevBuildStep+ ", nextBuildStep=" +nextBuildStep.get());
System.out.println("resetBuildStep(): prevBuildStep=" +prevBuildStep+ ", nextBuildStep=" +
((nextBuildStep==null)?null:nextBuildStep.get()));
// updateBuildStep();
}
......@@ -208,8 +211,10 @@ public class VDTRunnerConfiguration {
public boolean acquireBuildStep (int expected){
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING))
System.out.println("acquireBuildStep(): prevBuildStep=" +prevBuildStep+ ", nextBuildStep=" +nextBuildStep.get()+" expected="+expected);
if (nextBuildStep.compareAndSet(expected, expected+1)){
System.out.println("acquireBuildStep(): prevBuildStep=" +prevBuildStep+ ", nextBuildStep=" +
((nextBuildStep==null)?null:nextBuildStep.get())+
" expected="+expected);
if ((nextBuildStep!=null) && nextBuildStep.compareAndSet(expected, expected+1)){
prevBuildStep=expected;
return true;
}
......
......@@ -376,7 +376,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
public void setMode(TOOL_MODE mode) {
DEBUG_PRINT(">>--- "+name+": setMode("+mode+"), runMode="+runMode+", lastRunMode="+lastRunMode+" "+this.toString()+" threadID="+Thread.currentThread().getId());
if (mode !=TOOL_MODE.WAIT) this.toolWaitingArguments = null;
if ((runMode!=TOOL_MODE.STOP) && (mode==TOOL_MODE.STOP)){ // just stopped
if ((runMode!=TOOL_MODE.PLAYBACK) && (runMode!=TOOL_MODE.STOP) && (mode==TOOL_MODE.STOP)){ // just stopped, but not from PLAYBACK
timeStampRan=timeStamp; // to determine that the tool is tried for the second time in a launch (loop)
lastRunHash=getCurrentHash();
DEBUG_PRINT(":::: Tool "+name+": lastRunHash="+lastRunHash);
......
......@@ -207,12 +207,15 @@ public class ToolSequence {
}
}
public void doToolFinished(Tool tool){
if (tool.isRunning()) {
if (tool.isRunning()) { // PLAYBACK is also isRunning()
DEBUG_PRINT("\nTool "+tool.getName()+" is (still) running");
return;
}
DEBUG_PRINT("\n-----> Tool "+tool.getName()+" FINISHED , state="+tool.getState()+", mode="+tool.getLastMode()+" threadID="+Thread.currentThread().getId());
if (tool.getLastMode()==TOOL_MODE.PLAYBACK) { // Stopped after finishing playback
DEBUG_PRINT("\nTool "+tool.getName()+" finished playback");
return;
}
// Restore tool in Run mode - same as RESTORE_MODE ? Change it to tool.setMode?
// RESTORE - only manual command "restore", automatic runs with RUN
if ((tool.getState()==TOOL_STATE.SUCCESS) || (tool.getState()==TOOL_STATE.KEPT_OPEN)){
......@@ -752,6 +755,7 @@ public class ToolSequence {
* @return never null, may be empty list
*/
public List<Tool> getToolsToSave(){
DEBUG_PRINT("getToolsToSave():");
IProject project = SelectedResourceManager.getDefault().getSelectedProject(); // should not be null when we got here
List<Tool> saveToolsList=new ArrayList<Tool>();
for (Tool tool : ToolsCore.getConfig().getContextManager().getToolList()){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment