This is an archive of the discontinued LLVM Phabricator instance.

[LLDB/API] Expose args and env from SBProcessInfo.
AcceptedPublic

Authored by brucem on Jun 4 2021, 1:34 AM.

Details

Reviewers
mib
Group Reviewers
Restricted Project
Commits
rG8d33437d030a: [LLDB/API] Expose args and env from SBProcessInfo.
Summary

This is another step towards implementing the equivalent of
platform process list and related functionality.

uint32_t is used for the argument count and index despite the
underlying value being size_t to be consistent with other
index-based access to arguments.

Diff Detail

Event Timeline

brucem requested review of this revision.Jun 4 2021, 1:34 AM
brucem created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJun 4 2021, 1:34 AM
teemperor added a reviewer: Restricted Project.Jun 4 2021, 2:01 AM
mib accepted this revision as: mib.Jun 4 2021, 2:02 AM
mib added a subscriber: mib.

LGTM!

This revision is now accepted and ready to land.Jun 4 2021, 2:02 AM
teemperor added inline comments.
lldb/bindings/interface/SBProcessInfo.i
78

Can you add this line here?

%feature("autodoc", "GetArgumentAtIndex(int index) -> string") GetArgumentAtIndex;

Otherwise the Python docs will mention that this returns const char * which is always kinda weird for users to see.

brucem updated this revision to Diff 349895.Jun 4 2021, 9:28 AM

Rebase and address feedback.

brucem marked an inline comment as done.Jun 4 2021, 9:31 AM
brucem added inline comments.
lldb/bindings/interface/SBProcessInfo.i
78

I changed this to have the whole thing be an autodoc rather than both an autodoc and a docstring. This isn't consistently done throughout the code though and in this case, the resulting syntax help is a bit different.

This revision was landed with ongoing or failed builds.Jun 4 2021, 11:43 PM
This revision was automatically updated to reflect the committed changes.
brucem marked an inline comment as done.
brucem reopened this revision.Jun 5 2021, 1:54 AM

Not sure why this failed. Is it perhaps a difference where some processes have args including the executable and some do not?

This revision is now accepted and ready to land.Jun 5 2021, 1:54 AM

Not sure why this failed. Is it perhaps a difference where some processes have args including the executable and some do not?

Do you have the bot failures around for that? (Or, the platform at least so I could reproduce it locally?)

lldb/bindings/interface/SBProcessInfo.i
78

Sure, let's see how it looks on the website and then we can decide what works.

It failed because on macOS, the underlying args contains argv0 while on Linux it does not. So my test that checked that GetNumArguments is 1 fails on macOS, since there are 2.

Ideally, each platform would agree on whether or not the argv0 was included in the args ... or I can modify the test to check that the last argument is --abc.

(I've just been busy this week, so I hadn't gotten back to this.)