[lldb/test] Fix TestScriptedProcess.py timeout on x86_64

This patch fixes a timeout issue on the ScriptedProcess test that was
happening on intel platforms. The timeout was due to a misreporting of
the StopInfo in the ScriptedThread that caused the ScriptedProcess to
never stop.

To solve this, this patch changes the way a ScriptedThread reports its
stop reason by making it more architecture specific. In order to do so,
this patch also refactors the ScriptedProcess & ScriptedThread
initializer methods to provide an easy access to the target architecture.

Differential Revision: https://reviews.llvm.org/D118484

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
This commit is contained in:
Med Ismail Bennani
2022-02-08 14:43:36 -08:00
parent 48d889079a
commit f5e5074c40
4 changed files with 110 additions and 81 deletions

View File

@@ -196,6 +196,22 @@ class ScriptedProcesTestCase(TestBase):
self.assertTrue(thread, "Invalid thread.")
self.assertEqual(thread.GetName(), "StackCoreScriptedThread.thread-2")
self.assertTrue(target.triple, "Invalid target triple")
arch = target.triple.split('-')[0]
supported_arch = ['x86_64', 'arm64', 'arm64e']
self.assertIn(arch, supported_arch)
# When creating a corefile of a arm process, lldb saves the exception
# that triggers the breakpoint in the LC_NOTES of the corefile, so they
# can be reloaded with the corefile on the next debug session.
if arch in 'arm64e':
self.assertTrue(thread.GetStopReason(), lldb.eStopReasonException)
# However, it's architecture specific, and corefiles made from intel
# process don't save any metadata to retrieve to stop reason.
# To mitigate this, the StackCoreScriptedProcess will report a
# eStopReasonSignal with a SIGTRAP, mimicking what debugserver does.
else:
self.assertTrue(thread.GetStopReason(), lldb.eStopReasonSignal)
self.assertEqual(thread.GetNumFrames(), 6)
frame = thread.GetSelectedFrame()
self.assertTrue(frame, "Invalid frame.")