summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorklarlund <klarlund@01de4be4-8c4a-0410-9132-4925637da917>2008-06-02 19:35:26 +0000
committerklarlund <klarlund@01de4be4-8c4a-0410-9132-4925637da917>2008-06-02 19:35:26 +0000
commitef156006e39b1144e96ac121513d6ee7659edca3 (patch)
treec3607b7a85aeb28a0190d1a8d1f8e7563e601d64
parent1a6d0aba13bf3f365b15e173b363edf893eed879 (diff)
downloaddistcc-ef156006e39b1144e96ac121513d6ee7659edca3.tar.gz
Fix option real_path_warning_re not working.
I renamed the option to path_observation_re. Now by prefixing INCLUDE_SERVER_ARGS='-d1 --path_observation_re="/usr/.*"' to say make include-server-maintainer-check, one gets a message each time the include server finds a path whose realpath name matches the regular expression. That results in messages like: WARNING include server: For translation unit 'src/testtmp.c', lookup of file 'bits/stdio_lim.h' resolved to '/usr/include/bits/stdio_lim.h' whose realpath is '/usr/include/bits/stdio_lim.h'. To make the interpretation of quoted arguments within INCLUDE_SERVER_ARGS correct, I added 'eval' to the command that cranks up the include server. I remembered to put extra quoted quotes inside the parameters that should be considered a token after the double interpretation that eval implies. git-svn-id: http://distcc.googlecode.com/svn/trunk@436 01de4be4-8c4a-0410-9132-4925637da917
-rwxr-xr-xinclude_server/basics.py9
-rwxr-xr-xinclude_server/cache_basics.py36
-rwxr-xr-xinclude_server/include_server.py34
-rwxr-xr-xpump.in21
4 files changed, 51 insertions, 49 deletions
diff --git a/include_server/basics.py b/include_server/basics.py
index 327b952..87c16d1 100755
--- a/include_server/basics.py
+++ b/include_server/basics.py
@@ -203,7 +203,7 @@ opt_debug_pattern = 1 # see DEBUG below
opt_email_bound = MAX_EMAILS_TO_SEND
opt_exact_analysis = False # use CPP instead of include analyzer
opt_print_times = False
-opt_realpath_warning_re = None
+opt_path_observation_re = None
opt_send_email = False
opt_simple_algorithm = False
opt_stat_reset_triggers = {}
@@ -226,13 +226,6 @@ def Stamp(path):
return None
-# REALPATH WARNINGS
-
-BAD_REALPATH_WARNING_MSG = (
- """For translation unit '%s' while processing '%s': lookup of file '%s' """
- """resolved to '%s' whose realpath is '%s'.""")
-
-
# LANGUAGES AND FILE EXTENSIONS
# The languages that we recognize.
diff --git a/include_server/cache_basics.py b/include_server/cache_basics.py
index d7c98c2..c7a936c 100755
--- a/include_server/cache_basics.py
+++ b/include_server/cache_basics.py
@@ -639,7 +639,7 @@ class BuildStatCache(object):
self.includepath_map = includepath_map
self.directory_map = directory_map
self.realpath_map = realpath_map
- self.bad_realpath_tuples = []
+ self.path_observations = []
def _Verify(self, currdir_idx, searchdir_idx, includepath_idx):
"""Verify that the cached result is the same as obtained by stat call.
@@ -669,21 +669,18 @@ class BuildStatCache(object):
really_exists and "exists" or "does not exist",
cache_exists and "existed" or "did not exist"))
- def GetAndClearBadResolutions(self):
- """Return descriptions of resolutions matching realpath warning regexp.
- Returns:
- a list of tuples of the form
- (include_path, resolved_path, real_path)
- where include_path is the argument of an #include (or an initial file),
- resolved_path is the concatenation of the searchdir where the
- include_path is found with this include_path, and real_path is the
- realpath of this location (relative to the current directory).
- The list is reset to [] with this operation. Thus the items returned are
- those that occcurred since the last time this method was invoked.
+ def WarnAboutPathObservations(self, translation_unit):
+ """Print new paths found according to path observation expression option.
+
+ Args:
+ translation_unit: a string embedded in warning
"""
- bad_realpath_tuples = self.bad_realpath_tuples
- self.bad_realpath_tuples = []
- return bad_realpath_tuples
+ for (includepath, relpath, realpath) in self.path_observations:
+ Debug(DEBUG_WARNING,
+ "For translation unit '%s',"
+ " lookup of file '%s' resolved to '%s' whose realpath is '%s'.",
+ translation_unit, includepath, relpath, realpath)
+ self.path_observations = []
def Resolve(self, includepath_idx, currdir_idx, searchdir_idx,
searchlist_idxs):
@@ -786,12 +783,11 @@ class BuildStatCache(object):
realpath_idx = searchdir_realpaths[sl_idx] = (
self.realpath_map.Index(rpath))
# This is the place to catch errant files according to user defined
- # abspath_warning option. See documentation for method
- # GetAndClearBadResolutions.
- if basics.opt_realpath_warning_re:
+ # regular expression path_observation_re.
+ if basics.opt_path_observation_re:
realpath = self.realpath_map.string[realpath_idx]
- if basics.opt_realpath_warning_re.search(realpath):
- self.bad_realpath_tuples.append((includepath, relpath, realpath))
+ if basics.opt_path_observation_re.search(realpath):
+ self.path_observations.append((includepath, relpath, realpath))
return ((sl_idx, includepath_idx), realpath_idx)
else:
searchdir_stats[sl_idx] = False
diff --git a/include_server/include_server.py b/include_server/include_server.py
index a6b5960..aac3268 100755
--- a/include_server/include_server.py
+++ b/include_server/include_server.py
@@ -26,21 +26,22 @@ __author__ = "Nils Klarlund"
# Python imports
import gc
+import getopt
+import glob
import os
import re
-import sys
-import glob
+import shutil
import signal
-import getopt
+import SocketServer
+import sys
import tempfile
import traceback
-import SocketServer
# Include server imports
import basics
-import statistics
-import include_analyzer_memoizing_node
import distcc_pump_c_extensions
+import include_analyzer_memoizing_node
+import statistics
# The default size passed to listen by a streaming socket server of
# SocketServer is only 5. Make it 128 (which appears to be the hard
@@ -62,7 +63,7 @@ NotCoveredTimeOutError = basics.NotCoveredTimeOutError
def Usage():
print """Usage:
-include_server --port INCLUDE_SERVER_PORT [options]
+include_server --port INCLUDE_SERVER_PORT [OPTIONS]
where INCLUDE_SERVER_PORT is a socket name. Fork the include server
for incremental include analysis. The include server answers queries
@@ -70,7 +71,7 @@ from the distcc client about which files to include in a C/C++
compilation. This command itself terminates as soon as the include
server has been spawned.
-Options:
+OPTIONS:
--pid_file FILEPATH The pid of the include server is written to file
FILEPATH.
@@ -87,10 +88,12 @@ Options:
--email_bound NUMBER Maximal number of emails to send (in addition to
a final email). Default: 3.
- --realpath_warning_re=RE Write a warning to stderr whenever a filename is
+ --path_observation_re=RE Issue warning message whenever a filename is
resolved to a realpath that is matched by RE,
which is a regular expression in Python syntax.
- (Warnings must be enabled with at least -d1.)
+ This is useful for finding out where files included
+ actually come from. Use RE="" to find them all.
+ Note: warnings must be enabled with at least -d1.
--stat_reset_triggers=LIST Flush stat caches when the timestamp of any
filepath in LIST changes or the filepath comes in
@@ -441,12 +444,15 @@ def DistccIncludeHandlerGenerator(include_analyzer):
else:
# No exception raised, include closure can be trusted.
distcc_pump_c_extensions.XArgv(self.wfile.fileno(), files_and_links)
+ # Print out observed paths.
+ if basics.opt_path_observation_re:
+ include_analyzer.build_stat_cache.WarnAboutPathObservations(
+ include_analyzer.translation_unit)
# Finally, stop the clock and report statistics if needed.
statistics.EndTiming()
if basics.opt_statistics:
statistics.PrintStatistics(include_analyzer)
-
return IncludeHandler
@@ -469,9 +475,9 @@ def _ParseCommandLineOptions():
"no-email",
"email_bound=",
"exact_analysis",
+ "path_observation_re=",
"stat_reset_triggers=",
"simple_algorithm",
- "realpath_warning_re=",
"statistics",
"time",
"unsafe_absolute_includes",
@@ -497,8 +503,8 @@ def _ParseCommandLineOptions():
basics.opt_send_email = False
if opt in ("--email_bound",):
basics.opt_email_bound = int(arg)
- if opt in ("--realpath_warning_re",):
- basics.opt_realpath_warning_re = re.compile(arg)
+ if opt in ("--path_observation_re",):
+ basics.opt_path_observation_re = re.compile(arg)
if opt in ("--stat_reset_triggers",):
basics.opt_stat_reset_triggers = (
dict([ (glob_expr,
diff --git a/pump.in b/pump.in
index 0618efa..987a41f 100755
--- a/pump.in
+++ b/pump.in
@@ -275,15 +275,22 @@ StartIncludeServer() {
esac
if [ -z "$PYTHONOPTIMIZE" ]; then PYTHONOPTIMIZE=1; fi
+ # We use 'eval' so that INCLUDE_SERVER_ARGS can use shell quoting such
+ # as in:
+ #
+ # INCLUDE_SERVER_ARGS='--stat_reset_triggers="*"'
+ #
+ # which will pass '*' to the include server (that is, the string consisting
+ # of one asterisk) without filename expansion.
PYTHONOPTIMIZE=$PYTHONOPTIMIZE \
PYTHONPATH="$pythonpath::$PYTHONPATH" \
- $PYTHON \
- "$include_server" \
- --port "$socket" \
- --pid_file "$tmp_pid_file" \
- --email \
- --email_bound=5 \
- -d1 \
+ eval "'$PYTHON'" \
+ "'$include_server'" \
+ --port "'$socket'" \
+ --pid_file "'$tmp_pid_file'" \
+ --email \
+ --email_bound=5 \
+ -d1 \
$INCLUDE_SERVER_ARGS
)