Improve coding style

This commit is contained in:
Vladimir Golovnev (Glassez) 2020-11-16 10:02:11 +03:00 committed by sledgehammer999
commit 1728c16580
No known key found for this signature in database
GPG key ID: 6E4A2D025B7CC9A2
147 changed files with 4454 additions and 2227 deletions

View file

@ -54,7 +54,8 @@ void straceWin::demangle(QString& str)
int status = 0;
size_t outSz = 0;
char* demangled_name = abi::__cxa_demangle(inStr, 0, &outSz, &status);
if (status == 0) {
if (status == 0)
{
str = QString::fromLocal8Bit(demangled_name);
if (outSz > 0)
free(demangled_name);
@ -92,7 +93,8 @@ BOOL CALLBACK straceWin::EnumModulesCB(LPCSTR ModuleName, DWORD64 BaseOfDll, PVO
IMAGEHLP_MODULE64 mod;
EnumModulesContext* context = (EnumModulesContext*)UserContext;
mod.SizeOfStruct = sizeof(IMAGEHLP_MODULE64);
if(SymGetModuleInfo64(context->hProcess, BaseOfDll, &mod)) {
if(SymGetModuleInfo64(context->hProcess, BaseOfDll, &mod))
{
QString moduleBase = QString::fromLatin1("0x%1").arg(BaseOfDll, 16, 16, QLatin1Char('0'));
QString line = QString::fromLatin1("%1 %2 Image: %3")
.arg(mod.ModuleName, -25)
@ -101,7 +103,8 @@ BOOL CALLBACK straceWin::EnumModulesCB(LPCSTR ModuleName, DWORD64 BaseOfDll, PVO
context->stream << line << '\n';
QString pdbName(mod.LoadedPdbName);
if(!pdbName.isEmpty()) {
if(!pdbName.isEmpty())
{
QString line2 = QString::fromLatin1("%1 %2")
.arg("", 35)
.arg(pdbName);
@ -126,7 +129,8 @@ bool straceWin::makeRelativePath(const QString& dir, QString& file)
if (!d.isEmpty() && (d[d.length() - 1] != separator))
d += separator;
if (f.startsWith(d, Qt::CaseInsensitive)) {
if (f.startsWith(d, Qt::CaseInsensitive))
{
f.remove(0, d.length());
file.swap(f);
@ -142,7 +146,8 @@ QString straceWin::getSourcePathAndLineNumber(HANDLE hProcess, DWORD64 addr)
line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
DWORD dwDisplacement = 0;
if (SymGetLineFromAddr64(hProcess, addr, &dwDisplacement, &line)) {
if (SymGetLineFromAddr64(hProcess, addr, &dwDisplacement, &line))
{
QString path(line.FileName);
#if defined STACKTRACE_WIN_PROJECT_PATH || defined STACKTRACE_WIN_MAKEFILE_PATH
@ -159,7 +164,8 @@ QString straceWin::getSourcePathAndLineNumber(HANDLE hProcess, DWORD64 addr)
#endif
#ifdef STACKTRACE_WIN_MAKEFILE_PATH
if (!success) {
if (!success)
{
QString targetPath(STACKTRACE_WIN_STRING(STACKTRACE_WIN_MAKEFILE_PATH));
makeRelativePath(targetPath, path);
}
@ -201,7 +207,8 @@ const QString straceWin::getBacktrace()
: //no input
: "eax");
#else
_asm {
_asm
{
Label:
mov [Context.Ebp], ebp;
mov [Context.Esp], esp;
@ -269,15 +276,18 @@ const QString straceWin::getBacktrace()
int i = 0;
while(StackWalk64(MachineType, hProcess, hThread, &StackFrame, &Context, NULL, NULL, NULL, NULL)) {
while(StackWalk64(MachineType, hProcess, hThread, &StackFrame, &Context, NULL, NULL, NULL, NULL))
{
if(i == 128)
break;
loadHelpStackFrame(ihsf, StackFrame);
if(StackFrame.AddrPC.Offset != 0) { // Valid frame.
if(StackFrame.AddrPC.Offset != 0)
{ // Valid frame.
QString fileName("???");
if(SymGetModuleInfo64(hProcess, ihsf.InstructionOffset, &mod)) {
if(SymGetModuleInfo64(hProcess, ihsf.InstructionOffset, &mod))
{
fileName = QString(mod.ImageName);
int slashPos = fileName.lastIndexOf('\\');
if(slashPos != -1)
@ -285,7 +295,8 @@ const QString straceWin::getBacktrace()
}
QString funcName;
QString sourceFile;
if(SymFromAddr(hProcess, ihsf.InstructionOffset, &dwDisplacement, pSymbol)) {
if(SymFromAddr(hProcess, ihsf.InstructionOffset, &dwDisplacement, pSymbol))
{
funcName = QString(pSymbol->Name);
#ifdef __MINGW32__
demangle(funcName);
@ -295,7 +306,8 @@ const QString straceWin::getBacktrace()
// decrease the query address by one byte to point somewhere in the CALL instruction byte sequence
sourceFile = getSourcePathAndLineNumber(hProcess, ihsf.InstructionOffset - 1);
}
else {
else
{
funcName = QString::fromLatin1("0x%1").arg(ihsf.InstructionOffset, 8, 16, QLatin1Char('0'));
}
SymSetContext(hProcess, &ihsf, NULL);
@ -325,7 +337,8 @@ const QString straceWin::getBacktrace()
logStream << debugLine << '\n';
i++;
}
else {
else
{
break; // we're at the end.
}
}