diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/BuildDescriptionModelTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/BuildDescriptionModelTests.java index 9e435d0aae1..1381d277538 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/BuildDescriptionModelTests.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/BuildDescriptionModelTests.java @@ -813,7 +813,7 @@ public class BuildDescriptionModelTests extends TestCase { private void doTrace(String str){ if(DbgUtil.DEBUG) - DbgUtil.traceln(str); + DbgUtil.trace(str); } private void doTestBuildDescription(IBuildDescription des, IBuildDescription tDes){ diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildmodel/BuildDescriptionManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildmodel/BuildDescriptionManager.java index 03658cab9ba..fe14d657d8c 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildmodel/BuildDescriptionManager.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildmodel/BuildDescriptionManager.java @@ -182,7 +182,7 @@ public class BuildDescriptionManager { IBuildStep inputAction = rcs[0].getBuildDescription().getInputStep(); if(DbgUtil.DEBUG) - DbgUtil.traceln(">>found resources to clean:"); //$NON-NLS-1$ + DbgUtil.trace(">>found resources to clean:"); //$NON-NLS-1$ for(int i = 0; i < rcs.length; i++){ IBuildResource buildRc = rcs[i]; @@ -195,14 +195,14 @@ public class BuildDescriptionManager { && buildRc.isProjectResource()){ if(DbgUtil.DEBUG) - DbgUtil.traceln(path.toString()); + DbgUtil.trace(path.toString()); list.add(buildRc); } } if(DbgUtil.DEBUG) - DbgUtil.traceln("<<"); //$NON-NLS-1$ + DbgUtil.trace("<<"); //$NON-NLS-1$ } private static boolean checkFlags(int var, int flags){ diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuilderCorePlugin.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuilderCorePlugin.java index b196384a116..798994a9d79 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuilderCorePlugin.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuilderCorePlugin.java @@ -11,6 +11,7 @@ package org.eclipse.cdt.managedbuilder.core; import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.managedbuilder.internal.buildmodel.DbgUtil; import org.eclipse.cdt.managedbuilder.internal.core.GeneratedMakefileBuilder; import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages; import org.eclipse.cdt.managedbuilder.internal.core.ResourceChangeHandler; @@ -167,6 +168,7 @@ public class ManagedBuilderCorePlugin extends Plugin { private static final String PATH_ENTRY = ManagedBuilderCorePlugin.getUniqueIdentifier() + "/debug/pathEntry"; //$NON-NLS-1$ private static final String PATH_ENTRY_INIT = ManagedBuilderCorePlugin.getUniqueIdentifier() + "/debug/pathEntryInit"; //$NON-NLS-1$ private static final String BUILDER = ManagedBuilderCorePlugin.getUniqueIdentifier() + "/debug/builder"; //$NON-NLS-1$ + private static final String BUILD_MODEL = ManagedBuilderCorePlugin.getUniqueIdentifier() + "/debug/buildModel"; //$NON-NLS-1$ /** * @@ -185,6 +187,10 @@ public class ManagedBuilderCorePlugin extends Plugin { if (builder != null) { GeneratedMakefileBuilder.VERBOSE = builder.equalsIgnoreCase("true") ; //$NON-NLS-1$ } + String buildModel = Platform.getDebugOption(BUILD_MODEL); + if(buildModel != null){ + DbgUtil.DEBUG = buildModel.equalsIgnoreCase("true"); //$NON-NLS-1$ + } } } } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildDescription.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildDescription.java index dde1a0a9c4f..ad117774ad2 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildDescription.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildDescription.java @@ -229,7 +229,7 @@ public class BuildDescription implements IBuildDescription { public int visit(IBuildStep action) throws CoreException { if(DbgUtil.DEBUG){ - DbgUtil.traceln("StepCollector: visiting step " + DbgUtil.stepName(action)); //$NON-NLS-1$ + DbgUtil.trace("StepCollector: visiting step " + DbgUtil.stepName(action)); //$NON-NLS-1$ } fStepSet.add(action); return VISIT_CONTINUE; @@ -260,11 +260,7 @@ public class BuildDescription implements IBuildDescription { boolean removed = action.isRemoved(); if(DbgUtil.DEBUG){ - DbgUtil.trace(">>visiting action for tool = "); //$NON-NLS-1$ - if(((BuildStep)action).getTool() != null) - DbgUtil.traceln(action.getTool().getName()); - else - DbgUtil.traceln(""); //$NON-NLS-1$ + DbgUtil.trace(">>visiting step " + DbgUtil.stepName(a)); //$NON-NLS-1$ } if(!removed){ @@ -293,12 +289,12 @@ public class BuildDescription implements IBuildDescription { for(int i = 0; i < rcs.length; i++){ if(rcs[i].needsRebuild()){ if(DbgUtil.DEBUG) - DbgUtil.traceln("resource " + locationToRel(rcs[i].getLocation()).toString() + " needs rebuild"); //$NON-NLS-1$ //$NON-NLS-2$ + DbgUtil.trace("resource " + locationToRel(rcs[i].getLocation()).toString() + " needs rebuild"); //$NON-NLS-1$ //$NON-NLS-2$ rebuild = true; break; } else if(rcs[i].isRemoved()){ if(DbgUtil.DEBUG) - DbgUtil.traceln("resource " + locationToRel(rcs[i].getLocation()).toString() + " is removed"); //$NON-NLS-1$ //$NON-NLS-2$ + DbgUtil.trace("resource " + locationToRel(rcs[i].getLocation()).toString() + " is removed"); //$NON-NLS-1$ //$NON-NLS-2$ rebuild = true; break; } @@ -307,7 +303,7 @@ public class BuildDescription implements IBuildDescription { if(removed){ if(DbgUtil.DEBUG) - DbgUtil.traceln("action to be removed"); //$NON-NLS-1$ + DbgUtil.trace("action to be removed"); //$NON-NLS-1$ action.setRemoved(); @@ -315,14 +311,14 @@ public class BuildDescription implements IBuildDescription { for(int i = 0; i < outRcs.length; i++){ if(DbgUtil.DEBUG) - DbgUtil.traceln("setting remove state for resource " + locationToRel(outRcs[i].getLocation()).toString()); //$NON-NLS-1$ + DbgUtil.trace("setting remove state for resource " + locationToRel(outRcs[i].getLocation()).toString()); //$NON-NLS-1$ ((BuildResource)outRcs[i]).setRemoved(true); } } else if(rebuild){ if(DbgUtil.DEBUG) - DbgUtil.traceln("action needs rebuild"); //$NON-NLS-1$ + DbgUtil.trace("action needs rebuild"); //$NON-NLS-1$ action.setRebuildState(true); @@ -330,14 +326,14 @@ public class BuildDescription implements IBuildDescription { for(int i = 0; i < outRcs.length; i++){ if(DbgUtil.DEBUG) - DbgUtil.traceln("setting rebuild state for resource " + locationToRel(outRcs[i].getLocation()).toString()); //$NON-NLS-1$ + DbgUtil.trace("setting rebuild state for resource " + locationToRel(outRcs[i].getLocation()).toString()); //$NON-NLS-1$ ((BuildResource)outRcs[i]).setRebuildState(true); } } if(DbgUtil.DEBUG) - DbgUtil.traceln("<Synch started"); //$NON-NLS-1$ + DbgUtil.trace("--->Synch started"); //$NON-NLS-1$ BuildDescriptionManager.accept(new RebuildStateSynchronizer(), this, true); @@ -396,7 +392,7 @@ public class BuildDescription implements IBuildDescription { fInputStep.setRebuildState(true);//needed for the pre-build step invocation if(DbgUtil.DEBUG) - DbgUtil.traceln("<---Synch stopped"); //$NON-NLS-1$ + DbgUtil.trace("<---Synch stopped"); //$NON-NLS-1$ } private BuildIOType findTypeForExtension(BuildStep step, boolean input, String ext){ @@ -794,7 +790,7 @@ public class BuildDescription implements IBuildDescription { } if(i == rcs.length){ if(DbgUtil.DEBUG){ - DbgUtil.traceln("unused step found: " + DbgUtil.stepName(step)); //$NON-NLS-1$ + DbgUtil.trace("unused step found: " + DbgUtil.stepName(step)); //$NON-NLS-1$ } foundUnused = true; @@ -802,7 +798,7 @@ public class BuildDescription implements IBuildDescription { && step.getTool() != null && step.getTool().getCustomBuildStep()){ if(DbgUtil.DEBUG){ - DbgUtil.traceln("unused step is an RCBS needing rebuild, settings input step rebuild state to true"); //$NON-NLS-1$ + DbgUtil.trace("unused step is an RCBS needing rebuild, settings input step rebuild state to true"); //$NON-NLS-1$ } fInputStep.setRebuildState(true); } @@ -1689,7 +1685,7 @@ public class BuildDescription implements IBuildDescription { if(!fToolInProcesSet.add(tool)){ //TODO throw error? if(DbgUtil.DEBUG) - DbgUtil.traceln("loop dependency for tool" + tool.getName()); //$NON-NLS-1$ + DbgUtil.trace("loop dependency for tool" + tool.getName()); //$NON-NLS-1$ return new ITool[0]; } @@ -1718,7 +1714,7 @@ public class BuildDescription implements IBuildDescription { set.add(deps[k]); else{ if(DbgUtil.DEBUG) - DbgUtil.traceln("loop dependency for tool" + tool.getName()); //$NON-NLS-1$ + DbgUtil.trace("loop dependency for tool" + tool.getName()); //$NON-NLS-1$ //TODO throw error } } @@ -1735,7 +1731,7 @@ public class BuildDescription implements IBuildDescription { if(!fToolInProcesSet.add(tool)){ //TODO throw error? if(DbgUtil.DEBUG) - DbgUtil.traceln("loop dependency for tool" + tool.getName()); //$NON-NLS-1$ + DbgUtil.trace("loop dependency for tool" + tool.getName()); //$NON-NLS-1$ return new ITool[0]; } @@ -1764,7 +1760,7 @@ public class BuildDescription implements IBuildDescription { set.add(consumers[k]); else{ if(DbgUtil.DEBUG) - DbgUtil.traceln("loop dependency for tool" + tool.getName()); //$NON-NLS-1$ + DbgUtil.trace("loop dependency for tool" + tool.getName()); //$NON-NLS-1$ //TODO throw error } } @@ -1811,7 +1807,7 @@ public class BuildDescription implements IBuildDescription { if(fTargetStep != null){ //TODO: this is an error case, log or perform some special handling if(DbgUtil.DEBUG) - DbgUtil.traceln("ERROR: target action already created"); //$NON-NLS-1$ + DbgUtil.trace("ERROR: target action already created"); //$NON-NLS-1$ } fTargetStep = step; } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildIOType.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildIOType.java index 6e80c24fa2d..a2d7bce3eda 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildIOType.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildIOType.java @@ -63,7 +63,7 @@ public class BuildIOType implements IBuildIOType { fResources.add(rc); rc.addToArg(this); if(DbgUtil.DEBUG) - DbgUtil.traceln("resource " + DbgUtil.resourceName(rc) + " added as " //$NON-NLS-1$ //$NON-NLS-2$ + DbgUtil.trace("resource " + DbgUtil.resourceName(rc) + " added as " //$NON-NLS-1$ //$NON-NLS-2$ + (fIsInput ? "input" : "output") //$NON-NLS-1$ //$NON-NLS-2$ + " to the action " + DbgUtil.stepName(fStep)); //$NON-NLS-1$ @@ -75,7 +75,7 @@ public class BuildIOType implements IBuildIOType { rc.removeFromArg(this); if(DbgUtil.DEBUG) - DbgUtil.traceln("resource " + DbgUtil.resourceName(rc) + " removed as " //$NON-NLS-1$ //$NON-NLS-2$ + DbgUtil.trace("resource " + DbgUtil.resourceName(rc) + " removed as " //$NON-NLS-1$ //$NON-NLS-2$ + (fIsInput ? "input" : "output") //$NON-NLS-1$ //$NON-NLS-2$ + " from the action " + DbgUtil.stepName(fStep)); //$NON-NLS-1$ diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildResource.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildResource.java index b88d4cee5ca..904808315a5 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildResource.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildResource.java @@ -43,7 +43,7 @@ public class BuildResource implements IBuildResource { info.resourceCreated(this); if(DbgUtil.DEBUG) - DbgUtil.traceln("resource " + location + " created"); //$NON-NLS-1$ //$NON-NLS-2$ + DbgUtil.trace("resource " + location + " created"); //$NON-NLS-1$ //$NON-NLS-2$ } /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.builddescription.IBuildResource#getLocation() @@ -90,7 +90,7 @@ public class BuildResource implements IBuildResource { public void setRemoved(boolean removed) { if(DbgUtil.DEBUG){ if(removed) - DbgUtil.traceln("REMOVED state: resource " + DbgUtil.resourceName(this)); + DbgUtil.trace("REMOVED state: resource " + DbgUtil.resourceName(this)); } fIsRemoved = removed; if(fIsRemoved) @@ -153,7 +153,7 @@ public class BuildResource implements IBuildResource { BuildIOType types[][] = clear(); if(DbgUtil.DEBUG) - DbgUtil.traceln("resource " + DbgUtil.resourceName(this) + " removed"); //$NON-NLS-1$ //$NON-NLS-2$ + DbgUtil.trace("resource " + DbgUtil.resourceName(this) + " removed"); //$NON-NLS-1$ //$NON-NLS-2$ fInfo.resourceRemoved(this); fInfo = null; diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildStep.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildStep.java index 5350e294f74..22465053d29 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildStep.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildStep.java @@ -60,7 +60,7 @@ public class BuildStep implements IBuildStep { fBuildDescription = des; if(DbgUtil.DEBUG) - DbgUtil.traceln("step " + DbgUtil.stepName(this) + " created"); //$NON-NLS-1$ //$NON-NLS-2$ + DbgUtil.trace("step " + DbgUtil.stepName(this) + " created"); //$NON-NLS-1$ //$NON-NLS-2$ des.stepCreated(this); } @@ -114,7 +114,7 @@ public class BuildStep implements IBuildStep { BuildResource[][] rcs = clear(); if(DbgUtil.DEBUG) - DbgUtil.traceln("step " + DbgUtil.stepName(this) + " removed"); //$NON-NLS-1$ //$NON-NLS-2$ + DbgUtil.trace("step " + DbgUtil.stepName(this) + " removed"); //$NON-NLS-1$ //$NON-NLS-2$ fBuildDescription.stepRemoved(this); fBuildDescription = null; diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/CommandBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/CommandBuilder.java index 9155310783e..f41a3f5c6fd 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/CommandBuilder.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/CommandBuilder.java @@ -112,7 +112,7 @@ public class CommandBuilder implements IBuildModelBuilder { } else { fErrMsg = launcher.getErrorMessage(); if(DbgUtil.DEBUG) - DbgUtil.traceln("error launching the command: " + fErrMsg); //$NON-NLS-1$ + DbgUtil.trace("error launching the command: " + fErrMsg); //$NON-NLS-1$ status = STATUS_ERROR_LAUNCH; } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/DbgUtil.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/DbgUtil.java index f2af35a481b..40e0f554b29 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/DbgUtil.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/DbgUtil.java @@ -25,13 +25,16 @@ import org.eclipse.cdt.managedbuilder.core.ITool; public class DbgUtil { public static boolean DEBUG = false; private static PrintStream out = System.out; + private static final String TRACE_PREFIX = "BuildModel[ "; //$NON-NLS-1$ + private static final String TRACE_SUFIX = " ]"; //$NON-NLS-1$ + public static void trace(String str){ - out.print(str); + out.println(formatMsg(str)); } - - public static void traceln(String str){ - out.println(str); + + public static String formatMsg(String msg){ + return TRACE_PREFIX + msg + TRACE_SUFIX; } public static String stepName(IBuildStep action){ diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/DescriptionBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/DescriptionBuilder.java index c8c07788279..addac8a418c 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/DescriptionBuilder.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/DescriptionBuilder.java @@ -59,11 +59,11 @@ public class DescriptionBuilder implements IBuildModelBuilder { return VISIT_STOP; if(DbgUtil.DEBUG) - DbgUtil.traceln("visiting step " + DbgUtil.stepName(action)); + DbgUtil.trace("visiting step " + DbgUtil.stepName(action)); if(!action.isRemoved() && (!fBuildIncrementaly || action.needsRebuild())){ if(DbgUtil.DEBUG) - DbgUtil.traceln("step " + DbgUtil.stepName(action) + " needs rebuild" ); + DbgUtil.trace("step " + DbgUtil.stepName(action) + " needs rebuild" ); StepBuilder builder = new StepBuilder(action, fCWD, fResumeOnErrs, fDir); switch(builder.build(fOut, fErr, fMonitor)){ diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/StepBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/StepBuilder.java index 83ff5bf39f9..62ebe40545e 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/StepBuilder.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/StepBuilder.java @@ -129,7 +129,7 @@ public class StepBuilder implements IBuildModelBuilder { file.refreshLocal(IResource.DEPTH_ZERO, monitor); } catch (CoreException e) { if(DbgUtil.DEBUG){ - DbgUtil.traceln("failed to refresh resource " //$NON-NLS-1$ + DbgUtil.trace("failed to refresh resource " //$NON-NLS-1$ + file.getFullPath() + ", error: " + e.getLocalizedMessage()); //$NON-NLS-1$ } @@ -150,7 +150,7 @@ public class StepBuilder implements IBuildModelBuilder { rc.delete(true, monitor); } catch (CoreException e) { if(DbgUtil.DEBUG){ - DbgUtil.traceln("failed to delete resource " //$NON-NLS-1$ + DbgUtil.trace("failed to delete resource " //$NON-NLS-1$ + rc.getFullPath() + ", error: " + e.getLocalizedMessage()); //$NON-NLS-1$ }