Thread-topic: [cdt-dev] Debug support in C/C++ Unit Testing Plugin
Hi,
do you need to handle the output of the debugged program
(inferior) or of GDB?
I'm guessing that you want the output of the
inferior.
Dealing with the streams of the inferior will
be tricky. For Linux, we use a PTY
and GDB automatically writes all the output to that PTY, we
don't have any access
to it. You will have to not use a PTY I guess, but
this has some annoying
side effects where the program output can be confused for
GDB output.
You can look at MIInferiorProcess. If the PTY param
to the constructor is
not null, we use a PTY, if it is null we use the
OutputStream param.
Marc
From: sprigogin@xxxxxxxxxx
[mailto:sprigogin@xxxxxxxxxx] On Behalf Of Sergey
Prigogin Sent: Tuesday, November 01, 2011 12:39 PM To: CDT
General developers list.; Marc Khouzam Subject: Re: [cdt-dev] Debug
support in C/C++ Unit Testing Plugin
Re-sending
with corrected Marc's email address.
On
Tue, Nov 1, 2011 at 12:58 AM, xgsa <xgsa@xxxxxxxxx>
wrote:
Should
I call getDelegate().launch(...) in the launch() method of
my delegate or should I provide my delegate in another way (currently I just
use the extension point
org.eclipse.debug.core.launchDelegates)?
Yes.
To
modify launch configuration I should copy it before, am I right? And then I
should pass this modified copy to the CDT delegate, right?
Yes.
But
all listed above gives me ability to pass custom program arguments. Have you
any advices about streams handling?
I'm not sure about that. Marc can you chime in?
-sergey
-------- Original message
--------
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:
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?