This is an archive of the discontinued LLVM Phabricator instance.

[LLDB] Add formatters for PointerIntPair, PointerUnion
ClosedPublic

Authored by broadwaylamb on Jan 20 2022, 5:47 AM.

Details

Summary

Also, add summaries for SmallVector and ArrayRef,
and fix the StringRef summary provider so it doesn't ignore the Length field.

Diff Detail

Event Timeline

broadwaylamb requested review of this revision.Jan 20 2022, 5:47 AM
broadwaylamb created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJan 20 2022, 5:47 AM

Thanks for doing this! I have not used PointerIntPair or PointerUnion, but I will take a look at those types. I take it these expression evaluations are necessary?

llvm/utils/lldbDataFormatters.py
176–179

when the string length is greater than max_length, it would be nice for the returned string to indicate truncation. I just checked a long std::string and the output was:

"really long string"...

Also the max length for std::string is 1024, should StringRef use 1024 too?

186–187

should this print an error message?

188

what's the best way to handle quotes inside the string? A quick search shows this could use json (a hack):

return json.dumps(string)

for example:

json.dumps('hello world') # '"hello world"'
json.dumps('hello "quoted" world') # '"hello \\"quoted\\" world"'

Address review comments

broadwaylamb added a comment.EditedJan 21 2022, 7:56 AM

I take it these expression evaluations are necessary?

Well, I think they are. There is too much template magic behind figuring out how many bits in the pointer we use to store an additional integer value.

Expression evaluations are not only slow, but they also prevent us from formatting nested PointerIntPairs, since the expression path is modified and doesn't correspond to the actual implementation anymore, therefore evaluating expressions down the tree will not work.
But I guess we can live with that for now.

llvm/utils/lldbDataFormatters.py
176–179

LLDB supports the max-string-summary-length setting, but unfortunately there is no way to get the value of that setting through Python API.

kastiglione accepted this revision.Jan 26 2022, 9:02 AM

But I guess we can live with that for now.

That's fair. Thanks again for adding more llvm formatters.

This revision is now accepted and ready to land.Jan 26 2022, 9:02 AM
This revision was landed with ongoing or failed builds.Jan 27 2022, 1:54 AM
This revision was automatically updated to reflect the committed changes.
kastiglione added inline comments.Feb 14 2022, 10:55 AM
llvm/utils/lldbDataFormatters.py
185

For some binary strings, decode will thrown an exception.

@broadwaylamb hi, have you been using the PointerUnion formatter? We have seen a variety of issues, which don't seem to have easy fixes. If you're not using it, I will disable it. Alternatively, I propose creating a separate file that you and others could choose to import separately from lldbDataFormatters.py.

Herald added a project: Restricted Project. · View Herald TranscriptJul 13 2023, 7:31 AM

@broadwaylamb hi, have you been using the PointerUnion formatter? We have seen a variety of issues, which don't seem to have easy fixes. If you're not using it, I will disable it. Alternatively, I propose creating a separate file that you and others could choose to import separately from lldbDataFormatters.py.

No, I haven't been working with LLVM for a while.

Thanks, I will disable these for now, and see what can be done to address the issues we've seen.