Fossil SCM
Make it possible to debug child processes on Windows.
Commit
e285341f0cf07735f0b3ff22f83286f3fab23e3049a31c605077628c548f94ed
Parent
7014c2ddf1bd5c7…
2 files changed
+21
+4
+21
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -20,10 +20,11 @@ | ||
| 20 | 20 | */ |
| 21 | 21 | #include "VERSION.h" |
| 22 | 22 | #include "config.h" |
| 23 | 23 | #if defined(_WIN32) |
| 24 | 24 | # include <windows.h> |
| 25 | +# define GETPID (int)GetCurrentProcessId | |
| 25 | 26 | #endif |
| 26 | 27 | #include "main.h" |
| 27 | 28 | #include <string.h> |
| 28 | 29 | #include <time.h> |
| 29 | 30 | #include <fcntl.h> |
| @@ -30,10 +31,13 @@ | ||
| 30 | 31 | #include <sys/types.h> |
| 31 | 32 | #include <sys/stat.h> |
| 32 | 33 | #include <stdlib.h> /* atexit() */ |
| 33 | 34 | #if !defined(_WIN32) |
| 34 | 35 | # include <errno.h> /* errno global */ |
| 36 | +# include <unistd.h> | |
| 37 | +# include <signal.h> | |
| 38 | +# define GETPID getpid | |
| 35 | 39 | #endif |
| 36 | 40 | #ifdef FOSSIL_ENABLE_SSL |
| 37 | 41 | # include "openssl/crypto.h" |
| 38 | 42 | #endif |
| 39 | 43 | #if defined(FOSSIL_ENABLE_MINIZ) |
| @@ -599,10 +603,27 @@ | ||
| 599 | 603 | #endif |
| 600 | 604 | { |
| 601 | 605 | const char *zCmdName = "unknown"; |
| 602 | 606 | const CmdOrPage *pCmd = 0; |
| 603 | 607 | int rc; |
| 608 | + | |
| 609 | +#if !defined(_WIN32_WCE) | |
| 610 | + if( fossil_getenv("FOSSIL_BREAK") ){ | |
| 611 | + if( isatty(0) && isatty(2) ){ | |
| 612 | + fprintf(stderr, | |
| 613 | + "attach debugger to process %d and press any key to continue.\n", | |
| 614 | + GETPID()); | |
| 615 | + fgetc(stdin); | |
| 616 | + }else{ | |
| 617 | +#if defined(_WIN32) || defined(WIN32) | |
| 618 | + DebugBreak(); | |
| 619 | +#elif defined(SIGTRAP) | |
| 620 | + raise(SIGTRAP); | |
| 621 | +#endif | |
| 622 | + } | |
| 623 | + } | |
| 624 | +#endif | |
| 604 | 625 | |
| 605 | 626 | fossil_limit_memory(1); |
| 606 | 627 | if( sqlite3_libversion_number()<3014000 ){ |
| 607 | 628 | fossil_panic("Unsuitable SQLite version %s, must be at least 3.14.0", |
| 608 | 629 | sqlite3_libversion()); |
| 609 | 630 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -20,10 +20,11 @@ | |
| 20 | */ |
| 21 | #include "VERSION.h" |
| 22 | #include "config.h" |
| 23 | #if defined(_WIN32) |
| 24 | # include <windows.h> |
| 25 | #endif |
| 26 | #include "main.h" |
| 27 | #include <string.h> |
| 28 | #include <time.h> |
| 29 | #include <fcntl.h> |
| @@ -30,10 +31,13 @@ | |
| 30 | #include <sys/types.h> |
| 31 | #include <sys/stat.h> |
| 32 | #include <stdlib.h> /* atexit() */ |
| 33 | #if !defined(_WIN32) |
| 34 | # include <errno.h> /* errno global */ |
| 35 | #endif |
| 36 | #ifdef FOSSIL_ENABLE_SSL |
| 37 | # include "openssl/crypto.h" |
| 38 | #endif |
| 39 | #if defined(FOSSIL_ENABLE_MINIZ) |
| @@ -599,10 +603,27 @@ | |
| 599 | #endif |
| 600 | { |
| 601 | const char *zCmdName = "unknown"; |
| 602 | const CmdOrPage *pCmd = 0; |
| 603 | int rc; |
| 604 | |
| 605 | fossil_limit_memory(1); |
| 606 | if( sqlite3_libversion_number()<3014000 ){ |
| 607 | fossil_panic("Unsuitable SQLite version %s, must be at least 3.14.0", |
| 608 | sqlite3_libversion()); |
| 609 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -20,10 +20,11 @@ | |
| 20 | */ |
| 21 | #include "VERSION.h" |
| 22 | #include "config.h" |
| 23 | #if defined(_WIN32) |
| 24 | # include <windows.h> |
| 25 | # define GETPID (int)GetCurrentProcessId |
| 26 | #endif |
| 27 | #include "main.h" |
| 28 | #include <string.h> |
| 29 | #include <time.h> |
| 30 | #include <fcntl.h> |
| @@ -30,10 +31,13 @@ | |
| 31 | #include <sys/types.h> |
| 32 | #include <sys/stat.h> |
| 33 | #include <stdlib.h> /* atexit() */ |
| 34 | #if !defined(_WIN32) |
| 35 | # include <errno.h> /* errno global */ |
| 36 | # include <unistd.h> |
| 37 | # include <signal.h> |
| 38 | # define GETPID getpid |
| 39 | #endif |
| 40 | #ifdef FOSSIL_ENABLE_SSL |
| 41 | # include "openssl/crypto.h" |
| 42 | #endif |
| 43 | #if defined(FOSSIL_ENABLE_MINIZ) |
| @@ -599,10 +603,27 @@ | |
| 603 | #endif |
| 604 | { |
| 605 | const char *zCmdName = "unknown"; |
| 606 | const CmdOrPage *pCmd = 0; |
| 607 | int rc; |
| 608 | |
| 609 | #if !defined(_WIN32_WCE) |
| 610 | if( fossil_getenv("FOSSIL_BREAK") ){ |
| 611 | if( isatty(0) && isatty(2) ){ |
| 612 | fprintf(stderr, |
| 613 | "attach debugger to process %d and press any key to continue.\n", |
| 614 | GETPID()); |
| 615 | fgetc(stdin); |
| 616 | }else{ |
| 617 | #if defined(_WIN32) || defined(WIN32) |
| 618 | DebugBreak(); |
| 619 | #elif defined(SIGTRAP) |
| 620 | raise(SIGTRAP); |
| 621 | #endif |
| 622 | } |
| 623 | } |
| 624 | #endif |
| 625 | |
| 626 | fossil_limit_memory(1); |
| 627 | if( sqlite3_libversion_number()<3014000 ){ |
| 628 | fossil_panic("Unsuitable SQLite version %s, must be at least 3.14.0", |
| 629 | sqlite3_libversion()); |
| 630 |
+4
| --- www/env-opts.md | ||
| +++ www/env-opts.md | ||
| @@ -119,10 +119,14 @@ | ||
| 119 | 119 | used as the location of the `~/.fossil` file. |
| 120 | 120 | |
| 121 | 121 | `EDITOR`: Name the editor to use for check-in and stash comments. |
| 122 | 122 | Overridden by the local or global `editor` setting or the `VISUAL` |
| 123 | 123 | environment variable. |
| 124 | + | |
| 125 | +`FOSSIL_BREAK`: If set, an opportunity will be created to attach a | |
| 126 | +debugger to the Fossil process prior to any significant work being | |
| 127 | +performed. | |
| 124 | 128 | |
| 125 | 129 | `FOSSIL_FORCE_TICKET_MODERATION`: If set, *ALL* changes for tickets |
| 126 | 130 | will be required to go through moderation (even those performed by the |
| 127 | 131 | local interactive user via the command line). This can be useful for |
| 128 | 132 | local (or remote) testing of the moderation subsystem and its impact |
| 129 | 133 |
| --- www/env-opts.md | |
| +++ www/env-opts.md | |
| @@ -119,10 +119,14 @@ | |
| 119 | used as the location of the `~/.fossil` file. |
| 120 | |
| 121 | `EDITOR`: Name the editor to use for check-in and stash comments. |
| 122 | Overridden by the local or global `editor` setting or the `VISUAL` |
| 123 | environment variable. |
| 124 | |
| 125 | `FOSSIL_FORCE_TICKET_MODERATION`: If set, *ALL* changes for tickets |
| 126 | will be required to go through moderation (even those performed by the |
| 127 | local interactive user via the command line). This can be useful for |
| 128 | local (or remote) testing of the moderation subsystem and its impact |
| 129 |
| --- www/env-opts.md | |
| +++ www/env-opts.md | |
| @@ -119,10 +119,14 @@ | |
| 119 | used as the location of the `~/.fossil` file. |
| 120 | |
| 121 | `EDITOR`: Name the editor to use for check-in and stash comments. |
| 122 | Overridden by the local or global `editor` setting or the `VISUAL` |
| 123 | environment variable. |
| 124 | |
| 125 | `FOSSIL_BREAK`: If set, an opportunity will be created to attach a |
| 126 | debugger to the Fossil process prior to any significant work being |
| 127 | performed. |
| 128 | |
| 129 | `FOSSIL_FORCE_TICKET_MODERATION`: If set, *ALL* changes for tickets |
| 130 | will be required to go through moderation (even those performed by the |
| 131 | local interactive user via the command line). This can be useful for |
| 132 | local (or remote) testing of the moderation subsystem and its impact |
| 133 |