mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-19 20:53:52 +00:00
Update Windows crash dump path once we know where we're logging
Manual rewrite of 5102f4b11d
This commit is contained in:
parent
72d99237e3
commit
48368f79b6
3 changed files with 40 additions and 0 deletions
|
@ -77,6 +77,32 @@ namespace Crash
|
||||||
CloseHandle(mShmHandle);
|
CloseHandle(mShmHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CrashCatcher::updateDumpPaths(
|
||||||
|
const std::filesystem::path& crashDumpPath, const std::filesystem::path& freezeDumpPath)
|
||||||
|
{
|
||||||
|
shmLock();
|
||||||
|
|
||||||
|
memset(mShm->mStartup.mCrashDumpFilePath, 0, sizeof(mShm->mStartup.mCrashDumpFilePath));
|
||||||
|
const auto str = crashDumpPath.u8string();
|
||||||
|
size_t length = str.length();
|
||||||
|
if (length >= MAX_LONG_PATH)
|
||||||
|
length = MAX_LONG_PATH - 1;
|
||||||
|
strncpy_s(mShm->mStartup.mCrashDumpFilePath, sizeof mShm->mStartup.mCrashDumpFilePath,
|
||||||
|
Misc::StringUtils::u8StringToString(str).c_str(), length);
|
||||||
|
mShm->mStartup.mCrashDumpFilePath[length] = '\0';
|
||||||
|
|
||||||
|
memset(mShm->mStartup.mFreezeDumpFilePath, 0, sizeof(mShm->mStartup.mFreezeDumpFilePath));
|
||||||
|
const auto strFreeze = freezeDumpPath.u8string();
|
||||||
|
length = strFreeze.length();
|
||||||
|
if (length >= MAX_LONG_PATH)
|
||||||
|
length = MAX_LONG_PATH - 1;
|
||||||
|
strncpy_s(mShm->mStartup.mFreezeDumpFilePath, sizeof mShm->mStartup.mFreezeDumpFilePath,
|
||||||
|
Misc::StringUtils::u8StringToString(strFreeze).c_str(), length);
|
||||||
|
mShm->mStartup.mFreezeDumpFilePath[length] = '\0';
|
||||||
|
|
||||||
|
shmUnlock();
|
||||||
|
}
|
||||||
|
|
||||||
void CrashCatcher::setupIpc()
|
void CrashCatcher::setupIpc()
|
||||||
{
|
{
|
||||||
SECURITY_ATTRIBUTES attributes;
|
SECURITY_ATTRIBUTES attributes;
|
||||||
|
|
|
@ -27,10 +27,14 @@ namespace Crash
|
||||||
class CrashCatcher final
|
class CrashCatcher final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static CrashCatcher* instance() { return sInstance; }
|
||||||
|
|
||||||
CrashCatcher(int argc, char** argv, const std::filesystem::path& crashDumpPath,
|
CrashCatcher(int argc, char** argv, const std::filesystem::path& crashDumpPath,
|
||||||
const std::filesystem::path& freezeDumpPath);
|
const std::filesystem::path& freezeDumpPath);
|
||||||
~CrashCatcher();
|
~CrashCatcher();
|
||||||
|
|
||||||
|
void updateDumpPaths(const std::filesystem::path& crashDumpPath, const std::filesystem::path& freezeDumpPath);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static CrashCatcher* sInstance;
|
static CrashCatcher* sInstance;
|
||||||
|
|
||||||
|
|
|
@ -314,6 +314,16 @@ void setupLogging(const std::filesystem::path& logDir, std::string_view appName,
|
||||||
std::cout.rdbuf(&coutsb);
|
std::cout.rdbuf(&coutsb);
|
||||||
std::cerr.rdbuf(&cerrsb);
|
std::cerr.rdbuf(&cerrsb);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
if (Crash::CrashCatcher::instance())
|
||||||
|
{
|
||||||
|
const std::string crashDumpName = Misc::StringUtils::lowerCase(appName) + "-crash.dmp";
|
||||||
|
const std::string freezeDumpName = Misc::StringUtils::lowerCase(appName) + "-freeze.dmp";
|
||||||
|
std::filesystem::path dumpDirectory = logDir;
|
||||||
|
Crash::CrashCatcher::instance()->updateDumpPaths(dumpDirectory / crashDumpName, dumpDirectory / freezeDumpName);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int wrapApplication(int (*innerApplication)(int argc, char* argv[]), int argc, char* argv[], std::string_view appName)
|
int wrapApplication(int (*innerApplication)(int argc, char* argv[]), int argc, char* argv[], std::string_view appName)
|
||||||
|
|
Loading…
Reference in a new issue