This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 218311

Summary: KdpDebugTask do not attach debugger in some cases
Product: javame Reporter: alexander.burdukov
Component: -- Other --Assignee: Tomas Zezula <tzezula>
Status: CLOSED FIXED    
Severity: normal CC: mmirilovic, psomol
Priority: P2    
Version: 7.2   
Hardware: PC   
OS: Windows 7   
Issue Type: DEFECT Exception Reporter:

Description alexander.burdukov 2012-09-13 17:28:59 UTC
The problem exists in NetBeans at least starting from 7.1.1 latest nightly 7.2.x and 7.3 builds are also affected.

On slow PCs debugger did not attached, but thinks that it attached successfully.
Reproduced with ME SDK (not in this case it can be reproduced not on every PC), but can be reproduced also using following steps without any emulator:

1. Create any simple Java ME project.
2. Optionally set breakpoint somewhere
3. Open project build-impl.xml file and find "cldc-debug" target
4. In this target comment out or remove invocation of "nb-run" target 
   and set jpda.port property to value some free port.
   E.g. "cldc-debug" target after these changes will look like:
    
   <target name="cldc-debug" if="cldc-platform.trigger">
        <parallel>
            <property name="jpda.port" value="65432"/>
            <sequential>
                <sleep seconds="5"/>
                <antcall target="nbdebug"/>
            </sequential>
        </parallel>
    </target>

5. Debug the project (probably, several attempt will be required for this step to reproduce)

As the result, you will see following in the output view:

cldc-debug:
nbdebug:
KdpDebugTask connecting to debugger 1 ..
Attached JPDA debugger to localhost:65432
semc-debug-start:
semc-build-j9-debug:
semc-icon-assembly:
semc-ppro-emulator:
semc-do-run:
semc-debug:
savaje-debug:
sjmc-debug:
ojec-debug:
cdc-hi-debug:
nokiaS80-debug:
debug:
BUILD SUCCESSFUL (total time: 12 seconds)

As you can see NetBeans thinks that it successfully attached debugger, but in fact we even did not opened a port to attach the debugger.

The problem is located it least in KdpDebugTask.execute method. It uses JPDADebugger.attach method to attach debugger. If this method did not thow any exception it is assumed as the debugger is attached. This assumption is incorrect: JPDADebugger.attach returns JPDADebugger object and at least the result value of JPDADebugger.getState() method must be taken into account to detect if the debugger was really attached.
Comment 1 alexander.burdukov 2012-09-13 17:30:49 UTC
The priority is set to P2 since due to this problem debugging with ME SDK works very unstable on wide range of PCs, however, ME SDK workarounded this problem on its side in the nearest release.
Comment 2 Tomas Zezula 2013-01-14 16:21:01 UTC
Fixed jet-main e27e4ab38382
Comment 3 Petr Somol 2013-01-14 17:09:59 UTC
reviewed the patch. false debugger attachment is now prevented.
Comment 4 Quality Engineering 2013-01-15 07:29:36 UTC
Integrated into 'main-golden', will be available in build *201301150001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/e27e4ab38382
User: Tomas Zezula <tzezula@netbeans.org>
Log: #218311:KdpDebugTask do not attach debugger in some cases
Comment 5 Stepan Zebra 2013-01-15 14:42:24 UTC
verified in trunk
Comment 6 Tomas Zezula 2013-01-18 10:14:50 UTC
Integrated into NB 7.3: 5d5eccb709b2
Comment 7 Quality Engineering 2013-01-19 00:03:15 UTC
Integrated into 'releases', will be available in build *201301182100* or newer. Wait for official and publicly available build.
Changeset: http://hg.netbeans.org/releases/rev/5d5eccb709b2
User: Tomas Zezula <tzezula@netbeans.org>
Log: #218311:KdpDebugTask do not attach debugger in some cases
Comment 8 Stepan Zebra 2013-01-25 11:40:08 UTC
verified in 7.3 RC1
Comment 9 alexander.burdukov 2014-04-16 19:10:55 UTC
Verified on NB8.0. Closing.