Page MenuHomePhabricator

[lldb/API] Add RunCommandInterpreter overload that returns SBCommandInterpreterRunResults (NFC)

Authored by JDevlieghere on Apr 29 2020, 1:11 PM.



This adds an RunCommandInterpreter overload that returns an instance of SBCommandInterpreterRunResults. The goal is to avoid having to add more and more overloads when we need more output arguments.

Event Timeline

clayborg accepted this revision.Apr 29 2020, 5:21 PM

Yeah, anytime you see API calls that have many arguments it is a good idea to switch to this kind of API as adding accessors doesn't require us to change the API. We did this with SBTarget::Attach() and SBTarget::Launch() after having many variants of these functions...

This revision is now accepted and ready to land.Apr 29 2020, 5:21 PM
clayborg requested changes to this revision.Apr 29 2020, 5:25 PM

Sorry, missed the fact that the new class had ivars. For ABI stability, we can't modify the number of ivars since we need the class size of SBCommandInterpreterRunResults to never change even if we add more things to it.


We need to abstract these, they can't be in the lldb::SB class. So you just need to make an opaque class that contains these ivar and use a std::unique_ptr to the opaque class.

This revision now requires changes to proceed.Apr 29 2020, 5:25 PM
clayborg added inline comments.Apr 29 2020, 5:35 PM

like how SBCommandInterpreterRunOptions does it above with its ivar "m_opaque_up" that never changes size

Here I would be interested to know whether the "stop reasons" are mutually exclusive? It sounds like they should be...

And if they are, it seems that a better way to express this would be via something like GetRunResult which returns Success, or InferiorCrash, or CommandError, or QuitRequested. Other reasons can be added to the enum later, if needed...

clayborg accepted this revision.Apr 30 2020, 6:26 PM
This revision is now accepted and ready to land.Apr 30 2020, 6:26 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMay 1 2020, 5:29 PM