WvStreams
|
00001 /* -*- Mode: C++ -*- 00002 * Worldvisions Weaver Software: 00003 * Copyright (C) 1997-2002 Net Integration Technologies, Inc. 00004 * 00005 * Routines to generate a stack backtrace automatically when a program 00006 * crashes. 00007 */ 00008 #ifndef __WVCRASH_H 00009 #define __WVCRASH_H 00010 00011 #include <sys/types.h> 00012 00013 void wvcrash_setup(const char *_argv0, const char *_desc = 0); 00014 void wvcrash(int sig); 00015 void wvcrash_add_signal(int sig); 00016 00017 // Leave a last will and testament in the WvCrash, if your program dies. 00018 void wvcrash_leave_will(const char *will); 00019 // Read the will back. 00020 const char *wvcrash_read_will(); 00021 // Read the assertion back. 00022 const char *wvcrash_read_assert(); 00023 00024 00025 class IWvStream; 00026 00027 struct WvCrashInfo 00028 { 00029 // This is kind of ugly and used only for the guts of WvStreams, 00030 // but it's a significant rather than a premature optimization, 00031 // unfortunately. 00032 static IWvStream *in_stream; 00033 static const char *in_stream_id; 00034 static enum InStreamState { 00035 UNUSED, 00036 PRE_SELECT, 00037 POST_SELECT, 00038 EXECUTE, 00039 } in_stream_state; 00040 }; 00041 00042 const int wvcrash_ring_buffer_order = 12; 00043 const int wvcrash_ring_buffer_size = 1 << wvcrash_ring_buffer_order; 00044 void wvcrash_ring_buffer_put(const char *str); 00045 void wvcrash_ring_buffer_put(const char *str, size_t len); 00046 const char *wvcrash_ring_buffer_get(); 00047 00048 #if defined(_WIN32) 00049 extern void setup_console_crash(); 00050 #endif 00051 00052 #endif // __WVCRASH_H