This is an archive of the discontinued LLVM Phabricator instance.

Move the shell expansion code to Host/common
AbandonedPublic

Authored by zturner on Feb 20 2015, 10:07 PM.

Details

Summary

This moves the shell expansion code from different implementation files for every Host to Host/common. The reason for this is that the method for expanding the shell arguments is the same for a majority of platforms, so there is no reason to leave it unimplemented for everyone.

Additionally, this generalizes the Host method a little to be useful even if you don't have a ProcessLaunchInfo handy by changing the arguments to accept only the information that it needs, instead of the entire ProcessLaunchInfo. As a side effect, this also fixes a redundant test of the process launch flag, which was being checked once in the Platform and another time in Host::ShellExpandArguments.

Diff Detail

Event Timeline

zturner updated this revision to Diff 20454.Feb 20 2015, 10:07 PM
zturner retitled this revision from to Move the shell expansion code to Host/common.
zturner updated this object.
zturner edited the test plan for this revision. (Show Details)
zturner added a subscriber: Unknown Object (MLST).

Anyone have thoughts on this? If there's no suggestions I'd like to commit, but I'll give another day or two for comments.

clayborg requested changes to this revision.Feb 25 2015, 10:22 AM
clayborg edited edge metadata.

A few changes, see inlined comments.

include/lldb/Host/Host.h
263

Use lldb_private::Args instead of std::vector<std::string>.

include/lldb/Target/Platform.h
395

Use lldb_private::Args instead of std::vector<std::string>.

source/Host/common/Host.cpp
529

Use lldb_private::Args instead of std::vector<std::string>.

source/Target/Platform.cpp
1119

Remove this and use launch_info.GetArguments() below, or change to Args type then copy back into launch_info.GetArguments() if all goes well.

1122

Pass launch_info.GetArguments() instead of expanded_args, or a temp Args variable.

1141

Change "vector<string" over to Args.

This revision now requires changes to proceed.Feb 25 2015, 10:22 AM

Well, I agree in principle that the API is meant to support process
launching. But if its utility can be trivially extended to support other
use cases, then why not?

FWIW, when I decided to do this, it was only to enable the functionality
for other platforms (i.e. moving from specific dirs to common), because
only Windows is going to have a different codepath here so it didn't make
sense to increase the code debt for everyone just because of Windows. Then
changing of the signature was just something I noticed on the side. I can
change it back if people feel strongly, but at the same time, I really like
making code as general as possible, as long as the generality doesn't
hinder the readability or usability for the primary use case (which in this
case I don't think it does)

I agree with Enrico's email comments that it would be nice to still use ProcessLaunchInfo so we can pass the environment variables down to the argdumper program so that it could us the env vars to expand command line stuff if needed.

Understood. I will update the patch when I have time and commit the
result. Thanks for the review!

zturner abandoned this revision.Oct 15 2015, 1:51 PM