Skip to content

Commit

Permalink
Remove printing of thread id from DiagnosticPrinter
Browse files Browse the repository at this point in the history
This removes the dependency on the GraalVM internal
`com.oracle.svm.core.posix.headers.Pthread`.

Closes quarkusio#23517

(cherry picked from commit d928f25)
  • Loading branch information
zakkak authored and gsmet committed Feb 21, 2022
1 parent 8b06e0f commit 5265620
Showing 1 changed file with 0 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,10 @@
import java.time.Instant;
import java.util.Map;

import org.graalvm.nativeimage.Platform;
import org.graalvm.nativeimage.Platforms;

import com.oracle.svm.core.annotate.Alias;
import com.oracle.svm.core.annotate.TargetClass;
import com.oracle.svm.core.posix.headers.Pthread;

/**
* A signal handler that prints diagnostic thread info to standard output.
*/
public final class DiagnosticPrinter {
@TargetClass(className = "com.oracle.svm.core.posix.thread.PosixJavaThreads")
@Platforms({ Platform.LINUX.class, Platform.DARWIN.class })
static final class Target_PosixJavaThreads {
@Alias
static native Pthread.pthread_t getPthreadIdentifier(Thread thread);

@Alias
static native boolean hasThreadIdentifier(Thread thread);
}

public static void printDiagnostics(PrintStream w) {
Map<Thread, StackTraceElement[]> allStackTraces = Thread.getAllStackTraces();
w.println(Instant.now().toString());
Expand All @@ -42,15 +25,6 @@ public static void printDiagnostics(PrintStream w) {
w.print("daemon ");
w.print("prio=");
w.print(thread.getPriority());
w.print(" tid=");
if ((Platform.includedIn(Platform.LINUX.class) || Platform.includedIn(Platform.DARWIN.class))
&& Target_PosixJavaThreads.hasThreadIdentifier(thread)) {
final long nativeId = Target_PosixJavaThreads.getPthreadIdentifier(thread).rawValue();
w.print("0x");
w.println(Long.toHexString(nativeId));
} else {
w.println("(unknown)");
}
w.print(" java.lang.thread.State: ");
w.println(thread.getState());
for (StackTraceElement element : stackTrace) {
Expand Down

0 comments on commit 5265620

Please sign in to comment.