From: Ken Raeburn <raeburn@raeburn.org>
To: Andy Wingo <wingo@pobox.com>
Cc: guile-devel <guile-devel@gnu.org>
Subject: Re: advice on reducing C stack frame size?
Date: Tue, 16 Sep 2008 01:27:45 -0400 [thread overview]
Message-ID: <7683D3EC-06F5-407D-B353-E5E7BB1836EA@raeburn.org> (raw)
In-Reply-To: <m34p4kx9w5.fsf@pobox.com>
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 <gdb_main>: push %ebp
[...]
0x796c6 <gdb_main+51>: mov %ecx,0x4(%esp)
0x796ca <gdb_main+55>: mov %eax,(%esp)
0x796cd <gdb_main+58>: call 0x7743a <catch_errors>
0x796d2 <gdb_main+63>: add $0x14,%esp <---- insn to return to
0x796d5 <gdb_main+66>: mov $0x1,%eax
0x796da <gdb_main+71>: 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
next prev parent reply other threads:[~2008-09-16 5:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-13 16:56 advice on reducing C stack frame size? Andy Wingo
2008-09-13 18:48 ` Han-Wen Nienhuys
2008-09-14 16:46 ` Neil Jerram
2008-09-16 5:27 ` Ken Raeburn [this message]
2008-09-16 17:57 ` Andy Wingo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7683D3EC-06F5-407D-B353-E5E7BB1836EA@raeburn.org \
--to=raeburn@raeburn.org \
--cc=guile-devel@gnu.org \
--cc=wingo@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).