| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 Eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 #include "PluginStdAfx.h" | 18 #include "PluginStdAfx.h" |
| 19 | |
| 20 #include "PluginDebug.h" | 19 #include "PluginDebug.h" |
| 20 #include "Exception.h" | |
| 21 #include "PluginMutex.h" | 21 #include "PluginMutex.h" |
| 22 #include "PluginSettings.h" | 22 #include "PluginSettings.h" |
| 23 | 23 |
| 24 #if (defined ENABLE_DEBUG_INFO) | |
| 25 struct EntryPointHandlers | |
| 26 { | |
| 27 static void Unknown(std::string name) | |
| 28 { | |
| 29 CPluginDebug::Debug("Unknown exception in catch-all for entry point " + name ); | |
| 30 } | |
| 31 static void Exception(std::exception& ex, std::string name) | |
| 32 { | |
| 33 CPluginDebug::DebugOrdinaryException(ex, | |
| 34 PLUGIN_ERROR_ENTRY_POINT, PLUGIN_ERROR_ENTRY_POINT_CATCHALL_EXCEPTION, | |
| 35 "std::exception in catch-all for entry point " + name); | |
| 36 } | |
| 37 static void LogicError(std::logic_error& ex, std::string name) | |
| 38 { | |
| 39 CPluginDebug::DebugOrdinaryException(ex, | |
| 40 PLUGIN_ERROR_ENTRY_POINT, PLUGIN_ERROR_ENTRY_POINT_CATCHALL_EXCEPTION, | |
| 41 "std::logic_error in catch-all for entry point " + name); | |
| 42 } | |
| 43 static void RuntimeError(std::runtime_error& ex, std::string name) | |
| 44 { | |
| 45 CPluginDebug::DebugOrdinaryException(ex, | |
| 46 PLUGIN_ERROR_ENTRY_POINT, PLUGIN_ERROR_ENTRY_POINT_CATCHALL_EXCEPTION, | |
| 47 "std::runtime_error in catch-all for entry point " + name); | |
| 48 } | |
| 49 static void SystemError(std::system_error& ex, std::string name) | |
| 50 { | |
| 51 CPluginDebug::DebugSystemException(ex, | |
| 52 PLUGIN_ERROR_ENTRY_POINT, PLUGIN_ERROR_ENTRY_POINT_CATCHALL_EXCEPTION, | |
| 53 "std::system_error in catch-all for entry point " + name); | |
| 54 } | |
| 55 }; | |
| 56 #endif | |
| 57 | |
| 58 void EntryPointExceptionDefault(std::string name) | |
|
Oleksandr
2015/03/05 07:18:55
I'd prefer 'DefaultExceptionHander' instead. This
Eric
2015/03/05 14:58:04
As a small point of language, there's no need to u
| |
| 59 { | |
| 60 #if (defined ENABLE_DEBUG_INFO) | |
| 61 CatchAllVoid<EntryPointHandlers>::Handler(name); | |
| 62 #endif | |
| 63 } | |
| 64 | |
| 65 | |
| 24 class CPluginDebugLock : public CPluginMutex | 66 class CPluginDebugLock : public CPluginMutex |
| 25 { | 67 { |
| 26 | 68 |
| 27 private: | 69 private: |
| 28 | 70 |
| 29 static CComAutoCriticalSection s_criticalSectionDebugLock; | 71 static CComAutoCriticalSection s_criticalSectionDebugLock; |
| 30 | 72 |
| 31 public: | 73 public: |
| 32 | 74 |
| 33 CPluginDebugLock() : CPluginMutex(L"DebugFile", PLUGIN_ERROR_MUTEX_DEBUG_FILE) | 75 CPluginDebugLock() : CPluginMutex(L"DebugFile", PLUGIN_ERROR_MUTEX_DEBUG_FILE) |
| 34 { | 76 { |
| 35 s_criticalSectionDebugLock.Lock(); | 77 s_criticalSectionDebugLock.Lock(); |
| 36 } | 78 } |
| 37 | 79 |
| 38 ~CPluginDebugLock() | 80 ~CPluginDebugLock() |
| 39 { | 81 { |
| 40 s_criticalSectionDebugLock.Unlock(); | 82 s_criticalSectionDebugLock.Unlock(); |
| 41 } | 83 } |
| 42 }; | 84 }; |
| 43 | 85 |
| 44 CComAutoCriticalSection CPluginDebugLock::s_criticalSectionDebugLock; | 86 CComAutoCriticalSection CPluginDebugLock::s_criticalSectionDebugLock; |
| 45 | 87 |
| 46 void CPluginDebug::DebugSystemException(const std::system_error& ex, int errorId , int errorSubid, const std::string& description) | 88 void CPluginDebug::DebugSystemException(const std::system_error& ex, int errorId , int errorSubid, const std::string& description) |
| 47 { | 89 { |
| 48 std::string message = description + ", " + ex.code().message() + ", " + ex.wha t(); | 90 std::string message = description + ", " + ex.code().message() + ", " + ex.wha t(); |
| 49 DEBUG_ERROR_LOG(ex.code().value(), errorId, errorSubid, message); | 91 DEBUG_ERROR_LOG(ex.code().value(), errorId, errorSubid, message); |
| 50 } | 92 } |
| 51 | 93 |
| 94 void CPluginDebug::DebugOrdinaryException(const std::exception& ex, int errorId, int errorSubid, const std::string& description) | |
| 95 { | |
| 96 std::string message = description + ", " + ex.what(); | |
| 97 DEBUG_ERROR_LOG(0, errorId, errorSubid, message); | |
| 98 } | |
| 99 | |
| 100 | |
| 101 | |
| 52 #ifdef ENABLE_DEBUG_INFO | 102 #ifdef ENABLE_DEBUG_INFO |
| 53 | 103 |
| 54 void DebugLegacy(const CString& text, DWORD dwProcessId, DWORD dwThreadId) | 104 void DebugLegacy(const CString& text, DWORD dwProcessId, DWORD dwThreadId) |
| 55 { | 105 { |
| 56 #ifdef USE_CONSOLE | 106 #ifdef USE_CONSOLE |
| 57 CONSOLE("%s", CT2A(text.GetString(), CP_UTF8)); | 107 CONSOLE("%s", CT2A(text.GetString(), CP_UTF8)); |
| 58 #endif | 108 #endif |
| 59 | 109 |
| 60 if (CPluginSettings::HasInstance()) | 110 if (CPluginSettings::HasInstance()) |
| 61 { | 111 { |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 249 srcTrunc = srcTrunc.Left(67) + L"..." + srcTrunc.Right(30); | 299 srcTrunc = srcTrunc.Left(67) + L"..." + srcTrunc.Right(30); |
| 250 } | 300 } |
| 251 | 301 |
| 252 CString blocking; | 302 CString blocking; |
| 253 blocking.Format(L"Ignored %-12s %s %s", ToCString(type), domain.empty()? L" -" : ToCString(domain), srcTrunc); | 303 blocking.Format(L"Ignored %-12s %s %s", ToCString(type), domain.empty()? L" -" : ToCString(domain), srcTrunc); |
| 254 | 304 |
| 255 DebugResultLegacy(blocking); | 305 DebugResultLegacy(blocking); |
| 256 } | 306 } |
| 257 | 307 |
| 258 #endif // ENABLE_DEBUG_RESULT_IGNORED | 308 #endif // ENABLE_DEBUG_RESULT_IGNORED |
| OLD | NEW |