Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Mar 2015 00:26:22 +0100
From:      Mateusz Guzik <mjguzik@gmail.com>
To:        Yue Chen <ycyc321@gmail.com>
Cc:        "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org>
Subject:   Re: How to traverse kernel threads?
Message-ID:  <20150321232622.GF14650@dft-labs.eu>
In-Reply-To: <CAKtBrB5KNqt6UJ1R_BQpPfTvQZdUzGvZZtT7Uz5qd4VrrfgEdw@mail.gmail.com>
References:  <CAKtBrB4h13ZFJ=V0fvkDeTG-L6=e5Uz9%2BHfYc8vY523Y3X6N0A@mail.gmail.com> <20150321220246.GE14650@dft-labs.eu> <CAKtBrB5KNqt6UJ1R_BQpPfTvQZdUzGvZZtT7Uz5qd4VrrfgEdw@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Mar 21, 2015 at 06:11:57PM -0400, Yue Chen wrote:
> Thanks for the quick reply.
> 
> What I am trying to achieve is to get the stack starting and ending address
> of a kernel module.
> I think it could be got from
> 
> struct thread *td
> td->td_kstack
> td->td_kstack + td->td_kstack_pages * PAGE_SIZE
> 
> So I need to get the ``td'' first.
> Maybe there is another way to get it other than traversing?
> 

Kernel modules don't have stacks, presumably you mean kernel threads
created by code in modules.

But how would you go about recognising that given thread was created by
given module? I don't see starting func stored anywhere, so you would
need some crap hacks to unwind the stack by hand and even that is not
reliable (not to mention terrible).

But once more the real question is what are you trying to do. I don't
see any use for stack info of random threads.

-- 
Mateusz Guzik <mjguzik gmail.com>



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