fix some missed references when calling C functions
authorAndy Wingo <wingo@pobox.com>
Tue, 30 Sep 2008 20:50:48 +0000 (22:50 +0200)
committerAndy Wingo <wingo@pobox.com>
Tue, 30 Sep 2008 20:50:48 +0000 (22:50 +0200)
* gdbinit: Update to be a bit more useful.

* libguile/vm-i-system.c: Make sure that arguments to C procedures are
  visible on the stack so they get marked. Could be a source for the
  missed references.

gdbinit
libguile/vm-i-system.c

diff --git a/gdbinit b/gdbinit
index 40c8f62..ad7881f 100644 (file)
--- a/gdbinit
+++ b/gdbinit
@@ -99,90 +99,98 @@ define smobdescriptor
   p scm_smobs[0xff & (((scm_t_bits)$arg0) >> 8)]
 end
 
-define vmstack
+define vmstackinit
   set $vmsp=sp
   set $vmstack_base=stack_base
   set $vmfp=fp
   set $vmbp=bp
   set $vmframe=0
-  while $vmsp > vp->stack_base
-    set $orig_vmsp=$vmsp
-    while $vmsp > $vmstack_base
-      output $orig_vmsp - $vmsp
-      sputs "\t"
-      output $vmsp
-      sputs "\t"
-      gwrite *$vmsp
-      set $vmsp=$vmsp-1
-    end
-    newline
-    sputs "Frame "
-    output $vmframe
-    newline
-    sputs "ra:\t"
-    output $vmsp
-    sputs "\t"
-    output (SCM*)*$vmsp
-    set $vmsp=$vmsp-1
-    newline
-    sputs "mvra:\t"
-    output $vmsp
-    sputs "\t"
-    output (SCM*)*$vmsp
-    set $vmsp=$vmsp-1
-    newline
-    sputs "dl:\t"
-    output $vmsp
+end
+
+define nextframe
+  set $orig_vmsp=$vmsp
+  while $vmsp > $vmstack_base
+    output $orig_vmsp - $vmsp
     sputs "\t"
-    set $vmdl=(SCM*)(*$vmsp)
-    output $vmdl
-    newline
-    set $vmsp=$vmsp-1
-    sputs "hl:\t"
     output $vmsp
     sputs "\t"
     gwrite *$vmsp
     set $vmsp=$vmsp-1
-    sputs "el:\t"
+  end
+  newline
+  sputs "Frame "
+  output $vmframe
+  newline
+  sputs "ra:\t"
+  output $vmsp
+  sputs "\t"
+  output (SCM*)*$vmsp
+  set $vmsp=$vmsp-1
+  newline
+  sputs "mvra:\t"
+  output $vmsp
+  sputs "\t"
+  output (SCM*)*$vmsp
+  set $vmsp=$vmsp-1
+  newline
+  sputs "dl:\t"
+  output $vmsp
+  sputs "\t"
+  set $vmdl=(SCM*)(*$vmsp)
+  output $vmdl
+  newline
+  set $vmsp=$vmsp-1
+  sputs "hl:\t"
+  output $vmsp
+  sputs "\t"
+  gwrite *$vmsp
+  set $vmsp=$vmsp-1
+  sputs "el:\t"
+  output $vmsp
+  sputs "\t"
+  gwrite *$vmsp
+  set $vmsp=$vmsp-1
+  set $vmnlocs=(int)$vmbp->nlocs
+  while $vmnlocs > 0
+    sputs "loc #"
+    output $vmnlocs
+    sputs ":\t"
     output $vmsp
     sputs "\t"
     gwrite *$vmsp
     set $vmsp=$vmsp-1
-    set $vmnlocs=(int)$vmbp->nlocs
-    while $vmnlocs > 0
-      sputs "loc #"
-      output $vmnlocs
-      sputs ":\t"
-      output $vmsp
-      sputs "\t"
-      gwrite *$vmsp
-      set $vmsp=$vmsp-1
-      set $vmnlocs=$vmnlocs-1
-    end
-    set $vmnargs=(int)$vmbp->nargs
-    while $vmnargs > 0
-      sputs "arg #"
-      output $vmnargs
-      sputs ":\t"
-      output $vmsp
-      sputs "\t"
-      gwrite *$vmsp
-      set $vmsp=$vmsp-1
-      set $vmnargs=$vmnargs-1
-    end
-    sputs "prog:\t"
+    set $vmnlocs=$vmnlocs-1
+  end
+  set $vmnargs=(int)$vmbp->nargs
+  while $vmnargs > 0
+    sputs "arg #"
+    output $vmnargs
+    sputs ":\t"
     output $vmsp
     sputs "\t"
     gwrite *$vmsp
     set $vmsp=$vmsp-1
-    newline
-    if !$vmdl
-      loop_break
-    end
-    set $vmfp=$vmdl
-    set $vmbp=(struct scm_program*)(((SCM*)($vmfp[-1]))[1])
-    set $vmstack_base=$vmfp+$vmbp->nargs+$vmbp->nlocs+4
-    set $vmframe=$vmframe+1
-    newline
+    set $vmnargs=$vmnargs-1
+  end
+  sputs "prog:\t"
+  output $vmsp
+  sputs "\t"
+  gwrite *$vmsp
+  set $vmsp=$vmsp-1
+  newline
+  if !$vmdl
+    loop_break
+  end
+  set $vmfp=$vmdl
+  set $vmbp=(struct scm_program*)(((SCM*)($vmfp[-1]))[1])
+  set $vmstack_base=$vmfp+$vmbp->nargs+$vmbp->nlocs+4
+  set $vmframe=$vmframe+1
+  newline
+end
+
+define vmstack
+  vmstackinit
+  while $vmsp > vp->stack_base
+    nextframe
   end
 end
index 87d3a53..46075c0 100644 (file)
@@ -558,12 +558,12 @@ VM_DEFINE_INSTRUCTION (call, "call", 1, -1, 1)
     {
       /* At this point, the stack contains the procedure and each one of its
         arguments.  */
-      SCM args;
       POP_LIST (nargs);
-      POP (args);
       SYNC_REGISTER ();
-      *sp = scm_apply (x, args, SCM_EOL);
+      /* keep args on stack so they are marked */
+      sp[-1] = scm_apply (x, sp[0], SCM_EOL);
       /* FIXME what if SCM_VALUESP(*sp) */
+      DROP ();
       NEXT;
     }
   /*
@@ -729,11 +729,10 @@ VM_DEFINE_INSTRUCTION (goto_args, "goto/args", 1, -1, 1)
    */
   if (!SCM_FALSEP (scm_procedure_p (x)))
     {
-      SCM args;
       POP_LIST (nargs);
-      POP (args);
       SYNC_REGISTER ();
-      *sp = scm_apply (x, args, SCM_EOL);
+      sp[-1] = scm_apply (x, sp[0], SCM_EOL);
+      DROP ();
       /* FIXME what if SCM_VALUESP(*sp) */
       goto vm_return;
     }
@@ -798,11 +797,10 @@ VM_DEFINE_INSTRUCTION (mv_call, "mv-call", 3, -1, 1)
     {
       /* At this point, the stack contains the procedure and each one of its
         arguments.  */
-      SCM args;
       POP_LIST (nargs);
-      POP (args);
       SYNC_REGISTER ();
-      *sp = scm_apply (x, args, SCM_EOL);
+      sp[-1] = scm_apply (x, sp[0], SCM_EOL);
+      DROP ();
       if (SCM_VALUESP (*sp))
         {
           SCM values, len;