Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Unified Diff: build/android/test_runner.py

Issue 59873011: Add threads stack dumping feature (through SIGUSR1) to test_runner.py. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/test_runner.py
diff --git a/build/android/test_runner.py b/build/android/test_runner.py
index fa3e785da34a5a24b564aa5875467cc2f7343d93..ea6ef0917ba9958da2f46f297e0a3a9628700b78 100755
--- a/build/android/test_runner.py
+++ b/build/android/test_runner.py
@@ -11,7 +11,10 @@ import logging
import optparse
import os
import shutil
+import signal
import sys
+import threading
+import traceback
from pylib import android_commands
from pylib import constants
@@ -793,7 +796,23 @@ VALID_COMMANDS = {
}
+def DumpThreadStacks(signal, frame):
+ thread_names_map = dict(
+ [(thread.ident, thread.name) for thread in threading.enumerate()])
+ lines = []
+ for thread_id, stack in sys._current_frames().items():
+ lines.append(
+ '\n# Thread: %s (%d)' % (
+ thread_names_map.get(thread_id, ''), thread_id))
+ for filename, lineno, name, line in traceback.extract_stack(stack):
+ lines.append('File: "%s", line %d, in %s' % (filename, lineno, name))
+ if line:
+ lines.append(' %s' % (line.strip()))
+ print '\n'.join(lines)
+
+
def main(argv):
+ signal.signal(signal.SIGUSR1, DumpThreadStacks)
option_parser = command_option_parser.CommandOptionParser(
commands_dict=VALID_COMMANDS)
return command_option_parser.ParseAndExecute(option_parser)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698