Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions make/hotspot/lib/CompileJvm.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ ifeq ($(call isTargetOs, windows), true)
WIN_EXPORT_FILE := $(JVM_OUTPUTDIR)/win-exports.def
endif

ifeq ($(SHIP_DEBUG_SYMBOLS), public)
CFLAGS_STRIPPED_DEBUGINFO := -DHAS_STRIPPED_DEBUGINFO
endif

JVM_LDFLAGS += -def:$(WIN_EXPORT_FILE)
endif

Expand All @@ -183,6 +187,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJVM, \
CFLAGS := $(JVM_CFLAGS), \
abstract_vm_version.cpp_CXXFLAGS := $(CFLAGS_VM_VERSION), \
arguments.cpp_CXXFLAGS := $(CFLAGS_VM_VERSION), \
whitebox.cpp_CXXFLAGS := $(CFLAGS_STRIPPED_DEBUGINFO), \
DISABLED_WARNINGS_gcc := $(DISABLED_WARNINGS_gcc), \
DISABLED_WARNINGS_gcc_ad_$(HOTSPOT_TARGET_CPU_ARCH).cpp := nonnull, \
DISABLED_WARNINGS_gcc_bytecodeInterpreter.cpp := unused-label, \
Expand Down
9 changes: 9 additions & 0 deletions src/hotspot/share/prims/whitebox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,14 @@ WB_ENTRY(jboolean, WB_ConcurrentGCRunTo(JNIEnv* env, jobject o, jobject at))
return ConcurrentGCBreakpoints::run_to(c_name);
WB_END

WB_ENTRY(jboolean, WB_HasExternalSymbolsStripped(JNIEnv* env, jobject o))
#if defined(HAS_STRIPPED_DEBUGINFO)
return true;
#else
return false;
#endif
WB_END

#if INCLUDE_G1GC

WB_ENTRY(jboolean, WB_G1IsHumongous(JNIEnv* env, jobject o, jobject obj))
Expand Down Expand Up @@ -2813,6 +2821,7 @@ static JNINativeMethod methods[] = {
{CC"getVMLargePageSize", CC"()J", (void*)&WB_GetVMLargePageSize},
{CC"getHeapSpaceAlignment", CC"()J", (void*)&WB_GetHeapSpaceAlignment},
{CC"getHeapAlignment", CC"()J", (void*)&WB_GetHeapAlignment},
{CC"hasExternalSymbolsStripped", CC"()Z", (void*)&WB_HasExternalSymbolsStripped},
{CC"countAliveClasses0", CC"(Ljava/lang/String;)I", (void*)&WB_CountAliveClasses },
{CC"getSymbolRefcount", CC"(Ljava/lang/String;)I", (void*)&WB_GetSymbolRefcount },
{CC"parseCommandLine0",
Expand Down
15 changes: 12 additions & 3 deletions test/hotspot/jtreg/runtime/NMT/CheckForProperDetailStackTrace.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2025, 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 All @@ -26,11 +26,14 @@
* @bug 8133747 8218458
* @summary Running with NMT detail should produce expected stack traces.
* @library /test/lib
* @library /
* @modules java.base/jdk.internal.misc
* java.management
* @requires vm.debug
* @build jdk.test.whitebox.WhiteBox
* @compile ../modules/CompilerUtils.java
* @run driver CheckForProperDetailStackTrace
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI CheckForProperDetailStackTrace
*/

import jdk.test.lib.Platform;
Expand All @@ -40,6 +43,7 @@
import java.nio.file.Paths;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import jdk.test.whitebox.WhiteBox;

/**
* We are checking for details that should be seen with NMT detail enabled.
Expand All @@ -59,7 +63,10 @@ public class CheckForProperDetailStackTrace {
private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
private static final Path MODS_DIR = Paths.get(TEST_CLASSES, "mods");

private static final boolean expectSourceInformation = Platform.isLinux() || Platform.isWindows();
// Windows has source information only in full pdbs, not in stripped pdbs
private static boolean expectSourceInformation = Platform.isLinux() || Platform.isWindows();

static WhiteBox wb = WhiteBox.getWhiteBox();

/* The stack trace we look for by default. Note that :: has been replaced by .*
to make sure it matches even if the symbol is not unmangled.
Expand Down Expand Up @@ -138,6 +145,8 @@ public static void main(String args[]) throws Exception {
throw new RuntimeException("Expected stack trace missing from output");
}

if (wb.hasExternalSymbolsStripped()) { expectSourceInformation = false; }

System.out.println("Looking for source information:");
if (expectSourceInformation) {
if (!stackTraceMatches(".*moduleEntry.cpp.*", output)) {
Expand Down
2 changes: 2 additions & 0 deletions test/lib/jdk/test/whitebox/WhiteBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ public long getObjectAddress(Object o) {
public native long getHeapSpaceAlignment();
public native long getHeapAlignment();

public native boolean hasExternalSymbolsStripped();

private native boolean isObjectInOldGen0(Object o);
public boolean isObjectInOldGen(Object o) {
Objects.requireNonNull(o);
Expand Down