HotSpot Serviceability Agent for BSD

Greg Lewis glewis at
Mon Feb 2 09:22:16 PST 2009

I've been toying with the idea of porting the HotSpot Serviceability Agent
( to BSD
for a while now.

Brian Gardner's work on getting jmap -dump and jmap -histo to work for
FreeBSD's jdk16 port catalysed this.  A work in progress patch is
available at
This allows me to use the other jmap options (-finalizerinfo, -heap,
-permstat) and allows jinfo to work.  It should also get jsadebugd
to work, but I haven't tried that yet.

The patch is for OpenJDK7 and includes changes based in part on
Brian's work (so jmap -dump and jmap -histo work as well).

There are some serious caveats so far though.

1. The Java process being attached to appears to be killed after the
   attachment completes.  So I can, for example, run 'jmap -permstat <pid>'
   and get the expected output, but then <pid> dies.  I haven't looked
   into this yet, but its obviously a big problem :).

2. It works on FreeBSD 7.x only since it uses the undocumented
   kinfo_getvmmap function to look up information about the shared
   libraries that the process has open.  I suspect we can do something
   with libkvm for OpenBSD and NetBSD.  Anyone know how to do this on
   Mac OS X?  On Linux (which is what I ported against) this is done
   by looking at /proc/<pid>/maps.  Better suggestions?

3. It includes the hsearch_r source from GNU libc since BSD doesn't have
   this.  I don't think this is a problem license wise, but in case it is
   I think we can come up with something similar that is available on
   BSD.  I just grabbed it 'cos it was simpler at the time to keep things
   as close to the Linux version as was reasonable.

For me this moves us towards closing one of our only feature gaps (as I
see it).  But it definitely needs some more review and fixing, so all
comments, patches, etc. appreciated.

Greg Lewis                          Email   : glewis at
Eyes Beyond                         Web     :
Information Technology              FreeBSD : glewis at

More information about the bsd-port-dev mailing list