* [PATCH 0/3] Misc dumper improvements
@ 2020-07-21 14:26 Jon Turney
2020-07-21 14:26 ` [PATCH 1/3] Cygwin: Add --nokill dumper option Jon Turney
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Jon Turney @ 2020-07-21 14:26 UTC (permalink / raw)
To: cygwin-patches; +Cc: Jon Turney
Jon Turney (3):
Cygwin: Add --nokill dumper option
CYgwin: Remove synchronization event from dumper
Cygwin: Speed up dumper
winsup/doc/utils.xml | 9 ++++++---
winsup/utils/dumper.cc | 41 +++++++++++++++++++++--------------------
2 files changed, 27 insertions(+), 23 deletions(-)
--
2.27.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] Cygwin: Add --nokill dumper option
2020-07-21 14:26 [PATCH 0/3] Misc dumper improvements Jon Turney
@ 2020-07-21 14:26 ` Jon Turney
2020-07-21 14:26 ` [PATCH 2/3] CYgwin: Remove synchronization event from dumper Jon Turney
2020-07-21 14:26 ` [PATCH 3/3] Cygwin: Speed up dumper Jon Turney
2 siblings, 0 replies; 4+ messages in thread
From: Jon Turney @ 2020-07-21 14:26 UTC (permalink / raw)
To: cygwin-patches; +Cc: Jon Turney
Add --nokill option to dumper, for compatibility with minidumper, and to
assist with testing.
---
winsup/doc/utils.xml | 9 ++++++---
winsup/utils/dumper.cc | 20 +++++++++++++++++++-
2 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/winsup/doc/utils.xml b/winsup/doc/utils.xml
index 8b92bfdf1..176f9a0d3 100644
--- a/winsup/doc/utils.xml
+++ b/winsup/doc/utils.xml
@@ -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,11 @@ 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>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
diff --git a/winsup/utils/dumper.cc b/winsup/utils/dumper.cc
index 3af138b9e..fa6d9641a 100644
--- a/winsup/utils/dumper.cc
+++ b/winsup/utils/dumper.cc
@@ -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;
--
2.27.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/3] CYgwin: Remove synchronization event from dumper
2020-07-21 14:26 [PATCH 0/3] Misc dumper improvements Jon Turney
2020-07-21 14:26 ` [PATCH 1/3] Cygwin: Add --nokill dumper option Jon Turney
@ 2020-07-21 14:26 ` Jon Turney
2020-07-21 14:26 ` [PATCH 3/3] Cygwin: Speed up dumper Jon Turney
2 siblings, 0 replies; 4+ messages in thread
From: Jon Turney @ 2020-07-21 14:26 UTC (permalink / raw)
To: cygwin-patches; +Cc: Jon Turney
The use of the 'cygwin_error_start_event' for synchronization with
dumper was removed from the DLL in commit 8abeff1e (April 2001).
---
winsup/utils/dumper.cc | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/winsup/utils/dumper.cc b/winsup/utils/dumper.cc
index fa6d9641a..ace752464 100644
--- a/winsup/utils/dumper.cc
+++ b/winsup/utils/dumper.cc
@@ -627,10 +627,6 @@ dumper::collect_process_information ()
return 0;
}
- char event_name[sizeof ("cygwin_error_start_event") + 20];
- sprintf (event_name, "cygwin_error_start_event%16x", (unsigned int) pid);
- HANDLE sync_with_debugee = OpenEvent (EVENT_MODIFY_STATE, FALSE, event_name);
-
DEBUG_EVENT current_event;
while (1)
@@ -701,10 +697,6 @@ dumper::collect_process_information ()
goto failed;
};
- /* signal a debugee that we've finished */
- if (sync_with_debugee)
- SetEvent (sync_with_debugee);
-
break;
default:
@@ -730,10 +722,6 @@ failed:
/* 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);
-
return 0;
}
--
2.27.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 3/3] Cygwin: Speed up dumper
2020-07-21 14:26 [PATCH 0/3] Misc dumper improvements Jon Turney
2020-07-21 14:26 ` [PATCH 1/3] Cygwin: Add --nokill dumper option Jon Turney
2020-07-21 14:26 ` [PATCH 2/3] CYgwin: Remove synchronization event from dumper Jon Turney
@ 2020-07-21 14:26 ` Jon Turney
2 siblings, 0 replies; 4+ messages in thread
From: Jon Turney @ 2020-07-21 14:26 UTC (permalink / raw)
To: cygwin-patches; +Cc: Jon Turney
Stop after we've written the dump in response to the initial breakpoint
EXCEPTION_DEBUG_EVENT we recieve for attaching to the process.
(rather than bogusly sitting there for 20 seconds waiting for more debug
events from a stopped process after we've already written the dump).
---
winsup/utils/dumper.cc | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/winsup/utils/dumper.cc b/winsup/utils/dumper.cc
index ace752464..e80758e0c 100644
--- a/winsup/utils/dumper.cc
+++ b/winsup/utils/dumper.cc
@@ -615,8 +615,6 @@ out:
int
dumper::collect_process_information ()
{
- int exception_level = 0;
-
if (!sane ())
return 0;
@@ -631,7 +629,7 @@ dumper::collect_process_information ()
while (1)
{
- if (!WaitForDebugEvent (¤t_event, 20000))
+ if (!WaitForDebugEvent (¤t_event, INFINITE))
return 0;
deb_printf ("got debug event %d\n", current_event.dwDebugEventCode);
@@ -675,12 +673,6 @@ dumper::collect_process_information ()
case EXCEPTION_DEBUG_EVENT:
- exception_level++;
- if (exception_level == 2)
- break;
- else if (exception_level > 2)
- return 0;
-
collect_memory_sections ();
/* got all info. time to dump */
@@ -697,6 +689,9 @@ dumper::collect_process_information ()
goto failed;
};
+ /* We're done */
+ goto failed;
+
break;
default:
--
2.27.0
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-07-21 14:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-21 14:26 [PATCH 0/3] Misc dumper improvements Jon Turney
2020-07-21 14:26 ` [PATCH 1/3] Cygwin: Add --nokill dumper option Jon Turney
2020-07-21 14:26 ` [PATCH 2/3] CYgwin: Remove synchronization event from dumper Jon Turney
2020-07-21 14:26 ` [PATCH 3/3] Cygwin: Speed up dumper Jon Turney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).