1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 06:45:43 +02:00

Build Model debug(verbose) mode can now be enabled with the debug options

This commit is contained in:
Mikhail Sennikovsky 2006-04-20 12:08:13 +00:00
parent c3277d0f4c
commit 315143d916
11 changed files with 47 additions and 42 deletions

View file

@ -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){

View file

@ -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){

View file

@ -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$
}
}
}
}

View file

@ -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("<<leaving.."); //$NON-NLS-1$
DbgUtil.trace("<<leaving.."); //$NON-NLS-1$
return VISIT_CONTINUE;
}
@ -388,7 +384,7 @@ public class BuildDescription implements IBuildDescription {
public void synchRebuildState() throws CoreException{
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;
}

View file

@ -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$

View file

@ -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;

View file

@ -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;

View file

@ -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;
}

View file

@ -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){

View file

@ -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)){

View file

@ -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$
}