1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 23:05:47 +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){ private void doTrace(String str){
if(DbgUtil.DEBUG) if(DbgUtil.DEBUG)
DbgUtil.traceln(str); DbgUtil.trace(str);
} }
private void doTestBuildDescription(IBuildDescription des, IBuildDescription tDes){ private void doTestBuildDescription(IBuildDescription des, IBuildDescription tDes){

View file

@ -182,7 +182,7 @@ public class BuildDescriptionManager {
IBuildStep inputAction = rcs[0].getBuildDescription().getInputStep(); IBuildStep inputAction = rcs[0].getBuildDescription().getInputStep();
if(DbgUtil.DEBUG) 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++){ for(int i = 0; i < rcs.length; i++){
IBuildResource buildRc = rcs[i]; IBuildResource buildRc = rcs[i];
@ -195,14 +195,14 @@ public class BuildDescriptionManager {
&& buildRc.isProjectResource()){ && buildRc.isProjectResource()){
if(DbgUtil.DEBUG) if(DbgUtil.DEBUG)
DbgUtil.traceln(path.toString()); DbgUtil.trace(path.toString());
list.add(buildRc); list.add(buildRc);
} }
} }
if(DbgUtil.DEBUG) if(DbgUtil.DEBUG)
DbgUtil.traceln("<<"); //$NON-NLS-1$ DbgUtil.trace("<<"); //$NON-NLS-1$
} }
private static boolean checkFlags(int var, int flags){ private static boolean checkFlags(int var, int flags){

View file

@ -11,6 +11,7 @@
package org.eclipse.cdt.managedbuilder.core; package org.eclipse.cdt.managedbuilder.core;
import org.eclipse.cdt.core.CCorePlugin; 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.GeneratedMakefileBuilder;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages; import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
import org.eclipse.cdt.managedbuilder.internal.core.ResourceChangeHandler; 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 = 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 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 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) { if (builder != null) {
GeneratedMakefileBuilder.VERBOSE = builder.equalsIgnoreCase("true") ; //$NON-NLS-1$ 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 { public int visit(IBuildStep action) throws CoreException {
if(DbgUtil.DEBUG){ 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); fStepSet.add(action);
return VISIT_CONTINUE; return VISIT_CONTINUE;
@ -260,11 +260,7 @@ public class BuildDescription implements IBuildDescription {
boolean removed = action.isRemoved(); boolean removed = action.isRemoved();
if(DbgUtil.DEBUG){ if(DbgUtil.DEBUG){
DbgUtil.trace(">>visiting action for tool = "); //$NON-NLS-1$ DbgUtil.trace(">>visiting step " + DbgUtil.stepName(a)); //$NON-NLS-1$
if(((BuildStep)action).getTool() != null)
DbgUtil.traceln(action.getTool().getName());
else
DbgUtil.traceln(""); //$NON-NLS-1$
} }
if(!removed){ if(!removed){
@ -293,12 +289,12 @@ public class BuildDescription implements IBuildDescription {
for(int i = 0; i < rcs.length; i++){ for(int i = 0; i < rcs.length; i++){
if(rcs[i].needsRebuild()){ if(rcs[i].needsRebuild()){
if(DbgUtil.DEBUG) 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; rebuild = true;
break; break;
} else if(rcs[i].isRemoved()){ } else if(rcs[i].isRemoved()){
if(DbgUtil.DEBUG) 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; rebuild = true;
break; break;
} }
@ -307,7 +303,7 @@ public class BuildDescription implements IBuildDescription {
if(removed){ if(removed){
if(DbgUtil.DEBUG) if(DbgUtil.DEBUG)
DbgUtil.traceln("action to be removed"); //$NON-NLS-1$ DbgUtil.trace("action to be removed"); //$NON-NLS-1$
action.setRemoved(); action.setRemoved();
@ -315,14 +311,14 @@ public class BuildDescription implements IBuildDescription {
for(int i = 0; i < outRcs.length; i++){ for(int i = 0; i < outRcs.length; i++){
if(DbgUtil.DEBUG) 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); ((BuildResource)outRcs[i]).setRemoved(true);
} }
} else if(rebuild){ } else if(rebuild){
if(DbgUtil.DEBUG) if(DbgUtil.DEBUG)
DbgUtil.traceln("action needs rebuild"); //$NON-NLS-1$ DbgUtil.trace("action needs rebuild"); //$NON-NLS-1$
action.setRebuildState(true); action.setRebuildState(true);
@ -330,14 +326,14 @@ public class BuildDescription implements IBuildDescription {
for(int i = 0; i < outRcs.length; i++){ for(int i = 0; i < outRcs.length; i++){
if(DbgUtil.DEBUG) 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); ((BuildResource)outRcs[i]).setRebuildState(true);
} }
} }
if(DbgUtil.DEBUG) if(DbgUtil.DEBUG)
DbgUtil.traceln("<<leaving.."); //$NON-NLS-1$ DbgUtil.trace("<<leaving.."); //$NON-NLS-1$
return VISIT_CONTINUE; return VISIT_CONTINUE;
} }
@ -388,7 +384,7 @@ public class BuildDescription implements IBuildDescription {
public void synchRebuildState() throws CoreException{ public void synchRebuildState() throws CoreException{
if(DbgUtil.DEBUG) if(DbgUtil.DEBUG)
DbgUtil.traceln("--->Synch started"); //$NON-NLS-1$ DbgUtil.trace("--->Synch started"); //$NON-NLS-1$
BuildDescriptionManager.accept(new RebuildStateSynchronizer(), this, true); 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 fInputStep.setRebuildState(true);//needed for the pre-build step invocation
if(DbgUtil.DEBUG) 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){ private BuildIOType findTypeForExtension(BuildStep step, boolean input, String ext){
@ -794,7 +790,7 @@ public class BuildDescription implements IBuildDescription {
} }
if(i == rcs.length){ if(i == rcs.length){
if(DbgUtil.DEBUG){ 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; foundUnused = true;
@ -802,7 +798,7 @@ public class BuildDescription implements IBuildDescription {
&& step.getTool() != null && step.getTool() != null
&& step.getTool().getCustomBuildStep()){ && step.getTool().getCustomBuildStep()){
if(DbgUtil.DEBUG){ 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); fInputStep.setRebuildState(true);
} }
@ -1689,7 +1685,7 @@ public class BuildDescription implements IBuildDescription {
if(!fToolInProcesSet.add(tool)){ if(!fToolInProcesSet.add(tool)){
//TODO throw error? //TODO throw error?
if(DbgUtil.DEBUG) 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]; return new ITool[0];
} }
@ -1718,7 +1714,7 @@ public class BuildDescription implements IBuildDescription {
set.add(deps[k]); set.add(deps[k]);
else{ else{
if(DbgUtil.DEBUG) 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 //TODO throw error
} }
} }
@ -1735,7 +1731,7 @@ public class BuildDescription implements IBuildDescription {
if(!fToolInProcesSet.add(tool)){ if(!fToolInProcesSet.add(tool)){
//TODO throw error? //TODO throw error?
if(DbgUtil.DEBUG) 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]; return new ITool[0];
} }
@ -1764,7 +1760,7 @@ public class BuildDescription implements IBuildDescription {
set.add(consumers[k]); set.add(consumers[k]);
else{ else{
if(DbgUtil.DEBUG) 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 //TODO throw error
} }
} }
@ -1811,7 +1807,7 @@ public class BuildDescription implements IBuildDescription {
if(fTargetStep != null){ if(fTargetStep != null){
//TODO: this is an error case, log or perform some special handling //TODO: this is an error case, log or perform some special handling
if(DbgUtil.DEBUG) 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; fTargetStep = step;
} }

View file

@ -63,7 +63,7 @@ public class BuildIOType implements IBuildIOType {
fResources.add(rc); fResources.add(rc);
rc.addToArg(this); rc.addToArg(this);
if(DbgUtil.DEBUG) 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$ + (fIsInput ? "input" : "output") //$NON-NLS-1$ //$NON-NLS-2$
+ " to the action " + DbgUtil.stepName(fStep)); //$NON-NLS-1$ + " to the action " + DbgUtil.stepName(fStep)); //$NON-NLS-1$
@ -75,7 +75,7 @@ public class BuildIOType implements IBuildIOType {
rc.removeFromArg(this); rc.removeFromArg(this);
if(DbgUtil.DEBUG) 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$ + (fIsInput ? "input" : "output") //$NON-NLS-1$ //$NON-NLS-2$
+ " from the action " + DbgUtil.stepName(fStep)); //$NON-NLS-1$ + " from the action " + DbgUtil.stepName(fStep)); //$NON-NLS-1$

View file

@ -43,7 +43,7 @@ public class BuildResource implements IBuildResource {
info.resourceCreated(this); info.resourceCreated(this);
if(DbgUtil.DEBUG) 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) /* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.builddescription.IBuildResource#getLocation() * @see org.eclipse.cdt.managedbuilder.builddescription.IBuildResource#getLocation()
@ -90,7 +90,7 @@ public class BuildResource implements IBuildResource {
public void setRemoved(boolean removed) { public void setRemoved(boolean removed) {
if(DbgUtil.DEBUG){ if(DbgUtil.DEBUG){
if(removed) if(removed)
DbgUtil.traceln("REMOVED state: resource " + DbgUtil.resourceName(this)); DbgUtil.trace("REMOVED state: resource " + DbgUtil.resourceName(this));
} }
fIsRemoved = removed; fIsRemoved = removed;
if(fIsRemoved) if(fIsRemoved)
@ -153,7 +153,7 @@ public class BuildResource implements IBuildResource {
BuildIOType types[][] = clear(); BuildIOType types[][] = clear();
if(DbgUtil.DEBUG) 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.resourceRemoved(this);
fInfo = null; fInfo = null;

View file

@ -60,7 +60,7 @@ public class BuildStep implements IBuildStep {
fBuildDescription = des; fBuildDescription = des;
if(DbgUtil.DEBUG) 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); des.stepCreated(this);
} }
@ -114,7 +114,7 @@ public class BuildStep implements IBuildStep {
BuildResource[][] rcs = clear(); BuildResource[][] rcs = clear();
if(DbgUtil.DEBUG) 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.stepRemoved(this);
fBuildDescription = null; fBuildDescription = null;

View file

@ -112,7 +112,7 @@ public class CommandBuilder implements IBuildModelBuilder {
} else { } else {
fErrMsg = launcher.getErrorMessage(); fErrMsg = launcher.getErrorMessage();
if(DbgUtil.DEBUG) 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; status = STATUS_ERROR_LAUNCH;
} }

View file

@ -25,13 +25,16 @@ import org.eclipse.cdt.managedbuilder.core.ITool;
public class DbgUtil { public class DbgUtil {
public static boolean DEBUG = false; public static boolean DEBUG = false;
private static PrintStream out = System.out; 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){ public static void trace(String str){
out.print(str); out.println(formatMsg(str));
} }
public static void traceln(String str){ public static String formatMsg(String msg){
out.println(str); return TRACE_PREFIX + msg + TRACE_SUFIX;
} }
public static String stepName(IBuildStep action){ public static String stepName(IBuildStep action){

View file

@ -59,11 +59,11 @@ public class DescriptionBuilder implements IBuildModelBuilder {
return VISIT_STOP; return VISIT_STOP;
if(DbgUtil.DEBUG) if(DbgUtil.DEBUG)
DbgUtil.traceln("visiting step " + DbgUtil.stepName(action)); DbgUtil.trace("visiting step " + DbgUtil.stepName(action));
if(!action.isRemoved() if(!action.isRemoved()
&& (!fBuildIncrementaly || action.needsRebuild())){ && (!fBuildIncrementaly || action.needsRebuild())){
if(DbgUtil.DEBUG) 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); StepBuilder builder = new StepBuilder(action, fCWD, fResumeOnErrs, fDir);
switch(builder.build(fOut, fErr, fMonitor)){ switch(builder.build(fOut, fErr, fMonitor)){

View file

@ -129,7 +129,7 @@ public class StepBuilder implements IBuildModelBuilder {
file.refreshLocal(IResource.DEPTH_ZERO, monitor); file.refreshLocal(IResource.DEPTH_ZERO, monitor);
} catch (CoreException e) { } catch (CoreException e) {
if(DbgUtil.DEBUG){ if(DbgUtil.DEBUG){
DbgUtil.traceln("failed to refresh resource " //$NON-NLS-1$ DbgUtil.trace("failed to refresh resource " //$NON-NLS-1$
+ file.getFullPath() + file.getFullPath()
+ ", error: " + e.getLocalizedMessage()); //$NON-NLS-1$ + ", error: " + e.getLocalizedMessage()); //$NON-NLS-1$
} }
@ -150,7 +150,7 @@ public class StepBuilder implements IBuildModelBuilder {
rc.delete(true, monitor); rc.delete(true, monitor);
} catch (CoreException e) { } catch (CoreException e) {
if(DbgUtil.DEBUG){ if(DbgUtil.DEBUG){
DbgUtil.traceln("failed to delete resource " //$NON-NLS-1$ DbgUtil.trace("failed to delete resource " //$NON-NLS-1$
+ rc.getFullPath() + rc.getFullPath()
+ ", error: " + e.getLocalizedMessage()); //$NON-NLS-1$ + ", error: " + e.getLocalizedMessage()); //$NON-NLS-1$
} }