Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@ interface DebugFileInfo {
Path filePath();

/**
* @return a relative path to the source cache containing the cached source file of a file
* element or {@code null} if sources are not available.
* @return the path to the source cache containing the cached source file of a file element
* or {@code null} if sources are not available. Relative paths to the target
* directory are preferred over absolute paths, to make it easier to move the binary
* and the cache directory around.
*/
Path cachePath();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,14 +476,28 @@ public static void defaultDebugInfoValueUpdateHandler(EconomicMap<OptionKey<?>,
@Option(help = "Directory under which to create source file cache for Application or GraalVM classes")//
public static final HostedOptionKey<String> DebugInfoSourceCacheRoot = new HostedOptionKey<>("sources");

public static Path getDebugInfoSourceCacheRoot() {
/**
* Returns {@link SubstrateOptions#DebugInfoSourceCacheRoot} as an absolute path, by resolving
* it on {@link SubstrateOptions#Path} if it's not already an absolute path.
*
* @return the source cache root as an absolute path
*/
public static Path getDebugInfoSourceCacheRootAsAbsolutePath() {
try {
return Paths.get(Path.getValue()).resolve(DebugInfoSourceCacheRoot.getValue());
} catch (InvalidPathException ipe) {
throw UserError.abort("Invalid path provided for option DebugInfoSourceCacheRoot %s", DebugInfoSourceCacheRoot.getValue());
}
}

public static Path getDebugInfoSourceCacheRoot() {
try {
return Paths.get(DebugInfoSourceCacheRoot.getValue());
} catch (InvalidPathException ipe) {
throw UserError.abort("Invalid path provided for option DebugInfoSourceCacheRoot %s", DebugInfoSourceCacheRoot.getValue());
}
}

@Option(help = "Omit generation of DebugLineInfo originating from inlined methods") //
public static final HostedOptionKey<Boolean> OmitInlinedMethodDebugLineInfo = new HostedOptionKey<>(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
class NativeImageDebugInfoProvider implements DebugInfoProvider {
private final DebugContext debugContext;
private final NativeImageCodeCache codeCache;
private final Path cachePath;
@SuppressWarnings("unused") private final NativeImageHeap heap;
boolean useHeapBase;
int compressShift;
Expand All @@ -101,6 +102,7 @@ class NativeImageDebugInfoProvider implements DebugInfoProvider {
super();
this.debugContext = debugContext;
this.codeCache = codeCache;
this.cachePath = SubstrateOptions.getDebugInfoSourceCacheRoot();
this.heap = heap;
ObjectHeader objectHeader = Heap.getHeap().getObjectHeader();
ObjectInfo primitiveFields = heap.getObjectInfo(StaticFieldsSupport.getStaticPrimitiveFields());
Expand Down Expand Up @@ -236,8 +238,6 @@ private static String toJavaName(JavaType javaType) {
return javaType.toJavaName();
}

private final Path cachePath = SubstrateOptions.getDebugInfoSourceCacheRoot();

private abstract class NativeImageDebugFileInfo implements DebugFileInfo {
private Path fullFilePath;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ public LinkerInvocation write(DebugContext debug, Path outputDirectory, Path tem
}

if (SubstrateOptions.GenerateDebugInfo.getValue() > 0) {
BuildArtifacts.singleton().add(ArtifactType.DEBUG_INFO, SubstrateOptions.getDebugInfoSourceCacheRoot());
BuildArtifacts.singleton().add(ArtifactType.DEBUG_INFO, SubstrateOptions.getDebugInfoSourceCacheRootAsAbsolutePath());
if (OS.getCurrent() == OS.WINDOWS) {
BuildArtifacts.singleton().add(ArtifactType.DEBUG_INFO, imagePath.resolveSibling(imageName + ".pdb"));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public class SourceCache {
* Create the source cache.
*/
protected SourceCache() {
basePath = SubstrateOptions.getDebugInfoSourceCacheRoot();
basePath = SubstrateOptions.getDebugInfoSourceCacheRootAsAbsolutePath();
srcRoots = new ArrayList<>();
specialSrcRoots = new HashMap<>();
addJDKSources();
Expand Down