diff options
Diffstat (limited to 'src/base/trace.cc')
-rw-r--r-- | src/base/trace.cc | 123 |
1 files changed, 1 insertions, 122 deletions
diff --git a/src/base/trace.cc b/src/base/trace.cc index 6e9838456..efa76b044 100644 --- a/src/base/trace.cc +++ b/src/base/trace.cc @@ -46,6 +46,7 @@ using namespace std; namespace Trace { const string DefaultName("global"); FlagVec flags(NumFlags, false); +bool enabled = true; // // This variable holds the output stream for debug information. Other @@ -223,125 +224,3 @@ DataRecord::dump(ostream &os) } } } // namespace Trace - -// -// Returns the current output stream for debug information. As a -// wrapper around Trace::dprintf_stream, this handles cases where debug -// information is generated in the process of parsing .ini options, -// before we process the option that sets up the debug output stream -// itself. -// -std::ostream & -DebugOut() -{ - return *Trace::dprintf_stream; -} - -///////////////////////////////////////////// -// -// C-linkage functions for invoking from gdb -// -///////////////////////////////////////////// - -// -// Dump trace buffer to specified file (cout if NULL) -// -void -dumpTrace(const char *filename) -{ - if (filename != NULL) { - ofstream out(filename); - Trace::theLog.dump(out); - out.close(); - } - else { - Trace::theLog.dump(cout); - } -} - - -// -// Turn on/off trace output to cerr. Typically used when trace output -// is only going to circular buffer, but you want to see what's being -// sent there as you step through some code in gdb. This uses the -// same facility as the "trace to file" feature, and will print error -// messages rather than clobbering an existing ostream pointer. -// -void -echoTrace(bool on) -{ - if (on) { - if (Trace::dprintf_stream != NULL) { - cerr << "Already echoing trace to a file... go do a 'tail -f'" - << " on that file instead." << endl; - } else { - Trace::dprintf_stream = &cerr; - } - } else { - if (Trace::dprintf_stream != &cerr) { - cerr << "Not echoing trace to cerr." << endl; - } else { - Trace::dprintf_stream = NULL; - } - } -} - -void -printTraceFlags() -{ - using namespace Trace; - for (int i = 0; i < numFlagStrings; ++i) - if (flags[i]) - cprintf("%s\n", flagStrings[i]); -} - -void -tweakTraceFlag(const char *string, bool value) -{ - using namespace Trace; - std::string str(string); - - for (int i = 0; i < numFlagStrings; ++i) { - if (str != flagStrings[i]) - continue; - - int idx = i; - - if (idx < NumFlags) { - flags[idx] = value; - } else { - idx -= NumFlags; - if (idx >= NumCompoundFlags) { - ccprintf(cerr, "Invalid compound flag"); - return; - } - - const Flags *flagVec = compoundFlags[idx]; - - for (int j = 0; flagVec[j] != -1; ++j) { - if (flagVec[j] >= NumFlags) { - ccprintf(cerr, "Invalid compound flag"); - return; - } - flags[flagVec[j]] = value; - } - } - - cprintf("flag %s was %s\n", string, value ? "set" : "cleared"); - return; - } - - cprintf("could not find flag %s\n", string); -} - -void -setTraceFlag(const char *string) -{ - tweakTraceFlag(string, true); -} - -void -clearTraceFlag(const char *string) -{ - tweakTraceFlag(string, false); -} |