lib/xbmc-dll-symbols/dll-symbols.a \
xbmc/addons/addons.a \
xbmc/cdrip/cdrip.a \
- xbmc/commons/commons.a \
xbmc/cores/AudioEngine/audioengine.a \
xbmc/cores/DllLoader/dllloader.a \
xbmc/cores/DllLoader/exports/exports.a \
xbmc/rendering/rendering.a \
xbmc/settings/settings.a \
xbmc/storage/storage.a \
- xbmc/threads/threads.a \
xbmc/utils/utils.a \
xbmc/video/dialogs/videodialogs.a \
xbmc/video/video.a \
xbmc/xbmc.a \
+NWAOBJSXBMC= xbmc/commons/commons.a \
+ xbmc/threads/threads.a \
+
+
ifeq (@USE_WEB_SERVER@,1)
DIRECTORY_ARCHIVES += xbmc/network/httprequesthandler/httprequesthandlers.a
endif
xbmc.bin: $(OBJSXBMC) $(DYNOBJSXBMC) $(NWAOBJSXBMC)
ifeq ($(findstring osx,@ARCH@), osx)
- $(SILENT_LD) $(CXX) $(LDFLAGS) -o xbmc.bin -Wl,-all_load,-ObjC $(DYNOBJSXBMC) $(OBJSXBMC) $(LIBS) -rdynamic
+ $(SILENT_LD) $(CXX) $(LDFLAGS) -o xbmc.bin -Wl,-all_load,-ObjC $(DYNOBJSXBMC) $(NWAOBJSXBMC) $(OBJSXBMC) $(LIBS) -rdynamic
else
- $(SILENT_LD) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o xbmc.bin -Wl,--whole-archive $(DYNOBJSXBMC) $(OBJSXBMC) -Wl,--no-whole-archive $(LIBS) -rdynamic
+ $(SILENT_LD) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o xbmc.bin -Wl,--whole-archive $(DYNOBJSXBMC) $(OBJSXBMC) -Wl,--no-whole-archive $(NWAOBJSXBMC) $(LIBS) -rdynamic
endif
xbmc-xrandr: xbmc-xrandr.c
<ClCompile Include="..\..\xbmc\utils\URIUtils.cpp" />
<ClCompile Include="..\..\xbmc\utils\Variant.cpp" />
<ClCompile Include="..\..\xbmc\utils\Weather.cpp" />
- <ClCompile Include="..\..\xbmc\utils\Win32Exception.cpp" />
<ClCompile Include="..\..\xbmc\utils\XBMCTinyXML.cpp" />
<ClCompile Include="..\..\xbmc\utils\XMLUtils.cpp" />
<ClCompile Include="..\..\xbmc\video\Bookmark.cpp" />
<ClInclude Include="..\..\xbmc\utils\URIUtils.h" />
<ClInclude Include="..\..\xbmc\utils\Variant.h" />
<ClInclude Include="..\..\xbmc\utils\Weather.h" />
- <ClInclude Include="..\..\xbmc\utils\Win32Exception.h" />
<ClInclude Include="..\..\xbmc\utils\XBMCTinyXML.h" />
<ClInclude Include="..\..\xbmc\utils\XMLUtils.h" />
<ClInclude Include="..\..\xbmc\video\Bookmark.h" />
</VisualStudio>
</ProjectExtensions>
<Import Project="$(SolutionDir)\$(ProjectFileName).targets.user" Condition="Exists('$(SolutionDir)\$(ProjectFileName).targets.user')" />
-</Project>
+</Project>
\ No newline at end of file
<ClCompile Include="..\..\xbmc\utils\Weather.cpp">
<Filter>utils</Filter>
</ClCompile>
- <ClCompile Include="..\..\xbmc\utils\Win32Exception.cpp">
- <Filter>utils</Filter>
- </ClCompile>
<ClCompile Include="..\..\xbmc\utils\XMLUtils.cpp">
<Filter>utils</Filter>
</ClCompile>
<ClInclude Include="..\..\xbmc\utils\Weather.h">
<Filter>utils</Filter>
</ClInclude>
- <ClInclude Include="..\..\xbmc\utils\Win32Exception.h">
- <Filter>utils</Filter>
- </ClInclude>
<ClInclude Include="..\..\xbmc\utils\XMLUtils.h">
<Filter>utils</Filter>
</ClInclude>
<Filter>win32</Filter>
</CustomBuild>
</ItemGroup>
-</Project>
+</Project>
\ No newline at end of file
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
+ <ClCompile Include="..\..\xbmc\commons\Exception.cpp" />
<ClCompile Include="..\..\xbmc\commons\ilog.cpp" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="..\..\xbmc\commons\Exception.h" />
<ClInclude Include="..\..\xbmc\commons\ilog.h" />
</ItemGroup>
<PropertyGroup Label="Globals">
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="..\..\xbmc\commons\ilog.cpp" />
+ <ClCompile Include="..\..\xbmc\commons\Exception.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\xbmc\commons\ilog.h" />
+ <ClInclude Include="..\..\xbmc\commons\Exception.h" />
</ItemGroup>
</Project>
\ No newline at end of file
<ClInclude Include="..\..\xbmc\threads\platform\ThreadImpl.cpp" />
<ClCompile Include="..\..\xbmc\threads\platform\Implementation.cpp" />
<ClInclude Include="..\..\xbmc\threads\platform\win\Implementation.cpp" />
+ <ClCompile Include="..\..\xbmc\threads\platform\win\Win32Exception.cpp" />
<ClCompile Include="..\..\xbmc\threads\SystemClock.cpp" />
<ClCompile Include="..\..\xbmc\threads\Thread.cpp" />
</ItemGroup>
<ClInclude Include="..\..\xbmc\threads\platform\win\CriticalSection.h" />
<ClInclude Include="..\..\xbmc\threads\platform\win\ThreadImpl.h" />
<ClInclude Include="..\..\xbmc\threads\platform\win\ThreadLocal.h" />
+ <ClInclude Include="..\..\xbmc\threads\platform\win\Win32Exception.h" />
<ClInclude Include="..\..\xbmc\threads\SharedSection.h" />
<ClInclude Include="..\..\xbmc\threads\SingleLock.h" />
<ClInclude Include="..\..\xbmc\threads\SystemClock.h" />
<ClCompile Include="..\..\xbmc\threads\platform\Implementation.cpp">
<Filter>platform</Filter>
</ClCompile>
+ <ClCompile Include="..\..\xbmc\threads\platform\win\Win32Exception.cpp">
+ <Filter>platform\win</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\xbmc\threads\Atomics.h" />
<ClInclude Include="..\..\xbmc\threads\platform\win\Implementation.cpp">
<Filter>platform\win</Filter>
</ClInclude>
+ <ClInclude Include="..\..\xbmc\threads\platform\win\Win32Exception.h">
+ <Filter>platform\win</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="platform">
#include "network/Zeroconf.h"
#include "network/ZeroconfBrowser.h"
#ifndef _LINUX
-#include "utils/Win32Exception.h"
+#include "threads/platform/win/Win32Exception.h"
#endif
#ifdef HAS_EVENT_SERVER
#include "network/EventServer.h"
#include "XbmcContext.h"
#include "threads/Thread.h"
+#include "commons/Exception.h"
#include "utils/log.h"
namespace XBMC
impl->loggerImpl = new XbmcUtils::LogImplementation;
// set
+ XbmcCommons::Exception::SetLogger(impl->loggerImpl);
CThread::SetLogger(impl->loggerImpl);
}
--- /dev/null
+/*
+ * Copyright (C) 2005-2012 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#include "Exception.h"
+
+namespace XbmcCommons
+{
+ ILogger* Exception::logger = NULL;
+
+ Exception::~Exception() {}
+}
+
--- /dev/null
+/*
+ * Copyright (C) 2005-2012 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#pragma once
+
+//---------------------------------------------------------
+// This include should be moved to commons but even as it is,
+// it wont cause a linker circular dependency since it's just
+// a header.
+#include "utils/StdString.h"
+//---------------------------------------------------------
+#include "ilog.h"
+
+#define XBMCCOMMONS_COPYVARARGS(fmt) va_list argList; va_start(argList, fmt); Set(fmt, argList); va_end(argList)
+#define XBMCCOMMONS_STANDARD_EXCEPTION(E) \
+ class E : public XbmcCommons::Exception \
+ { \
+ public: \
+ inline E(const char* message,...) : Exception(#E) { XBMCCOMMONS_COPYVARARGS(message); } \
+ \
+ inline E(const E& other) : Exception(other) {} \
+ }
+
+namespace XbmcCommons
+{
+ /**
+ * This class a superclass for exceptions that want to utilize some
+ * utility functionality including autologging with the specific
+ * exception name.
+ */
+ class Exception
+ {
+ private:
+
+ std::string classname;
+ CStdString message;
+
+ protected:
+ static ILogger* logger;
+
+ inline Exception(const char* classname_) : classname(classname_) { }
+ inline Exception(const char* classname_, const char* message_) : classname(classname_), message(message_) { }
+ inline Exception(const Exception& other) : classname(other.classname), message(other.message) { }
+
+ /**
+ * This method is called from the constructor of subclasses. It
+ * will set the message from varargs as well as call log message
+ */
+ inline void Set(const char* fmt, va_list& argList)
+ {
+ message.FormatV(fmt, argList);
+ }
+
+ /**
+ * This message can be called from the constructor of subclasses.
+ * It will set the message and log the throwing.
+ */
+ inline void SetMessage(const char* fmt, ...)
+ {
+ // calls 'set'
+ XBMCCOMMONS_COPYVARARGS(fmt);
+ }
+
+ public:
+ virtual ~Exception();
+
+ inline virtual void LogThrowMessage(const char* prefix = NULL) const
+ {
+ if (logger)
+ logger->Log(LOGERROR,"EXCEPTION Thrown (%s) : %s", classname.c_str(), message.c_str());
+ }
+
+ inline virtual const char* GetMessage() const { return message.c_str(); }
+
+ inline static void SetLogger(ILogger* exceptionLogger) { logger = exceptionLogger; }
+ };
+
+ /**
+ * This class forms the base class for unchecked exceptions. Unchecked exceptions
+ * are those that really shouldn't be handled explicitly. For example, on windows
+ * when a access violaton is converted to a win32_exception, there's nothing
+ * that can be done in most code. The outer most stack frame might try to
+ * do some error logging prior to shutting down, but that's really it.
+ */
+ XBMCCOMMONS_STANDARD_EXCEPTION(UncheckedException);
+
+/**
+ * In cases where you catch(...){} you will (may) inadvertently be
+ * catching UncheckedException's. Therefore this macro will allow
+ * you to do something equivalent to:
+ * catch (anything except UncheckedException) {}
+ *
+ * In order to avoid catching UncheckedException, use the macro as follows:
+ *
+ * try { ... }
+ * XBMCCOMMONS_HANDLE_UNCHECKED
+ * catch(...){ ... }
+ */
+// Yes. I recognize that the name of this macro is an oxymoron.
+#define XBMCCOMMONS_HANDLE_UNCHECKED \
+ catch (const XbmcCommons::UncheckedException& ) { throw; } \
+ catch (const XbmcCommons::UncheckedException* ) { throw; }
+
+}
+
SRCS= \
+ Exception.cpp \
ilog.cpp
-
LIB=commons.a
include ../../Makefile.include
USHORT MaximumLength;
PWSTR Buffer;
} UNICODE_STRING, *PUNICODE_STRING;
-#include "utils/Win32Exception.h"
+#include "commons/Exception.h"
#define DLL_PROCESS_DETACH 0
#define DLL_PROCESS_ATTACH 1
#endif
}
- catch(win32_exception &e)
- {
- e.writelog(__FUNCTION__);
- return false;
- }
+ XBMCCOMMONS_HANDLE_UNCHECKED
catch(...)
{
CLog::Log(LOGERROR, "%s - Unhandled exception during DLL_PROCESS_ATTACH", __FUNCTION__);
#include "DVDOverlayImage.h"
#include "DVDStreamInfo.h"
#include "DVDClock.h"
-#include "utils/Win32Exception.h"
#include "utils/log.h"
#include "utils/EndianSwap.h"
avpkt.data = data;
avpkt.size = size;
- try
- {
- len = m_dllAvCodec.avcodec_decode_subtitle2(m_pCodecContext, &m_Subtitle, &gotsub, &avpkt);
- }
- catch (win32_exception e)
- {
- e.writelog("avcodec_decode_subtitle");
- return OC_ERROR;
- }
+ len = m_dllAvCodec.avcodec_decode_subtitle2(m_pCodecContext, &m_Subtitle, &gotsub, &avpkt);
if (len < 0)
{
FreeSubtitle(m_Subtitle);
m_SubtitleIndex = -1;
- try {
-
m_dllAvCodec.avcodec_flush_buffers(m_pCodecContext);
-
- } catch (win32_exception e) {
- e.writelog(__FUNCTION__);
- }
}
CDVDOverlay* CDVDOverlayCodecFFmpeg::GetOverlay()
#include "DVDClock.h"
#include "DVDCodecs/DVDCodecs.h"
#include "DVDCodecs/DVDCodecUtils.h"
-#include "../../../../utils/Win32Exception.h"
#if defined(_LINUX) || defined(_WIN32)
#include "utils/CPUInfo.h"
#endif
#endif
#include "DVDDemuxUtils.h"
#include "DVDClock.h" // for DVD_TIME_BASE
-#include "utils/Win32Exception.h"
+#include "commons/Exception.h"
#include "settings/AdvancedSettings.h"
#include "settings/GUISettings.h"
#include "filesystem/File.h"
// timeout reads after 100ms
m_timeout.Set(20000);
- int result = 0;
- try
- {
- result = m_dllAvFormat.av_read_frame(m_pFormatContext, &pkt);
- }
- catch(const win32_exception &e)
- {
- e.writelog(__FUNCTION__);
- result = AVERROR(EFAULT);
- }
+ int result = m_dllAvFormat.av_read_frame(m_pFormatContext, &pkt);
m_timeout.SetInfinite();
if (result == AVERROR(EINTR) || result == AVERROR(EAGAIN))
#include "Directory.h"
#include "DirectoryFactory.h"
#include "FileDirectoryFactory.h"
-#ifndef _LINUX
-#include "utils/Win32Exception.h"
-#endif
+#include "commons/Exception.h"
#include "FileItem.h"
#include "DirectoryCache.h"
#include "settings/GUISettings.h"
return true;
}
-#ifndef _LINUX
- catch (const win32_exception &e)
- {
- e.writelog(__FUNCTION__);
- }
-#endif
+ XBMCCOMMONS_HANDLE_UNCHECKED
catch (...)
{
CLog::Log(LOGERROR, "%s - Unhandled exception", __FUNCTION__);
if(pDirectory->Create(realPath.c_str()))
return true;
}
-#ifndef _LINUX
- catch (const win32_exception &e)
- {
- e.writelog(__FUNCTION__);
- }
-#endif
+ XBMCCOMMONS_HANDLE_UNCHECKED
catch (...)
{
CLog::Log(LOGERROR, "%s - Unhandled exception", __FUNCTION__);
if (pDirectory.get())
return pDirectory->Exists(realPath.c_str());
}
-#ifndef _LINUX
- catch (const win32_exception &e)
- {
- e.writelog(__FUNCTION__);
- }
-#endif
+ XBMCCOMMONS_HANDLE_UNCHECKED
catch (...)
{
CLog::Log(LOGERROR, "%s - Unhandled exception", __FUNCTION__);
if(pDirectory->Remove(realPath.c_str()))
return true;
}
-#ifndef _LINUX
- catch (const win32_exception &e)
- {
- e.writelog(__FUNCTION__);
- }
-#endif
+ XBMCCOMMONS_HANDLE_UNCHECKED
catch (...)
{
CLog::Log(LOGERROR, "%s - Unhandled exception", __FUNCTION__);
#include "utils/BitstreamStats.h"
#include "Util.h"
-#ifndef _LINUX
-#include "utils/Win32Exception.h"
-#endif
-#include "URL.h"
+#include "commons/Exception.h"
using namespace XFILE;
using namespace std;
return true;
}
-#ifndef _LINUX
- catch (const win32_exception &e)
- {
- e.writelog(__FUNCTION__);
- }
-#endif
+ XBMCCOMMONS_HANDLE_UNCHECKED
catch(...)
{
CLog::Log(LOGERROR, "%s - Unhandled exception", __FUNCTION__);
}
return false;
}
-#ifndef _LINUX
- catch (const win32_exception &e)
- {
- e.writelog(__FUNCTION__);
- }
-#endif
+ XBMCCOMMONS_HANDLE_UNCHECKED
catch(...)
{
CLog::Log(LOGERROR, "%s - Unhandled exception opening %s", __FUNCTION__, strFileName.c_str());
return pFile->Exists(url);
}
-#ifndef _LINUX
- catch (const win32_exception &e)
- {
- e.writelog(__FUNCTION__);
- }
-#endif
+ XBMCCOMMONS_HANDLE_UNCHECKED
catch (CRedirectException *pRedirectEx)
{
// the file implementation decided this item should use a different implementation.
return -1;
return pFile->Stat(url, buffer);
}
-#ifndef _LINUX
- catch (const win32_exception &e)
- {
- e.writelog(__FUNCTION__);
- }
-#endif
+ XBMCCOMMONS_HANDLE_UNCHECKED
catch (CRedirectException *pRedirectEx)
{
// the file implementation decided this item should use a different implementation.
return done;
}
}
-#ifndef _LINUX
- catch (const win32_exception &e)
- {
- e.writelog(__FUNCTION__);
- }
-#endif
+ XBMCCOMMONS_HANDLE_UNCHECKED
catch(...)
{
CLog::Log(LOGERROR, "%s - Unhandled exception", __FUNCTION__);
SAFE_DELETE(m_pBuffer);
SAFE_DELETE(m_pFile);
}
-#ifndef _LINUX
- catch (const win32_exception &e)
- {
- e.writelog(__FUNCTION__);
- }
-#endif
+ XBMCCOMMONS_HANDLE_UNCHECKED
catch(...)
{
CLog::Log(LOGERROR, "%s - Unhandled exception", __FUNCTION__);
if (m_pFile)
m_pFile->Flush();
}
-#ifndef _LINUX
- catch (const win32_exception &e)
- {
- e.writelog(__FUNCTION__);
- }
-#endif
+ XBMCCOMMONS_HANDLE_UNCHECKED
catch(...)
{
CLog::Log(LOGERROR, "%s - Unhandled exception", __FUNCTION__);
{
return m_pFile->Seek(iFilePosition, iWhence);
}
-#ifndef _LINUX
- catch (const win32_exception &e)
- {
- e.writelog(__FUNCTION__);
- }
-#endif
+ XBMCCOMMONS_HANDLE_UNCHECKED
catch(...)
{
CLog::Log(LOGERROR, "%s - Unhandled exception", __FUNCTION__);
return m_pFile->GetLength();
return 0;
}
-#ifndef _LINUX
- catch (const win32_exception &e)
- {
- e.writelog(__FUNCTION__);
- }
-#endif
+ XBMCCOMMONS_HANDLE_UNCHECKED
catch(...)
{
CLog::Log(LOGERROR, "%s - Unhandled exception", __FUNCTION__);
{
return m_pFile->GetPosition();
}
-#ifndef _LINUX
- catch (const win32_exception &e)
- {
- e.writelog(__FUNCTION__);
- }
-#endif
+ XBMCCOMMONS_HANDLE_UNCHECKED
catch(...)
{
CLog::Log(LOGERROR, "%s - Unhandled exception", __FUNCTION__);
{
return m_pFile->ReadString(szLine, iLineLength);
}
-#ifndef _LINUX
- catch (const win32_exception &e)
- {
- e.writelog(__FUNCTION__);
- }
-#endif
+ XBMCCOMMONS_HANDLE_UNCHECKED
catch(...)
{
CLog::Log(LOGERROR, "%s - Unhandled exception", __FUNCTION__);
{
return m_pFile->Write(lpBuf, uiBufSize);
}
-#ifndef _LINUX
- catch (const win32_exception &e)
- {
- e.writelog(__FUNCTION__);
- }
-#endif
+ XBMCCOMMONS_HANDLE_UNCHECKED
catch(...)
{
CLog::Log(LOGERROR, "%s - Unhandled exception", __FUNCTION__);
return true;
}
}
-#ifndef _LINUX
- catch (const access_violation &e)
- {
- e.writelog(__FUNCTION__);
- }
- catch (const win32_exception &e)
- {
- e.writelog(__FUNCTION__);
- }
-#endif
+ XBMCCOMMONS_HANDLE_UNCHECKED
catch(...)
{
CLog::Log(LOGERROR, "%s - Unhandled exception", __FUNCTION__);
return true;
}
}
-#ifndef _LINUX
- catch (const win32_exception &e)
- {
- e.writelog(__FUNCTION__);
- }
-#endif
+ XBMCCOMMONS_HANDLE_UNCHECKED
catch(...)
{
CLog::Log(LOGERROR, "%s - Unhandled exception ", __FUNCTION__);
memmove(m_buffer, egptr()-backsize, backsize);
}
- unsigned int size = 0;
-#ifndef _LINUX
- try
- {
-#endif
- size = m_file->Read(m_buffer+backsize, m_frontsize);
-#ifndef _LINUX
- }
- catch (const win32_exception &e)
- {
- e.writelog(__FUNCTION__);
- }
-#endif
+ unsigned int size = m_file->Read(m_buffer+backsize, m_frontsize);
if(size == 0)
return traits_type::eof();
setp(0,0);
int64_t position = -1;
-#ifndef _LINUX
- try
- {
-#endif
- if(way == ios_base::cur)
- position = m_file->Seek(offset, SEEK_CUR);
- else if(way == ios_base::end)
- position = m_file->Seek(offset, SEEK_END);
- else
- position = m_file->Seek(offset, SEEK_SET);
-#ifndef _LINUX
- }
- catch (const win32_exception &e)
- {
- e.writelog(__FUNCTION__);
- return streampos(-1);
- }
-#endif
+ if(way == ios_base::cur)
+ position = m_file->Seek(offset, SEEK_CUR);
+ else if(way == ios_base::end)
+ position = m_file->Seek(offset, SEEK_END);
+ else
+ position = m_file->Seek(offset, SEEK_SET);
if(position<0)
return streampos(-1);
#include "threads/SingleLock.h"
#include "utils/log.h"
#include "utils/TimeUtils.h"
+#include "commons/Exception.h"
using namespace XFILE;
smbc_set_context(NULL);
smbc_free_context(m_context, 1);
}
-#ifdef TARGET_WINDOWS
- catch(win32_exception e)
- {
- e.writelog(__FUNCTION__);
- }
- m_IdleTimeout = 180;
-#else
+ XBMCCOMMONS_HANDLE_UNCHECKED
catch(...)
{
CLog::Log(LOGERROR,"exception on CSMB::Deinit. errno: %d", errno);
}
-#endif
m_context = NULL;
}
}
#include "threads/SystemClock.h"
#include "Thread.h"
-#include "utils/log.h"
#include "threads/ThreadLocal.h"
#include "threads/SingleLock.h"
+#include "commons/Exception.h"
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
+#define LOG if(logger) logger->Log
+
CThread::CThread(const char* ThreadName)
: m_StopEvent(true,true), m_TermEvent(true), m_StartEvent(true)
{
StopThread();
}
+void CThread::Create(bool bAutoDelete, unsigned stacksize)
+{
+ if (m_ThreadId != 0)
+ {
+ LOG(LOGERROR, "%s - fatal error creating thread- old thread id not null", __FUNCTION__);
+ exit(1);
+ }
+ m_iLastTime = XbmcThreads::SystemClockMillis() * 10000;
+ m_iLastUsage = 0;
+ m_fLastUsage = 0.0f;
+ m_bAutoDelete = bAutoDelete;
+ m_bStop = false;
+ m_StopEvent.Reset();
+ m_TermEvent.Reset();
+ m_StartEvent.Reset();
+
+ SpawnThread(stacksize);
+}
+
bool CThread::IsRunning()
{
return m_ThreadId ? true : false;
bool autodelete;
if (!pThread) {
- if(logger) logger->Log(LOGERROR,"%s, sanity failed. thread is NULL.",__FUNCTION__);
+ LOG(LOGERROR,"%s, sanity failed. thread is NULL.",__FUNCTION__);
return 1;
}
pThread->SetThreadInfo();
- if(logger) logger->Log(LOGNOTICE,"Thread %s start, auto delete: %s", name.c_str(), (autodelete ? "true" : "false"));
+ LOG(LOGNOTICE,"Thread %s start, auto delete: %s", name.c_str(), (autodelete ? "true" : "false"));
currentThread.set(pThread);
pThread->m_StartEvent.Set();
if (autodelete)
{
- if(logger) logger->Log(LOGDEBUG,"Thread %s %"PRIu64" terminating (autodelete)", name.c_str(), (uint64_t)id);
+ LOG(LOGDEBUG,"Thread %s %"PRIu64" terminating (autodelete)", name.c_str(), (uint64_t)id);
delete pThread;
pThread = NULL;
}
else
- if(logger) logger->Log(LOGDEBUG,"Thread %s %"PRIu64" terminating", name.c_str(), (uint64_t)id);
+ LOG(LOGDEBUG,"Thread %s %"PRIu64" terminating", name.c_str(), (uint64_t)id);
return 0;
}
XbmcThreads::ThreadSleep(milliseconds);
}
+void CThread::Action()
+{
+
+ try
+ {
+ OnStartup();
+ }
+ catch (const XbmcCommons::UncheckedException &e)
+ {
+ e.LogThrowMessage("OnStartup");
+ if (IsAutoDelete())
+ return;
+ }
+ catch (...)
+ {
+ LOG(LOGERROR, "%s - thread %s, Unhandled exception caught in thread startup, aborting. auto delete: %d", __FUNCTION__, m_ThreadName.c_str(), IsAutoDelete());
+ if (IsAutoDelete())
+ return;
+ }
+
+ try
+ {
+ Process();
+ }
+ catch (const XbmcCommons::UncheckedException &e)
+ {
+ e.LogThrowMessage("Process");
+ }
+ catch (...)
+ {
+ LOG(LOGERROR, "%s - thread %s, Unhandled exception caught in thread process, aborting. auto delete: %d", __FUNCTION__, m_ThreadName.c_str(), IsAutoDelete());
+ }
+
+ try
+ {
+ OnExit();
+ }
+ catch (const XbmcCommons::UncheckedException &e)
+ {
+ e.LogThrowMessage("OnExit");
+ }
+ catch (...)
+ {
+ LOG(LOGERROR, "%s - thread %s, Unhandled exception caught in thread process, aborting. auto delete: %d", __FUNCTION__, m_ThreadName.c_str(), IsAutoDelete());
+ }
+}
CThread(IRunnable* pRunnable, const char* ThreadName);
virtual ~CThread();
void Create(bool bAutoDelete = false, unsigned stacksize = 0);
- bool WaitForThreadExit(unsigned int milliseconds);
void Sleep(unsigned int milliseconds);
- bool SetPriority(const int iPriority);
- int GetPriority(void);
- int GetMinPriority(void);
- int GetMaxPriority(void);
- int GetNormalPriority(void);
int GetSchedRRPriority(void);
bool SetPrioritySched_RR(int iPriority);
bool IsAutoDelete() const;
virtual void StopThread(bool bWait = true);
+ bool IsRunning();
+
+ // -----------------------------------------------------------------------------------
+ // These are platform specific and can be found in ./platform/[platform]/ThreadImpl.cpp
+ // -----------------------------------------------------------------------------------
+ bool IsCurrentThread() const;
+ int GetMinPriority(void);
+ int GetMaxPriority(void);
+ int GetNormalPriority(void);
+ int GetPriority(void);
+ bool SetPriority(const int iPriority);
+ bool WaitForThreadExit(unsigned int milliseconds);
float GetRelativeUsage(); // returns the relative cpu usage of this thread since last call
int64_t GetAbsoluteUsage();
- bool IsCurrentThread() const;
- bool IsRunning();
+ // -----------------------------------------------------------------------------------
static bool IsCurrentThread(const ThreadIdentifier tid);
static ThreadIdentifier GetCurrentThreadId();
static CThread* GetCurrentThread();
static inline void SetLogger(XbmcCommons::ILogger* logger_) { CThread::logger = logger_; }
+ static inline XbmcCommons::ILogger* GetLogger() { return CThread::logger; }
+
+ virtual void OnException(){} // signal termination handler
protected:
virtual void OnStartup(){};
virtual void OnExit(){};
- virtual void OnException(){} // signal termination handler
virtual void Process();
volatile bool m_bStop;
/**
* This call will wait on a CEvent in an interruptible way such that if
- * stop is called on the thread the wait will return with a respone
+ * stop is called on the thread the wait will return with a response
* indicating what happened.
*/
- inline WaitResponse AbortableWait(CEvent& event, int timeoutMillis)
- {
- XbmcThreads::CEventGroup group(&event, &m_StopEvent, NULL);
- CEvent* result = group.wait(timeoutMillis);
- return result == &event ? WAIT_SIGNALED :
- (result == NULL ? WAIT_TIMEDOUT : WAIT_INTERRUPTED);
- }
-
- inline WaitResponse AbortableWait(CEvent& event)
+ inline WaitResponse AbortableWait(CEvent& event, int timeoutMillis = -1 /* indicates wait forever*/)
{
XbmcThreads::CEventGroup group(&event, &m_StopEvent, NULL);
- CEvent* result = group.wait();
+ CEvent* result = timeoutMillis < 0 ? group.wait() : group.wait(timeoutMillis);
return result == &event ? WAIT_SIGNALED :
(result == NULL ? WAIT_TIMEDOUT : WAIT_INTERRUPTED);
}
private:
static THREADFUNC staticThread(void *data);
+ void Action();
+
+ // -----------------------------------------------------------------------------------
+ // These are platform specific and can be found in ./platform/[platform]/ThreadImpl.cpp
+ // -----------------------------------------------------------------------------------
ThreadIdentifier ThreadId() const;
void SetThreadInfo();
void TermHandler();
- void Action();
+ void SetSignalHandlers();
+ void SpawnThread(unsigned stacksize);
+ // -----------------------------------------------------------------------------------
ThreadIdentifier m_ThreadId;
ThreadOpaque m_ThreadOpaque;
#endif
#endif
-void CThread::Create(bool bAutoDelete, unsigned stacksize)
-{
- if (m_ThreadId != 0)
- {
- if (logger) logger->Log(LOGERROR, "%s - fatal error creating thread- old thread id not null", __FUNCTION__);
- exit(1);
- }
- m_iLastTime = XbmcThreads::SystemClockMillis() * 10000;
- m_iLastUsage = 0;
- m_fLastUsage = 0.0f;
- m_bAutoDelete = bAutoDelete;
- m_bStop = false;
- m_StopEvent.Reset();
- m_TermEvent.Reset();
- m_StartEvent.Reset();
+#include <signal.h>
+void CThread::SpawnThread(unsigned stacksize)
+{
pthread_attr_t attr;
pthread_attr_init(&attr);
if (stacksize > PTHREAD_STACK_MIN)
pthread_attr_destroy(&attr);
}
-void CThread::TermHandler()
-{
-
-}
+void CThread::TermHandler() { }
void CThread::SetThreadInfo()
{
return m_fLastUsage;
}
-void CThread::Action()
+void term_handler (int signum)
{
- try
- {
- OnStartup();
- }
- catch (...)
+ XbmcCommons::ILogger* logger = CThread::GetLogger();
+ if (logger)
+ logger->Log(LOGERROR,"thread 0x%lx (%lu) got signal %d. calling OnException and terminating thread abnormally.", (long unsigned int)pthread_self(), (long unsigned int)pthread_self(), signum);
+ CThread* curThread = CThread::GetCurrentThread();
+ if (curThread)
{
- CLog::Log(LOGERROR, "%s - thread %s, Unhandled exception caught in thread startup, aborting. auto delete: %d", __FUNCTION__, m_ThreadName.c_str(), IsAutoDelete());
- if (IsAutoDelete())
- return;
- }
-
- try
- {
- Process();
- }
- catch (...)
- {
- CLog::Log(LOGERROR, "%s - thread %s, Unhandled exception caught in thread process, aborting. auto delete: %d", __FUNCTION__, m_ThreadName.c_str(), IsAutoDelete());
- }
-
- try
- {
- OnExit();
- }
- catch (...)
- {
- CLog::Log(LOGERROR, "%s - thread %s, Unhandled exception caught in thread exit, aborting. auto delete: %d", __FUNCTION__, m_ThreadName.c_str(), IsAutoDelete());
+ curThread->StopThread(false);
+ curThread->OnException();
+ if( curThread->IsAutoDelete() )
+ delete curThread;
}
+ pthread_exit(NULL);
}
+void CThread::SetSignalHandlers()
+{
+ struct sigaction action;
+ action.sa_handler = term_handler;
+ sigemptyset (&action.sa_mask);
+ action.sa_flags = 0;
+ //sigaction (SIGABRT, &action, NULL);
+ //sigaction (SIGSEGV, &action, NULL);
+}
*/
#include <windows.h>
-#include "utils/Win32Exception.h"
+#include "threads/platform/win/Win32Exception.h"
-
-void CThread::Create(bool bAutoDelete, unsigned stacksize)
+void CThread::SpawnThread(unsigned stacksize)
{
- if (m_ThreadId != 0)
- {
- if (logger) logger->Log(LOGERROR, "%s - fatal error creating thread- old thread id not null", __FUNCTION__);
- exit(1);
- }
-
- m_iLastTime = XbmcThreads::SystemClockMillis() * 10000;
- m_iLastUsage = 0;
- m_fLastUsage = 0.0f;
- m_bAutoDelete = bAutoDelete;
- m_bStop = false;
- m_StopEvent.Reset();
- m_TermEvent.Reset();
- m_StartEvent.Reset();
-
// Create in the suspended state, so that no matter the thread priorities and scheduled order, the handle will be assigned
// before the new thread exits.
m_ThreadOpaque.handle = CreateThread(NULL, stacksize, (LPTHREAD_START_ROUTINE)&staticThread, this, CREATE_SUSPENDED, &m_ThreadId);
return m_fLastUsage;
}
-void CThread::Action()
+void CThread::SetSignalHandlers()
{
// install win32 exception translator
win32_exception::install_handler();
-
- try
- {
- OnStartup();
- }
- catch (const access_violation &e)
- {
- e.writelog(__FUNCTION__" thread startup");
- if (IsAutoDelete())
- return;
- }
- catch (const win32_exception &e)
- {
- e.writelog(__FUNCTION__" thread startup");
- if (IsAutoDelete())
- return;
- }
-
- try
- {
- Process();
- }
- catch (const access_violation &e)
- {
- e.writelog(__FUNCTION__" thread process");
- }
- catch (const win32_exception &e)
- {
- e.writelog(__FUNCTION__" thread process");
- }
-
- try
- {
- OnExit();
- }
- catch (const access_violation &e)
- {
- e.writelog(__FUNCTION__" thread exit");
- }
- catch (const win32_exception &e)
- {
- e.writelog(__FUNCTION__" thread exit");
- }
}
--- /dev/null
+/*
+ * Copyright (C) 2005-2008 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#include "Win32Exception.h"
+#include <eh.h>
+
+#define LOG if(logger) logger->Log
+
+void win32_exception::install_handler()
+{
+ _set_se_translator(win32_exception::translate);
+}
+
+void win32_exception::translate(unsigned code, EXCEPTION_POINTERS* info)
+{
+ // Windows guarantees that *(info->ExceptionRecord) is valid
+ switch (code) {
+ case EXCEPTION_ACCESS_VIOLATION:
+ throw access_violation(*(info->ExceptionRecord));
+ break;
+ default:
+ throw win32_exception(*(info->ExceptionRecord));
+ }
+}
+
+win32_exception::win32_exception(const EXCEPTION_RECORD& info, const char* classname) :
+ XbmcCommons::Exception(classname ? classname : "win32_exception"),
+mWhat("Win32 exception"), mWhere(info.ExceptionAddress), mCode(info.ExceptionCode)
+{
+ switch (info.ExceptionCode) {
+ case EXCEPTION_ACCESS_VIOLATION:
+ mWhat = "Access violation";
+ break;
+ case EXCEPTION_FLT_DIVIDE_BY_ZERO:
+ case EXCEPTION_INT_DIVIDE_BY_ZERO:
+ mWhat = "Division by zero";
+ break;
+ }
+}
+
+void win32_exception::LogThrowMessage(const char *prefix) const
+{
+ if( prefix )
+ LOG(LOGERROR, "%s : %s (code:0x%08x) at 0x%08x", prefix, (unsigned int) what(), code(), where());
+ else
+ LOG(LOGERROR, "%s (code:0x%08x) at 0x%08x", what(), code(), where());
+}
+
+access_violation::access_violation(const EXCEPTION_RECORD& info)
+: win32_exception(info,"access_voilation"), mAccessType(Invalid), mBadAddress(0)
+{
+ switch(info.ExceptionInformation[0])
+ {
+ case 0:
+ mAccessType = Read;
+ break;
+ case 1:
+ mAccessType = Write;
+ break;
+ case 8:
+ mAccessType = DEP;
+ break;
+ }
+ mBadAddress = reinterpret_cast<win32_exception ::Address>(info.ExceptionInformation[1]);
+}
+
+void access_violation::LogThrowMessage(const char *prefix) const
+{
+ if( prefix )
+ if( mAccessType == Write)
+ LOG(LOGERROR, "%s : %s at 0x%08x: Writing location 0x%08x", prefix, what(), where(), address());
+ else if( mAccessType == Read)
+ LOG(LOGERROR, "%s : %s at 0x%08x: Reading location 0x%08x", prefix, what(), where(), address());
+ else if( mAccessType == DEP)
+ LOG(LOGERROR, "%s : %s at 0x%08x: DEP violation, location 0x%08x", prefix, what(), where(), address());
+ else
+ LOG(LOGERROR, "%s : %s at 0x%08x: unknown access type, location 0x%08x", prefix, what(), where(), address());
+ else
+ if( mAccessType == Write)
+ LOG(LOGERROR, "%s at 0x%08x: Writing location 0x%08x", what(), where(), address());
+ else if( mAccessType == Read)
+ LOG(LOGERROR, "%s at 0x%08x: Reading location 0x%08x", what(), where(), address());
+ else if( mAccessType == DEP)
+ LOG(LOGERROR, "%s at 0x%08x: DEP violation, location 0x%08x", what(), where(), address());
+ else
+ LOG(LOGERROR, "%s at 0x%08x: unknown access type, location 0x%08x", what(), where(), address());
+}
--- /dev/null
+#pragma once
+
+/*
+ * Copyright (C) 2005-2008 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#include <windows.h>
+#include <exception>
+#include "commons/Exception.h"
+
+class win32_exception: public XbmcCommons::Exception
+{
+public:
+ typedef const void* Address; // OK on Win32 platform
+
+ static void install_handler();
+ virtual const char* what() const { return mWhat; };
+ Address where() const { return mWhere; };
+ unsigned code() const { return mCode; };
+ virtual void LogThrowMessage(const char *prefix) const;
+protected:
+ win32_exception(const EXCEPTION_RECORD& info, const char* classname = NULL);
+ static void translate(unsigned code, EXCEPTION_POINTERS* info);
+private:
+ const char* mWhat;
+ Address mWhere;
+ unsigned mCode;
+};
+
+class access_violation: public win32_exception
+{
+ enum access_type
+ {
+ Invalid,
+ Read,
+ Write,
+ DEP
+ };
+
+public:
+ Address address() const { return mBadAddress; };
+ virtual void LogThrowMessage(const char *prefix) const;
+protected:
+ friend void win32_exception::translate(unsigned code, EXCEPTION_POINTERS* info);
+private:
+ access_type mAccessType;
+ Address mBadAddress;
+ access_violation(const EXCEPTION_RECORD& info);
+};
URIUtils.cpp \
Variant.cpp \
Weather.cpp \
- Win32Exception.cpp \
XBMCTinyXML.cpp \
XMLUtils.cpp \
+++ /dev/null
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "Win32Exception.h"
-#ifndef _LINUX
-#include "eh.h"
-#endif
-#include "log.h"
-
-#ifdef _LINUX
-
-void win32_exception::writelog(const char *prefix) const
-{
- if( prefix )
- CLog::Log(LOGERROR, "%s : %s (code:0x%08x) at %p",
- prefix, what(), (unsigned int) code(), where());
- else
- CLog::Log(LOGERROR, "%s (code:0x%08x) at %p",
- what(), (unsigned int) code(), where());
-}
-
-
-#else
-
-void win32_exception::install_handler()
-{
- _set_se_translator(win32_exception::translate);
-}
-
-void win32_exception::translate(unsigned code, EXCEPTION_POINTERS* info)
-{
- // Windows guarantees that *(info->ExceptionRecord) is valid
- switch (code) {
- case EXCEPTION_ACCESS_VIOLATION:
- throw access_violation(*(info->ExceptionRecord));
- break;
- default:
- throw win32_exception(*(info->ExceptionRecord));
- }
-}
-
-win32_exception::win32_exception(const EXCEPTION_RECORD& info)
-: mWhat("Win32 exception"), mWhere(info.ExceptionAddress), mCode(info.ExceptionCode)
-{
- switch (info.ExceptionCode) {
- case EXCEPTION_ACCESS_VIOLATION:
- mWhat = "Access violation";
- break;
- case EXCEPTION_FLT_DIVIDE_BY_ZERO:
- case EXCEPTION_INT_DIVIDE_BY_ZERO:
- mWhat = "Division by zero";
- break;
- }
-}
-
-void win32_exception::writelog(const char *prefix) const
-{
- if( prefix )
- CLog::Log(LOGERROR, "%s : %s (code:0x%08x) at 0x%08x", prefix, (unsigned int) what(), code(), where());
- else
- CLog::Log(LOGERROR, "%s (code:0x%08x) at 0x%08x", what(), code(), where());
-}
-
-access_violation::access_violation(const EXCEPTION_RECORD& info)
-: win32_exception(info), mAccessType(Invalid), mBadAddress(0)
-{
- switch(info.ExceptionInformation[0])
- {
- case 0:
- mAccessType = Read;
- break;
- case 1:
- mAccessType = Write;
- break;
- case 8:
- mAccessType = DEP;
- break;
- }
- mBadAddress = reinterpret_cast<win32_exception ::Address>(info.ExceptionInformation[1]);
-}
-
-void access_violation::writelog(const char *prefix) const
-{
- if( prefix )
- if( mAccessType == Write)
- CLog::Log(LOGERROR, "%s : %s at 0x%08x: Writing location 0x%08x", prefix, what(), where(), address());
- else if( mAccessType == Read)
- CLog::Log(LOGERROR, "%s : %s at 0x%08x: Reading location 0x%08x", prefix, what(), where(), address());
- else if( mAccessType == DEP)
- CLog::Log(LOGERROR, "%s : %s at 0x%08x: DEP violation, location 0x%08x", prefix, what(), where(), address());
- else
- CLog::Log(LOGERROR, "%s : %s at 0x%08x: unknown access type, location 0x%08x", prefix, what(), where(), address());
- else
- if( mAccessType == Write)
- CLog::Log(LOGERROR, "%s at 0x%08x: Writing location 0x%08x", what(), where(), address());
- else if( mAccessType == Read)
- CLog::Log(LOGERROR, "%s at 0x%08x: Reading location 0x%08x", what(), where(), address());
- else if( mAccessType == DEP)
- CLog::Log(LOGERROR, "%s at 0x%08x: DEP violation, location 0x%08x", what(), where(), address());
- else
- CLog::Log(LOGERROR, "%s at 0x%08x: unknown access type, location 0x%08x", what(), where(), address());
-
-}
-
-#endif
+++ /dev/null
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#ifdef _WIN32
-#include <windows.h>
-#endif
-#include <exception>
-
-#ifdef _LINUX
-
-class win32_exception: public std::exception
-{
-public:
- virtual const char* what() const throw() { return mWhat; };
- void* where() const { return mWhere; };
- unsigned int code() const { return mCode; };
- virtual void writelog(const char *prefix) const;
-private:
- const char* mWhat;
- void* mWhere;
- unsigned mCode;
-};
-
-#else
-
-class win32_exception: public std::exception
-{
-public:
- typedef const void* Address; // OK on Win32 platform
-
- static void install_handler();
- virtual const char* what() const { return mWhat; };
- Address where() const { return mWhere; };
- unsigned code() const { return mCode; };
- virtual void writelog(const char *prefix) const;
-protected:
- win32_exception(const EXCEPTION_RECORD& info);
- static void translate(unsigned code, EXCEPTION_POINTERS* info);
-private:
- const char* mWhat;
- Address mWhere;
- unsigned mCode;
-};
-
-class access_violation: public win32_exception
-{
- enum access_type
- {
- Invalid,
- Read,
- Write,
- DEP
- };
-
-public:
- Address address() const { return mBadAddress; };
- virtual void writelog(const char *prefix) const;
-protected:
- friend void win32_exception::translate(unsigned code, EXCEPTION_POINTERS* info);
-private:
- access_type mAccessType;
- Address mBadAddress;
- access_violation(const EXCEPTION_RECORD& info);
-};
-#endif