From owner-freebsd-chat Mon Jul 23 16:37:59 2001 Delivered-To: freebsd-chat@freebsd.org Received: from meow.osd.bsdi.com (meow.osd.bsdi.com [204.216.28.88]) by hub.freebsd.org (Postfix) with ESMTP id 5EC8E37B401 for ; Mon, 23 Jul 2001 16:37:56 -0700 (PDT) (envelope-from jhb@FreeBSD.org) Received: from laptop.baldwin.cx (john@jhb-laptop.osd.bsdi.com [204.216.28.241]) by meow.osd.bsdi.com (8.11.4/8.11.2) with ESMTP id f6NNaVv06175; Mon, 23 Jul 2001 16:36:31 -0700 (PDT) (envelope-from jhb@FreeBSD.org) Message-ID: X-Mailer: XFMail 1.4.0 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <20010724002816.A62305@dogma.freebsd-uk.eu.org> Date: Mon, 23 Jul 2001 16:36:39 -0700 (PDT) From: John Baldwin To: j mckitrick Subject: Re: stack use preference Cc: freebsd-chat@FreeBSD.org Sender: owner-freebsd-chat@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org On 23-Jul-01 j mckitrick wrote: >| > memory. So the question (if it still stands) is do you subtract the space >| > for local vars before or after moving esp to ebp? I've seen both ways in >| > Win32 and Unix code. >| >| After. This way you can always get to the old frame at [ebp] and the IP of >| the >| previous frame at [ebp+4]. These constant offets are quite handy for >| walking >| back stack traces by hand. See the descriptions of the 286+ enter and leave >| instructions. > > Hmmm. The argument I heard for moving esp to ebp before making room for > local variables is that function parameters are accessible at positive > offsets from esp, and all locals are negative. I guess that puts the > previous IP and stack frame at [total space req'd by local vars + 0] and > [+4] respectively. Right, and 'total space req'd by local vars' is an opaque value that you don't know when you are walking back through a stack dump. :( About like walking back on a stack dump on an alpha. Alpha's use a function prologue that define what registers are saved on the stack when a functoin is called, so you have to just look for addresses that "look right" in the dump. Nor can you do a traceback on the alpha w/o a symbole table, which we can do on x86 in ddb for example. (Alpha also doesn't push the frame pointer, but that is another matter). -- John Baldwin -- http://www.FreeBSD.org/~jhb/ PGP Key: http://www.baldwin.cx/~john/pgpkey.asc "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-chat" in the body of the message