Commit 503c69a4 authored by David 'Digit' Turner's avatar David 'Digit' Turner Committed by Commit Bot

android: elf_symbolizer.py: Add WaitForIdle() method.

This method of ELFSymbolizer can be used to wait for the
completion of all async tasks, then allow additional ones
to be performed after that.

This is unlike the Join(), which waits for completion then
terminates all addr2line processes immediately, making any
future call to SymbolizeAsync() crash at runtime.

BUG=755225
R=pasko@chromium.org, lizeb@chromium.org, agrieve@chromium.org,jbudorick@chromium.org

Change-Id: Iea50c5e06bf495390dc1bc50a81151e069841175
Reviewed-on: https://chromium-review.googlesource.com/1046846Reviewed-by: default avataragrieve <agrieve@chromium.org>
Commit-Queue: David Turner <digit@chromium.org>
Cr-Commit-Position: refs/heads/master@{#556459}
parent b6d58e56
......@@ -185,6 +185,11 @@ class ELFSymbolizer(object):
a2l.EnqueueRequest(addr, callback_arg)
def WaitForIdle(self):
"""Waits for all the outstanding requests to complete."""
for a2l in self._a2l_instances:
a2l.WaitForIdle()
def Join(self):
"""Waits for all the outstanding requests to complete and terminates."""
for a2l in self._a2l_instances:
......
......@@ -117,6 +117,31 @@ class ELFSymbolizerTest(unittest.TestCase):
symbolizer.Join()
def testWaitForIdle(self):
symbolizer = elf_symbolizer.ELFSymbolizer(
elf_file_path='/path/doesnt/matter/mock_lib1.so',
addr2line_path=_MOCK_A2L_PATH,
callback=self._callback,
max_concurrent_jobs=1)
# Test symbols with valid name but incomplete path.
addr = _INCOMPLETE_MOCK_ADDR
exp_name = 'mock_sym_for_addr_%d' % addr
exp_source_path = None
exp_source_line = None
cb_arg = (addr, exp_name, exp_source_path, exp_source_line, False)
symbolizer.SymbolizeAsync(addr, cb_arg)
symbolizer.WaitForIdle()
# Test symbols with no name or sym info.
addr = _UNKNOWN_MOCK_ADDR
exp_name = None
exp_source_path = None
exp_source_line = None
cb_arg = (addr, exp_name, exp_source_path, exp_source_line, False)
symbolizer.SymbolizeAsync(addr, cb_arg)
symbolizer.Join()
def _RunTest(self, max_concurrent_jobs, num_symbols):
symbolizer = elf_symbolizer.ELFSymbolizer(
elf_file_path='/path/doesnt/matter/mock_lib1.so',
......
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