Skip site navigation (1)Skip section navigation (2)
Date:      14 Apr 1998 19:50:45 -0700
From:      Christoph Toshok <toshok@Hungry.COM>
To:        freebsd-mozilla@FreeBSD.ORG
Subject:   Re: GDB, Memory, and NSPR Threads?
Message-ID:  <m2d8ejajcq.fsf@terror.hungry.com>
In-Reply-To: stevemw@northwest.com's message of 14 Apr 1998 19:14:47 -0700
References:  <m2emyzalxz.fsf@terror.hungry.com> <199804150212.TAA00969@northwest.com>

next in thread | previous in thread | raw e-mail | index | archive | help
stevemw@northwest.com (Stephen Wynne) writes:
> 
> In message <m2emyzalxz.fsf@terror.hungry.com>, Christoph Toshok writes: 
> 
>     yeah, someone has brought it up on mozilla.general some days ago.
>     don't know if they're moving on it, though.
> 
> Chris,
> 
> Thanks for your reply. That someone would be I. And we didn't get a
> response (to that specific question) back from Brendan Eich in that
> thread, which is why I'm asking here.

ahh... sorry for the confusion :)

>     what exactly are you trying to do? I mean, why do you want to pop
>     between threads?
>     
> I want to walk through the code that handles plugins in order to more
> fully understand it. Also, when I start working on a plugin, I want to
> be able to set breakpoints in it and do the normal things I do with a
> debugger. Right now, I end up in the main thread (I think), and I
> never get the chance to enter the other ones. It's all very confusing
> still.

hmmm..  when I was debugging libmocha interactions with layout,
setting breakpoints in mocha functions that were called on the mocha
thread worked ok...  I mean, I don't know anyone at netscape using
unix that has ever been able to do what you want, and we've been
reasonably (heh :) effective at debugging things...

but nevertheless, information is always a good thing.

> Here's what Brendan advised in mozilla-general:
>     
>     I always end up memorizing the stack-pointer and program-counter
>     offsets in the PRThread's jmpbuf or ucontext or whatever struct,
>     printing them out (the current thread is pointed at by
>     [_pr_currentThread], usually the same as mozilla_thread or
>     lm_InterpretThread), setting $sp and $pc, and voila -- you've
>     convinced gdb to switch threads.
> 
> I think I might be able follow Brendan's advice if I knew how to find
> this alleged data structure that describes the threads. I don't know
> how to use his advice about "ucontext." I didn't see anything I could
> comprehend as a live thread map (is there such a thing?) when I looked
> at things declared as PRThread.

look in nsprpub/include/md/_freebsd.h.  <thread>->md.context is a
sigjmp_buf.  This should have all the information you need (the stack
pointer is <thread>->md.context[0]._sjb[2], for instance).

for the list of active threads (and the waitq links), look in
nsprpub/pr/include/private/primpl.h.  This file has the struct
definition for PRThread in it.  if you're not using pthreads (which
freebsd doesn't), there are PRCLists that you can use.

chris

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-mozilla" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?m2d8ejajcq.fsf>