1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-20 15:35:24 +02:00

Bug 223076

Generate tokenId when needed and printout debug traces when MI command is actually sent.
This commit is contained in:
Marc Khouzam 2008-04-29 20:09:48 +00:00
parent c067bd385f
commit 5474268d37

View file

@ -215,7 +215,7 @@ public abstract class AbstractMIControl extends AbstractDsfService
/* /*
* We are putting this one on the wire. We need to add it to the waiting list so * We are putting this one on the wire. We need to add it to the waiting list so
* the user has the chance to cancel it when we tell them we are acknowleding it * the user has the chance to cancel it when we tell them we are acknowledging it
* has been officially accepted. They could choose to cancel it before we go and * has been officially accepted. They could choose to cancel it before we go and
* send it. That is why we put it into the QUEUE and then check to see if it is * send it. That is why we put it into the QUEUE and then check to see if it is
* still there. * still there.
@ -235,8 +235,8 @@ public abstract class AbstractMIControl extends AbstractDsfService
fCurrentThreadId = handle.getThreadId().intValue(); fCurrentThreadId = handle.getThreadId().intValue();
CommandHandle cmdHandle = new CommandHandle( CommandHandle cmdHandle = new CommandHandle(
new MIThreadSelect(handle.fCommand.getContext(), fCurrentThreadId), null); new MIThreadSelect(handle.fCommand.getContext(), fCurrentThreadId), null);
cmdHandle.generateTokenId();
fTxCommands.add(cmdHandle); fTxCommands.add(cmdHandle);
MIPlugin.debug(MIPlugin.getDebugTime() + " " + cmdHandle.getTokenId() + cmdHandle.getCommand()); //$NON-NLS-1$
} }
// Before the command is sent, Check the Stack level and send it to // Before the command is sent, Check the Stack level and send it to
@ -248,9 +248,10 @@ public abstract class AbstractMIControl extends AbstractDsfService
fCurrentStackLevel = handle.getStackFrameId().intValue(); fCurrentStackLevel = handle.getStackFrameId().intValue();
CommandHandle cmdHandle = new CommandHandle( CommandHandle cmdHandle = new CommandHandle(
new MIStackSelectFrame(handle.fCommand.getContext(), fCurrentStackLevel), null); new MIStackSelectFrame(handle.fCommand.getContext(), fCurrentStackLevel), null);
cmdHandle.generateTokenId();
fTxCommands.add(cmdHandle); fTxCommands.add(cmdHandle);
MIPlugin.debug(MIPlugin.getDebugTime() + " " + cmdHandle.getTokenId() + cmdHandle.getCommand()); //$NON-NLS-1$
} }
handle.generateTokenId();
fTxCommands.add(handle); fTxCommands.add(handle);
} }
} }
@ -336,7 +337,6 @@ public abstract class AbstractMIControl extends AbstractDsfService
} }
private void processCommandSent(CommandHandle commandHandle) { private void processCommandSent(CommandHandle commandHandle) {
MIPlugin.debug(MIPlugin.getDebugTime() + " " + commandHandle.getTokenId() + commandHandle.getCommand()); //$NON-NLS-1$
for (ICommandListener processor : fCommandProcessors) { for (ICommandListener processor : fCommandProcessors) {
processor.commandSent(commandHandle); processor.commandSent(commandHandle);
} }
@ -403,11 +403,15 @@ public abstract class AbstractMIControl extends AbstractDsfService
CommandHandle(MICommand<MIInfo> c, DataRequestMonitor<MIInfo> d) { CommandHandle(MICommand<MIInfo> c, DataRequestMonitor<MIInfo> d) {
fCommand = c; fCommand = c;
fRequestMonitor = d; fRequestMonitor = d;
fTokenId = getNewTokenId() ; fTokenId = -1; // Only initialize to a real value when needed
} }
public MICommand<MIInfo> getCommand() { return fCommand; } public MICommand<MIInfo> getCommand() { return fCommand; }
public DataRequestMonitor<MIInfo> getRequestMonitor() { return fRequestMonitor; } public DataRequestMonitor<MIInfo> getRequestMonitor() { return fRequestMonitor; }
// This method allows us to generate the token Id when we area actually going to use
// it. It is meant to help order the token ids based on when commands will actually
// be sent
public void generateTokenId() { fTokenId = getNewTokenId(); }
public Integer getTokenId() { return fTokenId; } public Integer getTokenId() { return fTokenId; }
//public String getThreadId() { return null; } //public String getThreadId() { return null; }
@ -435,7 +439,7 @@ public abstract class AbstractMIControl extends AbstractDsfService
* This is the transmitter thread. When a command is given to this thread it has been * This is the transmitter thread. When a command is given to this thread it has been
* considered to be sent, even if it has not actually been sent yet. This assumption * considered to be sent, even if it has not actually been sent yet. This assumption
* makes it easier from state management. Whomever fill this pipeline handles all of * makes it easier from state management. Whomever fill this pipeline handles all of
* the required state notofication ( callbacks ). This thread simply physically gives * the required state notification ( callbacks ). This thread simply physically gives
* the message to the backend. * the message to the backend.
*/ */
@ -478,12 +482,17 @@ public abstract class AbstractMIControl extends AbstractDsfService
* Construct the new command and push this command out the pipeline. * Construct the new command and push this command out the pipeline.
*/ */
String str = commandHandle.getTokenId() + commandHandle.getCommand().constructCommand(); final String str = commandHandle.getTokenId() + commandHandle.getCommand().constructCommand();
try { try {
if (fOutputStream != null) { if (fOutputStream != null) {
fOutputStream.write(str.getBytes()); fOutputStream.write(str.getBytes());
fOutputStream.flush(); fOutputStream.flush();
getExecutor().execute(new DsfRunnable() {
public void run() {
MIPlugin.debug(MIPlugin.getDebugTime() + " " + str); //$NON-NLS-1$
}
});
} }
} catch (IOException e) { } catch (IOException e) {
// Shutdown thread in case of IO error. // Shutdown thread in case of IO error.
@ -717,6 +726,7 @@ public abstract class AbstractMIControl extends AbstractDsfService
CommandHandle comHandle = fCommandQueue.remove(0); CommandHandle comHandle = fCommandQueue.remove(0);
if ( comHandle != null ) { if ( comHandle != null ) {
processCommandSent(comHandle); processCommandSent(comHandle);
comHandle.generateTokenId();
fTxCommands.add(comHandle); fTxCommands.add(comHandle);
} }
} }