Discussion:
RFR JDK-8211292: [TEST] convert com/sun/jdi/DeferredStepTest.sh test
Alex Menkov
2018-10-04 00:49:26 UTC
Permalink
Hi all,

please review a fix for
https://bugs.openjdk.java.net/browse/JDK-8211292
webrev:
http://cr.openjdk.java.net/~amenkov/sh2java/DeferredStep_final/webrev/

The fix converts manual shell test to automatic java (as Java allows to
parse jdb replies much easier).
This is the last sub-task for the "shell to java conversion" task, so
the fix also removes shared shell scripts.

--alex
s***@oracle.com
2018-10-04 20:56:57 UTC
Permalink
Hi Alex,

Several minor suggestions.

77 new Thread(aRP, "jj1").start();
78 new Thread(asRP, "jj2").start(); What mean aRP and asRP? In fact, it
is confusing. Can they be renamed to something like obj1 and obj2.

79 // new Thread(aRP, "jj3").start();
80 // new Thread(asRP, "jj4").start();

 These lines can be removed.

94 // line of the last stop
95 int lastLine = -1;
96 // min line (-1 means "not known yet")
97 int minLine = -1;
98 // max line (-1 means "not known yet")
99 int maxLine = -1; ... 140 // the 1st stop in the thread
141 break;

  I'd suggest the refactor above as below:

int lastLine = -1; // line of the last stop
int minLine = -1; // min line (-1 means "not known yet")
int maxLine = -1;// max line (-1 means "not known yet")
...
break; // the 1st stop in the thread

116 private void next() {
117 List<String> reply = jdb.command(JdbCommand.next());
118 /* each "next" produces something like ("Breakpoint hit" line only
if the line has BP)
119 Step completed:
120 Breakpoint hit: "thread=jj2", DeferredStepTestTarg$jj2.run(),
line=74 bci=12
121 74 ++count2; // @2 breakpoint
122 <empty line>
123 jj2[1]
124 */ It would better to have it in this style: 118 /* * Each "next"
produces something like ("Breakpoint hit" line only if the line has BP).
119 * Step completed:
120 * Breakpoint hit: "thread=jj2", DeferredStepTestTarg$jj2.run(),
line=74 bci=12
121 * 74 ++count2; // @2 breakpoint
122 * <empty line>
123 * jj2[1]
124 */


Otherwise, it looks Okay to me.


Thanks,
Serguei
Post by Alex Menkov
Hi all,
please review a fix for
https://bugs.openjdk.java.net/browse/JDK-8211292
http://cr.openjdk.java.net/~amenkov/sh2java/DeferredStep_final/webrev/
The fix converts manual shell test to automatic java (as Java allows
to parse jdb replies much easier).
This is the last sub-task for the "shell to java conversion" task, so
the fix also removes shared shell scripts.
--alex
Alex Menkov
2018-10-04 23:11:00 UTC
Permalink
Hi Serguei,

Updated webrev:
http://cr.openjdk.java.net/~amenkov/sh2java/DeferredStep_final/webrev.02/

Fixed all issues except
140 // the 1st stop in the thread
141 break;
In this case the comment is an explanation why we reach the block, not
an explanation for the "break" statement.

--alex
Post by s***@oracle.com
Hi Alex,
Several minor suggestions.
77 new Thread(aRP, "jj1").start();
78 new Thread(asRP, "jj2").start(); What mean aRP and asRP? In fact, it
is confusing. Can they be renamed to something like obj1 and obj2.
79 // new Thread(aRP, "jj3").start();
80 // new Thread(asRP, "jj4").start();
 These lines can be removed.
94 // line of the last stop
95 int lastLine = -1;
96 // min line (-1 means "not known yet")
97 int minLine = -1;
98 // max line (-1 means "not known yet")
99 int maxLine = -1; ... 140 // the 1st stop in the thread
141 break;
int lastLine = -1; // line of the last stop
int minLine = -1; // min line (-1 means "not known yet")
int maxLine = -1;// max line (-1 means "not known yet")
...
break; // the 1st stop in the thread
116 private void next() {
117 List<String> reply = jdb.command(JdbCommand.next());
118 /* each "next" produces something like ("Breakpoint hit" line only
if the line has BP)
120 Breakpoint hit: "thread=jj2", DeferredStepTestTarg$jj2.run(),
line=74 bci=12
122 <empty line>
123 jj2[1]
124 */ It would better to have it in this style: 118 /* * Each "next"
produces something like ("Breakpoint hit" line only if the line has BP).
120 * Breakpoint hit: "thread=jj2", DeferredStepTestTarg$jj2.run(),
line=74 bci=12
122 * <empty line>
123 * jj2[1]
124 */
Otherwise, it looks Okay to me.
Thanks,
Serguei
Post by Alex Menkov
Hi all,
please review a fix for
https://bugs.openjdk.java.net/browse/JDK-8211292
http://cr.openjdk.java.net/~amenkov/sh2java/DeferredStep_final/webrev/
The fix converts manual shell test to automatic java (as Java allows
to parse jdb replies much easier).
This is the last sub-task for the "shell to java conversion" task, so
the fix also removes shared shell scripts.
--alex
s***@oracle.com
2018-10-05 01:31:05 UTC
Permalink
Hi Alex,

It looks good to me.
Could you, please, also remove the line? :

156 //

No need in new webrev.

Thanks,
Serguei
Post by Alex Menkov
Hi Serguei,
http://cr.openjdk.java.net/~amenkov/sh2java/DeferredStep_final/webrev.02/
Fixed all issues except
 140                 // the 1st stop in the thread
 141                 break;
In this case the comment is an explanation why we reach the block, not
an explanation for the "break" statement.
--alex
Post by s***@oracle.com
Hi Alex,
Several minor suggestions.
77 new Thread(aRP, "jj1").start();
78 new Thread(asRP, "jj2").start(); What mean aRP and asRP? In fact,
it is confusing. Can they be renamed to something like obj1 and obj2.
79 // new Thread(aRP, "jj3").start();
80 // new Thread(asRP, "jj4").start();
  These lines can be removed.
94 // line of the last stop
95 int lastLine = -1;
96 // min line (-1 means "not known yet")
97 int minLine = -1;
98 // max line (-1 means "not known yet")
99 int maxLine = -1; ... 140 // the 1st stop in the thread
141 break;
int lastLine = -1;  // line of the last stop
int minLine = -1;  // min line (-1 means "not known yet")
int maxLine = -1;// max line (-1 means "not known yet")
  ...
break;  // the 1st stop in the thread
116 private void next() {
117 List<String> reply = jdb.command(JdbCommand.next());
118 /* each "next" produces something like ("Breakpoint hit" line
only if the line has BP)
120 Breakpoint hit: "thread=jj2", DeferredStepTestTarg$jj2.run(),
line=74 bci=12
122 <empty line>
123 jj2[1]
124 */ It would better to have it in this style: 118 /* * Each "next"
produces something like ("Breakpoint hit" line only if the line has BP).
120 * Breakpoint hit: "thread=jj2", DeferredStepTestTarg$jj2.run(),
line=74 bci=12
122 * <empty line>
123 * jj2[1]
124 */
Otherwise, it looks Okay to me.
Thanks,
Serguei
Post by Alex Menkov
Hi all,
please review a fix for
https://bugs.openjdk.java.net/browse/JDK-8211292
http://cr.openjdk.java.net/~amenkov/sh2java/DeferredStep_final/webrev/
The fix converts manual shell test to automatic java (as Java allows
to parse jdb replies much easier).
This is the last sub-task for the "shell to java conversion" task,
so the fix also removes shared shell scripts.
--alex
JC Beyler
2018-10-05 17:34:55 UTC
Permalink
Hi Alex,

One question and a comment on this:
- I thought HashMap was not thread safe so I think you need to synchronize
the access to the map threadData

- I think your test code could be simplified if you moved it into a helper
method (not tested but just for example):

+ private void next() {
+ List<String> reply = jdb.command(JdbCommand.next());
+ /*
+ * Each "next" produces something like ("Breakpoint hit" line only
if the line has BP)
+ * Step completed:
+ * Breakpoint hit: "thread=jj2",
DeferredStepTestTarg$jj2.run(), line=74 bci=12
+ * 74 ++count2;
// @2 breakpoint
+ * <empty line>
+ * jj2[1]
+ */
+ // detect thread from the last line
+ String lastLine = reply.get(reply.size() - 1);
+ String threadName = parse(threadRegexp, lastLine);
+ String wholeReply =
reply.stream().collect(Collectors.joining(Utils.NEW_LINE));
+ int lineNum = Integer.parseInt(parse(lineRegexp, wholeReply));
+
+ System.out.println("got: thread=" + threadName + ", line=" +
lineNum);
+
+ ThreadData data = threadData.get(threadName);
+ if (data == null) {
+ data = new ThreadData();
+ threadData.put(threadName, data);
+ }
+ processNewData(data, threadName, lineNum);
+ data.lastLine = lineNum;
+ }
+
+ private void processNewData(ThreadData data, String threadName, int
lineNum) {
+ if (data.lastLine < 0) {
+ // the 1st stop in the thread
+ return;
+ }
+
+ if (lineNum == data.lastLine + 1) {
+ // expected.
+ return;
+ }
+
+ if (lineNum < data.lastLine) {
+ // looks like step to the beginning of the cycle
+ if (data.minLine > 0) {
+ // minLine and maxLine are not set - verify
+ Asserts.assertEquals(lineNum, data.minLine, threadName + "
- minLine");
+ Asserts.assertEquals(data.lastLine, data.maxLine,
threadName + " - maxLine");
+ } else {
+ // set minLine/maxLine
+ data.minLine = lineNum;
+ data.maxLine = data.lastLine;
+ }
+ return;
+ }
+
+ throw new RuntimeException(threadName + " (line " + lineNum + ") -
unexpected."
+ + " lastLine=" + data.lastLine + ", minLine=" + data.minLine +
", maxLine=" + data.maxLine);
+ }

Thanks,
Jc
Post by s***@oracle.com
Hi Alex,
It looks good to me.
156 //
No need in new webrev.
Thanks,
Serguei
Post by Alex Menkov
Hi Serguei,
http://cr.openjdk.java.net/~amenkov/sh2java/DeferredStep_final/webrev.02/
Post by Alex Menkov
Fixed all issues except
140 // the 1st stop in the thread
141 break;
In this case the comment is an explanation why we reach the block, not
an explanation for the "break" statement.
--alex
Post by s***@oracle.com
Hi Alex,
Several minor suggestions.
77 new Thread(aRP, "jj1").start();
78 new Thread(asRP, "jj2").start(); What mean aRP and asRP? In fact,
it is confusing. Can they be renamed to something like obj1 and obj2.
79 // new Thread(aRP, "jj3").start();
80 // new Thread(asRP, "jj4").start();
These lines can be removed.
94 // line of the last stop
95 int lastLine = -1;
96 // min line (-1 means "not known yet")
97 int minLine = -1;
98 // max line (-1 means "not known yet")
99 int maxLine = -1; ... 140 // the 1st stop in the thread
141 break;
int lastLine = -1; // line of the last stop
int minLine = -1; // min line (-1 means "not known yet")
int maxLine = -1;// max line (-1 means "not known yet")
...
break; // the 1st stop in the thread
116 private void next() {
117 List<String> reply = jdb.command(JdbCommand.next());
118 /* each "next" produces something like ("Breakpoint hit" line
only if the line has BP)
120 Breakpoint hit: "thread=jj2", DeferredStepTestTarg$jj2.run(),
line=74 bci=12
122 <empty line>
123 jj2[1]
124 */ It would better to have it in this style: 118 /* * Each "next"
produces something like ("Breakpoint hit" line only if the line has BP).
120 * Breakpoint hit: "thread=jj2", DeferredStepTestTarg$jj2.run(),
line=74 bci=12
122 * <empty line>
123 * jj2[1]
124 */
Otherwise, it looks Okay to me.
Thanks,
Serguei
Post by Alex Menkov
Hi all,
please review a fix for
https://bugs.openjdk.java.net/browse/JDK-8211292
http://cr.openjdk.java.net/~amenkov/sh2java/DeferredStep_final/webrev/
The fix converts manual shell test to automatic java (as Java allows
to parse jdb replies much easier).
This is the last sub-task for the "shell to java conversion" task,
so the fix also removes shared shell scripts.
--alex
--
Thanks,
Jc
Alex Menkov
2018-10-05 19:01:15 UTC
Permalink
Hi Jc,
Post by s***@oracle.com
Hi Alex,
- I thought HashMap was not thread safe so I think you need to
synchronize the access to the map threadData
The map is accessed from a single thread (main test thread which sends
jdb commands and handles jdb replies), so synchronization is not required.
Post by s***@oracle.com
- I think your test code could be simplified if you moved it into a
I suppose you don't like do/break/while(false)?
To me it's quite standard method to avoid multi-level if/then/else.
In your suggestion I don't like that processNewData() method handles
minLine/maxLine, but doesn't handle lastLine (i.e. it doesn't do all
processing). But if "data.lastLine = lineNum" is moved into the method,
we need something like do/break/while(false) in the method.

--alex
Post by s***@oracle.com
+    private void next() {
+        List<String> reply = jdb.command(JdbCommand.next());
+        /*
+         * Each "next" produces something like ("Breakpoint hit" line
only if the line has BP)
+         *     Breakpoint hit: "thread=jj2",
DeferredStepTestTarg$jj2.run(), line=74 bci=12
+         *     74                    ++count2;
+         *     <empty line>
+         *     jj2[1]
+         */
+        // detect thread from the last line
+        String lastLine = reply.get(reply.size() - 1);
+        String threadName = parse(threadRegexp, lastLine);
+        String wholeReply =
reply.stream().collect(Collectors.joining(Utils.NEW_LINE));
+        int lineNum = Integer.parseInt(parse(lineRegexp, wholeReply));
+
+        System.out.println("got: thread=" + threadName + ", line=" +
lineNum);
+
+        ThreadData data = threadData.get(threadName);
+        if (data == null) {
+            data = new ThreadData();
+            threadData.put(threadName, data);
+        }
+        processNewData(data, threadName, lineNum);
+        data.lastLine = lineNum;
+    }
+
+  private void processNewData(ThreadData data, String threadName, int
lineNum) {
+        if (data.lastLine < 0) {
+            // the 1st stop in the thread
+            return;
+        }
+
+        if (lineNum == data.lastLine + 1) {
+            // expected.
+            return;
+        }
+
+        if (lineNum < data.lastLine) {
+            // looks like step to the beginning of the cycle
+            if (data.minLine > 0) {
+               // minLine and maxLine are not set - verify
+               Asserts.assertEquals(lineNum, data.minLine, threadName +
" - minLine");
+               Asserts.assertEquals(data.lastLine, data.maxLine,
threadName + " - maxLine");
+            } else {
+                // set minLine/maxLine
+                data.minLine = lineNum;
+                data.maxLine = data.lastLine;
+           }
+           return;
+        }
+
+        throw new RuntimeException(threadName + " (line " + lineNum +
") - unexpected."
+            + " lastLine=" + data.lastLine + ", minLine=" +
data.minLine + ", maxLine=" + data.maxLine);
+ }
Thanks,
Jc
Hi Alex,
It looks good to me.
  156             //
No need in new webrev.
Thanks,
Serguei
Post by Alex Menkov
Hi Serguei,
http://cr.openjdk.java.net/~amenkov/sh2java/DeferredStep_final/webrev.02/
<http://cr.openjdk.java.net/%7Eamenkov/sh2java/DeferredStep_final/webrev.02/>
Post by Alex Menkov
Fixed all issues except
 140                 // the 1st stop in the thread
 141                 break;
In this case the comment is an explanation why we reach the
block, not
Post by Alex Menkov
an explanation for the "break" statement.
--alex
Post by s***@oracle.com
Hi Alex,
Several minor suggestions.
77 new Thread(aRP, "jj1").start();
78 new Thread(asRP, "jj2").start(); What mean aRP and asRP? In
fact,
Post by Alex Menkov
Post by s***@oracle.com
it is confusing. Can they be renamed to something like obj1 and
obj2.
Post by Alex Menkov
Post by s***@oracle.com
79 // new Thread(aRP, "jj3").start();
80 // new Thread(asRP, "jj4").start();
  These lines can be removed.
94 // line of the last stop
95 int lastLine = -1;
96 // min line (-1 means "not known yet")
97 int minLine = -1;
98 // max line (-1 means "not known yet")
99 int maxLine = -1; ... 140 // the 1st stop in the thread
141 break;
int lastLine = -1;  // line of the last stop
int minLine = -1;  // min line (-1 means "not known yet")
int maxLine = -1;// max line (-1 means "not known yet")
  ...
break;  // the 1st stop in the thread
116 private void next() {
117 List<String> reply = jdb.command(JdbCommand.next());
118 /* each "next" produces something like ("Breakpoint hit" line
only if the line has BP)
120 Breakpoint hit: "thread=jj2", DeferredStepTestTarg$jj2.run(),
line=74 bci=12
122 <empty line>
123 jj2[1]
124 */ It would better to have it in this style: 118 /* * Each
"next"
Post by Alex Menkov
Post by s***@oracle.com
produces something like ("Breakpoint hit" line only if the line
has BP).
Post by Alex Menkov
Post by s***@oracle.com
120 * Breakpoint hit: "thread=jj2", DeferredStepTestTarg$jj2.run(),
line=74 bci=12
122 * <empty line>
123 * jj2[1]
124 */
Otherwise, it looks Okay to me.
Thanks,
Serguei
Post by Alex Menkov
Hi all,
please review a fix for
https://bugs.openjdk.java.net/browse/JDK-8211292
http://cr.openjdk.java.net/~amenkov/sh2java/DeferredStep_final/webrev/
<http://cr.openjdk.java.net/%7Eamenkov/sh2java/DeferredStep_final/webrev/>
Post by Alex Menkov
Post by s***@oracle.com
Post by Alex Menkov
The fix converts manual shell test to automatic java (as Java
allows
Post by Alex Menkov
Post by s***@oracle.com
Post by Alex Menkov
to parse jdb replies much easier).
This is the last sub-task for the "shell to java conversion" task,
so the fix also removes shared shell scripts.
--alex
--
Thanks,
Jc
JC Beyler
2018-10-05 19:10:50 UTC
Permalink
You're right for the single threaded part; I misread that part and thought
it would be multi-threaded as well. And fair enough for the keeping it then
as a do..while(false); it just took me a while to figure out what was being
done. You could put the data.lastLine in a local variable and update it at
the start of the method (only using the local version for the rest of the
method); then everything would be in there. But, I'll still say it is a
more a question of style :)

LGTM,
Jc
Post by Alex Menkov
Hi Jc,
Post by s***@oracle.com
Hi Alex,
- I thought HashMap was not thread safe so I think you need to
synchronize the access to the map threadData
The map is accessed from a single thread (main test thread which sends
jdb commands and handles jdb replies), so synchronization is not required.
Post by s***@oracle.com
- I think your test code could be simplified if you moved it into a
I suppose you don't like do/break/while(false)?
To me it's quite standard method to avoid multi-level if/then/else.
In your suggestion I don't like that processNewData() method handles
minLine/maxLine, but doesn't handle lastLine (i.e. it doesn't do all
processing). But if "data.lastLine = lineNum" is moved into the method,
we need something like do/break/while(false) in the method.
--alex
Post by s***@oracle.com
+ private void next() {
+ List<String> reply = jdb.command(JdbCommand.next());
+ /*
+ * Each "next" produces something like ("Breakpoint hit" line
only if the line has BP)
+ * Breakpoint hit: "thread=jj2",
DeferredStepTestTarg$jj2.run(), line=74 bci=12
+ * 74 ++count2;
+ * <empty line>
+ * jj2[1]
+ */
+ // detect thread from the last line
+ String lastLine = reply.get(reply.size() - 1);
+ String threadName = parse(threadRegexp, lastLine);
+ String wholeReply =
reply.stream().collect(Collectors.joining(Utils.NEW_LINE));
+ int lineNum = Integer.parseInt(parse(lineRegexp, wholeReply));
+
+ System.out.println("got: thread=" + threadName + ", line=" +
lineNum);
+
+ ThreadData data = threadData.get(threadName);
+ if (data == null) {
+ data = new ThreadData();
+ threadData.put(threadName, data);
+ }
+ processNewData(data, threadName, lineNum);
+ data.lastLine = lineNum;
+ }
+
+ private void processNewData(ThreadData data, String threadName, int
lineNum) {
+ if (data.lastLine < 0) {
+ // the 1st stop in the thread
+ return;
+ }
+
+ if (lineNum == data.lastLine + 1) {
+ // expected.
+ return;
+ }
+
+ if (lineNum < data.lastLine) {
+ // looks like step to the beginning of the cycle
+ if (data.minLine > 0) {
+ // minLine and maxLine are not set - verify
+ Asserts.assertEquals(lineNum, data.minLine, threadName +
" - minLine");
+ Asserts.assertEquals(data.lastLine, data.maxLine,
threadName + " - maxLine");
+ } else {
+ // set minLine/maxLine
+ data.minLine = lineNum;
+ data.maxLine = data.lastLine;
+ }
+ return;
+ }
+
+ throw new RuntimeException(threadName + " (line " + lineNum +
") - unexpected."
+ + " lastLine=" + data.lastLine + ", minLine=" +
data.minLine + ", maxLine=" + data.maxLine);
+ }
Thanks,
Jc
Hi Alex,
It looks good to me.
156 //
No need in new webrev.
Thanks,
Serguei
Post by Alex Menkov
Hi Serguei,
http://cr.openjdk.java.net/~amenkov/sh2java/DeferredStep_final/webrev.02/
Post by s***@oracle.com
<
http://cr.openjdk.java.net/%7Eamenkov/sh2java/DeferredStep_final/webrev.02/
Post by s***@oracle.com
Post by Alex Menkov
Fixed all issues except
140 // the 1st stop in the thread
141 break;
In this case the comment is an explanation why we reach the
block, not
Post by Alex Menkov
an explanation for the "break" statement.
--alex
Post by s***@oracle.com
Hi Alex,
Several minor suggestions.
77 new Thread(aRP, "jj1").start();
78 new Thread(asRP, "jj2").start(); What mean aRP and asRP? In
fact,
Post by Alex Menkov
Post by s***@oracle.com
it is confusing. Can they be renamed to something like obj1 and
obj2.
Post by Alex Menkov
Post by s***@oracle.com
79 // new Thread(aRP, "jj3").start();
80 // new Thread(asRP, "jj4").start();
These lines can be removed.
94 // line of the last stop
95 int lastLine = -1;
96 // min line (-1 means "not known yet")
97 int minLine = -1;
98 // max line (-1 means "not known yet")
99 int maxLine = -1; ... 140 // the 1st stop in the thread
141 break;
int lastLine = -1; // line of the last stop
int minLine = -1; // min line (-1 means "not known yet")
int maxLine = -1;// max line (-1 means "not known yet")
...
break; // the 1st stop in the thread
116 private void next() {
117 List<String> reply = jdb.command(JdbCommand.next());
118 /* each "next" produces something like ("Breakpoint hit" line
only if the line has BP)
120 Breakpoint hit: "thread=jj2", DeferredStepTestTarg$jj2.run(),
line=74 bci=12
122 <empty line>
123 jj2[1]
124 */ It would better to have it in this style: 118 /* * Each
"next"
Post by Alex Menkov
Post by s***@oracle.com
produces something like ("Breakpoint hit" line only if the line
has BP).
Post by Alex Menkov
Post by s***@oracle.com
120 * Breakpoint hit: "thread=jj2",
DeferredStepTestTarg$jj2.run(),
Post by s***@oracle.com
Post by Alex Menkov
Post by s***@oracle.com
line=74 bci=12
122 * <empty line>
123 * jj2[1]
124 */
Otherwise, it looks Okay to me.
Thanks,
Serguei
Post by Alex Menkov
Hi all,
please review a fix for
https://bugs.openjdk.java.net/browse/JDK-8211292
http://cr.openjdk.java.net/~amenkov/sh2java/DeferredStep_final/webrev/
Post by s***@oracle.com
<
http://cr.openjdk.java.net/%7Eamenkov/sh2java/DeferredStep_final/webrev/>
Post by s***@oracle.com
Post by Alex Menkov
Post by s***@oracle.com
Post by Alex Menkov
The fix converts manual shell test to automatic java (as Java
allows
Post by Alex Menkov
Post by s***@oracle.com
Post by Alex Menkov
to parse jdb replies much easier).
This is the last sub-task for the "shell to java conversion"
task,
Post by s***@oracle.com
Post by Alex Menkov
Post by s***@oracle.com
Post by Alex Menkov
so the fix also removes shared shell scripts.
--alex
--
Thanks,
Jc
--
Thanks,
Jc
s***@oracle.com
2018-10-05 19:37:29 UTC
Permalink
In general, like the suggestion from Jc with the correction for lastLine
to be a local.
But leave it up to Alex to decide what is better as changes would
require another round of testing.

Thanks,
Serguei
Post by JC Beyler
You're right for the single threaded part; I misread that part and
thought it would be multi-threaded as well. And fair enough for the
keeping it then as a do..while(false); it just took me a while to
figure out what was being done. You could put the data.lastLine in a
local variable and update it at the start of the method (only using
the local version for the rest of the method); then everything would
be in there. But, I'll still say it is a more a question of style :)
LGTM,
Jc
Hi Jc,
Post by s***@oracle.com
Hi Alex,
- I thought HashMap was not thread safe so I think you need to
synchronize the access to the map threadData
The map is accessed from a single thread (main test thread which sends
jdb commands and handles jdb replies), so synchronization is not required.
Post by s***@oracle.com
- I think your test code could be simplified if you moved it into a
I suppose you don't like do/break/while(false)?
To me it's quite standard method to avoid multi-level if/then/else.
In your suggestion I don't like that processNewData() method handles
minLine/maxLine, but doesn't handle lastLine (i.e. it doesn't do all
processing). But if "data.lastLine = lineNum" is moved into the method,
we need something like do/break/while(false) in the method.
--alex
Post by s***@oracle.com
+    private void next() {
+        List<String> reply = jdb.command(JdbCommand.next());
+        /*
+         * Each "next" produces something like ("Breakpoint
hit" line
Post by s***@oracle.com
only if the line has BP)
+         *     Breakpoint hit: "thread=jj2",
DeferredStepTestTarg$jj2.run(), line=74 bci=12
+         *     74                    ++count2;
+         *     <empty line>
+         *     jj2[1]
+         */
+        // detect thread from the last line
+        String lastLine = reply.get(reply.size() - 1);
+        String threadName = parse(threadRegexp, lastLine);
+        String wholeReply =
reply.stream().collect(Collectors.joining(Utils.NEW_LINE));
+        int lineNum = Integer.parseInt(parse(lineRegexp,
wholeReply));
Post by s***@oracle.com
+
+        System.out.println("got: thread=" + threadName + ",
line=" +
Post by s***@oracle.com
lineNum);
+
+        ThreadData data = threadData.get(threadName);
+        if (data == null) {
+            data = new ThreadData();
+            threadData.put(threadName, data);
+        }
+        processNewData(data, threadName, lineNum);
+        data.lastLine = lineNum;
+    }
+
+  private void processNewData(ThreadData data, String
threadName, int
Post by s***@oracle.com
lineNum) {
+        if (data.lastLine < 0) {
+            // the 1st stop in the thread
+            return;
+        }
+
+        if (lineNum == data.lastLine + 1) {
+            // expected.
+            return;
+        }
+
+        if (lineNum < data.lastLine) {
+            // looks like step to the beginning of the cycle
+            if (data.minLine > 0) {
+               // minLine and maxLine are not set - verify
+               Asserts.assertEquals(lineNum, data.minLine,
threadName +
Post by s***@oracle.com
" - minLine");
+               Asserts.assertEquals(data.lastLine, data.maxLine,
threadName + " - maxLine");
+            } else {
+                // set minLine/maxLine
+                data.minLine = lineNum;
+                data.maxLine = data.lastLine;
+           }
+           return;
+        }
+
+        throw new RuntimeException(threadName + " (line " +
lineNum +
Post by s***@oracle.com
") - unexpected."
+            + " lastLine=" + data.lastLine + ", minLine=" +
data.minLine + ", maxLine=" + data.maxLine);
+ }
Thanks,
Jc
     Hi Alex,
     It looks good to me.
        156             //
     No need in new webrev.
     Thanks,
     Serguei
      > Hi Serguei,
      >
      >
http://cr.openjdk.java.net/~amenkov/sh2java/DeferredStep_final/webrev.02/
<http://cr.openjdk.java.net/%7Eamenkov/sh2java/DeferredStep_final/webrev.02/>
Post by s***@oracle.com
   
 <http://cr.openjdk.java.net/%7Eamenkov/sh2java/DeferredStep_final/webrev.02/>
Post by s***@oracle.com
      >
      > Fixed all issues except
      >  140                 // the 1st stop in the thread
      >  141                 break;
      > In this case the comment is an explanation why we reach the
     block, not
      > an explanation for the "break" statement.
      >
      > --alex
      >
      >> Hi Alex,
      >>
      >> Several minor suggestions.
      >>
      >> 77 new Thread(aRP, "jj1").start();
      >> 78 new Thread(asRP, "jj2").start(); What mean aRP and
asRP? In
Post by s***@oracle.com
     fact,
      >> it is confusing. Can they be renamed to something like
obj1 and
Post by s***@oracle.com
     obj2.
      >>
      >> 79 // new Thread(aRP, "jj3").start();
      >> 80 // new Thread(asRP, "jj4").start();
      >>
      >>   These lines can be removed.
      >>
      >> 94 // line of the last stop
      >> 95 int lastLine = -1;
      >> 96 // min line (-1 means "not known yet")
      >> 97 int minLine = -1;
      >> 98 // max line (-1 means "not known yet")
      >> 99 int maxLine = -1; ... 140 // the 1st stop in the thread
      >> 141 break;
      >>
      >>
      >> int lastLine = -1;  // line of the last stop
      >> int minLine = -1;  // min line (-1 means "not known yet")
      >> int maxLine = -1;// max line (-1 means "not known yet")
      >>   ...
      >> break;  // the 1st stop in the thread
      >>
      >> 116 private void next() {
      >> 117 List<String> reply = jdb.command(JdbCommand.next());
      >> 118 /* each "next" produces something like ("Breakpoint
hit" line
Post by s***@oracle.com
      >> only if the line has BP)
      >> 120 Breakpoint hit: "thread=jj2",
DeferredStepTestTarg$jj2.run(),
Post by s***@oracle.com
      >> line=74 bci=12
      >> 122 <empty line>
      >> 123 jj2[1]
      >> 124 */ It would better to have it in this style: 118 /*
* Each
Post by s***@oracle.com
     "next"
      >> produces something like ("Breakpoint hit" line only if
the line
Post by s***@oracle.com
     has BP).
      >> 120 * Breakpoint hit: "thread=jj2",
DeferredStepTestTarg$jj2.run(),
Post by s***@oracle.com
      >> line=74 bci=12
      >> 122 * <empty line>
      >> 123 * jj2[1]
      >> 124 */
      >>
      >>
      >> Otherwise, it looks Okay to me.
      >>
      >>
      >> Thanks,
      >> Serguei
      >>
      >>> Hi all,
      >>>
      >>> please review a fix for
      >>> https://bugs.openjdk.java.net/browse/JDK-8211292
      >>>
http://cr.openjdk.java.net/~amenkov/sh2java/DeferredStep_final/webrev/
<http://cr.openjdk.java.net/%7Eamenkov/sh2java/DeferredStep_final/webrev/>
Post by s***@oracle.com
   
 <http://cr.openjdk.java.net/%7Eamenkov/sh2java/DeferredStep_final/webrev/>
Post by s***@oracle.com
      >>>
      >>> The fix converts manual shell test to automatic java
(as Java
Post by s***@oracle.com
     allows
      >>> to parse jdb replies much easier).
      >>> This is the last sub-task for the "shell to java
conversion" task,
Post by s***@oracle.com
      >>> so the fix also removes shared shell scripts.
      >>>
      >>> --alex
      >>
--
Thanks,
Jc
--
Thanks,
Jc
Alex Menkov
2018-10-05 23:53:11 UTC
Permalink
ok, this is updated webrev:
http://cr.openjdk.java.net/~amenkov/sh2java/DeferredStep_final/webrev.03/

--alex
Post by s***@oracle.com
In general, like the suggestion from Jc with the correction for lastLine
to be a local.
But leave it up to Alex to decide what is better as changes would
require another round of testing.
Thanks,
Serguei
Post by JC Beyler
You're right for the single threaded part; I misread that part and
thought it would be multi-threaded as well. And fair enough for the
keeping it then as a do..while(false); it just took me a while to
figure out what was being done. You could put the data.lastLine in a
local variable and update it at the start of the method (only using
the local version for the rest of the method); then everything would
be in there. But, I'll still say it is a more a question of style :)
LGTM,
Jc
Hi Jc,
Post by s***@oracle.com
Hi Alex,
- I thought HashMap was not thread safe so I think you need to
synchronize the access to the map threadData
The map is accessed from a single thread (main test thread which sends
jdb commands and handles jdb replies), so synchronization is not required.
Post by s***@oracle.com
- I think your test code could be simplified if you moved it into a
I suppose you don't like do/break/while(false)?
To me it's quite standard method to avoid multi-level if/then/else.
In your suggestion I don't like that processNewData() method handles
minLine/maxLine, but doesn't handle lastLine (i.e. it doesn't do all
processing). But if "data.lastLine = lineNum" is moved into the method,
we need something like do/break/while(false) in the method.
--alex
Post by s***@oracle.com
+    private void next() {
+        List<String> reply = jdb.command(JdbCommand.next());
+        /*
+         * Each "next" produces something like ("Breakpoint
hit" line
Post by s***@oracle.com
only if the line has BP)
+         *     Breakpoint hit: "thread=jj2",
DeferredStepTestTarg$jj2.run(), line=74 bci=12
+         *     74                    ++count2;
+         *     <empty line>
+         *     jj2[1]
+         */
+        // detect thread from the last line
+        String lastLine = reply.get(reply.size() - 1);
+        String threadName = parse(threadRegexp, lastLine);
+        String wholeReply =
reply.stream().collect(Collectors.joining(Utils.NEW_LINE));
+        int lineNum = Integer.parseInt(parse(lineRegexp,
wholeReply));
Post by s***@oracle.com
+
+        System.out.println("got: thread=" + threadName + ",
line=" +
Post by s***@oracle.com
lineNum);
+
+        ThreadData data = threadData.get(threadName);
+        if (data == null) {
+            data = new ThreadData();
+            threadData.put(threadName, data);
+        }
+        processNewData(data, threadName, lineNum);
+        data.lastLine = lineNum;
+    }
+
+  private void processNewData(ThreadData data, String
threadName, int
Post by s***@oracle.com
lineNum) {
+        if (data.lastLine < 0) {
+            // the 1st stop in the thread
+            return;
+        }
+
+        if (lineNum == data.lastLine + 1) {
+            // expected.
+            return;
+        }
+
+        if (lineNum < data.lastLine) {
+            // looks like step to the beginning of the cycle
+            if (data.minLine > 0) {
+               // minLine and maxLine are not set - verify
+               Asserts.assertEquals(lineNum, data.minLine,
threadName +
Post by s***@oracle.com
" - minLine");
+               Asserts.assertEquals(data.lastLine, data.maxLine,
threadName + " - maxLine");
+            } else {
+                // set minLine/maxLine
+                data.minLine = lineNum;
+                data.maxLine = data.lastLine;
+           }
+           return;
+        }
+
+        throw new RuntimeException(threadName + " (line " +
lineNum +
Post by s***@oracle.com
") - unexpected."
+            + " lastLine=" + data.lastLine + ", minLine=" +
data.minLine + ", maxLine=" + data.maxLine);
+ }
Thanks,
Jc
     Hi Alex,
     It looks good to me.
        156             //
     No need in new webrev.
     Thanks,
     Serguei
      > Hi Serguei,
      >
      >
http://cr.openjdk.java.net/~amenkov/sh2java/DeferredStep_final/webrev.02/
<http://cr.openjdk.java.net/%7Eamenkov/sh2java/DeferredStep_final/webrev.02/>
 <http://cr.openjdk.java.net/%7Eamenkov/sh2java/DeferredStep_final/webrev.02/>
Post by s***@oracle.com
      >
      > Fixed all issues except
      >  140                 // the 1st stop in the thread
      >  141                 break;
      > In this case the comment is an explanation why we reach the
     block, not
      > an explanation for the "break" statement.
      >
      > --alex
      >
      >> Hi Alex,
      >>
      >> Several minor suggestions.
      >>
      >> 77 new Thread(aRP, "jj1").start();
      >> 78 new Thread(asRP, "jj2").start(); What mean aRP and
asRP? In
Post by s***@oracle.com
     fact,
      >> it is confusing. Can they be renamed to something like
obj1 and
Post by s***@oracle.com
     obj2.
      >>
      >> 79 // new Thread(aRP, "jj3").start();
      >> 80 // new Thread(asRP, "jj4").start();
      >>
      >>   These lines can be removed.
      >>
      >> 94 // line of the last stop
      >> 95 int lastLine = -1;
      >> 96 // min line (-1 means "not known yet")
      >> 97 int minLine = -1;
      >> 98 // max line (-1 means "not known yet")
      >> 99 int maxLine = -1; ... 140 // the 1st stop in the thread
      >> 141 break;
      >>
      >>
      >> int lastLine = -1;  // line of the last stop
      >> int minLine = -1;  // min line (-1 means "not known yet")
      >> int maxLine = -1;// max line (-1 means "not known yet")
      >>   ...
      >> break;  // the 1st stop in the thread
      >>
      >> 116 private void next() {
      >> 117 List<String> reply = jdb.command(JdbCommand.next());
      >> 118 /* each "next" produces something like ("Breakpoint
hit" line
Post by s***@oracle.com
      >> only if the line has BP)
      >> 120 Breakpoint hit: "thread=jj2",
DeferredStepTestTarg$jj2.run(),
Post by s***@oracle.com
      >> line=74 bci=12
      >> 122 <empty line>
      >> 123 jj2[1]
      >> 124 */ It would better to have it in this style: 118 /*
* Each
Post by s***@oracle.com
     "next"
      >> produces something like ("Breakpoint hit" line only if
the line
Post by s***@oracle.com
     has BP).
      >> 120 * Breakpoint hit: "thread=jj2",
DeferredStepTestTarg$jj2.run(),
Post by s***@oracle.com
      >> line=74 bci=12
      >> 122 * <empty line>
      >> 123 * jj2[1]
      >> 124 */
      >>
      >>
      >> Otherwise, it looks Okay to me.
      >>
      >>
      >> Thanks,
      >> Serguei
      >>
      >>> Hi all,
      >>>
      >>> please review a fix for
      >>> https://bugs.openjdk.java.net/browse/JDK-8211292
      >>>
http://cr.openjdk.java.net/~amenkov/sh2java/DeferredStep_final/webrev/
<http://cr.openjdk.java.net/%7Eamenkov/sh2java/DeferredStep_final/webrev/>
 <http://cr.openjdk.java.net/%7Eamenkov/sh2java/DeferredStep_final/webrev/>
Post by s***@oracle.com
      >>>
      >>> The fix converts manual shell test to automatic java
(as Java
Post by s***@oracle.com
     allows
      >>> to parse jdb replies much easier).
      >>> This is the last sub-task for the "shell to java
conversion" task,
Post by s***@oracle.com
      >>> so the fix also removes shared shell scripts.
      >>>
      >>> --alex
      >>
--
Thanks,
Jc
--
Thanks,
Jc
s***@oracle.com
2018-10-06 00:00:21 UTC
Permalink
Hi Alex,

It looks good to me.
Thank you for the update.

Thanks,
Serguei
Post by Alex Menkov
http://cr.openjdk.java.net/~amenkov/sh2java/DeferredStep_final/webrev.03/
--alex
Post by s***@oracle.com
In general, like the suggestion from Jc with the correction for
lastLine to be a local.
But leave it up to Alex to decide what is better as changes would
require another round of testing.
Thanks,
Serguei
Post by JC Beyler
You're right for the single threaded part; I misread that part and
thought it would be multi-threaded as well. And fair enough for the
keeping it then as a do..while(false); it just took me a while to
figure out what was being done. You could put the data.lastLine in a
local variable and update it at the start of the method (only using
the local version for the rest of the method); then everything would
be in there. But, I'll still say it is a more a question of style :)
LGTM,
Jc
On Fri, Oct 5, 2018 at 12:01 PM Alex Menkov
    Hi Jc,
    > Hi Alex,
    >
    > - I thought HashMap was not thread safe so I think you need to
    > synchronize the access to the map threadData
    The map is accessed from a single thread (main test thread which
    sends
    jdb commands and handles jdb replies), so synchronization is not
    required.
    >
    > - I think your test code could be simplified if you moved it
into a
    I suppose you don't like do/break/while(false)?
    To me it's quite standard method to avoid multi-level if/then/else.
    In your suggestion I don't like that processNewData() method
handles
    minLine/maxLine, but doesn't handle lastLine (i.e. it doesn't do
all
    processing). But if "data.lastLine = lineNum" is moved into the
    method,
    we need something like do/break/while(false) in the method.
    --alex
    >
    > +    private void next() {
    > +        List<String> reply = jdb.command(JdbCommand.next());
    > +        /*
    > +         * Each "next" produces something like ("Breakpoint
    hit" line
    > only if the line has BP)
    > +         *     Breakpoint hit: "thread=jj2",
    > DeferredStepTestTarg$jj2.run(), line=74 bci=12
    > +         *     74                    ++count2;
    > +         *     <empty line>
    > +         *     jj2[1]
    > +         */
    > +        // detect thread from the last line
    > +        String lastLine = reply.get(reply.size() - 1);
    > +        String threadName = parse(threadRegexp, lastLine);
    > +        String wholeReply =
    > reply.stream().collect(Collectors.joining(Utils.NEW_LINE));
    > +        int lineNum = Integer.parseInt(parse(lineRegexp,
    wholeReply));
    > +
    > +        System.out.println("got: thread=" + threadName + ",
    line=" +
    > lineNum);
    > +
    > +        ThreadData data = threadData.get(threadName);
    > +        if (data == null) {
    > +            data = new ThreadData();
    > +            threadData.put(threadName, data);
    > +        }
    > +        processNewData(data, threadName, lineNum);
    > +        data.lastLine = lineNum;
    > +    }
    > +
    > +  private void processNewData(ThreadData data, String
    threadName, int
    > lineNum) {
    > +        if (data.lastLine < 0) {
    > +            // the 1st stop in the thread
    > +            return;
    > +        }
    > +
    > +        if (lineNum == data.lastLine + 1) {
    > +            // expected.
    > +            return;
    > +        }
    > +
    > +        if (lineNum < data.lastLine) {
    > +            // looks like step to the beginning of the cycle
    > +            if (data.minLine > 0) {
    > +               // minLine and maxLine are not set - verify
    > +               Asserts.assertEquals(lineNum, data.minLine,
    threadName +
    > " - minLine");
    > +               Asserts.assertEquals(data.lastLine, data.maxLine,
    > threadName + " - maxLine");
    > +            } else {
    > +                // set minLine/maxLine
    > +                data.minLine = lineNum;
    > +                data.maxLine = data.lastLine;
    > +           }
    > +           return;
    > +        }
    > +
    > +        throw new RuntimeException(threadName + " (line " +
    lineNum +
    > ") - unexpected."
    > +            + " lastLine=" + data.lastLine + ", minLine=" +
    > data.minLine + ", maxLine=" + data.maxLine);
    > + }
    >
    > Thanks,
    > Jc
    >
    >
    >
    >
    >     Hi Alex,
    >
    >     It looks good to me.
    >
    >        156             //
    >
    >     No need in new webrev.
    >
    >     Thanks,
    >     Serguei
    >
    >
    >      > Hi Serguei,
    >      >
    >      >
    >
http://cr.openjdk.java.net/~amenkov/sh2java/DeferredStep_final/webrev.02/
<http://cr.openjdk.java.net/%7Eamenkov/sh2java/DeferredStep_final/webrev.02/>
    >
 <http://cr.openjdk.java.net/%7Eamenkov/sh2java/DeferredStep_final/webrev.02/>
    >      >
    >      > Fixed all issues except
    >      >  140                 // the 1st stop in the thread
    >      >  141                 break;
    >      > In this case the comment is an explanation why we reach
the
    >     block, not
    >      > an explanation for the "break" statement.
    >      >
    >      > --alex
    >      >
    >      >> Hi Alex,
    >      >>
    >      >> Several minor suggestions.
    >      >>
    >      >> 77 new Thread(aRP, "jj1").start();
    >      >> 78 new Thread(asRP, "jj2").start(); What mean aRP and
    asRP? In
    >     fact,
    >      >> it is confusing. Can they be renamed to something like
    obj1 and
    >     obj2.
    >      >>
    >      >> 79 // new Thread(aRP, "jj3").start();
    >      >> 80 // new Thread(asRP, "jj4").start();
    >      >>
    >      >>   These lines can be removed.
    >      >>
    >      >> 94 // line of the last stop
    >      >> 95 int lastLine = -1;
    >      >> 96 // min line (-1 means "not known yet")
    >      >> 97 int minLine = -1;
    >      >> 98 // max line (-1 means "not known yet")
    >      >> 99 int maxLine = -1; ... 140 // the 1st stop in the
thread
    >      >> 141 break;
    >      >>
    >      >>
    >      >> int lastLine = -1;  // line of the last stop
    >      >> int minLine = -1;  // min line (-1 means "not known yet")
    >      >> int maxLine = -1;// max line (-1 means "not known yet")
    >      >>   ...
    >      >> break;  // the 1st stop in the thread
    >      >>
    >      >> 116 private void next() {
    >      >> 117 List<String> reply = jdb.command(JdbCommand.next());
    >      >> 118 /* each "next" produces something like ("Breakpoint
    hit" line
    >      >> only if the line has BP)
    >      >> 120 Breakpoint hit: "thread=jj2",
    DeferredStepTestTarg$jj2.run(),
    >      >> line=74 bci=12
    >      >> 122 <empty line>
    >      >> 123 jj2[1]
    >      >> 124 */ It would better to have it in this style: 118 /*
    * Each
    >     "next"
    >      >> produces something like ("Breakpoint hit" line only if
    the line
    >     has BP).
    >      >> 120 * Breakpoint hit: "thread=jj2",
    DeferredStepTestTarg$jj2.run(),
    >      >> line=74 bci=12
    >      >> 122 * <empty line>
    >      >> 123 * jj2[1]
    >      >> 124 */
    >      >>
    >      >>
    >      >> Otherwise, it looks Okay to me.
    >      >>
    >      >>
    >      >> Thanks,
    >      >> Serguei
    >      >>
    >      >>> Hi all,
    >      >>>
    >      >>> please review a fix for
    >      >>> https://bugs.openjdk.java.net/browse/JDK-8211292
    >      >>>
    >
http://cr.openjdk.java.net/~amenkov/sh2java/DeferredStep_final/webrev/
<http://cr.openjdk.java.net/%7Eamenkov/sh2java/DeferredStep_final/webrev/>
    >
 <http://cr.openjdk.java.net/%7Eamenkov/sh2java/DeferredStep_final/webrev/>
    >      >>>
    >      >>> The fix converts manual shell test to automatic java
    (as Java
    >     allows
    >      >>> to parse jdb replies much easier).
    >      >>> This is the last sub-task for the "shell to java
    conversion" task,
    >      >>> so the fix also removes shared shell scripts.
    >      >>>
    >      >>> --alex
    >      >>
    >
    >
    >
    > --
    >
    > Thanks,
    > Jc
--
Tha
JC Beyler
2018-10-06 01:19:15 UTC
Permalink
Hi Alex,

Thanks also for the update; looks great to me!
Jc
Post by s***@oracle.com
Hi Alex,
It looks good to me.
Thank you for the update.
Thanks,
Serguei
http://cr.openjdk.java.net/~amenkov/sh2java/DeferredStep_final/webrev.03/
Post by Alex Menkov
--alex
Post by s***@oracle.com
In general, like the suggestion from Jc with the correction for
lastLine to be a local.
But leave it up to Alex to decide what is better as changes would
require another round of testing.
Thanks,
Serguei
Post by JC Beyler
You're right for the single threaded part; I misread that part and
thought it would be multi-threaded as well. And fair enough for the
keeping it then as a do..while(false); it just took me a while to
figure out what was being done. You could put the data.lastLine in a
local variable and update it at the start of the method (only using
the local version for the rest of the method); then everything would
be in there. But, I'll still say it is a more a question of style :)
LGTM,
Jc
On Fri, Oct 5, 2018 at 12:01 PM Alex Menkov
Hi Jc,
Post by s***@oracle.com
Hi Alex,
- I thought HashMap was not thread safe so I think you need to
synchronize the access to the map threadData
The map is accessed from a single thread (main test thread which sends
jdb commands and handles jdb replies), so synchronization is not required.
Post by s***@oracle.com
- I think your test code could be simplified if you moved it
into a
I suppose you don't like do/break/while(false)?
To me it's quite standard method to avoid multi-level if/then/else.
In your suggestion I don't like that processNewData() method handles
minLine/maxLine, but doesn't handle lastLine (i.e. it doesn't do all
processing). But if "data.lastLine = lineNum" is moved into the method,
we need something like do/break/while(false) in the method.
--alex
Post by s***@oracle.com
+ private void next() {
+ List<String> reply = jdb.command(JdbCommand.next());
+ /*
+ * Each "next" produces something like ("Breakpoint
hit" line
Post by s***@oracle.com
only if the line has BP)
+ * Breakpoint hit: "thread=jj2",
DeferredStepTestTarg$jj2.run(), line=74 bci=12
+ * 74 ++count2;
+ * <empty line>
+ * jj2[1]
+ */
+ // detect thread from the last line
+ String lastLine = reply.get(reply.size() - 1);
+ String threadName = parse(threadRegexp, lastLine);
+ String wholeReply =
reply.stream().collect(Collectors.joining(Utils.NEW_LINE));
+ int lineNum = Integer.parseInt(parse(lineRegexp,
wholeReply));
Post by s***@oracle.com
+
+ System.out.println("got: thread=" + threadName + ",
line=" +
Post by s***@oracle.com
lineNum);
+
+ ThreadData data = threadData.get(threadName);
+ if (data == null) {
+ data = new ThreadData();
+ threadData.put(threadName, data);
+ }
+ processNewData(data, threadName, lineNum);
+ data.lastLine = lineNum;
+ }
+
+ private void processNewData(ThreadData data, String
threadName, int
Post by s***@oracle.com
lineNum) {
+ if (data.lastLine < 0) {
+ // the 1st stop in the thread
+ return;
+ }
+
+ if (lineNum == data.lastLine + 1) {
+ // expected.
+ return;
+ }
+
+ if (lineNum < data.lastLine) {
+ // looks like step to the beginning of the cycle
+ if (data.minLine > 0) {
+ // minLine and maxLine are not set - verify
+ Asserts.assertEquals(lineNum, data.minLine,
threadName +
Post by s***@oracle.com
" - minLine");
+ Asserts.assertEquals(data.lastLine, data.maxLine,
threadName + " - maxLine");
+ } else {
+ // set minLine/maxLine
+ data.minLine = lineNum;
+ data.maxLine = data.lastLine;
+ }
+ return;
+ }
+
+ throw new RuntimeException(threadName + " (line " +
lineNum +
Post by s***@oracle.com
") - unexpected."
+ + " lastLine=" + data.lastLine + ", minLine=" +
data.minLine + ", maxLine=" + data.maxLine);
+ }
Thanks,
Jc
Hi Alex,
It looks good to me.
156 //
No need in new webrev.
Thanks,
Serguei
Post by Alex Menkov
Hi Serguei,
http://cr.openjdk.java.net/~amenkov/sh2java/DeferredStep_final/webrev.02/
Post by Alex Menkov
Post by s***@oracle.com
Post by JC Beyler
<
http://cr.openjdk.java.net/%7Eamenkov/sh2java/DeferredStep_final/webrev.02/
Post by Alex Menkov
Post by s***@oracle.com
Post by JC Beyler
<
http://cr.openjdk.java.net/%7Eamenkov/sh2java/DeferredStep_final/webrev.02/
Post by Alex Menkov
Post by s***@oracle.com
Post by JC Beyler
Post by s***@oracle.com
Post by Alex Menkov
Fixed all issues except
140 // the 1st stop in the thread
141 break;
In this case the comment is an explanation why we reach
the
Post by s***@oracle.com
block, not
Post by Alex Menkov
an explanation for the "break" statement.
--alex
Post by s***@oracle.com
Hi Alex,
Several minor suggestions.
77 new Thread(aRP, "jj1").start();
78 new Thread(asRP, "jj2").start(); What mean aRP and
asRP? In
Post by s***@oracle.com
fact,
Post by Alex Menkov
Post by s***@oracle.com
it is confusing. Can they be renamed to something like
obj1 and
Post by s***@oracle.com
obj2.
Post by Alex Menkov
Post by s***@oracle.com
79 // new Thread(aRP, "jj3").start();
80 // new Thread(asRP, "jj4").start();
These lines can be removed.
94 // line of the last stop
95 int lastLine = -1;
96 // min line (-1 means "not known yet")
97 int minLine = -1;
98 // max line (-1 means "not known yet")
99 int maxLine = -1; ... 140 // the 1st stop in the
thread
Post by s***@oracle.com
Post by Alex Menkov
Post by s***@oracle.com
141 break;
int lastLine = -1; // line of the last stop
int minLine = -1; // min line (-1 means "not known yet")
int maxLine = -1;// max line (-1 means "not known yet")
...
break; // the 1st stop in the thread
116 private void next() {
117 List<String> reply = jdb.command(JdbCommand.next());
118 /* each "next" produces something like ("Breakpoint
hit" line
Post by s***@oracle.com
Post by Alex Menkov
Post by s***@oracle.com
only if the line has BP)
120 Breakpoint hit: "thread=jj2",
DeferredStepTestTarg$jj2.run(),
Post by s***@oracle.com
Post by Alex Menkov
Post by s***@oracle.com
line=74 bci=12
122 <empty line>
123 jj2[1]
124 */ It would better to have it in this style: 118 /*
* Each
Post by s***@oracle.com
"next"
Post by Alex Menkov
Post by s***@oracle.com
produces something like ("Breakpoint hit" line only if
the line
Post by s***@oracle.com
has BP).
Post by Alex Menkov
Post by s***@oracle.com
120 * Breakpoint hit: "thread=jj2",
DeferredStepTestTarg$jj2.run(),
Post by s***@oracle.com
Post by Alex Menkov
Post by s***@oracle.com
line=74 bci=12
122 * <empty line>
123 * jj2[1]
124 */
Otherwise, it looks Okay to me.
Thanks,
Serguei
Post by Alex Menkov
Hi all,
please review a fix for
https://bugs.openjdk.java.net/browse/JDK-8211292
http://cr.openjdk.java.net/~amenkov/sh2java/DeferredStep_final/webrev/
<
http://cr.openjdk.java.net/%7Eamenkov/sh2java/DeferredStep_final/webrev/>
Post by Alex Menkov
Post by s***@oracle.com
Post by JC Beyler
<
http://cr.openjdk.java.net/%7Eamenkov/sh2java/DeferredStep_final/webrev/>
Post by Alex Menkov
Post by s***@oracle.com
Post by JC Beyler
Post by s***@oracle.com
Post by Alex Menkov
Post by s***@oracle.com
Post by Alex Menkov
The fix converts manual shell test to automatic java
(as Java
Post by s***@oracle.com
allows
Post by Alex Menkov
Post by s***@oracle.com
Post by Alex Menkov
to parse jdb replies much easier).
This is the last sub-task for the "shell to java
conversion" task,
Post by s***@oracle.com
Post by Alex Menkov
Post by s***@oracle.com
Post by Alex Menkov
so the fix also removes shared shell scripts.
--alex
--
Thanks,
Jc
--
Thanks,
Jc
--
Thanks,
Jc
Loading...