Skip to content

Commit ff76620

Browse files
committed
8282641: Make jdb "threadgroup" command with no args reset the current threadgroup back to the default
Reviewed-by: kevinw, amenkov
1 parent 70318e1 commit ff76620

File tree

5 files changed

+26
-14
lines changed

5 files changed

+26
-14
lines changed

src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/Commands.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -501,7 +501,7 @@ void commandThread(StringTokenizer t) {
501501

502502
void commandThreadGroup(StringTokenizer t) {
503503
if (!t.hasMoreTokens()) {
504-
MessageOutput.println("Threadgroup name not specified.");
504+
ThreadInfo.setThreadGroup(null); // reset to default (top level ThreadGroup)
505505
return;
506506
}
507507
String name = t.nextToken();

src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -312,7 +312,6 @@ public Object[][] getContents() {
312312
{"Thread has been resumed", "Thread has been resumed"},
313313
{"Thread not suspended", "Thread not suspended"},
314314
{"thread group number description name", "{0,number,integer}. {1} {2}"},
315-
{"Threadgroup name not specified.", "Threadgroup name not specified."},
316315
{"<thread_id> option not valid until the VM is started with the run command",
317316
"<thread_id> option not valid until the VM is started with the run command"},
318317
{"Threads must be suspended", "Threads must be suspended"},
@@ -354,7 +353,7 @@ public Object[][] getContents() {
354353
"\n" +
355354
"run [class [args]] -- start execution of application's main class\n" +
356355
"\n" +
357-
"threads [threadgroup] -- list threads\n" +
356+
"threads [threadgroup] -- list threads in threadgroup. Use current threadgroup if none specified.\n" +
358357
"thread <thread id> -- set default thread\n" +
359358
"suspend [thread id(s)] -- suspend threads (default: all)\n" +
360359
"resume [thread id(s)] -- resume threads (default: all)\n" +
@@ -377,7 +376,8 @@ public Object[][] getContents() {
377376
"fields <class id> -- list a class's fields\n" +
378377
"\n" +
379378
"threadgroups -- list threadgroups\n" +
380-
"threadgroup <name> -- set current threadgroup\n" +
379+
"threadgroup <name> -- set current threadgroup to <name>\n" +
380+
"threadgroup -- set current threadgroup back to the top level threadgroup\n" +
381381
"\n" +
382382
"stop [go|thread] [<thread_id>] <at|in> <location>\n" +
383383
" -- set a breakpoint\n" +

src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_ja.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -302,7 +302,6 @@ public Object[][] getContents() {
302302
{"Thread has been resumed", "\u30B9\u30EC\u30C3\u30C9\u304C\u518D\u958B\u3057\u307E\u3057\u305F"},
303303
{"Thread not suspended", "\u30B9\u30EC\u30C3\u30C9\u306F\u4E2D\u65AD\u3057\u3066\u3044\u307E\u305B\u3093"},
304304
{"thread group number description name", "{0,number,integer}. {1} {2}"},
305-
{"Threadgroup name not specified.", "\u30B9\u30EC\u30C3\u30C9\u30B0\u30EB\u30FC\u30D7\u540D\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002"},
306305
{"<thread_id> option not valid until the VM is started with the run command",
307306
"<thread_id>\u30AA\u30D7\u30B7\u30E7\u30F3\u306F\u3001VM\u304Crun\u30B3\u30DE\u30F3\u30C9\u3067\u958B\u59CB\u3055\u308C\u308B\u307E\u3067\u7121\u52B9\u3067\u3059"},
308307
{"Threads must be suspended", "\u30B9\u30EC\u30C3\u30C9\u3092\u4E2D\u65AD\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059"},

src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_zh_CN.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -302,7 +302,6 @@ public Object[][] getContents() {
302302
{"Thread has been resumed", "\u5DF2\u6062\u590D\u7EBF\u7A0B"},
303303
{"Thread not suspended", "\u672A\u6302\u8D77\u7EBF\u7A0B"},
304304
{"thread group number description name", "{0,number,integer}\u3002{1} {2}"},
305-
{"Threadgroup name not specified.", "\u672A\u6307\u5B9A\u7EBF\u7A0B\u7EC4\u540D\u3002"},
306305
{"<thread_id> option not valid until the VM is started with the run command",
307306
"\u5728\u4F7F\u7528 run \u547D\u4EE4\u542F\u52A8 VM \u524D\uFF0C<thread_id> \u9009\u9879\u65E0\u6548"},
308307
{"Threads must be suspended", "\u5FC5\u987B\u6302\u8D77\u7EBF\u7A0B"},

test/hotspot/jtreg/vmTestbase/nsk/jdb/threadgroup/threadgroup002/threadgroup002.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -29,11 +29,15 @@
2929
* VM Testbase keywords: [jpda, jdb]
3030
* VM Testbase readme:
3131
* DECSRIPTION
32-
* This is a test for jdb 'threadgroup <threadgroup_name>' command.
32+
* This is a test for jdb 'threadgroup <threadgroup_name>' command and
33+
* also for the 'threadgroup' command with no argument.
3334
* The main thread creates 3 threadgroups of 5 threads each.
3435
* All threads are locked in their 'run' method on a lock that the main
35-
* thread holds. The test passes if jdb correctly switches between
36-
* three user-defined threadgroups using 'threadgroup' command.
36+
* thread holds. The test then makes sure jdb correctly switches between
37+
* the three user-defined threadgroups using 'threadgroup' command. It then
38+
* resets the current threadgroup back to the default top level threadgroup
39+
* by using the 'threadgroup' command with no argument. It then tests that
40+
* all 3 created threadgroups can be found in the 'threads' output.
3741
* COMMENTS
3842
* This test functionally equals to nsk/jdb/threadgroup/threadgroup001
3943
* test and replaces it.
@@ -45,6 +49,7 @@
4549
* nsk.jdb.threadgroup.threadgroup002.threadgroup002
4650
* -arch=${os.family}-${os.simpleArch}
4751
* -waittime=5
52+
* -verbose
4853
* -debugee.vmkind=java
4954
* -transport.address=dynamic
5055
* -jdb=${test.jdk}/bin/jdb
@@ -100,6 +105,15 @@ protected void runCases() {
100105
}
101106
}
102107

108+
// Test switching back to the default top level group.
109+
reply = jdb.receiveReplyFor(JdbCommand.threadgroup);
110+
reply = jdb.receiveReplyFor(JdbCommand.threads);
111+
grep = new Paragrep(reply);
112+
count = grep.find(threadgroup002a.THREADGROUP_NAME);
113+
if (count != threadgroup002a.numThreadGroups) {
114+
failure("jdb cannot switch to default top level threadgroup");
115+
}
116+
103117
jdb.contToExit(1);
104118
}
105119
}

0 commit comments

Comments
 (0)