From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ken Raeburn Newsgroups: gmane.lisp.guile.devel Subject: Re: advice on reducing C stack frame size? Date: Tue, 16 Sep 2008 01:27:45 -0400 Message-ID: <7683D3EC-06F5-407D-B353-E5E7BB1836EA@raeburn.org> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v928.1) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1221542916 17667 80.91.229.12 (16 Sep 2008 05:28:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 16 Sep 2008 05:28:36 +0000 (UTC) Cc: guile-devel To: Andy Wingo Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Sep 16 07:29:32 2008 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KfT7z-00081v-H5 for guile-devel@m.gmane.org; Tue, 16 Sep 2008 07:29:31 +0200 Original-Received: from localhost ([127.0.0.1]:57361 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KfT6y-00069j-JX for guile-devel@m.gmane.org; Tue, 16 Sep 2008 01:28:28 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KfT6v-00068o-LM for guile-devel@gnu.org; Tue, 16 Sep 2008 01:28:25 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KfT6q-000654-LP for guile-devel@gnu.org; Tue, 16 Sep 2008 01:28:25 -0400 Original-Received: from [199.232.76.173] (port=45470 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KfT6q-00064t-73 for guile-devel@gnu.org; Tue, 16 Sep 2008 01:28:20 -0400 Original-Received: from raeburn.org ([69.25.196.97]:20046) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KfT6f-0005To-Lb for guile-devel@gnu.org; Tue, 16 Sep 2008 01:28:20 -0400 Original-Received: from squish.raeburn.org (squish.raeburn.org [69.25.196.102]) by raeburn.org (8.14.1/8.14.1) with ESMTP id m8G5Rj7W028369; Tue, 16 Sep 2008 01:27:45 -0400 (EDT) In-Reply-To: X-Mailer: Apple Mail (2.928.1) X-detected-operating-system: by monty-python.gnu.org: NetBSD 3.0 (DF) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:7700 Archived-At: On Sep 13, 2008, at 12:56, Andy Wingo wrote: > So for example, just sitting at the repl, we have: > > [...] > #27 0x0014e99b in scm_apply (proc=0xb7f0d718, arg1=0x404, > args=0x404) at eval.i.c:1656 > 1656 return scm_dapply (proc, arg1, args); > (gdb) > #28 0x001c48fc in vm_run (vm=0xb7f1ff58, program=0x8d53df8, > args=0x404) at vm-i-system.c:510 > 510 *sp = scm_apply (x, args, SCM_EOL); > (gdb) p sp - vp->stack_base > $3 = 104 > (gdb) up > #29 0x001bfcad in program_apply (program=0xb7ee2730, args=0x404) > at programs.c:126 > 126 return scm_vm_apply (scm_the_vm (), program, args); > (gdb) p 0x001c48fc - 0x001bfcad > $4 = 19535 > > The difference between #29 and #28 is the size of the vm_run() stack > frame (I think). Aren't those the program counter addresses you're looking at? Note that the value at #29 is in between #27 and #28. Stack frames usually don't work that way. :-) (gdb) bt [...] #7 0x00079691 in captured_main () #8 0x00077487 in catch_errors () #9 0x000796d2 in gdb_main () <---- pc address 0x796d2 #10 0x00001f1e in main () (gdb) x/20i gdb_main 0x79693 : push %ebp [...] 0x796c6 : mov %ecx,0x4(%esp) 0x796ca : mov %eax,(%esp) 0x796cd : call 0x7743a 0x796d2 : add $0x14,%esp <---- insn to return to 0x796d5 : mov $0x1,%eax 0x796da : pop %ebx (gdb) Try "print $sp" or "info reg" at each frame to see the stack pointer. Or you could try disassembling the entire thing, and scan for a regexp matching near the start of a function (say, symbol name, "+", one digit or a "1" and another digit, then ">", and an instruction that adjusts the stack pointer by a 3-digit value or more. If it works, that may show you all the biggest-frame functions. Ken