sieve
sieve copied to clipboard
Debug the Java Sieve Project as native-image.
Since d9a30a9127548ad3 we are able to build and execute the generated sieve
native executable:
Make sure the project is set to use GraalVM 20.3 with native-image exectable installed and that you select the native-image configuration in the toolbar choicebox.
After Build, or Clean and Build select Run and the native executable is going to be properly executed:
The question for the pull request is: Can we also get Debug working?
CCing @sdedic & @entlicher & @jlahoda
Right now (with 4ffdc70) invoking Debug Project results in
cd /home/devel/NetBeansProjects/sieve/java/algorithm; JAVA_HOME=/home/devel/bin/jdk-8 /home/devel/NetBeansProjects/netbeans/nbbuild/netbeans/java/maven/bin/mvn -Dexec.vmArgs= -Dexec.appArgs= -Pnative-image,native-image exec:exec@debug
Scanning for projects...
-----------------< org.apidesign.demo:sieve-algorithm >-----------------
Building Sieve Implementation 1.0-SNAPSHOT
-------------------------------[ bundle ]-------------------------------
--- exec-maven-plugin:1.6.0:exec (debug) @ sieve-algorithm ---
=thread-group-added,id="i1"
~"GNU gdb (Debian 10.1-2) 10.1.90.20210103-git\n"
~"Copyright (C) 2021 Free Software Foundation, Inc.\n"
~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law."
~"\nType \"show copying\" and \"show warranty\" for details.\n"
~"This GDB was configured as \"x86_64-linux-gnu\".\n"
~"Type \"show configuration\" for configuration details.\n"
~"For bug reporting instructions, please see:\n"
~"<https://www.gnu.org/software/gdb/bugs/>.\n"
~"Find the GDB manual and other documentation resources online at:\n <http://www.gnu.org/software/gdb/documentation/>."
~"\n\n"
~"For help, type \"help\".\n"
~"Type \"apropos word\" to search for commands related to \"word\"...\n"
&"\nwarning: "
&"/home/devel/NetBeansProjects/ttrace/zipkin/graal-enterprise/substratevm-enterprise/svmhelpers.py: Adresá�\231 nebo soubor neexistuje\n"
~"Reading symbols from /home/devel/NetBeansProjects/sieve/java/algorithm/target/sieve...\n"
~"Reading symbols from /home/devel/NetBeansProjects/sieve/java/algorithm/target/sieve.debug...\n"
&"warning: Unsupported auto-load script at offset 0 in section .debug_gdb_scripts\nof file "
&"/home/devel/NetBeansProjects/sieve/java/algorithm/target/sieve.debug.\nUse `info auto-load "
&"python-scripts [REGEXP]' to list them.\n"
(gdb)
that's not fully correct. @entlicher how do you want to establish connection between gdb
and the IDE? Is socket the option?
I am able to connect Java to gdb
with the help of socat
:
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import org.newsclub.net.unix.AFUNIXServerSocket;
import org.newsclub.net.unix.AFUNIXSocketAddress;
public final class SimpleTestServer {
public static void main(String[] args) throws IOException {
final File socketFile = new File(new File(System.getProperty("java.io.tmpdir")), "gdb.sock");
try (AFUNIXServerSocket server = AFUNIXServerSocket.newInstance()) {
server.bind(new AFUNIXSocketAddress(socketFile));
System.out.println("Server is waiting for connection: " + server);
try (Socket sock = server.accept()) {
try (InputStream is = sock.getInputStream(); //
OutputStream os = sock.getOutputStream()) {
os.write("run".getBytes("UTF-8"));
os.flush();
}
}
}
}
}
and then the Java part can send run
command to
$ socat /tmp/gdb.sock - | gdb target/sieve
However I am not able to achieve the same without socat
utility yet.