Windows: Use a timestamp for the minidump filename

Set the name of the minidump file to :
%TMP%\afsd-<yyyy>-<mm>-<dd>-<hh>_<mm>_<ss>.dmp

This prevents new minidump files from overwriting older ones.

Change-Id: I057963bedf618eb23720f17d62c8473790569273
Reviewed-on: http://gerrit.openafs.org/1633
Reviewed-by: Asanka Herath <asanka@secure-endpoints.com>
Tested-by: Asanka Herath <asanka@secure-endpoints.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: Jeffrey Altman <jaltman@openafs.org>
This commit is contained in:
Asanka Herath 2010-03-19 22:13:41 -04:00 committed by Jeffrey Altman
parent 1146d25df6
commit 37f3aabd9f

View File

@ -1679,16 +1679,21 @@ static BOOL (WINAPI *pMiniDumpWriteDump)(HANDLE hProcess,DWORD ProcessId,HANDLE
static HANDLE
OpenDumpFile(void)
{
char tmp[256];
char wd[256];
SYSTEMTIME st;
DWORD code;
code = GetEnvironmentVariable("TEMP", wd, sizeof(wd));
if ( code == 0 || code > sizeof(wd) )
code = GetEnvironmentVariable("TEMP", tmp, sizeof(tmp));
if ( code == 0 || code > sizeof(tmp) )
{
if (!GetWindowsDirectory(wd, sizeof(wd)))
if (!GetWindowsDirectory(tmp, sizeof(tmp)))
return NULL;
}
StringCbCatA(wd, sizeof(wd), "\\afsd.dmp");
GetLocalTime(&st);
StringCbPrintfA(wd, sizeof(wd),
"%s\\afsd-%04d-%02d-%02d-%02d_%02d_%02d.dmp", tmp,
st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);
return CreateFile( wd, GENERIC_WRITE, FILE_SHARE_READ, NULL,
CREATE_ALWAYS, FILE_FLAG_WRITE_THROUGH, NULL);
}