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: 1 addition & 0 deletions substratevm/mx.substratevm/mx_substratevm.py
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,7 @@ def _debuginfotest(native_image, path, build_only, args):
'-Dgraal.LogFile=graal.log',
'-g',
'-H:-OmitInlinedMethodDebugLineInfo',
'-H:+SourceLevelDebug',
'-H:DebugInfoSourceSearchPath=' + sourcepath,
'-H:DebugInfoSourceCacheRoot=' + join(path, 'sources'),
'hello.Hello'] + args
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import java.nio.file.InvalidPathException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.function.Predicate;

import org.graalvm.collections.EconomicMap;
import org.graalvm.collections.UnmodifiableEconomicMap;
Expand All @@ -47,6 +49,8 @@
import org.graalvm.compiler.options.OptionValues;
import org.graalvm.nativeimage.ImageInfo;
import org.graalvm.nativeimage.ImageSingletons;
import org.graalvm.nativeimage.Platform;
import org.graalvm.nativeimage.Platforms;

import com.oracle.svm.core.deopt.DeoptimizationSupport;
import com.oracle.svm.core.heap.ReferenceHandler;
Expand All @@ -56,6 +60,7 @@
import com.oracle.svm.core.option.HostedOptionValues;
import com.oracle.svm.core.option.ImmutableRuntimeOptionKey;
import com.oracle.svm.core.option.LocatableMultiOptionValue;
import com.oracle.svm.core.option.OptionUtils;
import com.oracle.svm.core.option.RuntimeOptionKey;
import com.oracle.svm.core.thread.VMOperationControl;
import com.oracle.svm.core.util.UserError;
Expand All @@ -66,6 +71,10 @@ public class SubstrateOptions {

@Option(help = "When true, compiler graphs are parsed only once before static analysis. When false, compiler graphs are parsed for static analysis and again for AOT compilation.")//
public static final HostedOptionKey<Boolean> ParseOnce = new HostedOptionKey<>(true);
@Option(help = "Preserve the local variable information for every Java source line to allow line-by-line stepping in the debugger. Allow the lookup of Java-level method information, e.g., in stack traces.")//
public static final HostedOptionKey<Boolean> SourceLevelDebug = new HostedOptionKey<>(false);
@Option(help = "Constrain debug info generation to the comma-separated list of package prefixes given to this option.")//
public static final HostedOptionKey<LocatableMultiOptionValue.Strings> SourceLevelDebugFilter = new HostedOptionKey<>(new LocatableMultiOptionValue.Strings());

public static boolean parseOnce() {
/*
Expand Down Expand Up @@ -154,6 +163,32 @@ protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, Boolean o
private static ValueUpdateHandler<OptimizationLevel> optimizeValueUpdateHandler;
private static ValueUpdateHandler<Integer> debugInfoValueUpdateHandler = SubstrateOptions::defaultDebugInfoValueUpdateHandler;

@Fold
public static boolean getSourceLevelDebug() {
return SourceLevelDebug.getValue();
}

@Fold
public static Predicate<String> getSourceLevelDebugFilter() {
return makeFilter(SourceLevelDebugFilter.getValue().values());
}

@Platforms(Platform.HOSTED_ONLY.class)
private static Predicate<String> makeFilter(List<String> definedFilters) {
if (definedFilters.isEmpty()) {
return javaName -> true;
}
List<String> wildCardList = OptionUtils.flatten(",", definedFilters);
return javaName -> {
for (String wildCard : wildCardList) {
if (javaName.startsWith(wildCard)) {
return true;
}
}
return false;
};
}

/**
* The currently supported optimization levels. See the option description of {@link #Optimize}
* for a description of the levels.
Expand All @@ -171,6 +206,7 @@ public enum OptimizationLevel {
protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, String oldValue, String newValue) {
OptimizationLevel newLevel = parseOptimizationLevel(newValue);
SubstrateOptions.IncludeNodeSourcePositions.update(values, newLevel == OptimizationLevel.O0);
SubstrateOptions.SourceLevelDebug.update(values, newLevel == OptimizationLevel.O0);
SubstrateOptions.AOTTrivialInline.update(values, newLevel != OptimizationLevel.O0);
if (optimizeValueUpdateHandler != null) {
optimizeValueUpdateHandler.onValueUpdate(values, newLevel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public boolean isInitialized(AnalysisType type) {
public GraphBuilderConfiguration updateGraphBuilderConfiguration(GraphBuilderConfiguration config, AnalysisMethod method) {
return config.withRetainLocalVariables(retainLocalVariables())
.withUnresolvedIsError(linkAtBuildTimeSupport.linkAtBuildTime(method.getDeclaringClass()))
.withFullInfopoints(SubstrateOptions.GenerateDebugInfo.getValue() > 0);
.withFullInfopoints(SubstrateOptions.getSourceLevelDebug() && SubstrateOptions.getSourceLevelDebugFilter().test(method.getDeclaringClass().toJavaName()));
}

private boolean retainLocalVariables() {
Expand Down