From bd5ea1c46ca21631194610f88f2ba420e8982d5b Mon Sep 17 00:00:00 2001 From: Mike McLaughlin Date: Tue, 8 Jan 2019 09:35:12 -0800 Subject: Fix issue #20585 createdump explicitly uses /tmp. (#21866) Changed to PAL's GetTempPathA to get the temp path. --- src/debug/createdump/main.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'src/debug') diff --git a/src/debug/createdump/main.cpp b/src/debug/createdump/main.cpp index 2caf3a8957..e7d97c27df 100644 --- a/src/debug/createdump/main.cpp +++ b/src/debug/createdump/main.cpp @@ -20,11 +20,7 @@ bool CreateDumpCommon(const char* dumpPathTemplate, MINIDUMP_TYPE minidumpType, int __cdecl main(const int argc, const char* argv[]) { MINIDUMP_TYPE minidumpType = MiniDumpWithPrivateReadWriteMemory; -#ifdef ANDROID - const char* dumpPathTemplate = "/data/local/tmp/coredump.%d"; -#else - const char* dumpPathTemplate = "/tmp/coredump.%d"; -#endif + const char* dumpPathTemplate = nullptr; pid_t pid = 0; int exitCode = PAL_InitializeDLL(); @@ -34,6 +30,7 @@ int __cdecl main(const int argc, const char* argv[]) return exitCode; } + // Parse the command line options and target pid argv++; for (int i = 1; i < argc; i++) @@ -70,8 +67,25 @@ int __cdecl main(const int argc, const char* argv[]) argv++; } } + if (pid != 0) { + if (dumpPathTemplate == nullptr) + { + char tmpPath[MAX_LONGPATH]; + if (::GetTempPathA(MAX_LONGPATH, tmpPath) == 0) + { + fprintf(stderr, "GetTempPath failed (0x%08x)", ::GetLastError()); + return ::GetLastError(); + } + exitCode = strcat_s(tmpPath, MAX_LONGPATH, "coredump.%d"); + if (exitCode != 0) + { + fprintf(stderr, "strcat_s failed (%d)", exitCode); + return exitCode; + } + dumpPathTemplate = tmpPath; + } ReleaseHolder dataTarget = new DumpDataTarget(pid); ReleaseHolder crashInfo = new CrashInfo(pid, dataTarget, false); -- cgit v1.2.3