2005-01-20 23:22:22 +00:00
|
|
|
// Berkeley Open Infrastructure for Network Computing
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2005 University of California
|
2004-11-14 08:29:32 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// This is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation;
|
|
|
|
// either version 2.1 of the License, or (at your option) any later version.
|
2004-03-24 07:39:24 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// This software is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
2004-03-24 07:39:24 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// To view the GNU Lesser General Public License visit
|
|
|
|
// http://www.gnu.org/copyleft/lesser.html
|
|
|
|
// or write to the Free Software Foundation, Inc.,
|
|
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2004-03-24 07:39:24 +00:00
|
|
|
|
2004-12-04 00:56:22 +00:00
|
|
|
#ifndef _BOINC_DIAGNOSTICS_
|
|
|
|
#define _BOINC_DIAGNOSTICS_
|
|
|
|
|
2004-12-06 23:02:47 +00:00
|
|
|
|
|
|
|
// NOTE: No other includes should be included from this file.
|
|
|
|
// Whatever is defined in this file should fit into
|
|
|
|
// any existing frameworks that might be used by BOINC.
|
|
|
|
//
|
|
|
|
#ifdef __cplusplus
|
|
|
|
#include <cassert>
|
|
|
|
#else
|
2004-07-15 22:55:34 +00:00
|
|
|
#include <assert.h>
|
2004-12-06 23:02:47 +00:00
|
|
|
#endif
|
|
|
|
|
2005-03-16 20:29:43 +00:00
|
|
|
#ifndef _WIN32
|
|
|
|
#include <signal.h>
|
|
|
|
#endif
|
|
|
|
|
2004-12-04 00:56:22 +00:00
|
|
|
|
|
|
|
// flags for boinc_init_diagnostics()
|
|
|
|
//
|
|
|
|
#define BOINC_DIAG_DUMPCALLSTACKENABLED 0x00000001L
|
|
|
|
#define BOINC_DIAG_HEAPCHECKENABLED 0x00000002L
|
|
|
|
#define BOINC_DIAG_MEMORYLEAKCHECKENABLED 0x00000004L
|
|
|
|
#define BOINC_DIAG_ARCHIVESTDERR 0x00000008L
|
|
|
|
#define BOINC_DIAG_ARCHIVESTDOUT 0x00000010L
|
|
|
|
#define BOINC_DIAG_REDIRECTSTDERR 0x00000020L
|
|
|
|
#define BOINC_DIAG_REDIRECTSTDOUT 0x00000040L
|
|
|
|
#define BOINC_DIAG_REDIRECTSTDERROVERWRITE 0x00000080L
|
|
|
|
#define BOINC_DIAG_REDIRECTSTDOUTOVERWRITE 0x00000100L
|
|
|
|
#define BOINC_DIAG_TRACETOSTDERR 0x00000200L
|
|
|
|
#define BOINC_DIAG_TRACETOSTDOUT 0x00000400L
|
2005-02-27 08:28:52 +00:00
|
|
|
#define BOINC_DIAG_HEAPCHECKEVERYALLOC 0x00000800L
|
|
|
|
|
2006-03-21 12:04:14 +00:00
|
|
|
// thread types used for dumping backtraces
|
|
|
|
//
|
|
|
|
#define BOINC_THREADTYPE_COUNT 3
|
|
|
|
#define BOINC_THREADTYPE_TIMER 0
|
|
|
|
#define BOINC_THREADTYPE_WORKER 1
|
|
|
|
#define BOINC_THREADTYPE_GRAPHICS 2
|
2004-12-04 00:56:22 +00:00
|
|
|
|
|
|
|
// filenames
|
|
|
|
//
|
2005-02-01 00:54:06 +00:00
|
|
|
#define BOINC_DIAG_STDERR "stderr"
|
|
|
|
#define BOINC_DIAG_STDOUT "stdout"
|
2004-12-04 00:56:22 +00:00
|
|
|
|
|
|
|
|
2005-03-16 20:29:43 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// These are functions common to all platforms
|
|
|
|
extern int boinc_init_diagnostics(int flags);
|
|
|
|
extern int boinc_finish_diag();
|
|
|
|
extern int boinc_install_signal_handlers();
|
|
|
|
|
|
|
|
extern int diagnostics_init(
|
|
|
|
int flags, const char* stdout_prefix, const char* stderr_prefix
|
|
|
|
);
|
|
|
|
extern int diagnostics_cycle_logs();
|
|
|
|
|
|
|
|
|
2006-03-21 12:04:14 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
|
|
|
|
extern int diagnostics_set_aborted_via_gui_flag();
|
|
|
|
extern int diagnostics_set_thread_info( int thread_type, DWORD thread_id, HANDLE thread_handle );
|
|
|
|
extern int diagnostics_is_thread_type_initialized( int thread_type );
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2005-03-16 20:29:43 +00:00
|
|
|
// These are functions that are specific to Unix
|
|
|
|
#ifndef _WIN32
|
|
|
|
|
|
|
|
extern void boinc_set_signal_handler(int sig, void(*handler)(int));
|
|
|
|
extern void boinc_set_signal_handler_force(int sig, void(*handler)(int));
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
// These functions are used to log the various messages that are
|
|
|
|
// defined in the BOINC Diagnostics Library
|
|
|
|
extern void boinc_trace(const char *pszFormat, ...);
|
|
|
|
extern void boinc_info_debug(const char *pszFormat, ...);
|
|
|
|
extern void boinc_info_release(const char *pszFormat, ...);
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-03-24 07:39:24 +00:00
|
|
|
#ifdef _WIN32
|
2004-12-04 00:56:22 +00:00
|
|
|
|
2004-03-24 07:39:24 +00:00
|
|
|
// Define macros for both debug and release builds.
|
|
|
|
//
|
|
|
|
// We are using the native debugging technology built into the Microsoft
|
|
|
|
// C Runtime Libraries to trap and report the asserts and traces.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
2004-12-06 23:02:47 +00:00
|
|
|
#if defined(WXDEBUG) || defined(WXNDEBUG)
|
2004-11-15 06:44:50 +00:00
|
|
|
|
|
|
|
// wxWidgets UI Framework
|
|
|
|
//
|
|
|
|
|
2005-11-26 08:02:05 +00:00
|
|
|
#define BOINCASSERT(expr) wxASSERT(expr)
|
|
|
|
#define BOINCTRACE wxLogDebug
|
2004-11-15 06:44:50 +00:00
|
|
|
#define BOINCINFO boinc_info_release
|
|
|
|
|
|
|
|
#elif defined(_CONSOLE)
|
2004-03-24 07:39:24 +00:00
|
|
|
|
|
|
|
// Microsoft CRT
|
|
|
|
//
|
|
|
|
|
2005-07-06 21:10:36 +00:00
|
|
|
#define BOINCASSERT(expr) _ASSERTE(expr)
|
2004-03-24 07:39:24 +00:00
|
|
|
#define BOINCTRACE boinc_trace
|
|
|
|
#define BOINCINFO boinc_info_debug
|
|
|
|
|
|
|
|
#endif // _CONSOLE
|
|
|
|
|
|
|
|
#else // _DEBUG
|
|
|
|
|
2005-12-16 03:35:15 +00:00
|
|
|
#if defined(__MINGW32__) || defined(__CYGWIN32__)
|
2005-12-01 00:25:21 +00:00
|
|
|
#define BOINCASSERT(expr)
|
|
|
|
#define BOINCTRACE(...)
|
|
|
|
#define BOINCINFO boinc_info_release
|
|
|
|
#else // __MINGW32__
|
2004-11-13 07:11:40 +00:00
|
|
|
#define BOINCASSERT(expr) __noop
|
|
|
|
#define BOINCTRACE __noop
|
2004-03-24 07:39:24 +00:00
|
|
|
#define BOINCINFO boinc_info_release
|
2005-12-01 00:25:21 +00:00
|
|
|
#endif // __MINGW32__
|
2004-03-24 07:39:24 +00:00
|
|
|
|
|
|
|
#endif // _DEBUG
|
|
|
|
|
2005-03-16 20:29:43 +00:00
|
|
|
#else
|
2004-12-30 18:13:29 +00:00
|
|
|
|
2005-03-16 20:29:43 +00:00
|
|
|
#ifdef _DEBUG
|
2005-02-01 00:54:06 +00:00
|
|
|
|
2005-03-16 20:29:43 +00:00
|
|
|
// Standard Frameworks
|
|
|
|
//
|
|
|
|
|
|
|
|
#define BOINCASSERT assert
|
|
|
|
#define BOINCTRACE boinc_trace
|
|
|
|
#define BOINCINFO boinc_info_debug
|
|
|
|
|
|
|
|
#else // _DEBUG
|
|
|
|
|
2005-03-25 12:51:07 +00:00
|
|
|
#define BOINCASSERT(expr)
|
|
|
|
#define BOINCTRACE(...)
|
2005-03-16 20:29:43 +00:00
|
|
|
#define BOINCINFO boinc_info_release
|
|
|
|
|
|
|
|
#endif // _DEBUG
|
2005-02-01 00:54:06 +00:00
|
|
|
|
2004-12-04 00:56:22 +00:00
|
|
|
#endif // ! _WIN32
|
2004-03-24 07:39:24 +00:00
|
|
|
|
2004-12-04 01:49:50 +00:00
|
|
|
|
2004-12-06 23:02:47 +00:00
|
|
|
// If none of the TRACE and INFO macros have been defined for
|
|
|
|
// any existing framework to plug into, null them out.
|
|
|
|
// ASSERT is a special case and should point to the CRT version
|
|
|
|
// if it hasn't already been redirected.
|
|
|
|
|
2004-12-04 01:49:50 +00:00
|
|
|
#ifndef BOINCASSERT
|
|
|
|
#define BOINCASSERT assert
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef BOINCTRACE
|
2005-03-19 23:48:50 +00:00
|
|
|
#define BOINCTRACE
|
2004-12-04 01:49:50 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef BOINCINFO
|
2005-03-19 23:48:50 +00:00
|
|
|
#define BOINCINFO
|
2004-12-04 01:49:50 +00:00
|
|
|
#endif
|
|
|
|
|
2004-12-06 23:02:47 +00:00
|
|
|
#endif
|