Commit aab611e5 by LIDINGDA\ldd

1.增崩溃时写dump;2.工程修改为msvc版本(编译时生成符号表)

parent 09a588d4
#ifndef FM_DUMP_H
#define FM_DUMP_H
#include <windows.h>
#include <DbgHelp.h>
#include <schannel.h>
void CreateMiniDump(char *file, EXCEPTION_POINTERS* pep)
{
// Open the file
HANDLE hFile = CreateFileA(file, GENERIC_READ | GENERIC_WRITE,
0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
if( ( hFile != NULL ) && ( hFile != INVALID_HANDLE_VALUE ) )
{
// Create the minidump
BOOL rv = 0;
MINIDUMP_EXCEPTION_INFORMATION mdei;
MINIDUMP_TYPE mdt;
mdei.ThreadId = GetCurrentThreadId();
mdei.ExceptionPointers = pep;
mdei.ClientPointers = TRUE;
mdt = MiniDumpWithFullMemory;
rv = MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(),
hFile, mdt, (pep != 0) ? &mdei : 0, 0, 0 );
// Close the file
CloseHandle( hFile );
}
}
long __stdcall FMExcpHandler(PEXCEPTION_POINTERS excp)
{
char mod[MAX_PATH] = { 0 };
FILE* ferr = NULL;
GetModuleFileNameA(NULL, mod, MAX_PATH);
strcat(mod, ".err");
ferr = fopen(mod, "w");
fprintf(ferr, "Error address %x\n",excp->ExceptionRecord->ExceptionAddress);
fprintf(ferr, "CPU register:\n");
fprintf(ferr, "eax %x ebx %x ecx %x edx %x\n",excp->ContextRecord->Eax,
excp->ContextRecord->Ebx,excp->ContextRecord->Ecx,
excp->ContextRecord->Edx);
fclose(ferr);
strcat(mod, ".dmp");
CreateMiniDump(mod, excp);
return EXCEPTION_EXECUTE_HANDLER;
}
#endif // DUMP
#ifndef FMDEFINE_H #ifndef FMDEFINE_H
#define FMDEFINE_H #define FMDEFINE_H
#define INIFILE_NAME "update.ini" #define INIFILE_NAME "update.ini"
......
...@@ -9,8 +9,8 @@ CONFIG += c++11 ...@@ -9,8 +9,8 @@ CONFIG += c++11
DEFINES += QUAZIP_STATIC DEFINES += QUAZIP_STATIC
#DEFINES += SHIQIJIA #DEFINES += SHIQIJIA
#DEFINES += SHAN_LIN DEFINES += SHAN_LIN
DEFINES += AI_SEN #DEFINES += AI_SEN
#DEFINES += TODAY #DEFINES += TODAY
TARGET = fmscupd TARGET = fmscupd
...@@ -27,11 +27,28 @@ HEADERS += \ ...@@ -27,11 +27,28 @@ HEADERS += \
fmservice.h \ fmservice.h \
fmdefine.h \ fmdefine.h \
fmcontrol.h \ fmcontrol.h \
fmtools.h fmtools.h \
dump.h
OTHER_FILES += \ OTHER_FILES += \
update.ini \ update.ini \
changes.txt changes.txt
LIBS += -lUserenv #QMAKE_CXXFLAGS += -g
LIBS += -lz
INCLUDEPATH += $$PWD/../include/zlib
LIBS += -lUserenv -ldbghelp
CONFIG(debug,debug|release) {
LIBS += -L$$PWD/../lib -lzlibstaticd
}
else {
LIBS += -L$$PWD/../lib -lzlibstatic
QMAKE_LFLAGS += /DEBUG
}
#LIBS += -lz
win32 {
LIBS += -luser32 -lAdvapi32
}
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include "fmcontrol.h" #include "fmcontrol.h"
#include "QsLog.h" #include "QsLog.h"
#include "dump.h"
using namespace QsLogging; using namespace QsLogging;
class FmService : public QtService<QCoreApplication> class FmService : public QtService<QCoreApplication>
...@@ -14,8 +16,10 @@ public: ...@@ -14,8 +16,10 @@ public:
FmService(int argc, char **argv) FmService(int argc, char **argv)
:QtService<QCoreApplication>(argc, argv, SERVICE_NAME) :QtService<QCoreApplication>(argc, argv, SERVICE_NAME)
{ {
setServiceDescription(SERVICE_DESC); setServiceDescription(SERVICE_DESC);
setStartupType(QtServiceController::AutoStartup); setStartupType(QtServiceController::AutoStartup);
SetUnhandledExceptionFilter(FMExcpHandler);
} }
protected: protected:
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <QSqlDatabase> #include <QSqlDatabase>
#include <QSqlQuery> #include <QSqlQuery>
#include <QFile> #include <QFile>
#include <QDir>
FmTools &FmTools::GetInstance() FmTools &FmTools::GetInstance()
{ {
...@@ -45,6 +46,7 @@ FmTools::FmTools() ...@@ -45,6 +46,7 @@ FmTools::FmTools()
m_partnerId = "1484"; m_partnerId = "1484";
QSettings reg("HKEY_LOCAL_MACHINE\\SOFTWARE\\Hisensoft Co.Ltd\\FoodPos", QSettings::NativeFormat); QSettings reg("HKEY_LOCAL_MACHINE\\SOFTWARE\\Hisensoft Co.Ltd\\FoodPos", QSettings::NativeFormat);
QString appDir = reg.value("AppDir").toString(); QString appDir = reg.value("AppDir").toString();
m_siIniPath = appDir + "/PosCfg.ini"; m_siIniPath = appDir + "/PosCfg.ini";
......
File added
File added
File added
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment