[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [cdt-dev] Debug support in C/C++ Unit Testing Plugin
|
Subclassing delegates usually is a bad idea. A better approach is to create your own delegate class implementing ILaunchConfigurationDelegate2 that delegates the actual launch to the delegate configured in cdt.debug plugin. Here is code for getting hold of that delegate:
ILaunchConfigurationDelegate2 getDelegate(ILaunchConfiguration config, String mode) throws CoreException {
ILaunchManager launchMgr = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType localCfg =
launchMgr.getLaunchConfigurationType(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_APP);
Set<String> modes = config.getModes();
modes.add(mode);
// Explicitly force the CDT Debug Core plugin to be activated by accessing a method on it.
// This ensures that the start() method of that plugin will initialize the preferred delegates.
CDebugCorePlugin.getDefault();
return (ILaunchConfigurationDelegate2) localCfg.getPreferredDelegate(modes).getDelegate();
}
Your delegate can modify the launch configuration before passing it on the other delegate.
-sergey
On Sun, Oct 30, 2011 at 9:48 AM, xgsa
<xgsa@xxxxxxxxx> wrote:
Hi,
I am working on debug support in
C/C++
Unit Testing Plugin. It means that user should be able to
easily start debug session for the "C/C++ Unit" configuration.
To make "C/C++ Unit" view work properly I need to be able to do 2
things:
- I need to be able to provide additional program arguments (not
only stored in PROGRAM_ARGUMENTS attribute of launch
configuration);
- I need to be able to handle output and/or error streams of the
started process (and prevent its output to "Console" view).
I
also want to reuse standard CDI & DSF launch
delegates as much as possible and I want to place
all the code necessary for test modules launching
in org.eclipse.cdt.testsrunner.
For CDI I decided to derive LocalCDILaunchDelegate. To
handle program arguments I have just override getProgramArgumentsArray().
To obtain output/error streams I have wrapped the
process creation in
launchLocalDebugSession() with a
custom method
wrapProcess() that by default just return
the process passed to its arguments. However in my implementation of
delegate it stores the necessary stream and returns a wrapper (that
returns
null on
getInputStream()/
getErrorStream()
if necessary).
Is
this an acceptable solution? And if yes, could I move LocalCDILaunchDelegate
from org.eclipse.cdt.launch.internal
to
org.eclipse.cdt.launch to be able to place my delegate
in
org.eclipse.cdt.testsrunner?
Or will it be better to configure package visibility in "Runtime"
tab of
plugins.xml and to add
org.eclipse.cdt.testsrunner
there?
For DSF I have no solution how to do the similar things. I have
found that program arguments are provided by
GDBBackend
service and the inferior process is created in
GDBProcesses
&
GDBProcesses_7_0, but I don't know how I can
override the default behaviour. Can somebody advise me something or
is there another way to do the things described above?
Anton
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev