graalvm / mandrel

Mandrel is a downstream distribution of the GraalVM community edition. Mandrel's main goal is to provide a native-image release specifically to support Quarkus.
Other
394 stars 15 forks source link

No sources for native libraries #119

Open zakkak opened 4 years ago

zakkak commented 4 years ago

Description

Mandrel ships with libjvm.a and liblibchelper.a but not their sources. As a result gdb (as well as other tools) fail to show the source code.

How To Reproduce

native-image -g HelloWorld
gdb helloworld
(gdb) b determineCPUFeatures 
Breakpoint 1 at 0x6c12c0: file /usr/lib/gcc/x86_64-redhat-linux/8/include/cpuid.h, line 241.
(gdb) r
Starting program: /home/zakkak/code/graal/helloworld
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Breakpoint 1, determineCPUFeatures (features=0x7fffffffd328) at /home/jenkins/jenkins/workspace/mandrel-linux-build/mandrel/substratevm/src/com.oracle.svm.native.libchelper/src/cpuid.c:121
121     /home/jenkins/jenkins/workspace/mandrel-linux-build/mandrel/substratevm/src/com.oracle.svm.native.libchelper/src/cpuid.c: No such file or directory.

Additional context

In order to fix this we need to:

  1. Ship the sources along the binaries
  2. Find a way for gdb to detect the sources. Currently it's looking in the directory where the sources were built from:
    readelf --debug-dump=info /opt/jvms/mandrel-java11-20.1.0.1.Final/lib/svm/clibraries/linux-amd64/libjvm.a| grep comp_dir
    <15>   DW_AT_comp_dir    : (indirect string, offset: 0x975): /home/jenkins/jenkins/workspace/mandrel-linux-build/mandrel/substratevm/mxbuild/linux-amd64/src/com.oracle.svm.native.jvm.posix/amd64
    <15>   DW_AT_comp_dir    : (indirect string, offset: 0x1bb): /home/jenkins/jenkins/workspace/mandrel-linux-build/mandrel/substratevm/mxbuild/linux-amd64/src/com.oracle.svm.native.jvm.posix/amd64
jerboaa commented 2 years ago

This program is a simple reproducer which uses JvmFunc.cs JVM_ActiveProcessorCount from libjvm.a:

$ cat TestLibjvmaDebugInfo.java 
public class TestLibjvmaDebugInfo {
    public static void main(String[] args) {
        System.out.println("Active proc count: " + Runtime.getRuntime().availableProcessors());
    }
}