2 * Copyright (c) 2002-2005 The Regents of The University of Michigan
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.
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.
28 * Authors: Nathan Binkert
37 #include "base/compiler.hh"
38 #include "base/cprintf.hh"
39 #include "base/varargs.hh"
41 #if defined(__SUNPRO_CC)
42 #define __FUNCTION__ "how to fix me?"
46 // This implements a cprintf based panic() function. panic() should
47 // be called when something happens that should never ever happen
48 // regardless of what the user does (i.e., an acutal m5 bug). panic()
49 // calls abort which can dump core or enter the debugger.
52 void __panic(const char *func, const char *file, int line, const char *format,
53 CPRINTF_DECLARATION) M5_ATTR_NORETURN;
54 void __panic(const char *func, const char *file, int line,
55 const std::string &format, CPRINTF_DECLARATION)
59 __panic(const char *func, const char *file, int line,
60 const std::string &format, CPRINTF_DEFINITION)
62 __panic(func, file, line, format.c_str(), VARARGS_ALLARGS);
64 M5_PRAGMA_NORETURN(__panic)
65 #define panic(...) __panic(__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
68 // This implements a cprintf based fatal() function. fatal() should
69 // be called when the simulation cannot continue due to some condition
70 // that is the user's fault (bad configuration, invalid arguments,
71 // etc.) and not a simulator bug. fatal() calls exit(1), i.e., a
72 // "normal" exit with an error code, as opposed to abort() like
75 void __fatal(const char *func, const char *file, int line, const char *format,
76 CPRINTF_DECLARATION) M5_ATTR_NORETURN;
77 void __fatal(const char *func, const char *file, int line,
78 const std::string &format, CPRINTF_DECLARATION)
82 __fatal(const char *func, const char *file, int line,
83 const std::string &format, CPRINTF_DEFINITION)
85 __fatal(func, file, line, format.c_str(), VARARGS_ALLARGS);
87 M5_PRAGMA_NORETURN(__fatal)
88 #define fatal(...) __fatal(__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
91 // This implements a cprintf based warn
93 void __warn(const char *func, const char *file, int line, const char *format,
96 __warn(const char *func, const char *file, int line, const std::string &format,
99 __warn(func, file, line, format, VARARGS_ALLARGS);
101 #define warn(...) __warn(__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
103 // Only print the warning message the first time it is seen. This
104 // doesn't check the warning string itself, it just only lets one
105 // warning come from the statement. So, even if the arguments change
106 // and that would have resulted in a different warning message,
107 // subsequent messages would still be supressed.
108 #define warn_once(...) do { \
109 static bool once = false; \
117 // assert() that prints out the current cycle
119 #define m5_assert(TEST) do { \
121 ccprintf(std::cerr, "Assertion failure, curTick = %d\n", curTick); \
125 #endif // __MISC_HH__