HotSpot Serviceability Agent for BSD
Greg Lewis
glewis at eyesbeyond.com
Wed Feb 4 22:27:32 PST 2009
G'day Swamy,
On Wed, Feb 04, 2009 at 04:22:26PM -0600, Swamy Venkataramanappa wrote:
> Hi Greg and Brain,
>
> Thanks for porting the Serviceability Agent for BSD. I briefly looked
> at the patch code and it looks
> good. Regarding issue #1. I suspect the problem is in the detach code:
>
> +// detach all pids of a ps_prochandle
> +static void detach_all_pids(struct ps_prochandle* ph) {
> + thread_info* thr = ph->threads;
> + while (thr) {
> + ptrace_detach(thr->lwp_id);
> + thr = thr->next;
> + }
> +}
>
> On linux we need to call ptrace(DETACH) for all the threads. This not
> required for other unix
> OS. It depends on how threads are implemented in the OS. I guess for BSD
> you just need to
> call ptrace(DETACH) for process id once.
> I am currently maintaining the Serviceability agent code at Sun. If you
> need any help let me
> know.
Thanks! This is definitely part of the puzzle. I tried replacing the
loop with a ptrace_detach(ph->pid), but now the process segfaults rather
than dying. I think a review of the ptrace calls is in order :).
> Brian Gardner wrote:
> > Great Greg,
> > I'll check out #1 for you later in the week after I release another
> > version of my openjdk6 patch. :)
> >
> > Brian
> >
> > Greg Lewis wrote:
> >
> >> I've been toying with the idea of porting the HotSpot Serviceability Agent
> >> (http://openjdk.java.net/groups/hotspot/docs/Serviceability.html) 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 http://www.eyesbeyond.com/freebsddom/java/saproc.diff
> >> 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 eyesbeyond.com
Eyes Beyond Web : http://www.eyesbeyond.com
Information Technology FreeBSD : glewis at FreeBSD.org
More information about the bsd-port-dev
mailing list