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