1/* 2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
| 1/* 2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
|
| 3 * Copyright (c) 2010 The Hewlett-Packard Development Company
|
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; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Authors: Nathan Binkert 29 */ 30 31#ifndef __BASE_DEBUG_HH__ 32#define __BASE_DEBUG_HH__ 33
| 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer; 10 * redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution; 13 * neither the name of the copyright holders nor the names of its 14 * contributors may be used to endorse or promote products derived from 15 * this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * 29 * Authors: Nathan Binkert 30 */ 31 32#ifndef __BASE_DEBUG_HH__ 33#define __BASE_DEBUG_HH__ 34
|
| 35#include <string> 36#include <vector> 37
|
34namespace Debug { 35 36void breakpoint(); 37
| 38namespace Debug { 39 40void breakpoint(); 41
|
| 42class Flag 43{ 44 protected: 45 const char *_name; 46 const char *_desc; 47 48 public: 49 Flag(const char *name, const char *desc); 50 virtual ~Flag(); 51 52 std::string name() const { return _name; } 53 std::string desc() const { return _desc; } 54 55 virtual void enable() = 0; 56 virtual void disable() = 0; 57}; 58 59class SimpleFlag : public Flag 60{ 61 protected: 62 bool _status; 63 64 public: 65 SimpleFlag(const char *name, const char *desc) 66 : Flag(name, desc) 67 { } 68 69 bool status() const { return _status; } 70 operator bool() const { return _status; } 71 bool operator!() const { return !_status; } 72 73 void enable() { _status = true; } 74 void disable() { _status = false; } 75}; 76 77class CompoundFlag : public SimpleFlag 78{ 79 protected: 80 std::vector<Flag *> flags; 81 82 public: 83 CompoundFlag(const char *name, const char *desc, 84 Flag &f00 = *(Flag *)0, Flag &f01 = *(Flag *)0, 85 Flag &f02 = *(Flag *)0, Flag &f03 = *(Flag *)0, 86 Flag &f04 = *(Flag *)0, Flag &f05 = *(Flag *)0, 87 Flag &f06 = *(Flag *)0, Flag &f07 = *(Flag *)0, 88 Flag &f08 = *(Flag *)0, Flag &f09 = *(Flag *)0, 89 Flag &f10 = *(Flag *)0, Flag &f11 = *(Flag *)0, 90 Flag &f12 = *(Flag *)0, Flag &f13 = *(Flag *)0, 91 Flag &f14 = *(Flag *)0, Flag &f15 = *(Flag *)0, 92 Flag &f16 = *(Flag *)0, Flag &f17 = *(Flag *)0, 93 Flag &f18 = *(Flag *)0, Flag &f19 = *(Flag *)0) 94 : SimpleFlag(name, desc) 95 { 96 addFlag(f00); addFlag(f01); addFlag(f02); addFlag(f03); addFlag(f04); 97 addFlag(f05); addFlag(f06); addFlag(f07); addFlag(f08); addFlag(f09); 98 addFlag(f10); addFlag(f11); addFlag(f12); addFlag(f13); addFlag(f14); 99 addFlag(f15); addFlag(f16); addFlag(f17); addFlag(f18); addFlag(f19); 100 } 101 102 void 103 addFlag(Flag &f) 104 { 105 if (&f != NULL) 106 flags.push_back(&f); 107 } 108 109 void enable(); 110 void disable(); 111}; 112
|
38} // namespace Debug 39 40#endif // __BASE_DEBUG_HH__
| 113} // namespace Debug 114 115#endif // __BASE_DEBUG_HH__
|