title: Valgrind stack misses a function completely
body: <p>i have two c files:</p>
  
  <p>a.c</p>
  
  <pre><code>void main(){
      ...
      getvtable()-&gt;function();
  }
  </code></pre>
  
  <p>the vtable is pointing to a function that is located in b.c:</p>
  
  <pre><code>void function(){
      malloc(42);
  }
  </code></pre>
  
  <p>now if i trace the program in valgrind I get the following:</p>
  
  <pre><code>==29994== 4,155 bytes in 831 blocks are definitely lost in loss record 26 of 28
  ==29994==    at 0x402CB7A: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
  ==29994==    by 0x40A24D2: (below main) (libc-start.c:226)
  </code></pre>
  
  <p>so the call to function is completely ommited on the stack! How is it possible? In case I use GDB, a correct stack including "function" is shown.</p>
  
  <p>Debug symbols are included, Linux, 32-bit.</p>
  
  <p>Upd:</p>
  
  <p>Answering the first question, I get the following output when debugging valgrind's GDB server. The breakpoint is not coming, while it comes when i debug directly with GDB.</p>
  
  <pre><code>stasik@gemini:~$ gdb -q
  (gdb) set confirm off
  (gdb) target remote | vgdb
  Remote debugging using | vgdb
  relaying data between gdb and process 11665
  [Switching to Thread 11665]
  0x040011d0 in ?? ()
  (gdb) file /home/stasik/leak.so
  Reading symbols from /home/stasik/leak.so...done.
  (gdb) break function
  Breakpoint 1 at 0x110c: file ../../source/leakclass.c, line 32.
  (gdb) commands
  Type commands for breakpoint(s) 1, one per line.
  End with a line saying just "end".
  &gt;silent
  &gt;end
  (gdb) continue
  Continuing.
  
  Program received signal SIGTRAP, Trace/breakpoint trap.
  0x0404efcb in ?? ()
  (gdb) source thread-frames.py
  Stack level 0, frame at 0x42348a0:
   eip = 0x404efcb; saved eip 0x4f2f544c
   called by frame at 0x42348a4
   Arglist at 0x4234898, args:
   Locals at 0x4234898, Previous frame's sp is 0x42348a0
   Saved registers:
    ebp at 0x4234898, eip at 0x423489c
  Stack level 1, frame at 0x42348a4:
   eip = 0x4f2f544c; saved eip 0x6e492056
   called by frame at 0x42348a8, caller of frame at 0x42348a0
   Arglist at 0x423489c, args:
   Locals at 0x423489c, Previous frame's sp is 0x42348a4
   Saved registers:
    eip at 0x42348a0
  Stack level 2, frame at 0x42348a8:
   eip = 0x6e492056; saved eip 0x205d6f66
   called by frame at 0x42348ac, caller of frame at 0x42348a4
   Arglist at 0x42348a0, args:
   Locals at 0x42348a0, Previous frame's sp is 0x42348a8
   Saved registers:
    eip at 0x42348a4
  Stack level 3, frame at 0x42348ac:
   eip = 0x205d6f66; saved eip 0x61746144
  ---Type &lt;return&gt; to continue, or q &lt;return&gt; to quit---
   called by frame at 0x42348b0, caller of frame at 0x42348a8
   Arglist at 0x42348a4, args:
   Locals at 0x42348a4, Previous frame's sp is 0x42348ac
   Saved registers:
    eip at 0x42348a8
  Stack level 4, frame at 0x42348b0:
   eip = 0x61746144; saved eip 0x65736162
   called by frame at 0x42348b4, caller of frame at 0x42348ac
   Arglist at 0x42348a8, args:
   Locals at 0x42348a8, Previous frame's sp is 0x42348b0
   Saved registers:
    eip at 0x42348ac
  Stack level 5, frame at 0x42348b4:
   eip = 0x65736162; saved eip 0x70616d20
   called by frame at 0x42348b8, caller of frame at 0x42348b0
   Arglist at 0x42348ac, args:
   Locals at 0x42348ac, Previous frame's sp is 0x42348b4
   Saved registers:
    eip at 0x42348b0
  Stack level 6, frame at 0x42348b8:
   eip = 0x70616d20; saved eip 0x2e646570
   called by frame at 0x42348bc, caller of frame at 0x42348b4
   Arglist at 0x42348b0, args:
  ---Type &lt;return&gt; to continue, or q &lt;return&gt; to quit---
   Locals at 0x42348b0, Previous frame's sp is 0x42348b8
   Saved registers:
    eip at 0x42348b4
  Stack level 7, frame at 0x42348bc:
   eip = 0x2e646570; saved eip 0x0
   called by frame at 0x42348c0, caller of frame at 0x42348b8
   Arglist at 0x42348b4, args:
   Locals at 0x42348b4, Previous frame's sp is 0x42348bc
   Saved registers:
    eip at 0x42348b8
  Stack level 8, frame at 0x42348c0:
   eip = 0x0; saved eip 0x0
   caller of frame at 0x42348bc
   Arglist at 0x42348b8, args:
   Locals at 0x42348b8, Previous frame's sp is 0x42348c0
   Saved registers:
    eip at 0x42348bc
  (gdb) continue
  Continuing.
  
  Program received signal SIGTRAP, Trace/breakpoint trap.
  0x0404efcb in ?? ()
  (gdb) continue
  Continuing.
  </code></pre>