|
From: | Ken Raeburn |
Subject: | Re: advice on reducing C stack frame size? |
Date: | Tue, 16 Sep 2008 01:27:45 -0400 |
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:16561656 return scm_dapply (proc, arg1, args); (gdb)#28 0x001c48fc in vm_run (vm=0xb7f1ff58, program=0x8d53df8, args=0x404) at vm-i-system.c:510510 *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:126126 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
[Prev in Thread] | Current Thread | [Next in Thread] |