19 #ifndef LUNCHBOX_DEBUG_H 20 #define LUNCHBOX_DEBUG_H 36 LUNCHBOX_API
void abort(
bool dumpThreads =
false);
42 LUNCHBOX_API
void checkHeap();
50 LUNCHBOX_API std::ostream&
sysError(std::ostream& os);
63 LUNCHBOX_API std::string
backtrace(
const size_t skipFrames);
66 LUNCHBOX_API std::ostream&
backtrace(std::ostream& os);
68 LUNCHBOX_API std::string demangleTypeID(
const char* mangled);
71 #pragma warning(disable : 4100) // VS Bug 77 return demangleTypeID(
typeid(
object).name());
88 #pragma warning(default : 4100) 101 inline std::string
format(
const T* data,
const size_t num)
103 std::ostringstream os;
104 os << num <<
" " <<
className(data) <<
" @ " << std::hex
105 << (
const void*)data <<
": 0x";
106 for (
size_t i = 0; i < num; ++i)
109 os <<
" " << std::endl;
110 os <<
' ' << data[i];
116 inline std::string
format(
const uint8_t* data,
const size_t num)
118 std::ostringstream os;
119 os << num <<
" bytes @ " << std::hex << (
const void*)data <<
": 0x";
121 for (
size_t i = 0; i < num; ++i)
124 os <<
" " << std::endl;
125 else if ((i % 8) == 0)
127 os <<
' ' << std::setw(2) << int(data[i]);
133 inline std::string
format(
const void* data,
const size_t num)
135 return format(reinterpret_cast<const uint8_t*>(data), num);
139 inline std::string
format(
const std::vector<T>& data)
141 return format<T>(&data[0], data.size());
147 #ifdef LB_RELEASE_ASSERT 148 #define LBASSERT(x) \ 151 LBERROR << "##### Assert: " << #x << " #####" << std::endl \ 152 << lunchbox::forceFlush; \ 153 lunchbox::checkHeap(); \ 155 #define LBASSERTINFO(x, info) \ 158 LBERROR << "##### Assert: " << #x << " [" << info << "] #####" \ 160 << lunchbox::forceFlush; \ 161 lunchbox::checkHeap(); \ 165 const bool eqOk = x; \ 166 LBASSERTINFO(eqOk, #x) \ 170 #define LBASSERTINFO(x, info) 177 #define LBUNIMPLEMENTED \ 179 LBERROR << "Unimplemented code in " << __FILE__ << ":" << __LINE__ \ 181 << lunchbox::forceFlush; \ 183 #define LBUNREACHABLE \ 185 LBERROR << "Unreachable code in " << __FILE__ << ":" << __LINE__ \ 187 << lunchbox::forceFlush; \ 191 LBERROR << "Code is not supposed to be called in this context" \ 193 << lunchbox::forceFlush; \ 195 #define LBABORT(info) \ 197 LBERROR << "##### Abort: " << info << " #####" << std::endl \ 198 << lunchbox::forceFlush; \ 203 #define LBASSERT(x) \ 207 LBERROR << "Assert: " << #x << " "; \ 210 lunchbox::checkHeap(); \ 212 #define LBASSERTINFO(x, info) \ 216 LBERROR << "Assert: " << #x << " [" << info << "] "; \ 219 lunchbox::checkHeap(); \ 222 #define LBUNIMPLEMENTED \ 224 LBERROR << "Unimplemented code in " << __FILE__ << ":" << __LINE__ \ 225 << " " << lunchbox::className(*this); \ 228 #define LBUNREACHABLE \ 230 LBERROR << "Unreachable code in " << __FILE__ << ":" << __LINE__ \ 231 << " " << lunchbox::className(*this); \ 236 LBERROR << "Code is not supposed to be called in this context, type " \ 237 << lunchbox::className(*this); \ 243 const bool eqOk = x; \ 244 LBASSERTINFO(eqOk, #x) \ 246 #define LBABORT(info) \ 248 LBERROR << "Abort: " << info; \ 253 #define LBSAFECAST(to, in) \ 254 static_cast<to>(in); \ 255 LBASSERT(in == 0 || dynamic_cast<to>(static_cast<to>(in))) 257 #endif // LUNCHBOX_DEBUG_H std::string className(const T &object)
Print the RTTI name of the given class.
std::ostream & sysError(std::ostream &os)
Print a textual description of the current system error.
std::string format(const T *data, const size_t num)
Format the given array in a human-readable form.
Includes compile-time defines of Lunchbox.
std::string backtrace(const size_t skipFrames)
Get the current call stack.
Abstraction layer and common utilities for multi-threaded programming.
This file contains logging classes.