Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 197297

Summary: Problems with the process console when attaching to an agent
Product: z_Archived Reporter: amehrega
Component: TPTPAssignee: Stanislav Polevic <stanislav.v.polevic>
Status: CLOSED FIXED QA Contact:
Severity: major    
Priority: P1 CC: igor.alelekov, jkubasta, samwai, stanislav.v.polevic
Version: unspecifiedKeywords: plan
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: closed460
Attachments:
Description Flags
Add configureConsole to IProcess interface
none
Configure the console during attach
none
Initialize console in IProcess#getConsole
none
Invoke getConsole in attachAgent method
none
Provide correct Process creation/deletion from AC Java code
none
Add console listener in attach procedure none

Description amehrega CLA 2007-07-20 09:40:51 EDT
There are problems with the console when the user attaches to a detached JVMTI agent.  Follow the steps below to reproduce the problem:

- Make sure that the driver that is being used contains the fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=187744 (or the patch is manually applied)
- Launch StartStop using the JVMTI agent (execution time analysis)
- Detach from the agent
- Open the launch configuration > Create a launch configuration of type "Attach to Agent" > and attach to the detached JVMTI agent
- Notice that a console is created for the attached agent but when the user presses enter the input is not sent to the process.

Debugging this problem exposed the following exception whenever there is an input provided in the console of the attached agent:

java.lang.NullPointerException
	at org.eclipse.tptp.platform.execution.client.core.internal.ConsoleImpl.write(ConsoleImpl.java:177)
	at org.eclipse.hyades.trace.ui.internal.util.IOProxy.write(ProcessAdapter.java:299)
	at org.eclipse.debug.internal.ui.views.console.ProcessConsole$InputReadJob.run(ProcessConsole.java:685)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)


I'm marking this as major because the workaround is to switch to the console of the originally launched process to provide console input.
Comment 1 Igor Alelekov CLA 2007-09-25 03:50:48 EDT
Hi Ali,
Could you please help to clarify this?
In regular attachment to an external jvm (Profile Dialog / Attach to Agent ...), an empty inactive console windows also appears for both agents - TI and PI. Is it normal?
Comment 2 amehrega CLA 2007-09-25 11:15:27 EDT
An inactive console is not created when you attach to a process that's running with the PI agent.  You can interact with that console by entering input.  There are two inactive consoles created when the TI agent is used.  Try entering input in the console created by the attached TI agent.  Notice that user input is not processed.  Please follow the steps outlined in the original comment of the bugzilla.

(4.4.0.1 was used to test this)
Comment 3 Igor Alelekov CLA 2007-09-26 09:40:49 EDT
Thanks, now I've catched the PI-TI difference :)
Comment 4 Stanislav Polevic CLA 2007-10-15 08:00:27 EDT
Created attachment 80346 [details]
Add configureConsole to IProcess interface

The main problem is that console is not configured during attaching to the process.
Proposed patch adds new method IProcess#configureConsole() which is intended to be invoked by the client before attaching.
I'm not sure that introducing new method is the most elegant and efficient solution...
Could somebody (Igor?) review this patch?
Comment 5 Stanislav Polevic CLA 2007-10-15 08:02:05 EDT
Created attachment 80347 [details]
Configure the console during attach
Comment 6 Igor Alelekov CLA 2007-10-15 09:30:08 EDT
(In reply to comment #5)
> Created an attachment (id=80347) [details]
> Configure the console during attach

Hi Stas,
The patches are fine.
Could you please investigate if the same actions might be done without API changes?
Comment 7 Stanislav Polevic CLA 2007-10-15 10:08:48 EDT
Created attachment 80353 [details]
Initialize console in IProcess#getConsole

Better solution was found and there is no need to change public API, thanks to Igor.
Comment 8 Stanislav Polevic CLA 2007-10-15 10:10:08 EDT
Created attachment 80354 [details]
Invoke getConsole in attachAgent method
Comment 9 Igor Alelekov CLA 2007-10-15 10:13:46 EDT
(In reply to comment #8)
> Created an attachment (id=80354) [details]
> Invoke getConsole in attachAgent method

The patches look good.
Stas, have you tested them?
Comment 10 Stanislav Polevic CLA 2007-10-15 10:21:20 EDT
I tested it using described scenario.
Comment 11 Igor Alelekov CLA 2007-10-15 10:33:47 EDT
Reassigning bug to Stanislav.
Samson could you please check the patch into CVS HEAD?
Thanks, 
Igor
Comment 12 Samson Wai CLA 2007-10-15 13:24:11 EDT
Hi. I have trouble checking in "client_patch.txt". It seems that the patch is created using an older version of the source file. Please resync and generate a new patch file. Thanks.
Comment 13 Stanislav Polevic CLA 2007-10-16 10:06:19 EDT
Comment on attachment 80353 [details]
Initialize console in IProcess#getConsole

Patch is incorrect
Comment 14 Stanislav Polevic CLA 2007-10-16 10:07:07 EDT
Comment on attachment 80354 [details]
Invoke getConsole in attachAgent method

Patch is incorrect
Comment 15 Stanislav Polevic CLA 2007-10-17 04:05:53 EDT
Comment on attachment 80354 [details]
Invoke getConsole in attachAgent method

Invalid patch
Comment 16 Stanislav Polevic CLA 2007-12-10 10:48:41 EST
Created attachment 84867 [details]
Provide correct Process creation/deletion from AC Java code
Comment 17 Stanislav Polevic CLA 2007-12-10 10:50:14 EST
Created attachment 84868 [details]
Add console listener in attach procedure
Comment 18 Stanislav Polevic CLA 2007-12-10 10:51:22 EST
Igor, could you, please, review and commit the patches?
Comment 19 Stanislav Polevic CLA 2008-01-09 05:06:25 EST
Patch checked in.
Comment 20 Stanislav Polevic CLA 2008-01-21 11:03:03 EST
Updated a target.
Comment 21 Paul Slauenwhite CLA 2009-06-30 13:45:40 EDT
As of TPTP 4.6.0, TPTP is in maintenance mode and focusing on improving quality by resolving relevant enhancements/defects and increasing test coverage through test creation, automation, Build Verification Tests (BVTs), and expanded run-time execution. As part of the TPTP Bugzilla housecleaning process (see http://wiki.eclipse.org/Bugzilla_Housecleaning_Processes), this enhancement/defect is verified/closed by the Project Lead since this enhancement/defect has been resolved and unverified for more than 1 year and considered to be fixed. If this enhancement/defect is still unresolved and reproducible in the latest TPTP release (http://www.eclipse.org/tptp/home/downloads/), please re-open.
Comment 22 Paul Slauenwhite CLA 2009-06-30 13:48:06 EDT
As of TPTP 4.6.0, TPTP is in maintenance mode and focusing on improving quality by resolving relevant enhancements/defects and increasing test coverage through test creation, automation, Build Verification Tests (BVTs), and expanded run-time execution. As part of the TPTP Bugzilla housecleaning process (see http://wiki.eclipse.org/Bugzilla_Housecleaning_Processes), this enhancement/defect is verified/closed by the Project Lead since this enhancement/defect has been resolved and unverified for more than 1 year and considered to be fixed. If this enhancement/defect is still unresolved and reproducible in the latest TPTP release (http://www.eclipse.org/tptp/home/downloads/), please re-open.