params = new ArrayList<>(5);
+ char c;
+
+ int state = NULL;
+ StringBuilder buff = new StringBuilder(20);
+ int slength = s.length();
+
+ for (int i = 0; i < slength; i++) {
+ c = s.charAt(i);
+ switch (state) {
+ case NULL:
+ switch (c) {
+ case '\'':
+ state = IN_SINGLE_QUOTE;
+ break;
+ case '"':
+ state = IN_DOUBLE_QUOTE;
+ break;
+ default:
+ if (!Character.isWhitespace(c)) {
+ buff.append(c);
+ state = IN_PARAM;
+ }
+ }
+ break;
+ case IN_SINGLE_QUOTE:
+ if (c != '\'') {
+ buff.append(c);
+ } else {
+ state = IN_PARAM;
+ }
+ break;
+ case IN_DOUBLE_QUOTE:
+ switch (c) {
+ case '\\':
+ char peek = (i < slength - 1) ? s.charAt(i+1) : Character.MIN_VALUE;
+ if (peek == '"' || peek =='\\') {
+ buff.append(peek);
+ i++;
+ } else {
+ buff.append(c);
+ }
+ break;
+ case '"':
+ state = IN_PARAM;
+ break;
+ default:
+ buff.append(c);
+ }
+ break;
+ case IN_PARAM:
+ switch (c) {
+ case '\'':
+ state = IN_SINGLE_QUOTE;
+ break;
+ case '"':
+ state = IN_DOUBLE_QUOTE;
+ break;
+ default:
+ if (Character.isWhitespace(c)) {
+ params.add(buff.toString());
+ buff.setLength(0);
+ state = NULL;
+ } else {
+ buff.append(c);
+ }
+ }
+ break;
+ }
+ }
+ if (buff.length() > 0) {
+ params.add(buff.toString());
+ }
+
+ return params.toArray(new String[params.size()])
+ }
}
diff --git a/ide/extexecution.base/manifest.mf b/ide/extexecution.base/manifest.mf
index 21ce6ef39596..8c1e50ff55a2 100644
--- a/ide/extexecution.base/manifest.mf
+++ b/ide/extexecution.base/manifest.mf
@@ -2,6 +2,6 @@ Manifest-Version: 1.0
AutoUpdate-Show-In-Client: false
OpenIDE-Module: org.netbeans.modules.extexecution.base/2
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/extexecution/base/resources/Bundle.properties
-OpenIDE-Module-Specification-Version: 1.19
+OpenIDE-Module-Specification-Version: 1.20
OpenIDE-Module-Recommends: org.netbeans.spi.extexecution.base.ProcessesImplementation
diff --git a/ide/extexecution.base/src/org/netbeans/api/extexecution/base/ExplicitProcessParameters.java b/ide/extexecution.base/src/org/netbeans/api/extexecution/base/ExplicitProcessParameters.java
index 9aa9d0328f33..91ee25a1d760 100644
--- a/ide/extexecution.base/src/org/netbeans/api/extexecution/base/ExplicitProcessParameters.java
+++ b/ide/extexecution.base/src/org/netbeans/api/extexecution/base/ExplicitProcessParameters.java
@@ -18,11 +18,15 @@
*/
package org.netbeans.api.extexecution.base;
+import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import org.netbeans.api.annotations.common.CheckForNull;
import org.netbeans.api.annotations.common.NonNull;
import org.netbeans.api.annotations.common.NullAllowed;
import org.openide.util.Lookup;
@@ -45,8 +49,7 @@
* process arguments.
*
* For java applications when {@code java} executable is used to launch the application, or even Maven project (see below), the launcherArgs should correspond to VM
- * arguments, and args correspond to the main class' arguments (passed to the main class). Environment variables for the new process are not
- * supported at the moment.
+ * arguments, and args correspond to the main class' arguments (passed to the main class). Additional environment variables can be specified.
*
*
* If the object is marked as {@link #isArgReplacement()}, the launcher implementor SHOULD replace all
@@ -92,17 +95,22 @@ public final class ExplicitProcessParameters {
private final List arguments;
private final boolean replaceArgs;
private final boolean replaceLauncherArgs;
+ private final File workingDirectory;
+ private final Map environmentVars;
private ExplicitProcessParameters(int position, List launcherArguments,
- List arguments, boolean appendArgs, boolean appendLauncherArgs) {
+ List arguments, boolean appendArgs, boolean appendLauncherArgs,
+ File workingDirectory, Map environmentVars) {
this.position = position;
this.launcherArguments = launcherArguments == null ? null : Collections.unmodifiableList(launcherArguments);
this.arguments = arguments == null ? null : Collections.unmodifiableList(arguments);
this.replaceArgs = appendArgs;
this.replaceLauncherArgs = appendLauncherArgs;
+ this.workingDirectory = workingDirectory;
+ this.environmentVars = environmentVars == null ? null : Collections.unmodifiableMap(environmentVars);
}
- private static final ExplicitProcessParameters EMPTY = new ExplicitProcessParameters(0, null, null, false, false);
+ private static final ExplicitProcessParameters EMPTY = new ExplicitProcessParameters(0, null, null, false, false, null, null);
/**
* Returns an empty instance of parameters that has no effect. DO NOT check for emptiness by
@@ -122,7 +130,10 @@ public boolean isEmpty() {
if (isArgReplacement() || isLauncherArgReplacement()) {
return false;
}
- return (((arguments == null) || arguments.isEmpty()) && (launcherArguments == null || launcherArguments.isEmpty()));
+ return ((arguments == null) || arguments.isEmpty()) &&
+ (launcherArguments == null || launcherArguments.isEmpty()) &&
+ workingDirectory == null &&
+ (environmentVars == null || environmentVars.isEmpty());
}
/**
@@ -189,6 +200,27 @@ public boolean isLauncherArgReplacement() {
return getAllArguments(middle == null ? Collections.emptyList() : Arrays.asList(middle));
}
+ /**
+ * Returns working directory to be set for the process.
+ *
+ * @return working directory, or nul
+ * @since 1.20
+ */
+ public @CheckForNull File getWorkingDirectory() {
+ return workingDirectory;
+ }
+
+ /**
+ * Returns a map of additional environment variables to be set for the process.
+ * Always non-null. Values of existing environment variables are overridden.
+ *
+ * @return map of additional environment variables
+ * @since 1.20
+ */
+ public @NonNull Map getEnvironmentVariables() {
+ return environmentVars != null ? environmentVars : Collections.emptyMap();
+ }
+
/**
* Merges ExplicitProcessParameters instructions found in the Lookup. See {@link #buildExplicitParameters(java.util.Collection)}
* for more details.
@@ -238,7 +270,7 @@ public static Builder builder() {
* appends launcher arguments
* replaces (normal) arguments
*
- * and the mode can be overriden for each group.
+ * and the mode can be overridden for each group.
*/
public final static class Builder {
private int position = 0;
@@ -246,6 +278,8 @@ public final static class Builder {
private List arguments = null;
private Boolean replaceArgs;
private Boolean replaceLauncherArgs;
+ private File workingDirectory = null;
+ private Map environmentVars;
private void initArgs() {
if (arguments == null) {
@@ -370,6 +404,53 @@ public Builder replaceLauncherArgs(boolean replace) {
return this;
}
+ /**
+ * Sets working directory to be used for the process.
+ *
+ * @param workingDirectory the working directory
+ * @return the builder
+ * @since 1.20
+ */
+ public Builder workingDirectory(File workingDirectory) {
+ this.workingDirectory = workingDirectory;
+ return this;
+ }
+
+ /**
+ * Provide additional environment variables for the process. Values of
+ * existing environment variables are overridden.
+ *
+ * @param env a map of additional environment variables
+ * @return the builder
+ * @since 1.20
+ */
+ public Builder environmentVariables(Map env) {
+ if (!env.isEmpty()) {
+ if (this.environmentVars == null) {
+ this.environmentVars = new HashMap<>();
+ }
+ this.environmentVars.putAll(env);
+ }
+ return this;
+ }
+
+ /**
+ * Provide an additional environment variable for the process. If the variable
+ * already exists, it's overridden with the new value.
+ *
+ * @param name name of the environment variable
+ * @param value value of the environment variable
+ * @return the builder
+ * @since 1.20
+ */
+ public Builder environmentVariable(String name, String value) {
+ if (this.environmentVars == null) {
+ this.environmentVars = new HashMap<>();
+ }
+ this.environmentVars.put(name, value);
+ return this;
+ }
+
/**
* Defines a position for combining. The default rank is {@code 0}. When used in a collection in
* {@link ExplicitProcessParameters#buildExplicitParameters(java.util.Collection)}, instances are sorted
@@ -416,6 +497,12 @@ public Builder combine(@NullAllowed ExplicitProcessParameters p) {
if (p.getArguments() != null) {
args(p.getArguments());
}
+ if (p.getWorkingDirectory() != null) {
+ workingDirectory(p.getWorkingDirectory());
+ }
+ if (!p.getEnvironmentVariables().isEmpty()) {
+ environmentVariables(p.getEnvironmentVariables());
+ }
return this;
}
@@ -430,7 +517,7 @@ public ExplicitProcessParameters build() {
return new ExplicitProcessParameters(position, launcherArguments, arguments,
// if no args / launcher args given and no explicit instruction on append,
// make the args appending.
- aa, apa);
+ aa, apa, workingDirectory, environmentVars);
}
}
}
diff --git a/ide/nativeimage.api/manifest.mf b/ide/nativeimage.api/manifest.mf
index 8989b99cbc4f..4fee1da371d8 100644
--- a/ide/nativeimage.api/manifest.mf
+++ b/ide/nativeimage.api/manifest.mf
@@ -2,5 +2,5 @@ Manifest-Version: 1.0
AutoUpdate-Show-In-Client: false
OpenIDE-Module: org.netbeans.modules.nativeimage.api/0
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/nativeimage/api/Bundle.properties
-OpenIDE-Module-Specification-Version: 0.4
+OpenIDE-Module-Specification-Version: 0.5
diff --git a/ide/nativeimage.api/src/org/netbeans/modules/nativeimage/api/debug/EvaluateException.java b/ide/nativeimage.api/src/org/netbeans/modules/nativeimage/api/debug/EvaluateException.java
index 1d542bb1752a..88a2cd8f6dc1 100644
--- a/ide/nativeimage.api/src/org/netbeans/modules/nativeimage/api/debug/EvaluateException.java
+++ b/ide/nativeimage.api/src/org/netbeans/modules/nativeimage/api/debug/EvaluateException.java
@@ -21,7 +21,7 @@
/**
* Thrown when evaluation in the native debugger fails.
*
- * @since 1.0
+ * @since 0.1
*/
public class EvaluateException extends Exception {
@@ -30,7 +30,7 @@ public class EvaluateException extends Exception {
* specified detail message.
*
* @param msg the detail message.
- * @since 1.0
+ * @since 0.1
*/
public EvaluateException(String msg) {
super(msg);
@@ -41,10 +41,9 @@ public EvaluateException(String msg) {
* existing exception.
*
* @param t exception.
- * @since 1.0
+ * @since 0.1
*/
public EvaluateException(Throwable t) {
super(t.getLocalizedMessage(), t);
-
}
}
diff --git a/ide/nativeimage.api/src/org/netbeans/modules/nativeimage/api/debug/NIDebugger.java b/ide/nativeimage.api/src/org/netbeans/modules/nativeimage/api/debug/NIDebugger.java
index bdd0245845f5..a66b353d4d47 100644
--- a/ide/nativeimage.api/src/org/netbeans/modules/nativeimage/api/debug/NIDebugger.java
+++ b/ide/nativeimage.api/src/org/netbeans/modules/nativeimage/api/debug/NIDebugger.java
@@ -21,6 +21,7 @@
import java.io.File;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.function.Consumer;
@@ -42,7 +43,7 @@
/**
* Representation of a native image debugger.
- * @since 1.0
+ * @since 0.1
*/
public final class NIDebugger {
@@ -59,7 +60,7 @@ public final class NIDebugger {
* @throws IllegalStateException when the native debugger is not available
* (there is not an implementation of {@link NIDebuggerServiceProvider}
* registered in the default lookup).
- * @since 1.0
+ * @since 0.1
*/
@NbBundle.Messages({"MSG_NoNativeDebug=No native debugger is available. Please install native debugger module."})
public static Builder newBuilder() throws IllegalStateException {
@@ -79,7 +80,7 @@ public static Builder newBuilder() throws IllegalStateException {
* @param id a unique ID of the breakpoint
* @param breakpointDescriptor the breakpoint descriptor
* @return an instance of the native breakpoint
- * @since 1.0
+ * @since 0.1
*/
public Breakpoint addLineBreakpoint(Object id, NILineBreakpointDescriptor breakpointDescriptor) {
Breakpoint breakpoint = provider.addLineBreakpoint(id, breakpointDescriptor);
@@ -91,7 +92,7 @@ public Breakpoint addLineBreakpoint(Object id, NILineBreakpointDescriptor breakp
* Remove breakpoint with the given id.
*
* @param id the ID of the breakpoint to remove
- * @since 1.0
+ * @since 0.1
*/
public void removeBreakpoint(Object id) {
provider.removeBreakpoint(id);
@@ -107,12 +108,41 @@ public void removeBreakpoint(Object id) {
* @param executionDescriptor execution descriptor that describes the runtime attributes
* @param startedEngine the corresponding DebuggerEngine is passed to this consumer
* @return future that completes on the execution finish
- * @since 1.0
+ * @since 0.1
+ * @deprecated Use {@link #start(org.netbeans.modules.nativeimage.api.debug.StartDebugParameters, java.util.function.Consumer)}
*/
+ @Deprecated
public CompletableFuture start(List command, File workingDirectory, String debugger, String displayName, ExecutionDescriptor executionDescriptor, Consumer startedEngine) {
return provider.start(command, workingDirectory, debugger, displayName, executionDescriptor, startedEngine);
}
+ /**
+ * Start the actual debugging session. Call this typically after breakpoints are added.
+ *
+ * @param debugParameters parameters to start the debugging with
+ * @param startedEngine the corresponding DebuggerEngine is passed to this consumer
+ * @return a future which is completed when the started debugger session finishes
+ * @since 0.5
+ */
+ public CompletableFuture start(StartDebugParameters debugParameters, Consumer startedEngine) {
+ Objects.requireNonNull(debugParameters);
+ CompletableFuture start = provider.start(debugParameters, startedEngine);
+ if (start.isCompletedExceptionally()) {
+ try {
+ start.get();
+ } catch (ExecutionException ex) {
+ if (ex.getCause() instanceof UnsupportedOperationException) {
+ return startLegacy(debugParameters, startedEngine);
+ }
+ } catch (Throwable ex) {}
+ }
+ return start;
+ }
+
+ private CompletableFuture startLegacy(StartDebugParameters debugParameters, Consumer startedEngine) {
+ return provider.start(debugParameters.getCommand(), debugParameters.getWorkingDirectory(), debugParameters.getDebugger(), debugParameters.getDisplayName(), debugParameters.getExecutionDescriptor(), startedEngine);
+ }
+
/**
* Attach to a process and create a debugging session. Call this typically after breakpoints are added.
*
@@ -135,7 +165,7 @@ public CompletableFuture attach(String executablePath, long processId, Str
* when null
the expression is used as the name
* @param frame the frame to evaluate at
* @return the completable future with the evaluation result
- * @since 1.0
+ * @since 0.1
*/
public CompletableFuture evaluateAsync(String expression, String resultName, NIFrame frame) {
return provider.evaluateAsync(expression, resultName, frame);
@@ -151,7 +181,7 @@ public CompletableFuture evaluateAsync(String expression, String res
* @param frame the frame to evaluate at
* @return the evaluation result
* @throws EvaluateException when evaluation fails
- * @since 1.0
+ * @since 0.1
*/
public NIVariable evaluate(String expression, String resultName, NIFrame frame) throws EvaluateException {
try {
@@ -169,7 +199,7 @@ public NIVariable evaluate(String expression, String resultName, NIFrame frame)
* @param length number of bytes to read
* @return hexadecimal representation of the memory content, or null
* when the read is not successful
- * @since 1.0
+ * @since 0.1
*/
public String readMemory(String address, long offset, int length) {
return provider.readMemory(address, offset, length);
@@ -178,7 +208,7 @@ public String readMemory(String address, long offset, int length) {
/**
* Get version of the underlying native debugger.
*
- * @since 1.0
+ * @since 0.1
*/
public String getVersion() {
return provider.getVersion();
@@ -230,7 +260,7 @@ public Map> listVariables(String name, boolean includeN
/**
* A builder that creates a Native Image debugger with optional displayers.
*
- * @since 1.0
+ * @since 0.1
*/
public static final class Builder {
@@ -244,7 +274,7 @@ public static final class Builder {
* Displayer of native frames.
*
* @param frameDisplayer translator of the native frame to it's displayed information
- * @since 1.0
+ * @since 0.1
*/
public Builder frameDisplayer(FrameDisplayer frameDisplayer) {
this.debuggerProvider.setFrameDisplayer(frameDisplayer);
@@ -255,7 +285,7 @@ public Builder frameDisplayer(FrameDisplayer frameDisplayer) {
* Displayer of native variables.
*
* @param variablesDisplayer translator of native variables to displayed variables.
- * @since 1.0
+ * @since 0.1
*/
public Builder variablesDisplayer(VariableDisplayer variablesDisplayer) {
this.debuggerProvider.setVariablesDisplayer(variablesDisplayer);
@@ -264,7 +294,7 @@ public Builder variablesDisplayer(VariableDisplayer variablesDisplayer) {
/**
* Create the debugger instance.
- * @since 1.0
+ * @since 0.1
*/
public NIDebugger build() {
return new NIDebugger(debuggerProvider);
diff --git a/ide/nativeimage.api/src/org/netbeans/modules/nativeimage/api/debug/NIFrame.java b/ide/nativeimage.api/src/org/netbeans/modules/nativeimage/api/debug/NIFrame.java
index 4ffc48c1259e..9cc338cdfef3 100644
--- a/ide/nativeimage.api/src/org/netbeans/modules/nativeimage/api/debug/NIFrame.java
+++ b/ide/nativeimage.api/src/org/netbeans/modules/nativeimage/api/debug/NIFrame.java
@@ -21,49 +21,49 @@
/**
* Representation of a native stack frame.
*
- * @since 1.0
+ * @since 0.1
*/
public interface NIFrame {
/**
* Frame's thread ID.
- * @since 1.0
+ * @since 0.1
*/
String getThreadId();
/**
* Frame's depth level. The top frame has level 0.
- * @since 1.0
+ * @since 0.1
*/
int getLevel();
/**
* Frame's native address.
- * @since 1.0
+ * @since 0.1
*/
String getAddress();
/**
* A short name of the file associated with the frame.
- * @since 1.0
+ * @since 0.1
*/
String getShortFileName();
/**
* A full name of the file associated with the frame.
- * @since 1.0
+ * @since 0.1
*/
String getFullFileName();
/**
* Name of the function associated with the frame.
- * @since 1.0
+ * @since 0.1
*/
String getFunctionName();
/**
* 1-based line of the frame location.
- * @since 1.0
+ * @since 0.1
*/
int getLine();
}
diff --git a/ide/nativeimage.api/src/org/netbeans/modules/nativeimage/api/debug/NILineBreakpointDescriptor.java b/ide/nativeimage.api/src/org/netbeans/modules/nativeimage/api/debug/NILineBreakpointDescriptor.java
index 192be780bb27..2033f392f9a0 100644
--- a/ide/nativeimage.api/src/org/netbeans/modules/nativeimage/api/debug/NILineBreakpointDescriptor.java
+++ b/ide/nativeimage.api/src/org/netbeans/modules/nativeimage/api/debug/NILineBreakpointDescriptor.java
@@ -23,7 +23,7 @@
/**
* Description of a line native breakpoint.
*
- * @since 1.0
+ * @since 0.1
*/
public final class NILineBreakpointDescriptor {
@@ -46,7 +46,7 @@ private NILineBreakpointDescriptor(String filePath, int line, boolean enabled, S
*
* @param filePath file path of the breakpoint
* @param lineNumber 1-based line number
- * @since 1.0
+ * @since 0.1
*/
public static Builder newBuilder(String filePath, int lineNumber) {
return new Builder(filePath, lineNumber);
@@ -55,7 +55,7 @@ public static Builder newBuilder(String filePath, int lineNumber) {
/**
* Get path of the file.
*
- * @since 1.0
+ * @since 0.1
*/
public String getFilePath() {
return filePath;
@@ -64,7 +64,7 @@ public String getFilePath() {
/**
* Get 1-based line number.
*
- * @since 1.0
+ * @since 0.1
*/
public int getLine() {
return line;
@@ -73,7 +73,7 @@ public int getLine() {
/**
* Check if the breakpoint is to be enabled.
*
- * @since 1.0
+ * @since 0.1
*/
public boolean isEnabled() {
return enabled;
@@ -83,7 +83,7 @@ public boolean isEnabled() {
* Get the breakpoint condition.
*
* @return the condition, or null
when the breakpoint does not have any condition.
- * @since 1.0
+ * @since 0.1
*/
@CheckForNull
public String getCondition() {
@@ -93,7 +93,7 @@ public String getCondition() {
/**
* Check if the breakpoint is to be hidden (not user-visible).
*
- * @since 1.0
+ * @since 0.1
*/
public boolean isHidden() {
return hidden;
@@ -103,7 +103,7 @@ public boolean isHidden() {
* Builder of a line native breakpoint descriptor. The builder is reusable
* and the built breakpoint descriptor can be used to update existing breakpoints.
*
- * @since 1.0
+ * @since 0.1
*/
public static final class Builder {
@@ -121,7 +121,7 @@ public static final class Builder {
/**
* Set a file path.
*
- * @since 1.0
+ * @since 0.1
*/
public Builder filePath(String filePath) {
this.filePath = filePath;
@@ -131,7 +131,7 @@ public Builder filePath(String filePath) {
/**
* Set a 1-based line number.
*
- * @since 1.0
+ * @since 0.1
*/
public Builder line(int lineNumber) {
this.line = lineNumber;
@@ -141,7 +141,7 @@ public Builder line(int lineNumber) {
/**
* Set a condition.
*
- * @since 1.0
+ * @since 0.1
*/
public Builder condition(String condition) {
this.condition = condition;
@@ -151,7 +151,7 @@ public Builder condition(String condition) {
/**
* Set an enabled state of the breakpoint. The breakpoint is enabled by default.
*
- * @since 1.0
+ * @since 0.1
*/
public Builder enabled(boolean enabled) {
this.enabled = enabled;
@@ -162,7 +162,7 @@ public Builder enabled(boolean enabled) {
* Set a hidden state of the breakpoint. Hidden breakpoints are not visible
* to users. The breakpoint is not hidden by default.
*
- * @since 1.0
+ * @since 0.1
*/
public Builder hidden(boolean hidden) {
this.hidden = hidden;
diff --git a/ide/nativeimage.api/src/org/netbeans/modules/nativeimage/api/debug/NIVariable.java b/ide/nativeimage.api/src/org/netbeans/modules/nativeimage/api/debug/NIVariable.java
index cd46e7c892a5..d2001929f303 100644
--- a/ide/nativeimage.api/src/org/netbeans/modules/nativeimage/api/debug/NIVariable.java
+++ b/ide/nativeimage.api/src/org/netbeans/modules/nativeimage/api/debug/NIVariable.java
@@ -20,28 +20,28 @@
/**
* Representation of a native variable.
- * @since 1.0
+ * @since 0.1
*/
public interface NIVariable {
/**
* Name of the variable.
*
- * @since 1.0
+ * @since 0.1
*/
String getName();
/**
* Type of the variable value.
*
- * @since 1.0
+ * @since 0.1
*/
String getType();
/**
* String representation of the variable value.
*
- * @since 1.0
+ * @since 0.1
*/
String getValue();
@@ -50,14 +50,14 @@ public interface NIVariable {
* variable.
*
* @return the parent variable, or null
.
- * @since 1.0
+ * @since 0.1
*/
NIVariable getParent();
/**
* Number of child variables (properties, or array elements) of this variable.
*
- * @since 1.0
+ * @since 0.1
*/
int getNumChildren();
@@ -66,14 +66,14 @@ public interface NIVariable {
* from
index and up to and excluding to
index will
* be returned. If from
is less than zero, all children are returned.
*
- * @since 1.0
+ * @since 0.1
*/
NIVariable[] getChildren(int from, int to);
/**
* Get all variable's children.
*
- * @since 1.0
+ * @since 0.1
*/
default NIVariable[] getChildren() {
return getChildren(0, Integer.MAX_VALUE);
@@ -82,7 +82,7 @@ default NIVariable[] getChildren() {
/**
* Get the full expression that this variable object represents.
*
- * @since 1.0
+ * @since 0.1
*/
String getExpressionPath();
@@ -90,7 +90,7 @@ default NIVariable[] getChildren() {
* Get the frame this variable is associated with.
*
* @return the frame, or null
.
- * @since 1.0
+ * @since 0.1
*/
NIFrame getFrame();
}
diff --git a/ide/nativeimage.api/src/org/netbeans/modules/nativeimage/api/debug/StartDebugParameters.java b/ide/nativeimage.api/src/org/netbeans/modules/nativeimage/api/debug/StartDebugParameters.java
new file mode 100644
index 000000000000..2716714f6ef9
--- /dev/null
+++ b/ide/nativeimage.api/src/org/netbeans/modules/nativeimage/api/debug/StartDebugParameters.java
@@ -0,0 +1,188 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.nativeimage.api.debug;
+
+import java.io.File;
+import java.util.List;
+import org.netbeans.api.extexecution.ExecutionDescriptor;
+import org.openide.util.Lookup;
+
+/**
+ * Parameters passed to {@link NIDebugger#start(org.netbeans.modules.nativeimage.api.debug.StartDebugParameters, java.util.function.Consumer)}.
+ *
+ * @since 0.5
+ */
+public final class StartDebugParameters {
+
+ private final List command;
+ private final File workingDirectory;
+ private final String debugger;
+ private final String displayName;
+ private final ExecutionDescriptor executionDescriptor;
+ private final Lookup contextLookup;
+
+ private StartDebugParameters(List command, File workingDirectory, String debugger, String displayName, ExecutionDescriptor executionDescriptor, Lookup contextLookup) {
+ this.command = command;
+ this.workingDirectory = workingDirectory;
+ this.debugger = debugger;
+ this.displayName = displayName;
+ this.executionDescriptor = executionDescriptor;
+ this.contextLookup = contextLookup;
+ }
+
+ /**
+ * The command to run the native image.
+ *
+ * @return the command with arguments.
+ */
+ public List getCommand() {
+ return command;
+ }
+
+ /**
+ * Working directory of the process.
+ *
+ * @return the working directory
+ */
+ public File getWorkingDirectory() {
+ return workingDirectory;
+ }
+
+ /**
+ * The native debugger command.
+ *
+ * @return the debugger command
+ */
+ public String getDebugger() {
+ return debugger;
+ }
+
+ /**
+ * Display name of the debugger task.
+ *
+ * @return the display name of debugger task
+ */
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ /**
+ * Execution descriptor that describes the runtime attributes.
+ *
+ * @return the execution descriptor
+ */
+ public ExecutionDescriptor getExecutionDescriptor() {
+ return executionDescriptor;
+ }
+
+ /**
+ * Context lookup. The lookup may contain other parameters, like ExplicitProcessParameters.
+ *
+ * @return the context lookup
+ */
+ public Lookup getContextLookup() {
+ return contextLookup;
+ }
+
+ /**
+ * Create a new debug parameters builder.
+ *
+ * @param command the command to run the native image.
+ * @return a new builder
+ */
+ public static Builder newBuilder(List command) {
+ return new Builder(command);
+ }
+
+ /**
+ * Builder of start debug parameters.
+ *
+ * @since 0.5
+ */
+ public static final class Builder {
+
+ private final List command;
+ private File workingDirectory;
+ private String debugger;
+ private String displayName;
+ private ExecutionDescriptor executionDescriptor;
+ private Lookup contextLookup;
+
+ Builder(List command) {
+ this.command = command;
+ }
+
+ /**
+ * Set the working directory.
+ * @return the builder
+ */
+ public Builder workingDirectory(File workingDirectory) {
+ this.workingDirectory = workingDirectory;
+ return this;
+ }
+
+ /**
+ * Set the native debugger command.
+ * @return the builder
+ */
+ public Builder debugger(String debugger) {
+ this.debugger = debugger;
+ return this;
+ }
+
+ /**
+ * Set display name of the debugger task.
+ *
+ * @return the builder
+ */
+ public Builder displayName(String displayName) {
+ this.displayName = displayName;
+ return this;
+ }
+
+ /**
+ * Set execution descriptor that describes the runtime attributes.
+ *
+ * @return the builder
+ */
+ public Builder executionDescriptor(ExecutionDescriptor executionDescriptor) {
+ this.executionDescriptor = executionDescriptor;
+ return this;
+ }
+
+ /**
+ * Context lookup. The lookup may contain other parameters, like ExplicitProcessParameters.
+ *
+ * @return the builder
+ */
+ public Builder lookup(Lookup contextLookup) {
+ this.contextLookup = contextLookup;
+ return this;
+ }
+
+ /**
+ * Build the {@link StartDebugParameters} based on the properties set.
+ *
+ * @return a new instance of {@link StartDebugParameters}.
+ */
+ public StartDebugParameters build() {
+ return new StartDebugParameters(command, workingDirectory, debugger, displayName, executionDescriptor, contextLookup);
+ }
+ }
+}
diff --git a/ide/nativeimage.api/src/org/netbeans/modules/nativeimage/spi/debug/NIDebuggerProvider.java b/ide/nativeimage.api/src/org/netbeans/modules/nativeimage/spi/debug/NIDebuggerProvider.java
index 10a5b8062b61..893f8399203d 100644
--- a/ide/nativeimage.api/src/org/netbeans/modules/nativeimage/spi/debug/NIDebuggerProvider.java
+++ b/ide/nativeimage.api/src/org/netbeans/modules/nativeimage/spi/debug/NIDebuggerProvider.java
@@ -33,6 +33,7 @@
import org.netbeans.modules.nativeimage.api.debug.NIFrame;
import org.netbeans.modules.nativeimage.api.debug.NILineBreakpointDescriptor;
import org.netbeans.modules.nativeimage.api.debug.NIVariable;
+import org.netbeans.modules.nativeimage.api.debug.StartDebugParameters;
import org.netbeans.modules.nativeimage.spi.debug.filters.FrameDisplayer;
import org.netbeans.modules.nativeimage.spi.debug.filters.VariableDisplayer;
@@ -40,7 +41,7 @@
* Provider of the native image debugger.
*
* @author martin
- * @since 1.0
+ * @since 0.1
*/
public interface NIDebuggerProvider {
@@ -52,7 +53,7 @@ public interface NIDebuggerProvider {
* @param id a unique ID of the breakpoint
* @param breakpointDescriptor the breakpoint descriptor
* @return an instance of the native breakpoint
- * @since 1.0
+ * @since 0.1
*/
Breakpoint addLineBreakpoint(Object id, NILineBreakpointDescriptor breakpointDescriptor);
@@ -60,7 +61,7 @@ public interface NIDebuggerProvider {
* Remove breakpoint with the given id.
*
* @param id the ID of the breakpoint to remove
- * @since 1.0
+ * @since 0.1
*/
void removeBreakpoint(Object id);
@@ -68,7 +69,7 @@ public interface NIDebuggerProvider {
* Set a displayer of native frames.
*
* @param frameDisplayer translator of the native frame to it's displayed information
- * @since 1.0
+ * @since 0.1
*/
void setFrameDisplayer(FrameDisplayer frameDisplayer);
@@ -76,7 +77,7 @@ public interface NIDebuggerProvider {
* Set a displayer of native variables.
*
* @param variablesDisplayer translator of native variables to displayed variables.
- * @since 1.0
+ * @since 0.1
*/
void setVariablesDisplayer(VariableDisplayer variablesDisplayer);
@@ -89,10 +90,33 @@ public interface NIDebuggerProvider {
* @param displayName display name of the debugger task
* @param executionDescriptor execution descriptor that describes the runtime attributes
* @param startedEngine the corresponding DebuggerEngine is passed to this consumer
- * @param finishedCallback notification of the execution finish
- * @since 1.0
+ * @since 0.1
+ * @deprecated Use {@link #start(org.netbeans.modules.nativeimage.api.debug.StartDebugParameters, java.util.function.Consumer)}
*/
- CompletableFuture start(List command, File workingDirectory, String debugger, String displayName, ExecutionDescriptor executionDescriptor, Consumer startedEngine);
+ @Deprecated
+ default CompletableFuture start(List command, File workingDirectory, String debugger, String displayName, ExecutionDescriptor executionDescriptor, Consumer startedEngine) {
+ StartDebugParameters parameters = StartDebugParameters.newBuilder(command)
+ .workingDirectory(workingDirectory)
+ .debugger(debugger)
+ .displayName(displayName)
+ .executionDescriptor(executionDescriptor)
+ .build();
+ return start(parameters, startedEngine);
+ }
+
+ /**
+ * Start the actual debugging session. Called typically after breakpoints are added.
+ *
+ * @param debugParameters parameters to start the debugging with
+ * @param startedEngine the corresponding DebuggerEngine is passed to this consumer
+ * @return a future which is completed when the started debugger session finishes
+ * @since 0.5
+ */
+ default CompletableFuture start(StartDebugParameters debugParameters, Consumer startedEngine) {
+ CompletableFuture cf = new CompletableFuture();
+ cf.completeExceptionally(new UnsupportedOperationException());
+ return cf;
+ }
/**
* Attach to a process and create a debugging session. Called typically after breakpoints are added.
@@ -118,7 +142,7 @@ default CompletableFuture attach(String executablePath, long processId, St
* when null
the expression is used as the name
* @param frame the frame to evaluate at
* @return the completable future with the evaluation result
- * @since 1.0
+ * @since 0.1
*/
CompletableFuture evaluateAsync(String expression, String resultName, NIFrame frame);
@@ -130,14 +154,14 @@ default CompletableFuture attach(String executablePath, long processId, St
* @param length number of bytes to read
* @return hexadecimal representation of the memory content, or null
* when the read is not successful
- * @since 1.0
+ * @since 0.1
*/
String readMemory(String address, long offset, int length);
/**
* Get version of the underlying native debugger.
*
- * @since 1.0
+ * @since 0.1
*/
String getVersion();
@@ -153,10 +177,20 @@ default List listLocations(String filePath) {
return null;
}
+ /**
+ * Provide a list of functions in the debuggee.
+ *
+ * @since 0.2
+ */
default Map> listFunctions(String name, boolean includeNondebug, int maxResults) {
return null;
}
+ /**
+ * Provide a list of global variables in the debuggee.
+ *
+ * @since 0.2
+ */
default Map> listVariables(String name, boolean includeNondebug, int maxResults) {
return null;
}
diff --git a/java/gradle.java/arch.xml b/java/gradle.java/arch.xml
index f9d2db2d2ddb..7c06a5f86046 100644
--- a/java/gradle.java/arch.xml
+++ b/java/gradle.java/arch.xml
@@ -110,6 +110,18 @@
in action's context Lookup. See ProjectActions.TOKEN_JAVAEXEC_ARGS
for more details.
+
+ {@code ${javaExec.runWorkingDir}} token is replaced in action mappings with working directory retrieved
+ from ExplicitProcessParameters
+ in action's context Lookup. See ProjectActions.TOKEN_JAVAEXEC_CWD
+ for more details.
+
+
+ {@code ${javaExec.runEnvironment}} token is replaced in action mappings with environment variables retrieved
+ from ExplicitProcessParameters
+ in action's context Lookup. See ProjectActions.TOKEN_JAVAEXEC_ENV
+ for more details.
+