[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Debug Command handler -- Eclipse

Hello guys,

This CDT forum has helped me a lot in my development Very Happy . I am in my last stage of development and am trying to figure something out. You help is much needed so I can get done with this.
Here goes the issue.

I have added my own MI commands in the MI interface of GDB and in the CDT.
Now I am trying to call these commands from the Eclipse UI.
I know that internally Eclipse platform schedules events from the UI (button presses etc...) as jobs. When a Worker thread becomes free, job manager selects a suitable jon to run.
I found out that this worker thread calls a method called execute in the class AbstractDebugCommand which is in org.eclipse.debug.core.commands.
This method creates a new Job object and calls a run method. This method calls a doExecute method which calls the command class ( StepCommand.java in the case of step command).
My idea is to create a new Job when my button is pressed and then schedule it. However the execute method of AbstractDebugCommand gets an IDebugCommandRequest as its parameter. I traced back the call hierarchy of this method to find out how to access this request. But i find it very confusing as to what exactly happens.
This is how the execute method of AbstractDebugCommand looks like.

	public boolean execute(final IDebugCommandRequest request) {
Job job = new Job(getExecuteTaskName()) {
protected IStatus run(IProgressMonitor monitor) {
if (DebugOptions.DEBUG_COMMANDS) {
System.out.println("execute: " + AbstractDebugCommand.this); //$NON-NLS-1$
}
Object[] elements = request.getElements();
Object[] targets = new Object[elements.length];
for (int i = 0; i < elements.length; i++) {
targets[i]= getTarget(elements[i]);
}
targets = coalesce(targets);
monitor.beginTask(getExecuteTaskName(), targets.length);
try {
doExecute(targets, monitor, request);
} catch (CoreException e) {
request.setStatus(e.getStatus());
if (DebugOptions.DEBUG_COMMANDS) {
System.out.println("\t" + e.getStatus().getMessage()); //$NON-NLS-1$
}
}
request.done();
monitor.setCanceled(request.isCanceled());
monitor.done();
return Status.OK_STATUS;
}
public boolean belongsTo(Object family) {
Object jobFamily = getExecuteJobFamily(request);
if (jobFamily != null) {
return jobFamily.equals(family);
}
return false;
}
};
job.setSystem(true);
job.setRule(getExecuteSchedulingRule(request));
job.schedule();
return isRemainEnabled(request);
}


I have implemented the button in Eclipse UI using the org.eclipse.ui.menus/handlers/commands. This button has an execute method to handle the button press.
This is how my execute method looks like. Right now I just have a print command in it.

public Object execute(ExecutionEvent event) throws ExecutionException {

Job job = new Job(getExecuteTaskName()) {
protected IStatus run(IProgressMonitor monitor) {


monitor.beginTask(getExecuteTaskName(), IProgressMonitor.UNKNOWN);

System.out.println("Inside run method of Job()");

monitor.setCanceled(false);
monitor.done();
return Status.OK_STATUS;
}
public boolean belongsTo(Object family) {
Object jobFamily = null;
if (jobFamily != null) {
return jobFamily.equals(family);
}
return false;
}
};
job.setSystem(true);
job.setRule(getExecuteSchedulingRule());
job.schedule();
return false;



}



I hope I have explained my issue clearly. Please let me know if anything is unclear.
Please let me know about any suggestions/similar posts, articles. I am grateful for your time.

Rohit


--
Thanks & Regards,
Rohit Girme