Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 0 additions & 1 deletion compiler/mx.compiler/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,6 @@
org.graalvm.nativeimage.foreign,
org.graalvm.nativeimage.llvm,
com.oracle.svm.svm_enterprise,
com.oracle.svm.jdwp.resident,
com.oracle.svm_enterprise.ml_dataset,
org.graalvm.nativeimage.base,
org.graalvm.extraimage.builder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@
*/
package jdk.graal.compiler.core.test;

import org.graalvm.word.WordFactory;

import jdk.graal.compiler.nodes.StructuredGraph;
import jdk.graal.compiler.nodes.java.MethodCallTargetNode;
import jdk.graal.compiler.nodes.spi.CoreProviders;
import jdk.graal.compiler.phases.VerifyPhase;
import jdk.graal.compiler.word.Word;
import jdk.vm.ci.meta.ResolvedJavaType;
import org.graalvm.word.WordFactory;

/**
* Ensures that Graal compiler code uses factory methods in {@link Word} instead of
Expand All @@ -53,7 +54,7 @@ protected void verify(StructuredGraph graph, CoreProviders context) {
wordFactory.toJavaName(),
graph.method().format("%H.%n(%p)"),
Word.class.getName(),
graph.method().format("%n(%p)"));
t.targetMethod().format("%n(%p)"));

}
}
Expand Down
35 changes: 11 additions & 24 deletions docs/reference-manual/native-image/JDWP.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,25 @@ This document describes the Java Debug Wire Protocol (JDWP) debugging support fo

## Installation

The JDWP feature is not included by default as part of Native Image. To use it, you need to [build GraalVM from source](https://github.com/oracle/graal/blob/master/vm/README.md) using the following [mx](https://github.com/graalvm/mx/) commands:
The JDWP feature relies on a shared library, which is loaded only when the debugger is actively used.
This library must be built once before building native images with JDWP enabled.
```shell
mx --dynamicimports /substratevm build
export JAVA_HOME=$(mx --dynamicimports /substratevm graalvm-home)
native-image --macro:svmjdwp-library
```

> Note: This is a one-time setup step. The same library will be used for all native images built with JDWP enabled.

> Note: This library is stored in the GraalVM installation by default.
> If that directory is not writable, provide an alternative destination path with `-o <path/to/writable/directory>/libsvmjdwp`, or on Windows, use `-o <path\\to\\writable\\directory>\\svmjdwp`.

## Usage

> Note: JDWP debugging for Native Image is currently under development.

To include JDWP support in a native image, add the `--macro:svmjdwp` option to your `native-image` command:
To include JDWP support in a native image, add the `-H:+JDWP` option to your `native-image` command:

```shell
native-image --macro:svmjdwp ... -cp <class/path> YourApplication ...
native-image -H:+UnlockExperimentalVMOptions -H:+JDWP ... -cp <class/path> YourApplication ...
```

This command produces:
Expand All @@ -42,7 +47,7 @@ To launch the native image in debug mode, use the `-XX:JDWPOptions=` option, sim
./your-application -XX:JDWPOptions=transport=dt_socket,server=y,address=8000
```

> Note: Debugging requires the _image-name.metadata_ file generated at build time and the `svmjdwp` shared library in the same directory as the native executable.
> Note: Debugging requires the _image-name.metadata_ file generated at build time and the `svmjdwp` shared library in the same directory as the native executable.

For a complete list of supported JDWP options on Native Image, run:

Expand Down Expand Up @@ -72,24 +77,6 @@ Examples:

Note: If `lib:svmjdwp` cannot be found, the application will terminate with error code 1.

### Build `lib:svmjdwp`

Run `mx --native-images=lib:svmjdwp build` to build the library.

### Build a Native Executable with JDWP Support

Add the `--macro:svmjdwp` option to the `native-image` command:
```shell
mx native-image --macro:svmjdwp -cp <class/path> MainClass ...
```

To build and include `lib:svmjdwp` as a build artifact, run:
```shell
mx --native-images=lib:svmjdwp native-image --macro:svmjdwp -cp <class/path> MainClass ...
```

Both commands produce a binary, an `<image-name>.metadata` file.

## Goals and Constraints

The JDWP debugging support for Native Image aims to:
Expand Down
1 change: 1 addition & 0 deletions substratevm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This changelog summarizes major changes to GraalVM Native Image.
* (GR-52400) The build process now uses 85% of system memory in containers and CI environments. Otherwise, it tries to only use available memory. If less than 8GB of memory are available, it falls back to 85% of system memory. The reason for the selected memory limit is now also shown in the build resources section of the build output.
* (GR-59864) Added JVM version check to the Native Image agent. The agent will abort execution if the JVM major version does not match the version it was built with, and warn if the full JVM version is different.
* (GR-59135) Verify if hosted options passed to `native-image` exist prior to starting the builder. Provide suggestions how to fix unknown options early on.
* (GR-61492) The experimental JDWP option is now present in standard GraalVM builds.

## GraalVM for JDK 24 (Internal Version 24.2.0)
* (GR-59717) Added `DuringSetupAccess.registerObjectReachabilityHandler` to allow registering a callback that is executed when an object of a specified type is marked as reachable during heap scanning.
Expand Down
9 changes: 0 additions & 9 deletions substratevm/mx.substratevm/macro-svmjdwp.properties

This file was deleted.

16 changes: 1 addition & 15 deletions substratevm/mx.substratevm/mx_substratevm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1627,20 +1627,6 @@ def prevent_build_path_in_libgraal():
"-H:+PreserveFramePointer",
]

mx_sdk_vm.register_graalvm_component(mx_sdk_vm.GraalVMSvmMacro(
suite=suite,
name='SubstrateVM JDWP Debugger Resident',
short_name='svmjdwp',
dir_name="svmjdwp",
license_files=[],
third_party_license_files=[],
dependencies=['SubstrateVM'],
builder_jar_distributions=['substratevm:SVM_JDWP_COMMON', 'substratevm:SVM_JDWP_RESIDENT'],
support_distributions=['substratevm:SVM_JDWP_RESIDENT_SUPPORT'],
stability="experimental",
jlink=False,
))

libsvmjdwp_lib_config = mx_sdk_vm.LibraryConfig(
destination="<lib:svmjdwp>",
jvm_library=True,
Expand All @@ -1655,7 +1641,7 @@ def prevent_build_path_in_libgraal():
libsvmjdwp = mx_sdk_vm.GraalVmJreComponent(
suite=suite,
name='SubstrateVM JDWP Debugger',
short_name='svmjdwpserver',
short_name='svmjdwp',
dir_name="svm",
license_files=[],
third_party_license_files=[],
Expand Down
76 changes: 15 additions & 61 deletions substratevm/mx.substratevm/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,7 @@
"requires" : [
"jdk.jfr",
"jdk.management",
"java.instrument",
],
"requiresConcealed" : {
"java.base" : [
Expand All @@ -710,9 +711,6 @@
"sun.util.locale",
"sun.invoke.util",
],
"java.instrument":[
"java.lang.instrument"
],
"java.management": [
"com.sun.jmx.mbeanserver", # Needed for javadoc links (MXBeanIntrospector,DefaultMXBeanMappingFactory, MXBeanProxy)
"sun.management", # Needed for javadoc links (MappedMXBeanType)
Expand Down Expand Up @@ -1575,7 +1573,8 @@
"subDir": "src",
"sourceDirs": ["src"],
"dependencies": [
"substratevm:SVM"
"com.oracle.svm.core",
"com.oracle.graal.pointsto",
],
"requiresConcealed" : {
"jdk.internal.vm.ci" : [
Expand All @@ -1593,6 +1592,8 @@
"sourceDirs": ["src"],
"dependencies": [
"com.oracle.svm.interpreter.metadata",
"com.oracle.svm.core.graal.aarch64",
"com.oracle.svm.graal",
],
"requires" : [
"java.base"
Expand Down Expand Up @@ -1621,7 +1622,7 @@
"subDir": "src",
"sourceDirs": ["src"],
"dependencies": [
"substratevm:SVM",
"com.oracle.svm.core",
],
"requiresConcealed" : {
"jdk.internal.vm.ci" : [
Expand Down Expand Up @@ -1718,6 +1719,7 @@
"com.oracle.svm.core.posix",
"com.oracle.svm.core.windows",
"com.oracle.svm.core.genscavenge",
"com.oracle.svm.jdwp.resident",
],
"distDependencies": [
"sdk:NATIVEIMAGE",
Expand Down Expand Up @@ -1747,12 +1749,15 @@
org.graalvm.extraimage.librarysupport,
com.oracle.svm.extraimage_enterprise,
org.graalvm.nativeimage.foreign,
com.oracle.svm.jdwp.common,
com.oracle.svm.jdwp.server,
com.oracle.svm.jdwp.resident,
org.graalvm.truffle.runtime.svm,
com.oracle.truffle.enterprise.svm""",
"com.oracle.svm.hosted.c.libc to com.oracle.graal.sandbox",
"com.oracle.svm.jdwp.bridge to com.oracle.svm.jdwp.server",
"com.oracle.svm.jdwp.bridge.nativebridge to com.oracle.svm.jdwp.server",
"com.oracle.svm.jdwp.bridge.jniutils to com.oracle.svm.jdwp.server",
"com.oracle.svm.interpreter.metadata to com.oracle.svm.jdwp.server",
"com.oracle.svm.interpreter.metadata.serialization to com.oracle.svm.jdwp.server",
],
"opens" : [
"com.oracle.svm.core to jdk.graal.compiler",
Expand All @@ -1762,7 +1767,6 @@
"com.oracle.svm.hosted.fieldfolding to jdk.graal.compiler",
"com.oracle.svm.hosted.phases to jdk.graal.compiler",
"com.oracle.svm.hosted.reflect to jdk.graal.compiler",
"com.oracle.svm.core.thread to com.oracle.svm.jdwp.resident",
],
"requires": [
"java.management",
Expand Down Expand Up @@ -2229,7 +2233,7 @@
"org.graalvm.collections",
],
"exports" : [
"com.oracle.svm.util to org.graalvm.nativeimage.pointsto,org.graalvm.nativeimage.builder,org.graalvm.nativeimage.librarysupport,org.graalvm.nativeimage.driver,org.graalvm.nativeimage.llvm,org.graalvm.nativeimage.agent.jvmtibase,org.graalvm.nativeimage.agent.tracing,org.graalvm.nativeimage.agent.diagnostics,org.graalvm.nativeimage.junitsupport,com.oracle.svm.svm_enterprise,com.oracle.svm_enterprise.ml_dataset,com.oracle.svm.jdwp.resident,org.graalvm.extraimage.builder,com.oracle.svm.extraimage_enterprise,org.graalvm.extraimage.librarysupport,org.graalvm.nativeimage.foreign,org.graalvm.truffle.runtime.svm,com.oracle.truffle.enterprise.svm",
"com.oracle.svm.util to org.graalvm.nativeimage.pointsto,org.graalvm.nativeimage.builder,org.graalvm.nativeimage.librarysupport,org.graalvm.nativeimage.driver,org.graalvm.nativeimage.llvm,org.graalvm.nativeimage.agent.jvmtibase,org.graalvm.nativeimage.agent.tracing,org.graalvm.nativeimage.agent.diagnostics,org.graalvm.nativeimage.junitsupport,com.oracle.svm.svm_enterprise,com.oracle.svm_enterprise.ml_dataset,org.graalvm.extraimage.builder,com.oracle.svm.extraimage_enterprise,org.graalvm.extraimage.librarysupport,org.graalvm.nativeimage.foreign,org.graalvm.truffle.runtime.svm,com.oracle.truffle.enterprise.svm",
"com.oracle.svm.common.meta to org.graalvm.nativeimage.pointsto,org.graalvm.nativeimage.builder,org.graalvm.nativeimage.llvm,org.graalvm.extraimage.builder,org.graalvm.nativeimage.foreign,org.graalvm.truffle.runtime.svm,com.oracle.truffle.enterprise.svm",
"com.oracle.svm.common.option to org.graalvm.nativeimage.pointsto,org.graalvm.nativeimage.builder,org.graalvm.nativeimage.driver,org.graalvm.nativeimage.foreign,org.graalvm.truffle.runtime.svm,com.oracle.truffle.enterprise.svm",
],
Expand Down Expand Up @@ -2549,68 +2553,18 @@
},
},

"SVM_JDWP_COMMON": {
"subDir": "src",
"dependencies": [
"com.oracle.svm.interpreter.metadata",
"com.oracle.svm.jdwp.bridge",
],
"distDependencies": [
"SVM",
],
"moduleInfo" : {
"name" : "com.oracle.svm.jdwp.common",
"exports" : [
"com.oracle.svm.jdwp.bridge to com.oracle.svm.jdwp.server,com.oracle.svm.jdwp.resident",
"com.oracle.svm.jdwp.bridge.nativebridge to com.oracle.svm.jdwp.server,com.oracle.svm.jdwp.resident",
"com.oracle.svm.jdwp.bridge.jniutils to com.oracle.svm.jdwp.server,com.oracle.svm.jdwp.resident",
"com.oracle.svm.interpreter.metadata to com.oracle.svm.jdwp.server,com.oracle.svm.jdwp.resident",
"com.oracle.svm.interpreter.metadata.serialization to com.oracle.svm.jdwp.server,com.oracle.svm.jdwp.resident",
],
"requires" : [
"org.graalvm.collections",
],
}
},

"SVM_JDWP_RESIDENT": {
"subDir": "src",
"dependencies": [
"com.oracle.svm.jdwp.resident",
],
"distDependencies": [
"SVM_JDWP_COMMON",
"sdk:COLLECTIONS",
"compiler:GRAAL",
],
"moduleInfo" : {
"name" : "com.oracle.svm.jdwp.resident",
"exports": [
"com.oracle.svm.interpreter,com.oracle.svm.jdwp.resident to org.graalvm.nativeimage.builder",
],
}
},

"SVM_JDWP_RESIDENT_SUPPORT" : {
"native" : True,
"description" : "JDWP debugging support",
"layout" : {
"native-image.properties" : "file:mx.substratevm/macro-svmjdwp.properties",
},
},

"SVM_JDWP_SERVER": {
"subDir": "src",
"dependencies": [
"com.oracle.svm.jdwp.server",
],
"distDependencies": [
"substratevm:SVM",
"SVM_JDWP_COMMON",
],
"moduleInfo" : {
"name" : "com.oracle.svm.jdwp.server",
}
},
"maven" : False,
},

},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@

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

import com.oracle.svm.core.FunctionPointerHolder;
import com.oracle.svm.core.meta.MethodPointer;
import com.oracle.svm.core.util.VMError;
import com.oracle.svm.interpreter.metadata.serialization.VisibleForSerialization;

import jdk.graal.compiler.word.Word;
import jdk.vm.ci.meta.Constant;
import jdk.vm.ci.meta.ExceptionHandler;
import jdk.vm.ci.meta.LineNumberTable;
Expand Down Expand Up @@ -387,7 +387,7 @@ public boolean hasNativeEntryPoint() {

public MethodPointer getNativeEntryPoint() {
if (nativeEntryPoint == null) {
return WordFactory.nullPointer();
return Word.nullPointer();
}
return (MethodPointer) nativeEntryPoint.getReferent().functionPointer;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@
import java.util.function.IntFunction;
import java.util.function.ToLongFunction;

import com.oracle.svm.interpreter.metadata.ReferenceConstant;
import org.graalvm.nativeimage.Platform;
import org.graalvm.nativeimage.Platforms;
import org.graalvm.word.Pointer;
import org.graalvm.word.WordFactory;

import com.oracle.svm.core.FunctionPointerHolder;
import com.oracle.svm.core.snippets.KnownIntrinsics;
Expand All @@ -47,7 +45,9 @@
import com.oracle.svm.interpreter.metadata.InterpreterResolvedObjectType;
import com.oracle.svm.interpreter.metadata.InterpreterResolvedPrimitiveType;
import com.oracle.svm.interpreter.metadata.InterpreterUnresolvedSignature;
import com.oracle.svm.interpreter.metadata.ReferenceConstant;

import jdk.graal.compiler.word.Word;
import jdk.vm.ci.meta.ExceptionHandler;
import jdk.vm.ci.meta.JavaConstant;
import jdk.vm.ci.meta.JavaKind;
Expand Down Expand Up @@ -282,7 +282,7 @@ static <T> ValueSerializer<T> asReferenceConstant() {
return ReferenceConstant.nullReference();
}
Pointer heapBase = KnownIntrinsics.heapBase();
Object ref = heapBase.add(WordFactory.unsigned(nativeHeapAddress)).toObject();
Object ref = heapBase.add(Word.unsigned(nativeHeapAddress)).toObject();
return ReferenceConstant.createFromNonNullReference(ref);
} else {
// The reference could have been serialized despite not being on the native image heap.
Expand Down
Loading
Loading