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 256771 - Script breakpoint not hit in the remote attach case
Summary: Script breakpoint not hit in the remote attach case
Status: RESOLVED FIXED
Alias: None
Product: javascript
Classification: Unclassified
Component: Debugger (show other bugs)
Version: 8.1
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Martin Entlicher
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-25 06:55 UTC by sundararajana
Modified: 2015-12-03 02:23 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description sundararajana 2015-11-25 06:55:08 UTC
Please see http://mail.openjdk.java.net/pipermail/nashorn-dev/2015-November/005621.html

--- my email above is reproduced here ----------

I used NetBeans 8.0.2 and jdk 8 update 65 on Windows 7.  I think I managed to reproduce the issue you described.
Steps I used are as follows:

1) create a new NB project called "script_sample" with one Main.java in it as source:

import javax.script.*;

public class Main {
   public static void main(String[] args) throws Exception {
       ScriptEngineManager m = new ScriptEngineManager();
       ScriptEngine e = m.getEngineByName("nashorn");
       e.eval("load(\"" + args[0] + "\")");
       System.out.println("press any key to continue..");
       System.in.read();
       e.eval("load(\"" + args[0] + "\")");
   }
}

2) "clean and build" the NB project

3) create a simple script test.js with the following content (outside the NB project)

print("in test.js script");
var x = 33;
x++;
print(x);

3) in a command line shell (I used cygwin), start the java process with debugger server on - but not suspended at the start:

     java -cp script_sample/dist/script_sample.jar -agentlib:jdwp=server=y,suspend=n,transport=dt_socket Main test.js

The last command runs code up to the point of System.in.read call in Main.java

4) In NetBeans, open the test script file "test.js" and set breakpoint @ "print" call.

5) In NetBeans, use "Debug->Attach Debugger..." menu and specify the socket port printed by step (3)

5) enter a value for System.in.read() in command line shell.

6) No breakpoint hit @ test.js

But, if step (3) was modified to suspend process at start for debugger attach:

     java -cp script_sample/dist/script_sample.jar -agentlib:jdwp=server=y,suspend=y,transport=dt_socket Main test.js

The breakpoint in test.js enters (twice) once for each "load("test.js")" call.

So, there seems to be a bug somewhere (in NetBeans?). That said, there seems to be a simple workaround for this issue.
Within NB, set a breakpoint in Main.java (in addition to breakpoint in test.js) at second eval call  (line 10).  breakpoint is hit in Main.java.
At that point, keep hitting "Step Into" (F7) menu. It eventually lands in test.js -- and stops at the breakpoint in script!

----------- email ends here --------------------------
Comment 1 sundararajana 2015-11-25 06:55:43 UTC
I tried the same with NetBeans 8.1 as well. Same result.
Comment 2 Martin Entlicher 2015-11-27 13:52:05 UTC
Reproduced.
Comment 3 Martin Entlicher 2015-12-01 12:37:45 UTC
Fixed by changeset:   294216:fea243944a8d
http://hg.netbeans.org/core-main/rev/fea243944a8d
Comment 4 Quality Engineering 2015-12-03 02:23:51 UTC
Integrated into 'main-silver', will be available in build *201512030002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/fea243944a8d
User: mentlicher@netbeans.org
Log: #256771: Retrieve existing scripts that may have been loaded before debugger was attached.