comparison osx/include/kj/exception.h @ 147:45360b968bf4

Cap'n Proto v0.6 + build for OSX
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 22 May 2017 10:01:37 +0100
parents 41e769c91eca
children
comparison
equal deleted inserted replaced
146:206f0eb279b8 147:45360b968bf4
191 // Called when something wants to log some debug text. `contextDepth` indicates how many levels 191 // Called when something wants to log some debug text. `contextDepth` indicates how many levels
192 // of context the message passed through; it may make sense to indent the message accordingly. 192 // of context the message passed through; it may make sense to indent the message accordingly.
193 // 193 //
194 // The global default implementation writes the text to stderr. 194 // The global default implementation writes the text to stderr.
195 195
196 enum class StackTraceMode {
197 FULL,
198 // Stringifying a stack trace will attempt to determine source file and line numbers. This may
199 // be expensive. For example, on Linux, this shells out to `addr2line`.
200 //
201 // This is the default in debug builds.
202
203 ADDRESS_ONLY,
204 // Stringifying a stack trace will only generate a list of code addresses.
205 //
206 // This is the default in release builds.
207
208 NONE
209 // Generating a stack trace will always return an empty array.
210 //
211 // This avoids ever unwinding the stack. On Windows in particular, the stack unwinding library
212 // has been observed to be pretty slow, so exception-heavy code might benefit significantly
213 // from this setting. (But exceptions should be rare...)
214 };
215
216 virtual StackTraceMode stackTraceMode();
217 // Returns the current preferred stack trace mode.
218
196 protected: 219 protected:
197 ExceptionCallback& next; 220 ExceptionCallback& next;
198 221
199 private: 222 private:
200 ExceptionCallback(ExceptionCallback& next); 223 ExceptionCallback(ExceptionCallback& next);
321 344
322 String stringifyStackTrace(ArrayPtr<void* const>); 345 String stringifyStackTrace(ArrayPtr<void* const>);
323 // Convert the stack trace to a string with file names and line numbers. This may involve executing 346 // Convert the stack trace to a string with file names and line numbers. This may involve executing
324 // suprocesses. 347 // suprocesses.
325 348
349 String getStackTrace();
350 // Get a stack trace right now and stringify it. Useful for debugging.
351
326 void printStackTraceOnCrash(); 352 void printStackTraceOnCrash();
327 // Registers signal handlers on common "crash" signals like SIGSEGV that will (attempt to) print 353 // Registers signal handlers on common "crash" signals like SIGSEGV that will (attempt to) print
328 // a stack trace. You should call this as early as possible on program startup. Programs using 354 // a stack trace. You should call this as early as possible on program startup. Programs using
329 // KJ_MAIN get this automatically. 355 // KJ_MAIN get this automatically.
330 356