Skip to content

Commit

Permalink
Adds more fixes to follow coding convention
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoAnomaly committed Mar 14, 2018
1 parent 8380d87 commit b7a8955
Showing 1 changed file with 7 additions and 36 deletions.
43 changes: 7 additions & 36 deletions src/xrCore/xrDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,8 @@ void xrDebug::SetBugReportFile(const char* fileName) { strcpy_s(BugReportFile, f

bool xrDebug::GetNextStackFrameString(LPSTACKFRAME stackFrame, PCONTEXT threadCtx, xr_string& frameStr)
{
BOOL result = StackWalk(
MACHINE_TYPE,
GetCurrentProcess(),
GetCurrentThread(),
stackFrame,
threadCtx,
nullptr,
SymFunctionTableAccess,
SymGetModuleBase,
nullptr
);
BOOL result = StackWalk(MACHINE_TYPE, GetCurrentProcess(), GetCurrentThread(), stackFrame, threadCtx, nullptr,
SymFunctionTableAccess, SymGetModuleBase, nullptr);

if (result == FALSE || stackFrame->AddrPC.Offset == 0)
{
Expand Down Expand Up @@ -127,12 +118,7 @@ bool xrDebug::GetNextStackFrameString(LPSTACKFRAME stackFrame, PCONTEXT threadCt
functionInfo->MaxNameLength = sizeof(arrSymBuffer) - sizeof(*functionInfo) + 1;
DWORD_PTR dwFunctionOffset;

result = SymGetSymFromAddr(
GetCurrentProcess(),
stackFrame->AddrPC.Offset,
&dwFunctionOffset,
functionInfo
);
result = SymGetSymFromAddr(GetCurrentProcess(), stackFrame->AddrPC.Offset, &dwFunctionOffset, functionInfo);

if (result)
{
Expand All @@ -154,25 +140,14 @@ bool xrDebug::GetNextStackFrameString(LPSTACKFRAME stackFrame, PCONTEXT threadCt
IMAGEHLP_LINE sourceInfo = { 0 };
sourceInfo.SizeOfStruct = sizeof(sourceInfo);

result = SymGetLineFromAddr(
GetCurrentProcess(),
stackFrame->AddrPC.Offset,
&dwLineOffset,
&sourceInfo
);
result = SymGetLineFromAddr(GetCurrentProcess(), stackFrame->AddrPC.Offset, &dwLineOffset, &sourceInfo);

if (result)
{
if (dwLineOffset)
{
xr_sprintf(
formatBuff,
_countof(formatBuff),
" in %s line %u + %u byte(s)",
sourceInfo.FileName,
sourceInfo.LineNumber,
dwLineOffset
);
xr_sprintf(formatBuff, _countof(formatBuff), " in %s line %u + %u byte(s)", sourceInfo.FileName,
sourceInfo.LineNumber, dwLineOffset);
}
else
{
Expand Down Expand Up @@ -242,11 +217,7 @@ xr_vector<xr_string> xrDebug::BuildStackTrace(PCONTEXT threadCtx, u16 maxFramesC
# error CPU architecture is not supported.
#endif

while (
GetNextStackFrameString(&stackFrame, threadCtx, frameStr)
&&
traceResult.size() <= maxFramesCount
)
while (GetNextStackFrameString(&stackFrame, threadCtx, frameStr) && traceResult.size() <= maxFramesCount)
{
traceResult.push_back(frameStr);
}
Expand Down

0 comments on commit b7a8955

Please sign in to comment.