Fossil SCM
Add the --systemtrace option for debugging calls to fossil_system.
Commit
5a4dc2239b5fb3fa86be396fd1de382ccf02afe7
Parent
02a6aa2d5e3ea14…
2 files changed
+3
-1
+4
M
src/db.c
+3
-1
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -1212,11 +1212,13 @@ | ||
| 1212 | 1212 | } |
| 1213 | 1213 | } |
| 1214 | 1214 | } |
| 1215 | 1215 | static void db_sql_trace(void *notUsed, const char *zSql){ |
| 1216 | 1216 | 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); | |
| 1218 | 1220 | } |
| 1219 | 1221 | |
| 1220 | 1222 | /* |
| 1221 | 1223 | ** Implement the user() SQL function. user() takes no arguments and |
| 1222 | 1224 | ** returns the user ID of the current user. |
| 1223 | 1225 |
| --- 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 @@ | ||
| 65 | 65 | int fSqlTrace; /* True if --sqltrace flag is present */ |
| 66 | 66 | int fSqlStats; /* True if --sqltrace or --sqlstats are present */ |
| 67 | 67 | int fSqlPrint; /* True if -sqlprint flag is present */ |
| 68 | 68 | int fQuiet; /* True if -quiet flag is present */ |
| 69 | 69 | int fHttpTrace; /* Trace outbound HTTP requests */ |
| 70 | + int fSystemTrace; /* Trace calls to fossil_system(), --systemtrace */ | |
| 70 | 71 | int fNoSync; /* Do not do an autosync even. --nosync */ |
| 71 | 72 | char *zPath; /* Name of webpage being served */ |
| 72 | 73 | char *zExtra; /* Extra path information past the webpage name */ |
| 73 | 74 | char *zBaseURL; /* Full text of the URL being served */ |
| 74 | 75 | char *zTop; /* Parent directory of zPath */ |
| @@ -245,10 +246,11 @@ | ||
| 245 | 246 | argv[0], argv[0], argv[0]); |
| 246 | 247 | }else{ |
| 247 | 248 | g.fQuiet = find_option("quiet", 0, 0)!=0; |
| 248 | 249 | g.fSqlTrace = find_option("sqltrace", 0, 0)!=0; |
| 249 | 250 | g.fSqlStats = find_option("sqlstats", 0, 0)!=0; |
| 251 | + g.fSystemTrace = find_option("systemtrace", 0, 0)!=0; | |
| 250 | 252 | if( g.fSqlTrace ) g.fSqlStats = 1; |
| 251 | 253 | g.fSqlPrint = find_option("sqlprint", 0, 0)!=0; |
| 252 | 254 | g.fHttpTrace = find_option("httptrace", 0, 0)!=0; |
| 253 | 255 | g.zLogin = find_option("user", "U", 1); |
| 254 | 256 | if( find_option("help",0,0)!=0 ){ |
| @@ -431,16 +433,18 @@ | ||
| 431 | 433 | /* On windows, we have to put double-quotes around the entire command. |
| 432 | 434 | ** Who knows why - this is just the way windows works. |
| 433 | 435 | */ |
| 434 | 436 | char *zNewCmd = mprintf("\"%s\"", zOrigCmd); |
| 435 | 437 | char *zMbcs = fossil_utf8_to_mbcs(zNewCmd); |
| 438 | + if( g.fSystemTrace ) fprintf(stderr, "SYSTEM: %s\n", zMbcs); | |
| 436 | 439 | rc = system(zMbcs); |
| 437 | 440 | fossil_mbcs_free(zMbcs); |
| 438 | 441 | free(zNewCmd); |
| 439 | 442 | #else |
| 440 | 443 | /* On unix, evaluate the command directly. |
| 441 | 444 | */ |
| 445 | + if( g.fSystemTrace ) fprintf(stderr, "SYSTEM: %s\n", zOrigCmd); | |
| 442 | 446 | rc = system(zOrigCmd); |
| 443 | 447 | #endif |
| 444 | 448 | return rc; |
| 445 | 449 | } |
| 446 | 450 | |
| 447 | 451 |
| --- 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 |