Fossil SCM

Make it possible to debug child processes on Windows.

mistachkin 2018-08-07 23:03 trunk
Commit e285341f0cf07735f0b3ff22f83286f3fab23e3049a31c605077628c548f94ed
2 files changed +21 +4
+21
--- src/main.c
+++ src/main.c
@@ -20,10 +20,11 @@
2020
*/
2121
#include "VERSION.h"
2222
#include "config.h"
2323
#if defined(_WIN32)
2424
# include <windows.h>
25
+# define GETPID (int)GetCurrentProcessId
2526
#endif
2627
#include "main.h"
2728
#include <string.h>
2829
#include <time.h>
2930
#include <fcntl.h>
@@ -30,10 +31,13 @@
3031
#include <sys/types.h>
3132
#include <sys/stat.h>
3233
#include <stdlib.h> /* atexit() */
3334
#if !defined(_WIN32)
3435
# include <errno.h> /* errno global */
36
+# include <unistd.h>
37
+# include <signal.h>
38
+# define GETPID getpid
3539
#endif
3640
#ifdef FOSSIL_ENABLE_SSL
3741
# include "openssl/crypto.h"
3842
#endif
3943
#if defined(FOSSIL_ENABLE_MINIZ)
@@ -599,10 +603,27 @@
599603
#endif
600604
{
601605
const char *zCmdName = "unknown";
602606
const CmdOrPage *pCmd = 0;
603607
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
604625
605626
fossil_limit_memory(1);
606627
if( sqlite3_libversion_number()<3014000 ){
607628
fossil_panic("Unsuitable SQLite version %s, must be at least 3.14.0",
608629
sqlite3_libversion());
609630
--- 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
--- www/env-opts.md
+++ www/env-opts.md
@@ -119,10 +119,14 @@
119119
used as the location of the `~/.fossil` file.
120120
121121
`EDITOR`: Name the editor to use for check-in and stash comments.
122122
Overridden by the local or global `editor` setting or the `VISUAL`
123123
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.
124128
125129
`FOSSIL_FORCE_TICKET_MODERATION`: If set, *ALL* changes for tickets
126130
will be required to go through moderation (even those performed by the
127131
local interactive user via the command line). This can be useful for
128132
local (or remote) testing of the moderation subsystem and its impact
129133
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button