Search in sources :

Example 1 with LLVMSourceFileReference

use of com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceFileReference in project graal by oracle.

the class LLScanner method findAndScanLLFile.

static LLSourceMap findAndScanLLFile(String bcPath, String pathMappings, LLVMContext context, List<LLVMSourceFileReference> sourceFileReferences) {
    if (bcPath == null) {
        return NOT_FOUND;
    }
    final TruffleFile llFile = findLLPathMapping(bcPath, pathMappings, context);
    if (llFile == null || !llFile.exists() || !llFile.isReadable()) {
        printWarning("Cannot find .ll file for %s (decrease %s logging level to disable this message)\n", bcPath, LLVMContext.llDebugLogger().getName());
        return NOT_FOUND;
    }
    try (BufferedReader llReader = llFile.newBufferedReader()) {
        final Source llSource = Source.newBuilder("llvm", llFile).mimeType("text/x-llvmir").build();
        final LLSourceMap sourceMap = new LLSourceMap(llSource);
        EconomicSet<LLVMSourceFileReference> sourceFileWorkset = createSourceFileSet(sourceFileReferences);
        if (sourceFileWorkset == null) {
            printVerbose("No source file checksums found in %s\n", bcPath);
        }
        final LLScanner scanner = new LLScanner(sourceMap, sourceFileWorkset);
        for (String line = llReader.readLine(); line != null; line = llReader.readLine()) {
            if (!scanner.continueAfter(line)) {
                break;
            }
        }
        if (sourceFileWorkset != null && !sourceFileWorkset.isEmpty()) {
            printVerbose("Checksums in the .ll file (%s) and the .bc file (%s) do not match!\n", llFile, bcPath);
            printVerbose("The following files have changed in the .bc file:\n");
            for (LLVMSourceFileReference sourceFileReference : sourceFileWorkset) {
                printVerbose("  %s\n", LLVMSourceFileReference.toString(sourceFileReference));
            }
        }
        return sourceMap;
    } catch (IOException e) {
        throw new LLVMParserException("Error while reading from file: " + llFile.getPath());
    }
}
Also used : BufferedReader(java.io.BufferedReader) TruffleFile(com.oracle.truffle.api.TruffleFile) IOException(java.io.IOException) LLVMSourceFileReference(com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceFileReference) Source(com.oracle.truffle.api.source.Source) LLVMParserException(com.oracle.truffle.llvm.runtime.except.LLVMParserException)

Aggregations

TruffleFile (com.oracle.truffle.api.TruffleFile)1 Source (com.oracle.truffle.api.source.Source)1 LLVMSourceFileReference (com.oracle.truffle.llvm.runtime.debug.scope.LLVMSourceFileReference)1 LLVMParserException (com.oracle.truffle.llvm.runtime.except.LLVMParserException)1 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1