diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py --- a/lldb/packages/Python/lldbsuite/test/dotest.py +++ b/lldb/packages/Python/lldbsuite/test/dotest.py @@ -449,6 +449,18 @@ lldbtest_config.codesign_identity = args.codesign_identity +def registerFaulthandler(): + try: + import faulthandler + except ImportError: + # faulthandler is not available until python3 + return + + faulthandler.enable() + # faulthandler.register is not available on Windows. + if getattr(faulthandler, 'register', None): + faulthandler.register(signal.SIGTERM, chain=True) + def setupSysPath(): """ Add LLDB.framework/Resources/Python to the search paths for modules. @@ -875,6 +887,9 @@ # parseOptionsAndInitTestdirs() + # Print a stack trace if the test hangs or is passed SIGTERM. + registerFaulthandler() + setupSysPath() import lldbconfig