1.1Tutorial for Error Dump System Construction (including game server and client)
DbgHelp Library Installation
Copy dbghelp.dll and insert it into the folder (C:\Windows\system32) in which OS has been installed or the current folder of the program.
dbghelp.dll is in \ProudNet\Sample\Bin (ProudNet installation directory).
Visual Studio Compile Option Setting
Configuration Properties > C/C++ > Code Generation > Enable C++ Exceptions > Select Yes With SEH Exceptions (/EHa)
Please refer to 2.5 Compile Setting for Error Dump System for more information.
Example of Dump Server Production
It collects error information dump files that have been received from a dump client.
#include "../../../include/ProudNetServer.h" #include "../../../include/DumpServer.h" #include "MyDumpServer.h" class CMyDumpServer : public IDumpServerDelegate { ... virtual void OnStartServer(CStartServerParameter &refParam) override; String GetDumpFilePath(HostID clientEnid, const Proud::AddrPort& clientAddr, CPnTime dumpTime) override; void Run(); } void main(int argc, char* argv[]) { CMyDumpServer srv; srv.Run(); }
Example of Dump Client Production
It must be executed as a dump client to send error information in case of crash at both a game server process and a game client process. The dump client generally sends a dump file that contains error information to the dump server.
If there is a crash at the process, temporary *.DMP dump file will be created and the information of error level will be attached to the Command Argument as the process is executed again. Error level information (that has been attached by Command Argument) should be managed as route processing (route setting) depending on the severity and MiniDumpAction_AlarmCrash is considered as serious error, so you must design the code that sends a dump file to a dump server.
Production of Dump Client for Game Server
Code design must be completed as *.DMP dump file is directly sent to a dump server without error report dialog box. It is because a game server does not provide user UI.
Production of Dump Client for Game Client
Code design must be completed after checking (with a user) if *.DMP dump file needs to be sent to a dump server with error report dialog box. It is because a game client provides user UI.
Caution :
Dump client is not supported at mobile environment including smartphone.
You must initialize the dump system by using Proud.CMiniDumpParameter.
In case of Unicode programming model, you may define wide characters version of main function and argv & envp parameter for wmain function is wchar_t* type.
In case of MiniDumpAction_AlarmCrash and MiniDumpAction_DoNothing, need to shut down the program by calling return after route processing (route setting). Otherwise, infinite loop might occur.
Please refer to The internal link is invalid. to check examples for Windows and demonstration that are relevant to this example.
#include "stdafx.h" #include <atlpath.h> #include "../../include/MiniDumper.h" #include "../../include/DumpCommon.h" using namespace Proud; const int _MAX_PATH2 = 8192; #define _COUNTOF(array) (sizeof(array)/sizeof(array[0])) void GetDumpFilePath(LPWSTR output) { WCHAR path[_MAX_PATH2]; WCHAR drive[_MAX_PATH2]; WCHAR dir[_MAX_PATH2]; WCHAR fname[_MAX_PATH2]; WCHAR ext[_MAX_PATH2]; WCHAR module_file_name[_MAX_PATH2]; GetModuleFileNameW(NULL, module_file_name, _COUNTOF(module_file_name)); _tsplitpath_s(module_file_name, drive, _MAX_PATH2, dir, _MAX_PATH2, fname, _MAX_PATH2, ext, _MAX_PATH2); _tmakepath_s(path, _MAX_PATH2, drive, dir, L"", L""); wsprintf(output, L"%s%s.DMP", path, fname); }; void AccessViolation() { int* a = 0; *a = 1; } // void wmain(int argc, wchar_t* argv[]) int main(int argc, char* argv[]) { int nRetCode = 0; int *data = 0; int menu = 0; WCHAR dumpFileName[_MAX_PATH2] = { 0, }; GetDumpFilePath(dumpFileName); CMiniDumpParameter parameter; parameter.m_dumpFileName = dumpFileName; parameter.m_miniDumpType = SmallMiniDumpType; switch (CMiniDumper::Instance().Startup(parameter)) { case MiniDumpAction_AlarmCrash: // 오류 발생으로 새로운 프로세스에서 덤프 파일을 생성한 후, 이 값이 return이 됩니다. // 생성된 덤프 파일을 메일로 보내거나 에러 창을 보이는 등 유저가 덤프 파일 생성 후, 처리해야할 작업을 처리해주시면 됩니다. // A dump file is created at a new process due to error occurrence and then this value will be returned. // After a user create a dump file, do works that need to be done such as sending a created dump file by email or showing an error window. // 因出现错误,在新的process中生成转储文件后该值将被返还。 // 将生成的转储文件以邮件的形式发送,或可以看到 Error对话框的用户生成转存文件后,处理应处理的事即可 // エラー発生により新しいプロセスからダンプファイルを生成した後、この値がreturnされます。 // 生成されたダンプファイルをメールで送ったり、エラーメッセージが提示されるなどユーザーがダンプファイル生成後、処理すべきの作業をしてください。 ... return nRetCode; case MiniDumpAction_DoNothing: // 유저 호출로 새로운 프로세스에서 덤프 파일을 생성한 후, 이 값이 반환됩니다. // 이 경우에는 아무것도 하지 말아야합니다. // After creating a dump file at a new process by calling a user, this value will be returned. // In this case, you should not do anything. // 因用户呼叫,在新的process中生成转储文件后,该值将被返还。 // 在这种情况,不要做任何事情。. // ユーザー呼び出しにより新しいプロセスからダンプファイルを生成した後、この値が返還されます。 // この場合何もしないでください。 ... return nRetCode; default: // MiniDumpAction_None // 일반적으로 앱 실행 시, 이 값이 반환됩니다. // 여기서는 일반적으로 처리해야할 일을 처리해주시면 됩니다. // When executing apps, this value will be returned. // In this case, do works that generally need to be done. // 一般运行App时,该值将被返还。 //在这里处理一般应处理的事情即可。 // 一般的にアプリ実行後、この値が返還されます。 // ここでは一般的に処理すべきの事を処理してください。 ... break; } while (1) { puts("MENU: 1. Access Violation('a')"); printf("> "); menu = getchar(); switch (menu) { case 'a': AccessViolation(); break; default: break; } } return 0; }
1.2API reference of error dump system
Please see this link.
1.3Compile Setting for Error Dump System
To use Part X. MiniDump (Error Dump System), apply C++ compile setting as shown in the below picture.
These settings can't be applied to Visual Studio 2003. Thus please select No then add /EHa on Configuration Properties->C/C++->Command Line->Additional Options.