* exceptions.cc (open_stackdumpfile): Use NtCreateFile to create

stackdump file.
This commit is contained in:
Corinna Vinschen 2008-02-28 15:50:51 +00:00
parent 11cd2378b0
commit 6965e46961
2 changed files with 28 additions and 5 deletions

View File

@ -1,3 +1,8 @@
2008-02-28 Corinna Vinschen <corinna@vinschen.de>
* exceptions.cc (open_stackdumpfile): Use NtCreateFile to create
stackdump file.
2008-02-27 Corinna Vinschen <corinna@vinschen.de> 2008-02-27 Corinna Vinschen <corinna@vinschen.de>
* exceptions.cc (stack_info::walk): Fix typo. * exceptions.cc (stack_info::walk): Fix typo.

View File

@ -32,6 +32,7 @@ details. */
#include "dtable.h" #include "dtable.h"
#include "cygheap.h" #include "cygheap.h"
#include "child_info.h" #include "child_info.h"
#include "ntdll.h"
#define CALL_HANDLER_RETRY 20 #define CALL_HANDLER_RETRY 20
@ -140,11 +141,28 @@ open_stackdumpfile ()
p++; p++;
else else
p = myself->progname; p = myself->progname;
char corefile[strlen (p) + sizeof (".stackdump")];
__small_sprintf (corefile, "%s.stackdump", p); WCHAR corefile[strlen (p) + sizeof (".stackdump")];
HANDLE h = CreateFile (corefile, GENERIC_WRITE, 0, &sec_none_nih, UNICODE_STRING ucore;
CREATE_ALWAYS, 0, 0); OBJECT_ATTRIBUTES attr;
if (h != INVALID_HANDLE_VALUE) RtlInitEmptyUnicodeString (&ucore, corefile,
sizeof corefile - sizeof (WCHAR));
ucore.Length = sys_mbstowcs (ucore.Buffer,
ucore.MaximumLength / sizeof (WCHAR),
p, strlen (p)) * sizeof (WCHAR);
RtlAppendUnicodeToString (&ucore, L".stackdump");
InitializeObjectAttributes (&attr, &ucore, OBJ_CASE_INSENSITIVE,
cygheap->cwd.get_handle (), NULL);
HANDLE h;
IO_STATUS_BLOCK io;
NTSTATUS status;
status = NtCreateFile (&h, GENERIC_WRITE | SYNCHRONIZE, &attr, &io,
NULL, FILE_ATTRIBUTE_NORMAL, 0, FILE_OVERWRITE_IF,
FILE_SYNCHRONOUS_IO_NONALERT
| FILE_OPEN_FOR_BACKUP_INTENT
| FILE_OPEN_FOR_RECOVERY, NULL, 0);
if (NT_SUCCESS (status))
{ {
if (!myself->cygstarted) if (!myself->cygstarted)
system_printf ("Dumping stack trace to %s", corefile); system_printf ("Dumping stack trace to %s", corefile);