]> git.donarmstrong.com Git - lilypond.git/commitdiff
More debugging output for cyclic callbacks
authorJoe Neeman <joeneeman@gmail.com>
Tue, 20 Feb 2007 21:27:03 +0000 (08:27 +1100)
committerJoe Neeman <joeneeman@gmail.com>
Tue, 20 Feb 2007 21:27:03 +0000 (08:27 +1100)
lily/grob-property.cc
lily/program-option-scheme.cc
scm/lily.scm

index 084ea42fbdb60ede609beddcf35b61cf8889f876..6a8faad0c114111bbf8be09790f0ec6bf288e15f 100644 (file)
 #include "profile.hh"
 #include "simple-closure.hh"
 #include "warn.hh"
+#include "protected-scm.hh"
+
+Protected_scm grob_property_callback_stack = SCM_EOL;
+extern bool debug_property_callbacks;
 
 #ifndef NDEBUG
 static SCM modification_callback = SCM_EOL;
@@ -139,6 +143,14 @@ Grob::internal_get_property_data (SCM sym) const
   return (handle == SCM_BOOL_F) ? SCM_EOL : scm_cdr (handle);
 }
 
+static void
+print_property_callback_stack ()
+{
+  int frame = 0;
+  for (SCM s = grob_property_callback_stack; scm_is_pair (s); s = scm_cdr (s))
+    message (_f ("%d: %s", frame++, ly_scm_write_string (scm_car (s)).c_str ()));
+}
+
 SCM
 Grob::internal_get_property (SCM sym) const
 {
@@ -146,9 +158,16 @@ Grob::internal_get_property (SCM sym) const
 
 #ifndef NDEBUG
   if (val == ly_symbol2scm ("calculation-in-progress"))
-    programming_error (_f ("cyclic dependency: calculation-in-progress encountered for #'%s (%s)",
-                          ly_symbol2string (sym).c_str (),
-                          name ().c_str ()));
+    {
+      programming_error (_f ("cyclic dependency: calculation-in-progress encountered for #'%s (%s)",
+                            ly_symbol2string (sym).c_str (),
+                            name ().c_str ()));
+      if (debug_property_callbacks)
+       {
+         message ("backtrace: ");
+         print_property_callback_stack ();
+       }
+    }
 #endif
   
   if (ly_is_procedure (val)
@@ -161,13 +180,6 @@ Grob::internal_get_property (SCM sym) const
   return val;
 }
 
-#ifndef NDEBUG
-#include "protected-scm.hh"
-
-Protected_scm grob_property_callback_stack = SCM_EOL;
-bool debug_property_callbacks = 0;
-#endif
-
 SCM
 Grob::try_callback_on_alist (SCM *alist, SCM sym, SCM proc)
 {      
@@ -180,7 +192,7 @@ Grob::try_callback_on_alist (SCM *alist, SCM sym, SCM proc)
 
 #ifndef NDEBUG
   if (debug_property_callbacks)
-    grob_property_callback_stack = scm_acons (sym, proc, grob_property_callback_stack);
+    grob_property_callback_stack = scm_cons (scm_list_3 (self_scm (), sym, proc), grob_property_callback_stack);
 #endif
 
   SCM value = SCM_EOL;
index 1efcc75a2949d164b9eb92661c635e5e10cdb6ac..2e92fcd45b7e23a45d7de4506dcaa918aa62b2dd 100644 (file)
@@ -20,6 +20,7 @@ using namespace std;
 #include "warn.hh"
 
 bool debug_skylines;
+bool debug_property_callbacks;
 
 /*
   Backwards compatibility.
@@ -88,6 +89,11 @@ void internal_set_option (SCM var, SCM val)
       debug_skylines = to_boolean (val);
       val = scm_from_bool (to_boolean (val));
     }
+  else if (var == ly_symbol2scm ("debug-property-callbacks"))
+    {
+      debug_property_callbacks = to_boolean (val);
+      val = scm_from_bool (to_boolean (val));
+    }
 }
 
 
index 94760bb5a849f635a5ea9a61d400157a574b57d6..5a8a74407470d6d0596ef0cec8e21ad0bfcd6cf9 100644 (file)
@@ -36,6 +36,7 @@
 ensure that all refs to parsed objects are dead.  This is an internal option, and is switched on automatically for -ddebug-gc.") 
     (debug-lexer #f "debug the flex lexer")
     (debug-parser #f "debug the bison parser")
+    (debug-property-callbacks #f "debug cyclic callback chains")
     (debug-skylines #f "debug skylines")
     (delete-intermediate-files #f
                               "delete unusable PostScript files")