summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2009-01-08 17:52:15 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2009-01-08 17:52:15 +0000
commit2e68619a9f31985b9d45441a46a33e2fdc542141 (patch)
tree1cb075320f821f48c0b15e4ffd4754bcf25718b7
parentc577ac1a31a8ae385405088e7faf475229f03ab1 (diff)
downloadswig-2e68619a9f31985b9d45441a46a33e2fdc542141.tar.gz
add some missing stats and logging
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11039 626c5289-ae23-0410-ae9c-e8d60b6d4f22
-rw-r--r--CCache/ccache.c11
-rw-r--r--CCache/ccache.h1
-rw-r--r--CCache/execute.c12
-rw-r--r--CCache/stats.c1
4 files changed, 15 insertions, 10 deletions
diff --git a/CCache/ccache.c b/CCache/ccache.c
index 0de4e4136..d1696da88 100644
--- a/CCache/ccache.c
+++ b/CCache/ccache.c
@@ -125,6 +125,7 @@ static void failed(void)
if ((e=getenv("CCACHE_PREFIX"))) {
char *p = find_executable(e, MYNAME);
if (!p) {
+ cc_log("could not find executable (%s)\n", e);
perror(e);
exit(1);
}
@@ -535,8 +536,8 @@ static void find_hash(ARGS *args)
correct i_tmpfile */
path_stdout = x_strdup(input_file);
if (create_empty_file(path_stderr) != 0) {
- stats_update(STATS_ERROR);
cc_log("failed to create empty stderr file\n");
+ stats_update(STATS_ERROR);
failed();
}
status = 0;
@@ -592,6 +593,7 @@ static void find_hash(ARGS *args)
char *p;
if (create_dir(hash_dir) != 0) {
cc_log("failed to create %s\n", hash_dir);
+ stats_update(STATS_ERROR);
failed();
}
x_asprintf(&p, "%s/%c", hash_dir, s[i]);
@@ -600,6 +602,7 @@ static void find_hash(ARGS *args)
}
if (create_dir(hash_dir) != 0) {
cc_log("failed to create %s\n", hash_dir);
+ stats_update(STATS_ERROR);
failed();
}
x_asprintf(&hashname, "%s/%s", hash_dir, s+nlevels);
@@ -785,6 +788,7 @@ static void find_compiler(int argc, char **argv)
/* can't find the compiler! */
if (!orig_args->argv[0]) {
stats_update(STATS_COMPILER);
+ cc_log("could not find compiler (%s)\n", base);
perror(base);
exit(1);
}
@@ -1069,6 +1073,7 @@ static void process_args(int argc, char **argv)
if (p) {
if (strlen(p) < 2) {
+ cc_log("badly formed dependency file %s\n", output_file);
stats_update(STATS_ARGS);
failed();
return;
@@ -1105,6 +1110,8 @@ static void process_args(int argc, char **argv)
if ((e=getenv("CCACHE_PREFIX"))) {
char *p = find_executable(e, MYNAME);
if (!p) {
+ cc_log("could not find executable (%s)\n", e);
+ stats_update(STATS_ENVIRONMMENT);
perror(e);
exit(1);
}
@@ -1288,6 +1295,7 @@ static void setup_uncached_err(void)
uncached_fd = dup(2);
if (uncached_fd == -1) {
cc_log("dup(2) failed\n");
+ stats_update(STATS_ERROR);
failed();
}
@@ -1296,6 +1304,7 @@ static void setup_uncached_err(void)
if (putenv(buf) == -1) {
cc_log("putenv failed\n");
+ stats_update(STATS_ERROR);
failed();
}
}
diff --git a/CCache/ccache.h b/CCache/ccache.h
index e95a92c43..668ce8288 100644
--- a/CCache/ccache.h
+++ b/CCache/ccache.h
@@ -84,6 +84,7 @@ enum stats {
STATS_NOTC,
STATS_DEVICE,
STATS_NOINPUT,
+ STATS_ENVIRONMMENT,
STATS_MULTIPLE,
STATS_CONFTEST,
STATS_UNSUPPORTED,
diff --git a/CCache/execute.c b/CCache/execute.c
index 5a5592bf5..165b91e66 100644
--- a/CCache/execute.c
+++ b/CCache/execute.c
@@ -123,9 +123,7 @@ int execute(char **argv,
std_od = _dup(1);
fd = _open(path_stdout, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666);
if (fd == -1) {
- status = STATUS_NOCACHE;
- cc_log("stdout error: failed to open %s\n", path_stdout);
- goto out;
+ exit(STATUS_NOCACHE);
}
_dup2(fd, 1);
_close(fd);
@@ -134,9 +132,7 @@ int execute(char **argv,
fd = _open(path_stderr, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666);
std_ed = _dup(2);
if (fd == -1) {
- status = STATUS_NOCACHE;
- cc_log("stderr error: failed to open %s\n", path_stderr);
- goto out;
+ exit(STATUS_NOCACHE);
}
_dup2(fd, 2);
_close(fd);
@@ -144,9 +140,6 @@ int execute(char **argv,
/* Spawn process (_exec* familly doesn't return) */
status = _spawnv(_P_WAIT, argv[0], (const char **)argv);
-out:
- if (status == -1) cc_log("Error %i: %s\n", errno, strerror(errno));
-
/* Restore descriptors */
if (std_od != -1) _dup2(std_od, 1);
if (std_ed != -1) _dup2(std_ed, 2);
@@ -235,6 +228,7 @@ char *find_executable(const char *name, const char *exclude_name)
}
if (!path) {
cc_log("no PATH variable!?\n");
+ stats_update(STATS_ENVIRONMMENT);
return NULL;
}
diff --git a/CCache/stats.c b/CCache/stats.c
index f87264794..92bc4a835 100644
--- a/CCache/stats.c
+++ b/CCache/stats.c
@@ -55,6 +55,7 @@ static struct {
{ STATS_OUTSTDOUT, "output to stdout ", NULL, 0 },
{ STATS_DEVICE, "output to a non-regular file ", NULL, 0 },
{ STATS_NOINPUT, "no input file ", NULL, 0 },
+ { STATS_ENVIRONMMENT, "error due to bad env variable ", NULL, 0 },
{ STATS_NUMFILES, "files in cache ", NULL, FLAG_NOZERO|FLAG_ALWAYS },
{ STATS_TOTALSIZE, "cache size ", display_size , FLAG_NOZERO|FLAG_ALWAYS },
{ STATS_MAXFILES, "max files ", NULL, FLAG_NOZERO },