Issues with dtraceasm, and a workaround

Henri Tremblay henri.tremblay at gmail.com
Tue Feb 23 04:27:03 UTC 2021


Yes. This looks fine:

Collection<String> messages = Utils.tryWith("sudo", "kill", "-TERM",
Long.toString(dtraceProcess.pid()));
if (!messages.isEmpty()) {
    throw new IllegalStateException(messages.toString());
}

However, Paul is right, the pid() method doesn't exist so you will need
something like this:

private long getPid(Process process) {
    String version = System.getProperty("java.version");
    if (!version.startsWith("1.")) {
        // Java 9 and above
        return process.pid();
    }
    try {
        Class<?> c = Class.forName("java.lang.UNIXProcess");
        Field f = c.getDeclaredField("pid");
        f.setAccessible(true);
        return (int) f.get(process);
    } catch (NoSuchFieldException | ClassNotFoundException |
IllegalAccessException e) {
        throw new RuntimeException(e);
    }
}

I wasn't able to compile hsdis to get the line resolution but I do get the
dtrace result. I get
jdk/src/utils/hsdis/binutils-2.31.1/libiberty/fibheap.c:220:30: error: use
of undeclared identifier 'LONG_MIN'
  if (okey == key && okey != FIBHEAPKEY_MIN)
                             ^
jdk/src/utils/hsdis/binutils-2.31.1/libiberty/fibheap.c:38:24: note:
expanded from macro 'FIBHEAPKEY_MIN'
#define FIBHEAPKEY_MIN  LONG_MIN
                        ^
jdk/src/utils/hsdis/binutils-2.31.1/libiberty/fibheap.c:261:36: error: use
of undeclared identifier 'LONG_MIN'
  fibheap_replace_key (heap, node, FIBHEAPKEY_MIN);
                                   ^
jdk/src/utils/hsdis/binutils-2.31.1/libiberty/fibheap.c:38:24: note:
expanded from macro 'FIBHEAPKEY_MIN'
#define FIBHEAPKEY_MIN  LONG_MIN

On master and jdk-1+9.

So if someone has an idea....


More information about the jmh-dev mailing list