Skip to content

Commit

Permalink
8309396: com/sun/jdi/JdbMethodExitTest.java fails with virtual thread…
Browse files Browse the repository at this point in the history
…s due to a bug in determining the main thread id

Reviewed-by: amenkov, sspitsyn
  • Loading branch information
plummercj committed Jun 6, 2023
1 parent 4a75fd4 commit 65bdbc7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
1 change: 0 additions & 1 deletion test/jdk/ProblemList-Virtual.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ com/sun/jdi/EATests.java#id0 8264699 generic-
#

com/sun/jdi/ExceptionEvents.java 8278470 generic-all
com/sun/jdi/JdbMethodExitTest.java 8285422 generic-all
com/sun/jdi/RedefineCrossStart.java 8278470 generic-all
com/sun/jdi/RedefineNestmateAttr/TestNestmateAttr.java 8285422 generic-all
com/sun/jdi/ReferrersTest.java 8285422 generic-all
Expand Down
14 changes: 9 additions & 5 deletions test/jdk/com/sun/jdi/JdbMethodExitTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -153,7 +153,6 @@ public static void main(String[] args) {
// a resume.

JdbMethodExitTestTarg xx = new JdbMethodExitTestTarg();
System.out.println("threadid="+Thread.currentThread().getId());
bkpt();

// test all possible return types
Expand Down Expand Up @@ -202,9 +201,14 @@ protected void runCases() {
// test all possible return types
execCommand(JdbCommand.run())
.shouldContain("Breakpoint hit");
Integer threadId = Integer.parseInt(
new OutputAnalyzer(getDebuggeeOutput())
.firstMatch("^threadid=(.*)$", 1));

// In order to find the main threadId, we need to parse a line from the "threads"
// command output that looks something like:
// (java.lang.VirtualThread)694 main running (at breakpoint)
OutputAnalyzer o = execCommand(JdbCommand.threads());
String match = o.firstMatch("^\\s*\\(.+\\)(\\d+)\\s+main\\s+running.+$", 1);
Integer threadId = Integer.parseInt(match);

jdb.command(JdbCommand.untrace());

jdb.command(JdbCommand.traceMethods(false, null));
Expand Down

1 comment on commit 65bdbc7

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.