]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/debug.cc
release: 1.3.26
[lilypond.git] / lily / debug.cc
index 4b95a385191f2765969b1131ea85d704101e9a1e..3638dd6c764ac0d74bc20b6ad144dc09fed16767 100644 (file)
@@ -1,65 +1,53 @@
+/*   
+  debug.cc --  implement debugging routines
+  
+  source file of the GNU LilyPond music typesetter
+  
+  (c) 1996,98 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  
+ */
+
 #include <fstream.h>
 #include <signal.h>
-#include <new.h>
 #include <stdlib.h>
+
 #include "debug.hh"
 #include "dstream.hh"
 #include "flower-debug.hh"
 #include "moment.hh"
+#include "misc.hh"
+#include "main.hh"
 
-Dstream *monitor=0;
-ostream * nulldev =0;
-static void (*rat_printer)(Moment const&);
-
-// ugh
-struct _Dinit {
-    _Dinit() {
-       nulldev = new ofstream("/dev/null");
-       monitor = new Dstream(&cout,".dstreamrc");
-    }
-    ~_Dinit() {
-       delete nulldev;
-       delete monitor;
-    }
-} dinit;
-
+Dstream *my_monitor=0;
 
-
-/*
-  want to do a stacktrace .
-  */
 void
-mynewhandler()
+float_handler (int)
 {
-    assert(false);
-}
-
-void
-float_handler(int)
-{
-    cerr << "Floating point exception .. \n"<< flush;
-    assert(false);
+  cerr << _ ("floating point exception") << endl;
+  assert (false);
 }
 
 void
 debug_init()
 {
-    rat_printer = printm;      // make sure this is linked in
-#ifndef NDEBUG
-    set_new_handler(&mynewhandler);
-#endif
-    set_flower_debug(*monitor, check_debug);
-    
-    signal(SIGFPE, float_handler);
-}   
+  my_monitor = new Dstream (&cout, ".dstreamrc");
+  signal (SIGFPE, float_handler);
+}
 
-bool check_debug=false;
+bool check_malloc_b = false;
 
 void
-set_debug(bool b)
+set_debug (bool b)
 {
-    check_debug =b;
-    set_flower_debug(*monitor, check_debug);
+  if (b)
+    flower_dstream = my_monitor;
+  else
+    flower_dstream = 0;
+  
+#ifdef MEMORY_PARANOID
+  if (check_malloc_b)
+    if (mcheck (0))
+      warning (_ ("Can't set mem-checking!"));
+#endif
 }
 
-