This is an archive of the discontinued LLVM Phabricator instance.

[lldb/Test] Add a trace method to replace (commented out) print statements.
ClosedPublic

Authored by JDevlieghere on May 22 2020, 10:22 AM.

Details

Summary

While debugging replay failures I noticed that a lot of tests have print statements, sometimes commented out, which half of the time don't show up in the terminal anyway because dotest swallows the output.

We already have a good mechanism for these kind of things: the -t flag to enable tracing. I've added a trace method to replace these print statements. In this patch I've only updated the ones that are commented out, but I feel all the print statements in the API tests should be replaced by this.

Diff Detail

Repository
rLLDB LLDB

Event Timeline

JDevlieghere created this revision.May 22 2020, 10:22 AM
JDevlieghere marked an inline comment as done.May 22 2020, 11:44 AM
JDevlieghere added inline comments.
lldb/packages/Python/lldbsuite/test/lldbtest.py
510

This should be

print(*args, kwargs, file=sbuf)
labath accepted this revision.May 25 2020, 1:22 AM

Yes, this is a good idea. It might it also nice to go through the if self.traceOn() calls and see which ones can be replaced by this function.

lldb/packages/Python/lldbsuite/test/lldbtest.py
510

Actually, it should be print(*args, **kwargs, file=sbuf)

lldb/test/API/lang/c/register_variables/TestRegisterVariables.py
32

uncomment this as well

This revision is now accepted and ready to land.May 25 2020, 1:22 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMay 25 2020, 11:15 AM
mboehme added inline comments.
lldb/packages/Python/lldbsuite/test/lldbtest.py
510

With both Python 2 and 3, this, is giving me an error:

    print(*args, **kwargs, file=sbuf)
                         ^
SyntaxError: invalid syntax

I believe this should be print(*args, file=sbuf, **kwargs). Can you fix this?

JDevlieghere marked an inline comment as done.Jun 3 2020, 2:55 PM
JDevlieghere added inline comments.
lldb/packages/Python/lldbsuite/test/lldbtest.py
510

Thanks, fixed by 5fa9c9d7f276b44b3da949382e0d0b5dbfd0ac8b