This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Add assertStopReason helper function
ClosedPublic

Authored by JDevlieghere on Aug 3 2022, 10:42 AM.

Details

Summary

Add a function to make it easier to debug a test failure caused by an unexpected stop reason. This is similar to the assertState helper function that I added in D127355.

Before:

self.assertEqual(stop_reason, lldb.eStopReasonInstrumentation)
AssertionError: 5 != 10

After:

self.assertStopReason(stop_reason, lldb.eStopReasonInstrumentation)
AssertionError: signal (5) != instrumentation (10)

Diff Detail

Event Timeline

JDevlieghere created this revision.Aug 3 2022, 10:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 3 2022, 10:42 AM
JDevlieghere requested review of this revision.Aug 3 2022, 10:42 AM
JDevlieghere updated this revision to Diff 449707.

Add missing stop reasons

mib accepted this revision.Aug 3 2022, 11:29 AM

LGTM!

lldb/packages/Python/lldbsuite/test/lldbutil.py
269–272

This is more a general comment, but I'm very annoyed at how C/C++ enums are exposed to Python ... Now every time we add a new value to the enum we need to remember to update these helper function. The comment is not related specifically to this patch but I think we can do a better job here.

This revision is now accepted and ready to land.Aug 3 2022, 11:29 AM
JDevlieghere marked an inline comment as done.Aug 3 2022, 11:41 AM
JDevlieghere added inline comments.
lldb/packages/Python/lldbsuite/test/lldbutil.py
269–272

I'm sure there's some kind of introspection API that would allow us to have the equivalent of a static_assert in C++. I'll add it to my list of nice-to-haves :-)

This revision was automatically updated to reflect the committed changes.
JDevlieghere marked an inline comment as done.
Herald added a project: Restricted Project. · View Herald TranscriptAug 3 2022, 11:44 AM
kastiglione added inline comments.Aug 3 2022, 8:55 PM
lldb/packages/Python/lldbsuite/test/lldbutil.py
269–272