2008-08-06 18:36:30 +00:00
|
|
|
// This file is part of BOINC.
|
2005-01-20 23:22:22 +00:00
|
|
|
// http://boinc.berkeley.edu
|
2008-08-06 18:36:30 +00:00
|
|
|
// Copyright (C) 2008 University of California
|
2004-11-14 08:29:32 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC 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 3 of the License, or (at your option) any later version.
|
2004-03-24 07:39:24 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
2005-01-20 23:22:22 +00:00
|
|
|
// 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
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
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
|
|
|
|
2006-05-01 21:36:38 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include "boinc_win.h"
|
|
|
|
#else
|
|
|
|
#include <signal.h>
|
2004-12-06 23:02:47 +00:00
|
|
|
#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
|
|
|
#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-04-10 06:20:02 +00:00
|
|
|
#define BOINC_DIAG_BOINCAPPLICATION 0x00001000L
|
2007-06-08 07:38:17 +00:00
|
|
|
#define BOINC_DIAG_DEFAULTS \
|
|
|
|
BOINC_DIAG_DUMPCALLSTACKENABLED | \
|
|
|
|
BOINC_DIAG_HEAPCHECKENABLED | \
|
|
|
|
BOINC_DIAG_MEMORYLEAKCHECKENABLED | \
|
|
|
|
BOINC_DIAG_REDIRECTSTDERR | \
|
|
|
|
BOINC_DIAG_TRACETOSTDERR
|
2006-04-10 06:20:02 +00:00
|
|
|
|
2005-02-27 08:28:52 +00:00
|
|
|
|
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"
|
2008-04-30 05:42:06 +00:00
|
|
|
#define BOINC_DIAG_GFX_STDERR "stderrgfx"
|
|
|
|
#define BOINC_DIAG_GFX_STDOUT "stdoutgfx"
|
2004-12-04 00:56:22 +00:00
|
|
|
|
|
|
|
|
2005-03-16 20:29:43 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2006-05-01 21:36:38 +00:00
|
|
|
|
2005-03-16 20:29:43 +00:00
|
|
|
// These are functions common to all platforms
|
2006-05-01 21:36:38 +00:00
|
|
|
extern int boinc_init_diagnostics( int flags );
|
2008-04-30 05:42:06 +00:00
|
|
|
extern int boinc_init_graphics_diagnostics( int flags );
|
2005-03-16 20:29:43 +00:00
|
|
|
extern int boinc_install_signal_handlers();
|
2006-05-01 21:36:38 +00:00
|
|
|
extern int boinc_finish_diag();
|
2005-03-16 20:29:43 +00:00
|
|
|
|
|
|
|
extern int diagnostics_init(
|
|
|
|
int flags, const char* stdout_prefix, const char* stderr_prefix
|
|
|
|
);
|
2006-05-17 07:44:54 +00:00
|
|
|
extern int diagnostics_finish();
|
2006-05-01 21:36:38 +00:00
|
|
|
extern int diagnostics_is_initialized();
|
2010-01-19 17:22:46 +00:00
|
|
|
extern int diagnostics_is_flag_set(int flags);
|
2005-03-16 20:29:43 +00:00
|
|
|
|
2006-05-01 21:36:38 +00:00
|
|
|
// Properties
|
|
|
|
extern char* diagnostics_get_boinc_dir();
|
2008-05-21 05:09:15 +00:00
|
|
|
extern char* diagnostics_get_boinc_install_dir();
|
2006-05-01 21:36:38 +00:00
|
|
|
extern char* diagnostics_get_symstore();
|
2006-05-24 23:56:41 +00:00
|
|
|
extern int diagnostics_set_symstore(char* symstore);
|
2006-05-01 21:36:38 +00:00
|
|
|
extern int diagnostics_is_proxy_enabled();
|
|
|
|
extern char* diagnostics_get_proxy();
|
2005-03-16 20:29:43 +00:00
|
|
|
|
2006-05-01 21:36:38 +00:00
|
|
|
extern int diagnostics_is_aborted_via_gui();
|
2006-05-08 18:35:56 +00:00
|
|
|
extern int diagnostics_set_aborted_via_gui();
|
2006-05-01 21:36:38 +00:00
|
|
|
|
|
|
|
// Log rotation
|
|
|
|
extern int diagnostics_cycle_logs();
|
2007-10-24 22:48:47 +00:00
|
|
|
extern void diagnostics_set_max_file_sizes(int stdout_size, int stderr_size);
|
2006-03-21 12:04:14 +00:00
|
|
|
|
2006-05-01 21:36:38 +00:00
|
|
|
// Thread Tracking
|
|
|
|
extern int diagnostics_init_thread_list();
|
2006-05-08 18:35:56 +00:00
|
|
|
extern int diagnostics_finish_thread_list();
|
|
|
|
extern int diagnostics_update_thread_list();
|
2006-05-02 07:53:28 +00:00
|
|
|
extern int diagnostics_set_thread_exempt_suspend();
|
2010-01-19 17:22:46 +00:00
|
|
|
extern int diagnostics_is_thread_exempt_suspend(long thread_id);
|
2006-03-21 12:04:14 +00:00
|
|
|
|
2006-05-01 21:36:38 +00:00
|
|
|
// Message Monitoring
|
|
|
|
extern int diagnostics_init_message_monitor();
|
2006-05-08 18:35:56 +00:00
|
|
|
extern int diagnostics_finish_message_monitor();
|
2006-05-01 21:36:38 +00:00
|
|
|
#ifdef _WIN32
|
2006-05-19 02:06:14 +00:00
|
|
|
extern UINT WINAPI diagnostics_message_monitor(LPVOID lpParameter);
|
2006-03-21 12:04:14 +00:00
|
|
|
#endif
|
|
|
|
|
2006-05-08 18:35:56 +00:00
|
|
|
// Unhandled exception monitor
|
|
|
|
extern int diagnostics_init_unhandled_exception_monitor();
|
|
|
|
extern int diagnostics_finish_unhandled_exception_monitor();
|
|
|
|
#ifdef _WIN32
|
2006-05-19 02:06:14 +00:00
|
|
|
extern UINT WINAPI diagnostics_unhandled_exception_monitor(LPVOID lpParameter);
|
2006-05-08 18:35:56 +00:00
|
|
|
extern LONG CALLBACK boinc_catch_signal(EXCEPTION_POINTERS *ExceptionInfo);
|
2007-06-27 21:12:13 +00:00
|
|
|
extern void boinc_catch_signal_invalid_parameter(const wchar_t* expression, const wchar_t* function, const wchar_t* file, unsigned int line, uintptr_t pReserved);
|
2006-05-08 18:35:56 +00:00
|
|
|
#else
|
|
|
|
extern void boinc_catch_signal(int signal);
|
2005-03-16 20:29:43 +00:00
|
|
|
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, ...);
|
2006-06-14 07:14:09 +00:00
|
|
|
extern void boinc_info(const char *pszFormat, ...);
|
2005-03-16 20:29:43 +00:00
|
|
|
|
2008-06-23 19:51:07 +00:00
|
|
|
extern void set_signal_exit_code(int);
|
2005-03-16 20:29:43 +00:00
|
|
|
|
|
|
|
#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)
|
2009-05-01 22:57:00 +00:00
|
|
|
#ifdef _UNICODE
|
|
|
|
#define BOINCTRACE __noop
|
|
|
|
#else
|
2005-11-26 08:02:05 +00:00
|
|
|
#define BOINCTRACE wxLogDebug
|
2009-05-01 22:57:00 +00:00
|
|
|
#endif
|
2004-11-15 06:44:50 +00:00
|
|
|
|
2007-03-22 00:22:02 +00:00
|
|
|
#elif defined(_CONSOLE) && !(defined(__MINGW32__) || defined(__CYGWIN32__))
|
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
|
|
|
|
|
|
|
|
#endif // _CONSOLE
|
|
|
|
|
|
|
|
#else // _DEBUG
|
|
|
|
|
2005-12-16 03:35:15 +00:00
|
|
|
#if defined(__MINGW32__) || defined(__CYGWIN32__)
|
2007-03-22 00:22:02 +00:00
|
|
|
#define BOINCASSERT(expr) assert(expr)
|
2006-06-14 07:44:51 +00:00
|
|
|
#define BOINCTRACE(...) boinc_trace
|
2005-12-01 00:25:21 +00:00
|
|
|
#else // __MINGW32__
|
2004-11-13 07:11:40 +00:00
|
|
|
#define BOINCASSERT(expr) __noop
|
2006-06-14 07:44:51 +00:00
|
|
|
#define BOINCTRACE boinc_trace
|
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
|
|
|
|
|
|
|
|
#else // _DEBUG
|
|
|
|
|
2005-03-25 12:51:07 +00:00
|
|
|
#define BOINCASSERT(expr)
|
2009-04-30 21:48:20 +00:00
|
|
|
#ifndef IRIX
|
2005-03-25 12:51:07 +00:00
|
|
|
#define BOINCTRACE(...)
|
2009-04-30 21:48:20 +00:00
|
|
|
#endif
|
2005-03-16 20:29:43 +00:00
|
|
|
|
|
|
|
#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
|
2006-06-14 07:14:09 +00:00
|
|
|
#define BOINCINFO boinc_info
|
2004-12-04 01:49:50 +00:00
|
|
|
#endif
|
|
|
|
|
2004-12-06 23:02:47 +00:00
|
|
|
#endif
|