X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=libs%2Fpbd%2Fdebug.cc;h=0940146aef756d7007026c7dad035fb20d49c6c0;hb=d40cc6f6f980686c4f1b0f3cd0126fe7ce80cf88;hp=25ebb64850e58771a0aa3101114871c903495e71;hpb=cc543280d9869d4a7b800d547c53e38b13d02cea;p=ardour.git diff --git a/libs/pbd/debug.cc b/libs/pbd/debug.cc index 25ebb64850..0940146aef 100644 --- a/libs/pbd/debug.cc +++ b/libs/pbd/debug.cc @@ -53,22 +53,50 @@ DebugBits PBD::DEBUG::EventLoop = PBD::new_debug_bit ("eventloop"); DebugBits PBD::DEBUG::AbstractUI = PBD::new_debug_bit ("abstractui"); DebugBits PBD::DEBUG::FileUtils = PBD::new_debug_bit ("fileutils"); DebugBits PBD::DEBUG::Configuration = PBD::new_debug_bit ("configuration"); +DebugBits PBD::DEBUG::UndoHistory = PBD::new_debug_bit ("undohistory"); +DebugBits PBD::DEBUG::Timing = PBD::new_debug_bit ("timing"); +DebugBits PBD::DEBUG::Threads = PBD::new_debug_bit ("threads"); +DebugBits PBD::DEBUG::Locale = PBD::new_debug_bit ("locale"); + +/* These are debug bits that are used by backends. Since these are loaded dynamically, + after command-line parsing, defining them in code that is part of the backend + doesn't make them available for command line parsing. Put them here. + + This is sort of a hack, because it means that the debug bits aren't defined + with the code in which they are relevant. But providing access to debug bits + from dynamically loaded code, for use in command line parsing, is way above the pay grade + of this debug tracing scheme. +*/ +DebugBits PBD::DEBUG::WavesMIDI = PBD::new_debug_bit ("WavesMIDI"); +DebugBits PBD::DEBUG::WavesAudio = PBD::new_debug_bit ("WavesAudio"); DebugBits PBD::debug_bits; DebugBits PBD::new_debug_bit (const char* name) { - DebugBits ret; - ret.set (_debug_bit++, 1); - _debug_bit_map().insert (make_pair (name, ret)); + DebugBits ret; + DebugMap::iterator i =_debug_bit_map().find (name); + + if (i != _debug_bit_map().end()) { + return i->second; + } + + if (_debug_bit >= debug_bits.size()) { + cerr << "Too many debug bits defined, offender was " << name << endl; + abort (); + /*NOTREACHED*/ + } + + ret.set (_debug_bit++, 1); + _debug_bit_map().insert (make_pair (name, ret)); return ret; } void PBD::debug_print (const char* prefix, string str) { - cerr << prefix << ": " << str; + cout << prefix << ": " << str; } int @@ -96,13 +124,13 @@ PBD::parse_debug_options (const char* str) if (strncasecmp (cstr, i->first, strlen (cstr)) == 0) { bits |= i->second; - cerr << i->first << " set ... debug bits now set to " << bits << " using " << i->second << endl; + cout << i->first << " set ... debug bits now set to " << bits << " using " << i->second << endl; } } } - + debug_bits = bits; - + return 0; } @@ -110,7 +138,7 @@ void PBD::list_debug_options () { cout << _("The following debug options are available. Separate multiple options with commas.\nNames are case-insensitive and can be abbreviated.") << endl << endl; - cout << '\t' << X_("all") << endl; + cout << '\t' << X_("all") << endl; vector options;