mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 15:27:54 +00:00
Follow project coding style. Issue #2192.
This commit is contained in:
parent
ed829bc93a
commit
ba9f6a3531
@ -24,7 +24,8 @@
|
||||
|
||||
#include <QTextStream>
|
||||
|
||||
namespace straceWin{
|
||||
namespace straceWin
|
||||
{
|
||||
void loadHelpStackFrame(IMAGEHLP_STACK_FRAME&, const STACKFRAME64&);
|
||||
BOOL CALLBACK EnumSymbolsCB(PSYMBOL_INFO, ULONG, PVOID);
|
||||
BOOL CALLBACK EnumModulesCB(LPCSTR, DWORD64, PVOID);
|
||||
@ -32,28 +33,31 @@ namespace straceWin{
|
||||
struct EnumModulesContext;
|
||||
}
|
||||
|
||||
void straceWin::loadHelpStackFrame(IMAGEHLP_STACK_FRAME &ihsf, const STACKFRAME64 &stackFrame) {
|
||||
void straceWin::loadHelpStackFrame(IMAGEHLP_STACK_FRAME& ihsf, const STACKFRAME64& stackFrame)
|
||||
{
|
||||
ZeroMemory(&ihsf, sizeof(IMAGEHLP_STACK_FRAME));
|
||||
ihsf.InstructionOffset = stackFrame.AddrPC.Offset;
|
||||
ihsf.FrameOffset = stackFrame.AddrFrame.Offset;
|
||||
}
|
||||
|
||||
BOOL CALLBACK straceWin::EnumSymbolsCB(PSYMBOL_INFO symInfo, ULONG size, PVOID user) {
|
||||
BOOL CALLBACK straceWin::EnumSymbolsCB(PSYMBOL_INFO symInfo, ULONG size, PVOID user)
|
||||
{
|
||||
QStringList* params = (QStringList*)user;
|
||||
if(symInfo->Flags & SYMFLAG_PARAMETER) {
|
||||
if (symInfo->Flags & SYMFLAG_PARAMETER)
|
||||
params->append(symInfo->Name);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
struct straceWin::EnumModulesContext {
|
||||
struct straceWin::EnumModulesContext
|
||||
{
|
||||
HANDLE hProcess;
|
||||
QTextStream& stream;
|
||||
EnumModulesContext(HANDLE hProcess, QTextStream& stream): hProcess(hProcess), stream(stream) {}
|
||||
};
|
||||
|
||||
BOOL CALLBACK straceWin::EnumModulesCB(LPCSTR ModuleName, DWORD64 BaseOfDll, PVOID UserContext) {
|
||||
BOOL CALLBACK straceWin::EnumModulesCB(LPCSTR ModuleName, DWORD64 BaseOfDll, PVOID UserContext)
|
||||
{
|
||||
IMAGEHLP_MODULE64 mod;
|
||||
EnumModulesContext* context = (EnumModulesContext*)UserContext;
|
||||
mod.SizeOfStruct = sizeof(IMAGEHLP_MODULE64);
|
||||
@ -86,7 +90,8 @@ BOOL CALLBACK straceWin::EnumModulesCB(LPCSTR ModuleName, DWORD64 BaseOfDll, PVO
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4748)
|
||||
#endif
|
||||
const QString straceWin::getBacktrace() {
|
||||
const QString straceWin::getBacktrace()
|
||||
{
|
||||
DWORD MachineType;
|
||||
CONTEXT Context;
|
||||
STACKFRAME64 StackFrame;
|
||||
@ -173,6 +178,7 @@ const QString straceWin::getBacktrace() {
|
||||
ZeroMemory(&ihsf, sizeof(IMAGEHLP_STACK_FRAME));
|
||||
|
||||
int i = 0;
|
||||
|
||||
while(StackWalk64(MachineType, hProcess, hThread, &StackFrame, &Context, NULL, NULL, NULL, NULL)) {
|
||||
if(i == 128)
|
||||
break;
|
||||
@ -188,11 +194,10 @@ const QString straceWin::getBacktrace() {
|
||||
fileName = fileName.mid(slashPos + 1);
|
||||
}
|
||||
QString funcName;
|
||||
if(SymFromAddr(hProcess, ihsf.InstructionOffset, &dwDisplacement, pSymbol)) {
|
||||
if(SymFromAddr(hProcess, ihsf.InstructionOffset, &dwDisplacement, pSymbol))
|
||||
funcName = QString(pSymbol->Name);
|
||||
} else {
|
||||
else
|
||||
funcName = QString("0x%1").arg(ihsf.InstructionOffset, 8, 16, QLatin1Char('0'));
|
||||
}
|
||||
QStringList params;
|
||||
SymSetContext(hProcess, &ihsf, NULL);
|
||||
SymEnumSymbols(hProcess, 0, NULL, EnumSymbolsCB, (PVOID)¶ms);
|
||||
@ -206,7 +211,8 @@ const QString straceWin::getBacktrace() {
|
||||
.arg(params.join(", "));
|
||||
logStream << debugLine << '\n';
|
||||
i++;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
break; // we're at the end.
|
||||
}
|
||||
}
|
||||
|
@ -7,17 +7,22 @@
|
||||
#include "libtorrent/version.hpp"
|
||||
#include "ui_stacktrace_win_dlg.h"
|
||||
|
||||
class StraceDlg : public QDialog, private Ui::errorDialog {
|
||||
class StraceDlg: public QDialog, private Ui::errorDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
StraceDlg(QWidget *parent = 0): QDialog(parent) {
|
||||
StraceDlg(QWidget* parent = 0): QDialog(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
~StraceDlg() {}
|
||||
~StraceDlg()
|
||||
{
|
||||
}
|
||||
|
||||
void setStacktraceString(const QString& trace) {
|
||||
void setStacktraceString(const QString& trace)
|
||||
{
|
||||
QString htmlStr;
|
||||
QTextStream outStream(&htmlStr);
|
||||
outStream << "<p align=center><b><font size=7 color=red>" <<
|
||||
|
Loading…
Reference in New Issue
Block a user