From 92ef5188af2deecd2054462bf940f6460d127fe9 Mon Sep 17 00:00:00 2001 From: Egor Duda Date: Sun, 9 Sep 2001 13:18:51 +0000 Subject: [PATCH] * dumper.cc (main): Change command-line arguments format to be similar to gdb. Allow adding error_start=x:\path\to\dumper.exe to CYGWIN environment variable to perform core dumping in case of program crash. (usage): Ditto. --- winsup/utils/ChangeLog | 8 +++++++ winsup/utils/dumper.cc | 53 ++++++++++++++++++++++++------------------ 2 files changed, 39 insertions(+), 22 deletions(-) diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog index e51ec6214..d54e0050f 100644 --- a/winsup/utils/ChangeLog +++ b/winsup/utils/ChangeLog @@ -1,3 +1,11 @@ +2001-09-09 Egor Duda + + * dumper.cc (main): Change command-line arguments format to be + similar to gdb. Allow adding error_start=x:\path\to\dumper.exe to + CYGWIN environment variable to perform core dumping in case of + program crash. + (usage): Ditto. + Wed Sep 5 22:37:21 2001 Christopher Faylor * Makefile.in (dumper): Change logic for libbfd and libintl so that diff --git a/winsup/utils/dumper.cc b/winsup/utils/dumper.cc index dfa0a7df5..ee4a9eabc 100644 --- a/winsup/utils/dumper.cc +++ b/winsup/utils/dumper.cc @@ -36,9 +36,9 @@ __attribute__ ((packed)) #endif note_header; - BOOL verbose = FALSE; +BOOL verbose = FALSE; - int deb_printf (const char *format,...) +int deb_printf (const char *format,...) { if (!verbose) return 0; @@ -768,10 +768,12 @@ dumper::write_core_dump () static void usage () { - fprintf (stderr, "Usage: dumper [-d] [-c filename] pid\n"); - fprintf (stderr, "-c filename -- dump core to filename.core\n"); - fprintf (stderr, "-d -- print some debugging info while dumping\n"); - fprintf (stderr, "pid -- win32-pid of process to dump\n"); + fprintf (stderr, "Usage: dumper [options] filename pid\n"); + fprintf (stderr, "filename -- dump core to filename.core\n"); + fprintf (stderr, "pid -- win32-pid of process to dump\n\n"); + fprintf (stderr, "Possible options are:\n"); + fprintf (stderr, "-d -- be verbose while dumping\n"); + fprintf (stderr, "-q -- be quite while dumping (default)\n"); } int @@ -780,23 +782,38 @@ main (int argc, char **argv) int opt; const char *p = ""; DWORD pid; + char win32_name [MAX_PATH]; - while ((opt = getopt (argc, argv, "dc:")) != EOF) + while ((opt = getopt (argc, argv, "dq")) != EOF) switch (opt) { case 'd': verbose = TRUE; break; - case 'c': - char win32_name[MAX_PATH]; - cygwin_conv_to_win32_path (optarg, win32_name); - if ((p = strrchr (win32_name, '\\'))) - p++; - else - p = win32_name; + case 'q': + verbose = FALSE; + break; + default: + usage (); break; } + if (argv && *(argv + optind) && *(argv + optind +1)) + { + *win32_name = '\0'; + cygwin_conv_to_win32_path (*(argv + optind), win32_name); + if ((p = strrchr (win32_name, '\\'))) + p++; + else + p = win32_name; + pid = atoi (*(argv + optind + 1)); + } + else + { + usage (); + return -1; + } + char *core_file = (char *) malloc (strlen (p) + sizeof (".core")); if (!core_file) { @@ -805,14 +822,6 @@ main (int argc, char **argv) } sprintf (core_file, "%s.core", p); - if (argv && *(argv + optind)) - pid = atoi (*(argv + optind)); - else - { - usage (); - return -1; - } - DWORD tid = 0; if (verbose)