コード例 #1
0
bool MACMemoryDump::miniDumpCallBack(const char * dump_path,
						const char * minidump_id,
						void* context,
						bool succeeded)
{
	if(succeeded) {
		std::string memoryDumpName (minidump_id);
		memoryDumpName += ".dmp";
		std::string memoryDumpFile(dump_path);
		memoryDumpFile += memoryDumpName;
		
		
		std::string command = Path::getApplicationDirPath() + "owcrashreport";
		char * commandArgs[10];
		int i = 0;
		commandArgs[i++] = (char *)command.c_str();
		commandArgs[i++] = "-d";
		commandArgs[i++] = (char *)memoryDumpFile.c_str();
		commandArgs[i++] = "-n";
		commandArgs[i++] = (char *)_applicationName.c_str();
		
		if (!_languageFilename.empty()) {
			commandArgs[i++] = "-l";
			commandArgs[i++] = (char *)_languageFilename.c_str();
		}
		
		if (getAdditionalInfo) {
			commandArgs[i++] = "-i";
			commandArgs[i++] = (char *)getAdditionalInfo().c_str();
		}
		
		commandArgs[i] = NULL;
		
		if (!fork()) {
			execv(command.c_str(), commandArgs);
		}
		
	}
	
	return succeeded;
}
コード例 #2
0
bool MSVCMemoryDump::miniDumpCallBack(const wchar_t* dump_path,
								  const wchar_t* minidump_id,
								  void* context,
								  EXCEPTION_POINTERS* exinfo,
								  MDRawAssertionInfo* assertion,
								  bool succeeded)
{
	if(succeeded) {

		//Launches crashreport.exe
		std::string commandLine = "owcrashreport";
		if (!_styleName.empty()) {
			commandLine += " -style=";
			commandLine += _styleName;
		}

		//Name of the memory dump
		//Use current path
		std::string memoryDumpName;

		if ( !_fileNamePrefix.empty() )
		{
			memoryDumpName += _fileNamePrefix;
			memoryDumpName += "-";
		}

		memoryDumpName += wstr2str(std::wstring(minidump_id));
		memoryDumpName += ".dmp";

		//GetModuleFileName retrieves the path of the executable file of the current process.
		std::string memoryDumpFile = wstr2str(std::wstring(dump_path));
		memoryDumpFile += memoryDumpName;

		commandLine += " -d ";
		commandLine += "\"";
		commandLine += memoryDumpFile;
		commandLine += "\"";

		commandLine += " -n ";
		commandLine += "\"";
		commandLine += _applicationName;
		commandLine += "\"";

		if (!_languageFilename.empty()) {
			commandLine += " -l ";
			commandLine += "\"";
			commandLine += _languageFilename;
			commandLine += "\"";
		}
		if (getAdditionalInfo) {
			commandLine += " -i ";
			commandLine += "\"";
			commandLine += getAdditionalInfo();
			commandLine += "\"";
		}
		
		//Flushes the logger file
		//Logger::logger.flush();

		executeProcess(commandLine);
	}	
	
	// force to terminate
	TerminateProcess(GetCurrentProcess(), 0);
	
	return succeeded;
}