Changeset 77994 in webkit


Ignore:
Timestamp:
Feb 8, 2011 4:48:35 PM (13 years ago)
Author:
dpranke@chromium.org
Message:

2011-02-08 Dirk Pranke <dpranke@chromium.org>

Reviewed by Mihai Parparita.

new-run-webkit-tests: split out thread stack logging code into a sharable module

This patch splits out the code used to find and log thread
stacks from NRWT-specific packages to something generic and
shareable by other python modules. It will be shared in the near
future by the manager_worker_broker module, for example.

https://bugs.webkit.org/show_bug.cgi?id=53656

  • Scripts/webkitpy/common/system/stack_utils.py: Added.
  • Scripts/webkitpy/common/system/stack_utils_unittest.py: Added.
  • Scripts/webkitpy/layout_tests/layout_package/message_broker.py:
  • Scripts/webkitpy/layout_tests/layout_package/message_broker_unittest.py:
Location:
trunk/Tools
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r77992 r77994  
     12011-02-08  Dirk Pranke  <dpranke@chromium.org>
     2
     3        Reviewed by Mihai Parparita.
     4
     5        new-run-webkit-tests: split out thread stack logging code into a sharable module
     6
     7        This patch splits out the code used to find and log thread
     8        stacks from NRWT-specific packages to something generic and
     9        shareable by other python modules. It will be shared in the near
     10        future by the manager_worker_broker module, for example.
     11
     12        https://bugs.webkit.org/show_bug.cgi?id=53656
     13
     14        * Scripts/webkitpy/common/system/stack_utils.py: Added.
     15        * Scripts/webkitpy/common/system/stack_utils_unittest.py: Added.
     16        * Scripts/webkitpy/layout_tests/layout_package/message_broker.py:
     17        * Scripts/webkitpy/layout_tests/layout_package/message_broker_unittest.py:
     18
    1192011-02-08  Dirk Pranke  <dpranke@chromium.org>
    220
  • trunk/Tools/Scripts/webkitpy/layout_tests/layout_package/message_broker.py

    r77586 r77994  
    4242
    4343import logging
    44 import sys
    4544import time
    46 import traceback
     45
     46from webkitpy.common.system import stack_utils
    4747
    4848import dump_render_tree_thread
     
    153153                    next_timeout = thread.next_timeout()
    154154                    if next_timeout and t > next_timeout:
    155                         log_wedged_worker(thread.getName(), thread.id())
     155                        stack_utils.log_thread_state(_log.error, thread.getName(), thread.id(), "is wedged")
    156156                        thread.clear_next_timeout()
    157157                        wedged_threads.add(thread)
     
    177177        for thread in threads:
    178178            thread.cancel()
    179 
    180 
    181 def log_wedged_worker(name, id):
    182     """Log information about the given worker state."""
    183     stack = _find_thread_stack(id)
    184     assert(stack is not None)
    185     _log.error("")
    186     _log.error("%s (tid %d) is wedged" % (name, id))
    187     _log_stack(stack)
    188     _log.error("")
    189 
    190 
    191 def _find_thread_stack(id):
    192     """Returns a stack object that can be used to dump a stack trace for
    193     the given thread id (or None if the id is not found)."""
    194     for thread_id, stack in sys._current_frames().items():
    195         if thread_id == id:
    196             return stack
    197     return None
    198 
    199 
    200 def _log_stack(stack):
    201     """Log a stack trace to log.error()."""
    202     for filename, lineno, name, line in traceback.extract_stack(stack):
    203         _log.error('File: "%s", line %d, in %s' % (filename, lineno, name))
    204         if line:
    205             _log.error('  %s' % line.strip())
  • trunk/Tools/Scripts/webkitpy/layout_tests/layout_package/message_broker_unittest.py

    r77595 r77994  
    9191        self._next_timeout = None
    9292
    93 
    9493class TestHandler(logging.Handler):
    9594    def __init__(self, astream):
     
    158157        self.assertRaises(ValueError, self.run_one_thread, 'Exception')
    159158
    160     def test_find_thread_stack_found(self):
    161         id, stack = sys._current_frames().items()[0]
    162         found_stack = message_broker._find_thread_stack(id)
    163         self.assertNotEqual(found_stack, None)
    164 
    165     def test_find_thread_stack_not_found(self):
    166         found_stack = message_broker._find_thread_stack(0)
    167         self.assertEqual(found_stack, None)
    168 
    169159
    170160if __name__ == '__main__':
Note: See TracChangeset for help on using the changeset viewer.