Make find_runtime_tools available for non-Chrome executables.

BUG=123750
TEST=None
NOTRY=True

Review URL: https://codereview.chromium.org/299753007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271872 0039d316-1c4b-4281-b951-d872f2087c98
parent 2d996c29
......@@ -154,6 +154,9 @@ def prepare_symbol_info(maps_path,
for target_path, host_path in alternative_dirs.iteritems():
if entry.name.startswith(target_path):
binary_path = entry.name.replace(target_path, host_path, 1)
if not (ProcMaps.EXECUTABLE_PATTERN.match(binary_path) or
(os.path.isfile(binary_path) and os.access(binary_path, os.X_OK))):
continue
nm_filename = _dump_command_result(
'nm -n --format bsd %s | c++filt' % binary_path,
output_dir_path, os.path.basename(binary_path), '.nm')
......
......@@ -310,6 +310,9 @@ class ProcMaps(object):
r'^([a-f0-9]+)-([a-f0-9]+)\s+(.)(.)(.)(.)\s+([a-f0-9]+)\s+(\S+):(\S+)\s+'
r'(\d+)\s*(.*)$', re.IGNORECASE)
EXECUTABLE_PATTERN = re.compile(
r'\S+\.(so|dll|dylib|bundle)((\.\d+)+\w*(\.\d+){0,3})?')
def __init__(self):
self._sorted_indexes = []
self._dictionary = {}
......@@ -373,22 +376,16 @@ class ProcMaps(object):
@staticmethod
def constants(entry):
return (entry.writable == '-' and entry.executable == '-' and re.match(
'\S+(\.(so|dll|dylib|bundle)|chrome)((\.\d+)+\w*(\.\d+){0,3})?',
entry.name))
return entry.writable == '-' and entry.executable == '-'
@staticmethod
def executable(entry):
return (entry.executable == 'x' and re.match(
'\S+(\.(so|dll|dylib|bundle)|chrome)((\.\d+)+\w*(\.\d+){0,3})?',
entry.name))
return entry.executable == 'x'
@staticmethod
def executable_and_constants(entry):
return (((entry.writable == '-' and entry.executable == '-') or
entry.executable == 'x') and re.match(
'\S+(\.(so|dll|dylib|bundle)|chrome)((\.\d+)+\w*(\.\d+){0,3})?',
entry.name))
return ((entry.writable == '-' and entry.executable == '-') or
entry.executable == 'x')
def _append_entry(self, entry):
if self._sorted_indexes and self._sorted_indexes[-1] > entry.begin:
......
......@@ -83,21 +83,21 @@ class ProcMapsTest(unittest.TestCase):
def test_constants(self):
maps = ProcMaps.load_file(cStringIO.StringIO(self._TEST_PROCMAPS))
selected = [4, 7]
selected = [0, 2, 4, 7]
for index, entry in enumerate(maps.iter(ProcMaps.constants)):
self.assertEqual(entry.as_dict(),
self._expected_as_dict(selected[index]))
def test_executable(self):
maps = ProcMaps.load_file(cStringIO.StringIO(self._TEST_PROCMAPS))
selected = [3, 6]
selected = [1, 3, 6, 9]
for index, entry in enumerate(maps.iter(ProcMaps.executable)):
self.assertEqual(entry.as_dict(),
self._expected_as_dict(selected[index]))
def test_executable_and_constants(self):
maps = ProcMaps.load_file(cStringIO.StringIO(self._TEST_PROCMAPS))
selected = [3, 4, 6, 7]
selected = [0, 1, 2, 3, 4, 6, 7, 9]
for index, entry in enumerate(maps.iter(ProcMaps.executable_and_constants)):
self.assertEqual(entry.as_dict(),
self._expected_as_dict(selected[index]))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment