Cygwin: Add --nokill dumper option

Add --nokill option to dumper, for compatibility with minidumper, and to
assist with testing.
This commit is contained in:
Jon Turney 2020-07-06 14:51:32 +01:00
parent ba283d8777
commit a5218ff772
No known key found for this signature in database
GPG Key ID: C7C86F0370285C81
2 changed files with 26 additions and 4 deletions

View File

@ -496,6 +496,7 @@ dumper [OPTION] FILENAME WIN32PID
<refsect1 id="dumper-options">
<title>Options</title>
<screen>
-n, --nokill don't terminate the dumped process
-d, --verbose be verbose while dumping
-h, --help output help information and exit
-q, --quiet be quiet while dumping (default)
@ -519,9 +520,12 @@ error_start=x:\path\to\dumper.exe
be started whenever some program encounters a fatal error. </para>
<para> <command>dumper</command> can be also be started from the command
line to create a core dump of any running process. Unfortunately, because
of a Windows API limitation, when a core dump is created and
<command>dumper</command> exits, the target process is terminated too. </para>
line to create a core dump of any running process.</para>
<para>For historical reasons, unless the <literal>-n</literal> option
is given, after the core dump is created and when the
<command>dumper</command> exits, the target process is also
terminated.</para>
<para> To save space in the core dump, <command>dumper</command> doesn't
write those portions of the target process's memory space that are loaded

View File

@ -64,6 +64,7 @@ __attribute__ ((packed))
note_header;
BOOL verbose = FALSE;
BOOL nokill = FALSE;
int deb_printf (const char *format,...)
{
@ -716,7 +717,19 @@ dumper::collect_process_information ()
current_event.dwThreadId,
DBG_CONTINUE);
}
failed:
if (nokill)
{
if (!DebugActiveProcessStop (pid))
{
fprintf (stderr, "Cannot detach from process #%u, error %ld",
(unsigned int) pid, (long) GetLastError ());
}
}
/* Otherwise, the debuggee is terminated when this process exits
(as DebugSetProcessKillOnExit() defaults to TRUE) */
/* set debugee free */
if (sync_with_debugee)
SetEvent (sync_with_debugee);
@ -960,6 +973,7 @@ Usage: %s [OPTION] FILENAME WIN32PID\n\
\n\
Dump core from WIN32PID to FILENAME.core\n\
\n\
-n, --nokill don't terminate the dumped process\n\
-d, --verbose be verbose while dumping\n\
-h, --help output help information and exit\n\
-q, --quiet be quiet while dumping (default)\n\
@ -969,13 +983,14 @@ Dump core from WIN32PID to FILENAME.core\n\
}
struct option longopts[] = {
{"nokill", no_argument, NULL, 'n'},
{"verbose", no_argument, NULL, 'd'},
{"help", no_argument, NULL, 'h'},
{"quiet", no_argument, NULL, 'q'},
{"version", no_argument, 0, 'V'},
{0, no_argument, NULL, 0}
};
const char *opts = "dhqV";
const char *opts = "ndhqV";
static void
print_version ()
@ -1001,6 +1016,9 @@ main (int argc, char **argv)
while ((opt = getopt_long (argc, argv, opts, longopts, NULL) ) != EOF)
switch (opt)
{
case 'n':
nokill = TRUE;
break;
case 'd':
verbose = TRUE;
break;