diff options
author | Mike McLaughlin <mikem@microsoft.com> | 2019-01-08 09:35:12 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-08 09:35:12 -0800 |
commit | bd5ea1c46ca21631194610f88f2ba420e8982d5b (patch) | |
tree | 81c863053da53beb5059856e7710eb7a5ab1d60e /src/debug | |
parent | d6bf5ed160e99b9a66087dcc8738f22a9a370121 (diff) | |
download | coreclr-bd5ea1c46ca21631194610f88f2ba420e8982d5b.tar.gz coreclr-bd5ea1c46ca21631194610f88f2ba420e8982d5b.tar.bz2 coreclr-bd5ea1c46ca21631194610f88f2ba420e8982d5b.zip |
Fix issue #20585 createdump explicitly uses /tmp. (#21866)
Changed to PAL's GetTempPathA to get the temp path.
Diffstat (limited to 'src/debug')
-rw-r--r-- | src/debug/createdump/main.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
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<DumpDataTarget> dataTarget = new DumpDataTarget(pid); ReleaseHolder<CrashInfo> crashInfo = new CrashInfo(pid, dataTarget, false); |