Big re-organization of repository [W.I.P]

This commit is contained in:
Yehonal
2016-08-11 20:25:27 +02:00
parent c62a72c0a8
commit 0f85ce1c54
3016 changed files with 1271 additions and 1 deletions

View File

@@ -0,0 +1,59 @@
/*
* Copyright (C)
* Copyright (C)
*
* 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 of the License, 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Errors.h"
#include <ace/Stack_Trace.h>
#include <ace/OS_NS_unistd.h>
#include <cstdlib>
namespace Trinity {
void Assert(char const* file, int line, char const* function, char const* message)
{
ACE_Stack_Trace st;
fprintf(stderr, "\n%s:%i in %s ASSERTION FAILED:\n %s\n%s\n",
file, line, function, message, st.c_str());
*((volatile int*)NULL) = 0;
exit(1);
}
void Fatal(char const* file, int line, char const* function, char const* message)
{
fprintf(stderr, "\n%s:%i in %s FATAL ERROR:\n %s\n",
file, line, function, message);
ACE_OS::sleep(10);
*((volatile int*)NULL) = 0;
exit(1);
}
void Error(char const* file, int line, char const* function, char const* message)
{
fprintf(stderr, "\n%s:%i in %s ERROR:\n %s\n",
file, line, function, message);
*((volatile int*)NULL) = 0;
exit(1);
}
void Warning(char const* file, int line, char const* function, char const* message)
{
fprintf(stderr, "\n%s:%i in %s WARNING:\n %s\n",
file, line, function, message);
}
} // namespace Trinity

View File

@@ -0,0 +1,44 @@
/*
* Copyright (C)
* Copyright (C)
*
* 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 of the License, 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef AZEROTHCORE_ERRORS_H
#define AZEROTHCORE_ERRORS_H
#include "Define.h"
namespace Trinity
{
DECLSPEC_NORETURN void Assert(char const* file, int line, char const* function, char const* message) ATTR_NORETURN;
DECLSPEC_NORETURN void Fatal(char const* file, int line, char const* function, char const* message) ATTR_NORETURN;
DECLSPEC_NORETURN void Error(char const* file, int line, char const* function, char const* message) ATTR_NORETURN;
void Warning(char const* file, int line, char const* function, char const* message);
} // namespace Trinity
#define WPAssert(cond) do { if (!(cond)) Trinity::Assert(__FILE__, __LINE__, __FUNCTION__, #cond); } while (0)
#define WPFatal(cond, msg) do { if (!(cond)) Trinity::Fatal(__FILE__, __LINE__, __FUNCTION__, (msg)); } while (0)
#define WPError(cond, msg) do { if (!(cond)) Trinity::Error(__FILE__, __LINE__, __FUNCTION__, (msg)); } while (0)
#define WPWarning(cond, msg) do { if (!(cond)) Trinity::Warning(__FILE__, __LINE__, __FUNCTION__, (msg)); } while (0)
#define ASSERT WPAssert
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,149 @@
#ifndef _WHEATYEXCEPTIONREPORT_
#define _WHEATYEXCEPTIONREPORT_
#if PLATFORM == PLATFORM_WINDOWS && !defined(__MINGW32__)
#include <dbghelp.h>
#include <set>
#if _MSC_VER < 1400
# define countof(array) (sizeof(array) / sizeof(array[0]))
#else
# include <stdlib.h>
# define countof _countof
#endif // _MSC_VER < 1400
enum BasicType // Stolen from CVCONST.H in the DIA 2.0 SDK
{
btNoType = 0,
btVoid = 1,
btChar = 2,
btWChar = 3,
btInt = 6,
btUInt = 7,
btFloat = 8,
btBCD = 9,
btBool = 10,
btLong = 13,
btULong = 14,
btCurrency = 25,
btDate = 26,
btVariant = 27,
btComplex = 28,
btBit = 29,
btBSTR = 30,
btHresult = 31,
// Custom types
btStdString = 101
};
const char* const rgBaseType[] =
{
" <user defined> ", // btNoType = 0,
" void ", // btVoid = 1,
" char* ", // btChar = 2,
" wchar_t* ", // btWChar = 3,
" signed char ",
" unsigned char ",
" int ", // btInt = 6,
" unsigned int ", // btUInt = 7,
" float ", // btFloat = 8,
" <BCD> ", // btBCD = 9,
" bool ", // btBool = 10,
" short ",
" unsigned short ",
" long ", // btLong = 13,
" unsigned long ", // btULong = 14,
" __int8 ",
" __int16 ",
" __int32 ",
" __int64 ",
" __int128 ",
" unsigned __int8 ",
" unsigned __int16 ",
" unsigned __int32 ",
" unsigned __int64 ",
" unsigned __int128 ",
" <currency> ", // btCurrency = 25,
" <date> ", // btDate = 26,
" VARIANT ", // btVariant = 27,
" <complex> ", // btComplex = 28,
" <bit> ", // btBit = 29,
" BSTR ", // btBSTR = 30,
" HRESULT " // btHresult = 31
};
struct SymbolPair
{
SymbolPair(DWORD type, DWORD_PTR offset)
{
_type = type;
_offset = offset;
}
bool operator<(const SymbolPair& other) const
{
return _offset < other._offset ||
(_offset == other._offset && _type < other._type);
}
DWORD _type;
DWORD_PTR _offset;
};
typedef std::set<SymbolPair> SymbolPairs;
class WheatyExceptionReport
{
public:
WheatyExceptionReport();
~WheatyExceptionReport();
// entry point where control comes on an unhandled exception
static LONG WINAPI WheatyUnhandledExceptionFilter(
PEXCEPTION_POINTERS pExceptionInfo);
static void printTracesForAllThreads(bool);
private:
// where report info is extracted and generated
static void GenerateExceptionReport(PEXCEPTION_POINTERS pExceptionInfo);
static void PrintSystemInfo();
static BOOL _GetWindowsVersion(TCHAR* szVersion, DWORD cntMax);
static BOOL _GetProcessorName(TCHAR* sProcessorName, DWORD maxcount);
// Helper functions
static LPTSTR GetExceptionString(DWORD dwCode);
static BOOL GetLogicalAddress(PVOID addr, PTSTR szModule, DWORD len,
DWORD& section, DWORD_PTR& offset);
static void WriteStackDetails(PCONTEXT pContext, bool bWriteVariables, HANDLE pThreadHandle);
static BOOL CALLBACK EnumerateSymbolsCallback(PSYMBOL_INFO, ULONG, PVOID);
static bool FormatSymbolValue(PSYMBOL_INFO, STACKFRAME64 *, char * pszBuffer, unsigned cbBuffer);
static char * DumpTypeIndex(char *, DWORD64, DWORD, unsigned, DWORD_PTR, bool &, char*, char*);
static char * FormatOutputValue(char * pszCurrBuffer, BasicType basicType, DWORD64 length, PVOID pAddress);
static BasicType GetBasicType(DWORD typeIndex, DWORD64 modBase);
static int __cdecl _tprintf(const TCHAR * format, ...);
static bool StoreSymbol(DWORD type , DWORD_PTR offset);
static void ClearSymbols();
// Variables used by the class
static TCHAR m_szLogFileName[MAX_PATH];
static TCHAR m_szDumpFileName[MAX_PATH];
static LPTOP_LEVEL_EXCEPTION_FILTER m_previousFilter;
static HANDLE m_hReportFile;
static HANDLE m_hDumpFile;
static HANDLE m_hProcess;
static SymbolPairs symbols;
};
extern WheatyExceptionReport g_WheatyExceptionReport; // global instance of class
#endif // _WIN32
#endif // _WHEATYEXCEPTIONREPORT_