Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Jun 2013 08:45:44 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        FreeBSD hackers Mail List <freebsd-hackers@freebsd.org>
Subject:   Re: Where is stack of program?
Message-ID:  <20130611054544.GI3047@kib.kiev.ua>
In-Reply-To: <20130610164425.GA2966@vagner-wrk.bsdway.ru>
References:  <20130610164425.GA2966@vagner-wrk.bsdway.ru>

next in thread | previous in thread | raw e-mail | index | archive | help

--Hb99djDM/33ECHXq
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Mon, Jun 10, 2013 at 08:44:25PM +0400, Vagner wrote:
> Hi!
> I need method of finding in struct vm_map or vm_object segments of
> memory which is situated in the stack.
> Can you help me please?

Note that the stack is per-thread.  The concept is somewhat machine-specific,
some architectures utilize two stacks, on some the stack is purely software
convention.

You did not specified what context your code is to be run, e.g. is
it kernel or user space ? Assuming it is kernel since you mentioned
vm_something. The least error prone route is the thread context (frame)
-> tf_esp on i386 (or tf_rsp on amd64) -> lookup of the map entry in the
process p_vmspace.

In reality, the stack is often fragmented, since the stack grow code
does not coalesce the adjacent grow-down map entries.

--Hb99djDM/33ECHXq
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.20 (FreeBSD)

iQIcBAEBAgAGBQJRtrmHAAoJEJDCuSvBvK1Bp2MP/RU9H5Tk8jOV7O7duw2OEVxV
9X2Hvt7KyhO0oqnbXEtjUhLIuhr6DnXNn8rG9amtW5asflPxKpGfm6SAJigMHJ6m
e0u+vxoywiswcoDW9s01z3DWjdcLaHN70juYPYgO2RLNB2tni7S3rWxd4c3aJXbk
o2Q4Mh8Pfiqu+Lql42MFUO8wxd2I1vmdMgceaP3+W6ydobcDjdtH/xIqjs745EI2
3DJQ8F1Nf9x8+42D0jkMZ9kfCxmI2fg7XLZmod2l6jUTvET6WivA08RDMPgjG3AT
aj6TmgYELA+N78p3AYiuw+J/E7+RXfMN2myxRnLVytiWO2RKc8TxE48O+tOpre7H
iWLhoTBZX8TKsbHpldV4DcVpedISBd0B3dadEhdUig4aaBIXaihrDaaM63nDGaho
zjQMLkXWJf3nQ/H07hQlMq5YckNGTWzcmN/UwR+Z1o8dC7nID+S1y6iqRbk0imga
WP7lYzhfXesEPpX53JcfYPrAmsTYu7/IxyMivo+xlJ5w28+FejoIk605hx2tORuR
uIBSKONb5VwIcQr4m4aZ8GcrFxNdlDBUpaS4ow6qaMap9s6DRBItHjmiN80/n3be
7LQRuQscOE7mo03X8FAW6jmqES9wK9XVe6yvpCWU8ixmC+PfI78IqZxZzMUG37f7
RFAzyVQPUWFN5Kwhlnba
=WvAu
-----END PGP SIGNATURE-----

--Hb99djDM/33ECHXq--



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