|
24 | 24 | */ |
25 | 25 | package com.oracle.svm.hosted.image; |
26 | 26 |
|
| 27 | +import java.nio.file.Files; |
| 28 | +import java.nio.file.Path; |
27 | 29 | import java.util.List; |
28 | 30 | import java.util.function.Function; |
| 31 | +import java.util.function.Supplier; |
29 | 32 |
|
30 | 33 | import com.oracle.svm.util.ReflectionUtil; |
31 | 34 | import jdk.graal.compiler.debug.DebugContext; |
@@ -140,11 +143,29 @@ public boolean isLoadable() { |
140 | 143 | }; |
141 | 144 | }; |
142 | 145 |
|
| 146 | + Supplier<BasicProgbitsSectionImpl> makeGDBSectionImpl = () -> { |
| 147 | + var content = AssemblyBuffer.createOutputAssembler(objectFile.getByteOrder()); |
| 148 | + // 1 -> python file |
| 149 | + content.writeByte((byte) 1); |
| 150 | + content.writeString("./svmhelpers.py"); |
| 151 | + return new BasicProgbitsSectionImpl(content.getBlob()) { |
| 152 | + @Override |
| 153 | + public boolean isLoadable() { |
| 154 | + return false; |
| 155 | + } |
| 156 | + }; |
| 157 | + }; |
| 158 | + |
143 | 159 | var imageClassLoader = accessImpl.getImageClassLoader(); |
144 | 160 | objectFile.newUserDefinedSection(".debug.svm.imagebuild.classpath", makeSectionImpl.apply(DiagnosticUtils.getClassPath(imageClassLoader))); |
145 | 161 | objectFile.newUserDefinedSection(".debug.svm.imagebuild.modulepath", makeSectionImpl.apply(DiagnosticUtils.getModulePath(imageClassLoader))); |
146 | 162 | objectFile.newUserDefinedSection(".debug.svm.imagebuild.arguments", makeSectionImpl.apply(DiagnosticUtils.getBuilderArguments(imageClassLoader))); |
147 | 163 | objectFile.newUserDefinedSection(".debug.svm.imagebuild.java.properties", makeSectionImpl.apply(DiagnosticUtils.getBuilderProperties())); |
| 164 | + |
| 165 | + Path svmDebugHelper = Path.of(System.getProperty("java.home"), "lib/svm/debug/svmhelpers.py"); |
| 166 | + if (Files.exists(svmDebugHelper)) { |
| 167 | + objectFile.newUserDefinedSection(".debug_gdb_scripts", makeGDBSectionImpl.get()); |
| 168 | + } |
148 | 169 | } |
149 | 170 | } |
150 | 171 | ProgressReporter.singleton().setDebugInfoTimer(timer); |
|
0 commit comments