[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [cdt-debug-dev] Launching the debugger/perspective on a PID
|
I've tried to implement this and am running into tons and tons of brick
walls. The code you sent me to look at utilizes a large number of
protected and private methods - the only public interfaces to it don't
let me send in a PID.
I implemented the following code but it doesn't work and brings me to
wonder if I'm approaching this the wrong way. My plugin is separate
from CDT - if that's true, can I call methods in the CDT plugin - even
if they are static?
It seems like a simple request:
I have a plugin, it starts a job running, I grab the PID of that job, I
provide a UI Button which reads 'debug process' which, upon clicked, I
want the debug perspective to start and start debugging my running job.
Obviously all of that is simple up until the very end.
I've read the articles after your suggestion on the Eclipse site having
to do with launch configurations and the like.
Any chance any more assistance can be provided that can point me in the
right direction?
Am I totally taking the wrong approach? :)
-- Nathan
Alain Magloire wrote:
I am trying to, within code, switch to the debug perspective and debug a
process which is already executing - I have its PID.
I see in the CDT code places where this is possible though there are all
sorts of configuration and related classes floating around that I feel
leery around jumping in and calling these methods - many are protected
anyway.
Can anyone explain to me how to do this? In pseudo-code I'm thinking
something like:
int pid = pid_of_currently_executing_process;
launchDebuggerAndPerspectiveOnPID(pid);
Surely it's not this simple, but I assume CDT was built in such a way as
the above is remotely possible.
It is possible but not simple 8-). It involves an understanding in
how Eclipse launch framework works.
So for more info on this take a look at the doc (Help contents).
The node of the Debug launch.
The good news:
For what you want to do the code is already in CApplicationLaunchShortcut.
This class tries to discover an already launch extension for the an executable
in none was found it creates a new one, an excerpt from the
createConfiguration() method.
ILaunchConfigurationWorkingCopy wc =
configType.newInstance(null, getLaunchManager().generateUniqueLaunchConfigurationNameFrom(bin.getElementName()));
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, projectName);
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, bin.getCProject().getElementName());
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, true);
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
ICDTLaunchConfigurationConstants.DEBUGGER_MODE_RUN);
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, debugConfig.getID());
config = wc.doSave();
config.launch(ILaunchManager.RUN_MODE, null);
In this case you probably want to set
ICDTLaunchConfigurationConstants.ATTR_ATTACH_PROCESS_ID
The bad news:
We are currently changing some of the attributes:
ICDTLaunchConfigurationConstants.ATTR_XXXX
and some of the launch interface in the head to remedy inconsistencies.
_______________________________________________
cdt-debug-dev mailing list
cdt-debug-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/cdt-debug-dev