trace.cc (8229:78bf55f23338) | trace.cc (8232:b28d06a175be) |
---|---|
1/* 2 * Copyright (c) 2001-2006 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 18 unchanged lines hidden (view full) --- 27 * 28 * Authors: Nathan Binkert 29 * Steve Reinhardt 30 */ 31 32#include <cctype> 33#include <fstream> 34#include <iostream> | 1/* 2 * Copyright (c) 2001-2006 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 18 unchanged lines hidden (view full) --- 27 * 28 * Authors: Nathan Binkert 29 * Steve Reinhardt 30 */ 31 32#include <cctype> 33#include <fstream> 34#include <iostream> |
35#include <list> | |
36#include <string> | 35#include <string> |
37#include <vector> | |
38 39#include "base/misc.hh" 40#include "base/output.hh" 41#include "base/str.hh" 42#include "base/trace.hh" 43#include "base/varargs.hh" 44 45using namespace std; 46 47namespace Trace { | 36 37#include "base/misc.hh" 38#include "base/output.hh" 39#include "base/str.hh" 40#include "base/trace.hh" 41#include "base/varargs.hh" 42 43using namespace std; 44 45namespace Trace { |
46 |
|
48const string DefaultName("global"); | 47const string DefaultName("global"); |
49FlagVec flags(NumFlags, false); | |
50bool enabled = false; 51 52// 53// This variable holds the output stream for debug information. Other 54// than setting up/redirecting this stream, do *NOT* reference this 55// directly; use DebugOut() (see below) to access this stream for 56// output. 57// --- 86 unchanged lines hidden (view full) --- 144 145 ccprintf(os, "\n"); 146 147 if (c < 16) 148 break; 149 } 150} 151 | 48bool enabled = false; 49 50// 51// This variable holds the output stream for debug information. Other 52// than setting up/redirecting this stream, do *NOT* reference this 53// directly; use DebugOut() (see below) to access this stream for 54// output. 55// --- 86 unchanged lines hidden (view full) --- 142 143 ccprintf(os, "\n"); 144 145 if (c < 16) 146 break; 147 } 148} 149 |
152bool 153changeFlag(const char *s, bool value) 154{ 155 using namespace Trace; 156 std::string str(s); 157 158 for (int i = 0; i < numFlagStrings; ++i) { 159 if (str != flagStrings[i]) 160 continue; 161 162 if (i < NumFlags) { 163 flags[i] = value; 164 } else { 165 i -= NumFlags; 166 167 const Flags *flagVec = compoundFlags[i]; 168 for (int j = 0; flagVec[j] != -1; ++j) { 169 if (flagVec[j] < NumFlags) 170 flags[flagVec[j]] = value; 171 } 172 } 173 174 return true; 175 } 176 177 // the flag was not found. 178 return false; 179} 180 181void 182dumpStatus() 183{ 184 using namespace Trace; 185 for (int i = 0; i < numFlagStrings; ++i) { 186 if (flags[i]) 187 cprintf("%s\n", flagStrings[i]); 188 } 189} 190 | |
191} // namespace Trace | 150} // namespace Trace |
192 193 194// add a set of functions that can easily be invoked from gdb 195void 196setTraceFlag(const char *string) 197{ 198 Trace::changeFlag(string, true); 199} 200 201void 202clearTraceFlag(const char *string) 203{ 204 Trace::changeFlag(string, false); 205} 206 207void 208dumpTraceStatus() 209{ 210 Trace::dumpStatus(); 211} | |