This is an archive of the discontinued LLVM Phabricator instance.

[lldb/API] Add convenience constructor for SBError (NFC)
ClosedPublic

Authored by mib on Apr 14 2023, 5:09 PM.

Details

Summary

This patch adds a new convience constructor to the SBError to initialize
it with a string message to avoid having to create the object and call
the SetErrorString method afterwards.

This is very handy to report errors from lldb scripted affordances.

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

Diff Detail

Event Timeline

mib created this revision.Apr 14 2023, 5:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 14 2023, 5:09 PM
mib requested review of this revision.Apr 14 2023, 5:09 PM
bulbazord accepted this revision.Apr 17 2023, 1:21 PM

I like this! Reading through the call stack, it looks like we shouldn't hit any issues if message is nullptr. Could you add a small test to TestSBError.py constructing an error with a message directly?

This revision is now accepted and ready to land.Apr 17 2023, 1:21 PM
mib added a comment.Apr 17 2023, 1:22 PM

I like this! Reading through the call stack, it looks like we shouldn't hit any issues if message is nullptr. Could you add a small test to TestSBError.py constructing an error with a message directly?

Yep, we create the underlying status object if the opaque ptr is null. Will add a test case :)

JDevlieghere added inline comments.Apr 17 2023, 1:50 PM
lldb/include/lldb/API/SBError.h
26

Why not a StringRef?

bulbazord added inline comments.Apr 17 2023, 1:51 PM
lldb/include/lldb/API/SBError.h
26

I'm not sure we have StringRef type map in swig? We would have to create one for swig to pick up on it correctly, no?

mib added inline comments.Apr 17 2023, 1:52 PM
lldb/include/lldb/API/SBError.h
26

+1

JDevlieghere accepted this revision.Apr 17 2023, 2:40 PM
JDevlieghere added inline comments.
lldb/include/lldb/API/SBError.h
26

Yeah nvm, I got Status and SBError confused.

This revision was automatically updated to reflect the committed changes.