Fossil SCM

Add the --systemtrace option for debugging calls to fossil_system.

drh 2011-05-26 11:57 trunk
Commit 5a4dc2239b5fb3fa86be396fd1de382ccf02afe7
2 files changed +3 -1 +4
+3 -1
--- src/db.c
+++ src/db.c
@@ -1212,11 +1212,13 @@
12121212
}
12131213
}
12141214
}
12151215
static void db_sql_trace(void *notUsed, const char *zSql){
12161216
int n = strlen(zSql);
1217
- fprintf(stderr, "%s%s\n", zSql, (n>0 && zSql[n-1]==';') ? "" : ";");
1217
+ char *zMsg = mprintf("%s%s\n", zSql, (n>0 && zSql[n-1]==';') ? "" : ";");
1218
+ fossil_puts(zMsg, 1);
1219
+ fossil_free(zMsg);
12181220
}
12191221
12201222
/*
12211223
** Implement the user() SQL function. user() takes no arguments and
12221224
** returns the user ID of the current user.
12231225
--- src/db.c
+++ src/db.c
@@ -1212,11 +1212,13 @@
1212 }
1213 }
1214 }
1215 static void db_sql_trace(void *notUsed, const char *zSql){
1216 int n = strlen(zSql);
1217 fprintf(stderr, "%s%s\n", zSql, (n>0 && zSql[n-1]==';') ? "" : ";");
 
 
1218 }
1219
1220 /*
1221 ** Implement the user() SQL function. user() takes no arguments and
1222 ** returns the user ID of the current user.
1223
--- src/db.c
+++ src/db.c
@@ -1212,11 +1212,13 @@
1212 }
1213 }
1214 }
1215 static void db_sql_trace(void *notUsed, const char *zSql){
1216 int n = strlen(zSql);
1217 char *zMsg = mprintf("%s%s\n", zSql, (n>0 && zSql[n-1]==';') ? "" : ";");
1218 fossil_puts(zMsg, 1);
1219 fossil_free(zMsg);
1220 }
1221
1222 /*
1223 ** Implement the user() SQL function. user() takes no arguments and
1224 ** returns the user ID of the current user.
1225
+4
--- src/main.c
+++ src/main.c
@@ -65,10 +65,11 @@
6565
int fSqlTrace; /* True if --sqltrace flag is present */
6666
int fSqlStats; /* True if --sqltrace or --sqlstats are present */
6767
int fSqlPrint; /* True if -sqlprint flag is present */
6868
int fQuiet; /* True if -quiet flag is present */
6969
int fHttpTrace; /* Trace outbound HTTP requests */
70
+ int fSystemTrace; /* Trace calls to fossil_system(), --systemtrace */
7071
int fNoSync; /* Do not do an autosync even. --nosync */
7172
char *zPath; /* Name of webpage being served */
7273
char *zExtra; /* Extra path information past the webpage name */
7374
char *zBaseURL; /* Full text of the URL being served */
7475
char *zTop; /* Parent directory of zPath */
@@ -245,10 +246,11 @@
245246
argv[0], argv[0], argv[0]);
246247
}else{
247248
g.fQuiet = find_option("quiet", 0, 0)!=0;
248249
g.fSqlTrace = find_option("sqltrace", 0, 0)!=0;
249250
g.fSqlStats = find_option("sqlstats", 0, 0)!=0;
251
+ g.fSystemTrace = find_option("systemtrace", 0, 0)!=0;
250252
if( g.fSqlTrace ) g.fSqlStats = 1;
251253
g.fSqlPrint = find_option("sqlprint", 0, 0)!=0;
252254
g.fHttpTrace = find_option("httptrace", 0, 0)!=0;
253255
g.zLogin = find_option("user", "U", 1);
254256
if( find_option("help",0,0)!=0 ){
@@ -431,16 +433,18 @@
431433
/* On windows, we have to put double-quotes around the entire command.
432434
** Who knows why - this is just the way windows works.
433435
*/
434436
char *zNewCmd = mprintf("\"%s\"", zOrigCmd);
435437
char *zMbcs = fossil_utf8_to_mbcs(zNewCmd);
438
+ if( g.fSystemTrace ) fprintf(stderr, "SYSTEM: %s\n", zMbcs);
436439
rc = system(zMbcs);
437440
fossil_mbcs_free(zMbcs);
438441
free(zNewCmd);
439442
#else
440443
/* On unix, evaluate the command directly.
441444
*/
445
+ if( g.fSystemTrace ) fprintf(stderr, "SYSTEM: %s\n", zOrigCmd);
442446
rc = system(zOrigCmd);
443447
#endif
444448
return rc;
445449
}
446450
447451
--- src/main.c
+++ src/main.c
@@ -65,10 +65,11 @@
65 int fSqlTrace; /* True if --sqltrace flag is present */
66 int fSqlStats; /* True if --sqltrace or --sqlstats are present */
67 int fSqlPrint; /* True if -sqlprint flag is present */
68 int fQuiet; /* True if -quiet flag is present */
69 int fHttpTrace; /* Trace outbound HTTP requests */
 
70 int fNoSync; /* Do not do an autosync even. --nosync */
71 char *zPath; /* Name of webpage being served */
72 char *zExtra; /* Extra path information past the webpage name */
73 char *zBaseURL; /* Full text of the URL being served */
74 char *zTop; /* Parent directory of zPath */
@@ -245,10 +246,11 @@
245 argv[0], argv[0], argv[0]);
246 }else{
247 g.fQuiet = find_option("quiet", 0, 0)!=0;
248 g.fSqlTrace = find_option("sqltrace", 0, 0)!=0;
249 g.fSqlStats = find_option("sqlstats", 0, 0)!=0;
 
250 if( g.fSqlTrace ) g.fSqlStats = 1;
251 g.fSqlPrint = find_option("sqlprint", 0, 0)!=0;
252 g.fHttpTrace = find_option("httptrace", 0, 0)!=0;
253 g.zLogin = find_option("user", "U", 1);
254 if( find_option("help",0,0)!=0 ){
@@ -431,16 +433,18 @@
431 /* On windows, we have to put double-quotes around the entire command.
432 ** Who knows why - this is just the way windows works.
433 */
434 char *zNewCmd = mprintf("\"%s\"", zOrigCmd);
435 char *zMbcs = fossil_utf8_to_mbcs(zNewCmd);
 
436 rc = system(zMbcs);
437 fossil_mbcs_free(zMbcs);
438 free(zNewCmd);
439 #else
440 /* On unix, evaluate the command directly.
441 */
 
442 rc = system(zOrigCmd);
443 #endif
444 return rc;
445 }
446
447
--- src/main.c
+++ src/main.c
@@ -65,10 +65,11 @@
65 int fSqlTrace; /* True if --sqltrace flag is present */
66 int fSqlStats; /* True if --sqltrace or --sqlstats are present */
67 int fSqlPrint; /* True if -sqlprint flag is present */
68 int fQuiet; /* True if -quiet flag is present */
69 int fHttpTrace; /* Trace outbound HTTP requests */
70 int fSystemTrace; /* Trace calls to fossil_system(), --systemtrace */
71 int fNoSync; /* Do not do an autosync even. --nosync */
72 char *zPath; /* Name of webpage being served */
73 char *zExtra; /* Extra path information past the webpage name */
74 char *zBaseURL; /* Full text of the URL being served */
75 char *zTop; /* Parent directory of zPath */
@@ -245,10 +246,11 @@
246 argv[0], argv[0], argv[0]);
247 }else{
248 g.fQuiet = find_option("quiet", 0, 0)!=0;
249 g.fSqlTrace = find_option("sqltrace", 0, 0)!=0;
250 g.fSqlStats = find_option("sqlstats", 0, 0)!=0;
251 g.fSystemTrace = find_option("systemtrace", 0, 0)!=0;
252 if( g.fSqlTrace ) g.fSqlStats = 1;
253 g.fSqlPrint = find_option("sqlprint", 0, 0)!=0;
254 g.fHttpTrace = find_option("httptrace", 0, 0)!=0;
255 g.zLogin = find_option("user", "U", 1);
256 if( find_option("help",0,0)!=0 ){
@@ -431,16 +433,18 @@
433 /* On windows, we have to put double-quotes around the entire command.
434 ** Who knows why - this is just the way windows works.
435 */
436 char *zNewCmd = mprintf("\"%s\"", zOrigCmd);
437 char *zMbcs = fossil_utf8_to_mbcs(zNewCmd);
438 if( g.fSystemTrace ) fprintf(stderr, "SYSTEM: %s\n", zMbcs);
439 rc = system(zMbcs);
440 fossil_mbcs_free(zMbcs);
441 free(zNewCmd);
442 #else
443 /* On unix, evaluate the command directly.
444 */
445 if( g.fSystemTrace ) fprintf(stderr, "SYSTEM: %s\n", zOrigCmd);
446 rc = system(zOrigCmd);
447 #endif
448 return rc;
449 }
450
451

Keyboard Shortcuts

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