diff options
| author | Med Ismail Bennani <medismail.bennani@gmail.com> | 2022-02-08 14:43:36 -0800 |
|---|---|---|
| committer | Med Ismail Bennani <medismail.bennani@gmail.com> | 2022-02-09 13:28:20 -0800 |
| commit | f5e5074c40be29d3a0c5d4ac616df8e61e4ddc63 (patch) | |
| tree | 29030d4999d828921883e8f8a8e28acafef84028 /lldb/test/API/functionalities/scripted_process | |
| parent | 48d889079a8a050bb41defd5688e0b213c1c5655 (diff) | |
| download | llvm-f5e5074c40be29d3a0c5d4ac616df8e61e4ddc63.tar.gz llvm-f5e5074c40be29d3a0c5d4ac616df8e61e4ddc63.tar.bz2 llvm-f5e5074c40be29d3a0c5d4ac616df8e61e4ddc63.zip | |
[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>
Diffstat (limited to 'lldb/test/API/functionalities/scripted_process')
3 files changed, 32 insertions, 10 deletions
diff --git a/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py b/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py index 2e80f74622fb..c8ce37c24d49 100644 --- a/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py +++ b/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py @@ -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.") diff --git a/lldb/test/API/functionalities/scripted_process/invalid_scripted_process.py b/lldb/test/API/functionalities/scripted_process/invalid_scripted_process.py index 0a2977c69d45..b5e8ece8b10f 100644 --- a/lldb/test/API/functionalities/scripted_process/invalid_scripted_process.py +++ b/lldb/test/API/functionalities/scripted_process/invalid_scripted_process.py @@ -54,7 +54,7 @@ class InvalidScriptedThread(ScriptedThread): def get_stop_reason(self) -> Dict[str, Any]: return { "type": lldb.eStopReasonSignal, "data": { - "signal": signal.SIGINT + "signal": signal.SIGTRAP } } def get_stackframes(self): diff --git a/lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py b/lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py index 1fabcf464e7d..b0ea6f68e9c7 100644 --- a/lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py +++ b/lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py @@ -30,6 +30,9 @@ class StackCoreScriptedProcess(ScriptedProcess): self.threads[corefile_thread.GetThreadID()] = StackCoreScriptedThread(self, structured_data) + if len(self.threads) == 3: + self.threads[len(self.threads) - 1].is_stopped = True + def get_memory_region_containing_address(self, addr: int) -> lldb.SBMemoryRegionInfo: mem_region = lldb.SBMemoryRegionInfo() error = self.corefile_process.GetMemoryRegionInfo(addr, mem_region) @@ -80,6 +83,7 @@ class StackCoreScriptedThread(ScriptedThread): super().__init__(process, args) backing_target_idx = args.GetValueForKey("backing_target_idx") thread_idx = args.GetValueForKey("thread_idx") + self.is_stopped = False def extract_value_from_structured_data(data, default_val): if data and data.IsValid(): @@ -119,17 +123,19 @@ class StackCoreScriptedThread(ScriptedThread): def get_stop_reason(self) -> Dict[str, Any]: stop_reason = { "type": lldb.eStopReasonInvalid, "data": { }} - if self.corefile_thread and self.corefile_thread.IsValid: - stop_reason["type"] = self.corefile_thread.GetStopReason() + if self.corefile_thread and self.corefile_thread.IsValid() \ + and self.get_thread_id() == self.corefile_thread.GetThreadID(): + stop_reason["type"] = lldb.eStopReasonNone - if self.corefile_thread.GetStopReasonDataCount() > 0: - if stop_reason["type"] == lldb.eStopReasonBreakpoint: - stop_reason["data"]["break_id"] = self.corefile_thread.GetStopReasonDataAtIndex(0) - stop_reason["data"]["break_loc_id"] = self.corefile_thread.GetStopReasonDataAtIndex(1) - elif stop_reason["type"] == lldb.eStopReasonSignal: - stop_reason["data"]["signal"] = signal.SIGINT - elif stop_reason["type"] == lldb.eStopReasonException: + if self.is_stopped: + if 'arm64' in self.scripted_process.arch: + stop_reason["type"] = lldb.eStopReasonException stop_reason["data"]["desc"] = self.corefile_thread.GetStopDescription(100) + elif self.scripted_process.arch == 'x86_64': + stop_reason["type"] = lldb.eStopReasonSignal + stop_reason["data"]["signal"] = signal.SIGTRAP + else: + stop_reason["type"] = self.corefile_thread.GetStopReason() return stop_reason |
