aboutsummaryrefslogtreecommitdiff
path: root/src/server/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/shared')
-rw-r--r--src/server/shared/Cryptography/OpenSSLCrypto.cpp5
-rw-r--r--src/server/shared/Debugging/WheatyExceptionReport.cpp181
-rw-r--r--src/server/shared/Debugging/WheatyExceptionReport.h6
-rw-r--r--src/server/shared/Utilities/EventProcessor.h6
4 files changed, 144 insertions, 54 deletions
diff --git a/src/server/shared/Cryptography/OpenSSLCrypto.cpp b/src/server/shared/Cryptography/OpenSSLCrypto.cpp
index 10ea595640a..bd72459e9df 100644
--- a/src/server/shared/Cryptography/OpenSSLCrypto.cpp
+++ b/src/server/shared/Cryptography/OpenSSLCrypto.cpp
@@ -33,7 +33,12 @@ static void lockingCallback(int mode, int type, const char* /*file*/, int /*line
static void threadIdCallback(CRYPTO_THREADID * id)
{
+/// ACE_thread_t turns out to be a struct under Mac OS.
+#ifndef __APPLE__
CRYPTO_THREADID_set_numeric(id, ACE_Thread::self());
+#else
+ CRYPTO_THREADID_set_pointer(id, ACE_Thread::self());
+#endif
}
void OpenSSLCrypto::threadsSetup()
diff --git a/src/server/shared/Debugging/WheatyExceptionReport.cpp b/src/server/shared/Debugging/WheatyExceptionReport.cpp
index f4da4093dfa..fcbfa221d6a 100644
--- a/src/server/shared/Debugging/WheatyExceptionReport.cpp
+++ b/src/server/shared/Debugging/WheatyExceptionReport.cpp
@@ -62,6 +62,13 @@ WheatyExceptionReport::WheatyExceptionReport() // Constructor
// Install the unhandled exception filter function
m_previousFilter = SetUnhandledExceptionFilter(WheatyUnhandledExceptionFilter);
m_hProcess = GetCurrentProcess();
+ if (!IsDebuggerPresent())
+ {
+ _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
+ _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
+ _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
+ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
+ }
}
//============
@@ -348,7 +355,7 @@ void WheatyExceptionReport::PrintSystemInfo()
}
//===========================================================================
-void WheatyExceptionReport::printTracesForAllThreads()
+void WheatyExceptionReport::printTracesForAllThreads(bool bWriteVariables)
{
THREADENTRY32 te32;
@@ -384,7 +391,7 @@ void WheatyExceptionReport::printTracesForAllThreads()
if (threadHandle)
{
if (GetThreadContext(threadHandle, &context))
- WriteStackDetails(&context, false, threadHandle);
+ WriteStackDetails(&context, bWriteVariables, threadHandle);
CloseHandle(threadHandle);
}
}
@@ -480,7 +487,7 @@ PEXCEPTION_POINTERS pExceptionInfo)
CONTEXT trashableContext = *pCtx;
WriteStackDetails(&trashableContext, false, NULL);
- printTracesForAllThreads();
+ printTracesForAllThreads(false);
// #ifdef _M_IX86 // X86 Only!
@@ -489,6 +496,7 @@ PEXCEPTION_POINTERS pExceptionInfo)
trashableContext = *pCtx;
WriteStackDetails(&trashableContext, true, NULL);
+ printTracesForAllThreads(true);
_tprintf(_T("========================\r\n"));
_tprintf(_T("Global Variables\r\n"));
@@ -566,6 +574,9 @@ PVOID addr, PTSTR szModule, DWORD len, DWORD& section, DWORD_PTR& offset)
DWORD_PTR hMod = (DWORD_PTR)mbi.AllocationBase;
+ if (!hMod)
+ return FALSE;
+
if (!GetModuleFileName((HMODULE)hMod, szModule, len))
return FALSE;
@@ -708,7 +719,7 @@ bool bWriteVariables, HANDLE pThreadHandle)
}
// Get the source line for this stack frame entry
- IMAGEHLP_LINE64 lineInfo = { sizeof(IMAGEHLP_LINE) };
+ IMAGEHLP_LINE64 lineInfo = { sizeof(IMAGEHLP_LINE64) };
DWORD dwLineDisplacement;
if (SymGetLineFromAddr64(m_hProcess, sf.AddrPC.Offset,
&dwLineDisplacement, &lineInfo))
@@ -746,15 +757,15 @@ ULONG /*SymbolSize*/,
PVOID UserContext)
{
- char szBuffer[2048];
+ char szBuffer[8192];
__try
{
- if (FormatSymbolValue(pSymInfo, (STACKFRAME*)UserContext,
+ if (FormatSymbolValue(pSymInfo, (STACKFRAME64*)UserContext,
szBuffer, sizeof(szBuffer)))
_tprintf(_T("\t%s\r\n"), szBuffer);
}
- __except(1)
+ __except (EXCEPTION_EXECUTE_HANDLER)
{
_tprintf(_T("punting on symbol %s\r\n"), pSymInfo->Name);
}
@@ -769,7 +780,7 @@ PVOID UserContext)
//////////////////////////////////////////////////////////////////////////////
bool WheatyExceptionReport::FormatSymbolValue(
PSYMBOL_INFO pSym,
-STACKFRAME * sf,
+STACKFRAME64 * sf,
char * pszBuffer,
unsigned /*cbBuffer*/)
{
@@ -782,7 +793,7 @@ unsigned /*cbBuffer*/)
pszCurrBuffer += sprintf(pszCurrBuffer, "Local ");
// If it's a function, don't do anything.
- if (pSym->Tag == 5) // SymTagFunction from CVCONST.H from the DIA SDK
+ if (pSym->Tag == SymTagFunction) // SymTagFunction from CVCONST.H from the DIA SDK
return false;
DWORD_PTR pVariable = 0; // Will point to the variable's data in memory
@@ -791,7 +802,11 @@ unsigned /*cbBuffer*/)
{
// if (pSym->Register == 8) // EBP is the value 8 (in DBGHELP 5.1)
{ // This may change!!!
+#ifdef _M_IX86
pVariable = sf->AddrFrame.Offset;
+#elif _M_X64
+ pVariable = sf->AddrStack.Offset;
+#endif
pVariable += (DWORD_PTR)pSym->Address;
}
// else
@@ -810,7 +825,7 @@ unsigned /*cbBuffer*/)
// will return true.
bool bHandled;
pszCurrBuffer = DumpTypeIndex(pszCurrBuffer, pSym->ModBase, pSym->TypeIndex,
- 0, pVariable, bHandled, pSym->Name);
+ 0, pVariable, bHandled, pSym->Name, "");
if (!bHandled)
{
@@ -842,10 +857,15 @@ DWORD dwTypeIndex,
unsigned nestingLevel,
DWORD_PTR offset,
bool & bHandled,
-char* /*Name*/)
+char* Name,
+char* suffix)
{
bHandled = false;
+ DWORD typeTag;
+ if (!SymGetTypeInfo(m_hProcess, modBase, dwTypeIndex, TI_GET_SYMTAG, &typeTag))
+ return pszCurrBuffer;
+
// Get the name of the symbol. This will either be a Type name (if a UDT),
// or the structure member name.
WCHAR * pwszTypeName;
@@ -856,10 +876,58 @@ char* /*Name*/)
LocalFree(pwszTypeName);
}
+ if (strlen(suffix) > 0)
+ pszCurrBuffer += sprintf(pszCurrBuffer, "%s", suffix);
+
+ switch (typeTag)
+ {
+ case SymTagPointerType:
+ DWORD innerTypeID;
+ if (SymGetTypeInfo(m_hProcess, modBase, dwTypeIndex, TI_GET_TYPEID, &innerTypeID))
+ {
+ pszCurrBuffer += sprintf(pszCurrBuffer, " %s", Name);
+ BOOL isReference;
+ SymGetTypeInfo(m_hProcess, modBase, dwTypeIndex, TI_GET_IS_REFERENCE, &isReference);
+
+ char addressStr[40];
+ memset(addressStr, 0, sizeof(addressStr));
+
+ if (isReference)
+ addressStr[0] = '&';
+ else
+ addressStr[0] = '*';
+
+ DWORD_PTR address = *(PDWORD_PTR)offset;
+ if (address == NULL)
+ {
+ pwszTypeName;
+ if (SymGetTypeInfo(m_hProcess, modBase, innerTypeID, TI_GET_SYMNAME,
+ &pwszTypeName))
+ {
+ pszCurrBuffer += sprintf(pszCurrBuffer, " %ls", pwszTypeName);
+ LocalFree(pwszTypeName);
+ }
+
+ pszCurrBuffer += sprintf(pszCurrBuffer, "%s = NULL", addressStr);
+
+ bHandled = true;
+ return pszCurrBuffer;
+ }
+ else
+ {
+ FormatOutputValue(&addressStr[1], btVoid, sizeof(PVOID), (PVOID)offset);
+ pszCurrBuffer = DumpTypeIndex(pszCurrBuffer, modBase, innerTypeID, nestingLevel + 1,
+ address, bHandled, "", addressStr);
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
// Determine how many children this type has.
DWORD dwChildrenCount = 0;
- SymGetTypeInfo(m_hProcess, modBase, dwTypeIndex, TI_GET_CHILDRENCOUNT,
- &dwChildrenCount);
+ SymGetTypeInfo(m_hProcess, modBase, dwTypeIndex, TI_GET_CHILDRENCOUNT, &dwChildrenCount);
if (!dwChildrenCount) // If no children, we're done
return pszCurrBuffer;
@@ -889,6 +957,12 @@ char* /*Name*/)
// Iterate through each of the children
for (unsigned i = 0; i < dwChildrenCount; i++)
{
+ DWORD symTag;
+ SymGetTypeInfo(m_hProcess, modBase, children.ChildId[i], TI_GET_SYMTAG, &symTag);
+
+ if (symTag == SymTagFunction || symTag == SymTagTypedef)
+ continue;
+
// Add appropriate indentation level (since this routine is recursive)
for (unsigned j = 0; j <= nestingLevel+1; j++)
pszCurrBuffer += sprintf(pszCurrBuffer, "\t");
@@ -898,18 +972,21 @@ char* /*Name*/)
BasicType basicType = GetBasicType(children.ChildId[i], modBase);
pszCurrBuffer += sprintf(pszCurrBuffer, rgBaseType[basicType]);
+ // Get the offset of the child member, relative to its parent
+ DWORD dwMemberOffset;
+ SymGetTypeInfo(m_hProcess, modBase, children.ChildId[i],
+ TI_GET_OFFSET, &dwMemberOffset);
+
+ // Calculate the address of the member
+ DWORD_PTR dwFinalOffset = offset + dwMemberOffset;
+
pszCurrBuffer = DumpTypeIndex(pszCurrBuffer, modBase,
children.ChildId[i], nestingLevel+1,
- offset, bHandled2, ""/*Name */);
+ dwFinalOffset, bHandled2, ""/*Name */, "");
// If the child wasn't a UDT, format it appropriately
if (!bHandled2)
{
- // Get the offset of the child member, relative to its parent
- DWORD dwMemberOffset;
- SymGetTypeInfo(m_hProcess, modBase, children.ChildId[i],
- TI_GET_OFFSET, &dwMemberOffset);
-
// Get the real "TypeId" of the child. We need this for the
// SymGetTypeInfo(TI_GET_TYPEID) call below.
DWORD typeId;
@@ -920,9 +997,6 @@ char* /*Name*/)
ULONG64 length;
SymGetTypeInfo(m_hProcess, modBase, typeId, TI_GET_LENGTH, &length);
- // Calculate the address of the member
- DWORD_PTR dwFinalOffset = offset + dwMemberOffset;
-
// BasicType basicType = GetBasicType(children.ChildId[i], modBase);
//
// pszCurrBuffer += sprintf(pszCurrBuffer, rgBaseType[basicType]);
@@ -946,41 +1020,52 @@ BasicType basicType,
DWORD64 length,
PVOID pAddress)
{
- // Format appropriately (assuming it's a 1, 2, or 4 bytes (!!!)
- if (length == 1)
- pszCurrBuffer += sprintf(pszCurrBuffer, " = %X", *(PBYTE)pAddress);
- else if (length == 2)
- pszCurrBuffer += sprintf(pszCurrBuffer, " = %X", *(PWORD)pAddress);
- else if (length == 4)
+ __try
{
- if (basicType == btFloat)
+ // Format appropriately (assuming it's a 1, 2, or 4 bytes (!!!)
+ if (length == 1)
+ pszCurrBuffer += sprintf(pszCurrBuffer, " = %X", *(PBYTE)pAddress);
+ else if (length == 2)
+ pszCurrBuffer += sprintf(pszCurrBuffer, " = %X", *(PWORD)pAddress);
+ else if (length == 4)
{
- pszCurrBuffer += sprintf(pszCurrBuffer, " = %f", *(PFLOAT)pAddress);
+ if (basicType == btFloat)
+ {
+ pszCurrBuffer += sprintf(pszCurrBuffer, " = %f", *(PFLOAT)pAddress);
+ }
+ else if (basicType == btChar)
+ {
+ if (!IsBadStringPtr(*(PSTR*)pAddress, 32))
+ {
+ pszCurrBuffer += sprintf(pszCurrBuffer, " = \"%.31s\"",
+ *(PSTR*)pAddress);
+ }
+ else
+ pszCurrBuffer += sprintf(pszCurrBuffer, " = %X",
+ *(PDWORD)pAddress);
+ }
+ else
+ pszCurrBuffer += sprintf(pszCurrBuffer, " = %X", *(PDWORD)pAddress);
}
- else if (basicType == btChar)
+ else if (length == 8)
{
- if (!IsBadStringPtr(*(PSTR*)pAddress, 32))
+ if (basicType == btFloat)
{
- pszCurrBuffer += sprintf(pszCurrBuffer, " = \"%.31s\"",
- *(PSTR*)pAddress);
+ pszCurrBuffer += sprintf(pszCurrBuffer, " = %lf",
+ *(double *)pAddress);
}
else
- pszCurrBuffer += sprintf(pszCurrBuffer, " = %X",
- *(PDWORD)pAddress);
+ pszCurrBuffer += sprintf(pszCurrBuffer, " = %I64X",
+ *(DWORD64*)pAddress);
}
- else
- pszCurrBuffer += sprintf(pszCurrBuffer, " = %X", *(PDWORD)pAddress);
}
- else if (length == 8)
+ __except (EXCEPTION_EXECUTE_HANDLER)
{
- if (basicType == btFloat)
- {
- pszCurrBuffer += sprintf(pszCurrBuffer, " = %lf",
- *(double *)pAddress);
- }
- else
- pszCurrBuffer += sprintf(pszCurrBuffer, " = %I64X",
- *(DWORD64*)pAddress);
+#if _WIN64
+ pszCurrBuffer += sprintf(pszCurrBuffer, " <Unable to read memory> = %I64X", (DWORD64*)pAddress);
+#else
+ pszCurrBuffer += sprintf(pszCurrBuffer, " <Unable to read memory> = %X", (PDWORD)pAddress);
+#endif
}
return pszCurrBuffer;
@@ -1017,7 +1102,7 @@ WheatyExceptionReport::GetBasicType(DWORD typeIndex, DWORD64 modBase)
//============================================================================
int __cdecl WheatyExceptionReport::_tprintf(const TCHAR * format, ...)
{
- TCHAR szBuff[1024];
+ TCHAR szBuff[8192];
int retValue;
DWORD cbWritten;
va_list argptr;
diff --git a/src/server/shared/Debugging/WheatyExceptionReport.h b/src/server/shared/Debugging/WheatyExceptionReport.h
index 582f1f157b8..48894a5db91 100644
--- a/src/server/shared/Debugging/WheatyExceptionReport.h
+++ b/src/server/shared/Debugging/WheatyExceptionReport.h
@@ -81,7 +81,7 @@ class WheatyExceptionReport
static LONG WINAPI WheatyUnhandledExceptionFilter(
PEXCEPTION_POINTERS pExceptionInfo);
- static void printTracesForAllThreads();
+ static void printTracesForAllThreads(bool);
private:
// where report info is extracted and generated
static void GenerateExceptionReport(PEXCEPTION_POINTERS pExceptionInfo);
@@ -98,9 +98,9 @@ class WheatyExceptionReport
static BOOL CALLBACK EnumerateSymbolsCallback(PSYMBOL_INFO, ULONG, PVOID);
- static bool FormatSymbolValue(PSYMBOL_INFO, STACKFRAME *, char * pszBuffer, unsigned cbBuffer);
+ static bool FormatSymbolValue(PSYMBOL_INFO, STACKFRAME64 *, char * pszBuffer, unsigned cbBuffer);
- static char * DumpTypeIndex(char *, DWORD64, DWORD, unsigned, DWORD_PTR, bool &, char*);
+ static char * DumpTypeIndex(char *, DWORD64, DWORD, unsigned, DWORD_PTR, bool &, char*, char*);
static char * FormatOutputValue(char * pszCurrBuffer, BasicType basicType, DWORD64 length, PVOID pAddress);
diff --git a/src/server/shared/Utilities/EventProcessor.h b/src/server/shared/Utilities/EventProcessor.h
index fd8b2909165..10ae6aa954c 100644
--- a/src/server/shared/Utilities/EventProcessor.h
+++ b/src/server/shared/Utilities/EventProcessor.h
@@ -28,9 +28,9 @@
class BasicEvent
{
public:
- BasicEvent()
- {
- to_Abort = false;
+ BasicEvent()
+ {
+ to_Abort = false;
m_addTime = 0;
m_execTime = 0;
}