This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by mib on Jan 28 2022, 9:28 AM.

Details

Summary

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.

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>

Diff Detail

Event Timeline

mib requested review of this revision.Jan 28 2022, 9:28 AM
mib created this revision.
JDevlieghere added inline comments.Jan 28 2022, 10:32 AM
lldb/examples/python/scripted_process/scripted_process.py
314–335

Since you're already modifying these lines, maybe it's worth moving this into a constant. That'll make the class itself a lot more readable.

lldb/test/API/functionalities/scripted_process/invalid_scripted_process.py
57

What's the motivation from switching from SIGINT to SIGTRAP?

lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py
133–142

Can you remind me why we can't read this information from the thread in the core file?

mib marked 2 inline comments as done.Jan 28 2022, 11:13 AM
mib added inline comments.
lldb/test/API/functionalities/scripted_process/invalid_scripted_process.py
57

I don't think this is very important, but reporting it as a SIGTRAP is more in line with what debugserver does for breakpoints.

lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py
133–142

Besides on arm, we don't save any breakpoint info in the core file, so all of the core file threads reports a eStopReasonNone. So when I try to emulate the core file process from a Scripted Process, the scripted process never stops because none of its threads has a stop reason. That's why we have to fake a SIGTRAP for x86_64.

mib updated this revision to Diff 404117.Jan 28 2022, 11:46 AM
mib marked 3 inline comments as done.

Address @JDevlieghere comments

mib updated this revision to Diff 404128.Jan 28 2022, 12:16 PM

Re-enabling a test function for intel.

JDevlieghere accepted this revision.Jan 28 2022, 12:24 PM

LGTM modulo the test comment.

lldb/examples/python/scripted_process/scripted_process.py
329

Generally constants go at the top of the file, but this is rather bulky, so I don't mind it being at the bottom.

lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py
133–142

That sounds like something worth mentioning as a comment in the test.

This revision is now accepted and ready to land.Jan 28 2022, 12:24 PM
mib updated this revision to Diff 404142.Jan 28 2022, 1:06 PM
mib marked 2 inline comments as done.

Add stop reason type test and comment explaining why it's different depending on the architecture.

mib updated this revision to Diff 404147.Jan 28 2022, 1:14 PM
mib added a subscriber: jingham.Jan 28 2022, 1:26 PM
mib added inline comments.
lldb/examples/python/scripted_process/scripted_process.py
329

Felt the same, so I put it here.

lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
203–213

@jingham This is also another reason why D118482 is "necessary":

On intel, the corefile threads all report an eStopReasonNone, so having a python lldb.ScriptedProcess.get_selected_thread_index allows me to create the signal stop reason, otherwise, all of the scripted process threads report eStopReasonNone and the process runs forever.

mib updated this revision to Diff 404726.Jan 31 2022, 2:06 PM

Update following D118482 latest change

mib updated this revision to Diff 407264.Feb 9 2022, 1:19 PM
mib edited the summary of this revision. (Show Details)

Added a is_stopped member variable to StackCoreScriptedThread since I abandoned D118482

This revision was landed with ongoing or failed builds.Feb 9 2022, 1:28 PM
This revision was automatically updated to reflect the committed changes.