lilypond-0.1.16
[lilypond.git] / lily / debug.cc
blob2141be63a461435f1550ee6c9ec392e5142523fb
1 #include <fstream.h>
2 #include <signal.h>
3 #include <std/new.h>
4 #include <stdlib.h>
5 #include "debug.hh"
6 #include "dstream.hh"
7 #include "flower-debug.hh"
8 #include "moment.hh"
10 Dstream *monitor=0;
11 ostream * nulldev =0;
14 // ugh
15 struct _Dinit {
16 _Dinit()
18 nulldev = new ofstream ("/dev/null");
19 monitor = new Dstream (&cout,".dstreamrc");
21 ~_Dinit()
23 delete nulldev;
24 delete monitor;
26 } dinit;
31 want to do a stacktrace .
33 void
34 mynewhandler()
36 assert (false);
39 void
40 float_handler (int)
42 cerr << "Floating point exception .. \n"<< flush;
43 assert (false);
46 /// just to make sure print_rat is linked in
47 static void (*rat_printer)(Moment const&);
49 void
50 debug_init()
52 rat_printer = print_rat;
53 #ifndef NDEBUG
54 set_new_handler (&mynewhandler);
55 #endif
56 set_flower_debug (*monitor, check_debug);
58 signal (SIGFPE, float_handler);
61 bool check_debug=false;
63 void
64 set_debug (bool b)
66 check_debug =b;
67 set_flower_debug (*monitor, check_debug);