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 | |
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')
-rw-r--r-- | src/debug/createdump/main.cpp | 24 | ||||
-rw-r--r-- | src/dlls/mscordac/mscordac_unixexports.src | 1 | ||||
-rw-r--r-- | src/pal/inc/pal.h | 8 |
3 files changed, 28 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); diff --git a/src/dlls/mscordac/mscordac_unixexports.src b/src/dlls/mscordac/mscordac_unixexports.src index 995f5da28f..3709d55356 100644 --- a/src/dlls/mscordac/mscordac_unixexports.src +++ b/src/dlls/mscordac/mscordac_unixexports.src @@ -131,6 +131,7 @@ nativeStringResourceTable_mscorrc_debug #GetSystemTime #GetSystemTimeAsFileTime #GetTempFileNameW +#GetTempPathA #GetTempPathW #HeapAlloc #HeapFree diff --git a/src/pal/inc/pal.h b/src/pal/inc/pal.h index 1621dcc4ad..d49cb13589 100644 --- a/src/pal/inc/pal.h +++ b/src/pal/inc/pal.h @@ -1103,6 +1103,14 @@ GetTempPathW( IN DWORD nBufferLength, OUT LPWSTR lpBuffer); +PALIMPORT +DWORD +PALAPI +GetTempPathA( + IN DWORD nBufferLength, + OUT LPSTR lpBuffer); + + #ifdef UNICODE #define GetTempPath GetTempPathW #else |