This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Respect empty arguments in target.run-args
ClosedPublic

Authored by bulbazord on Mar 6 2023, 4:09 PM.

Details

Summary

Currently empty arguments are not respected. They are silently dropped
in two places: (1) when extracting them from the target.run-args
setting and (2) when constructing the lldb-argdumper invocation.

(1) is actually a regression from a few years ago. We did not always
drop empty arguments. See 31d97a5c8ab78c619deada0cdb1fcf64021d25dd.

rdar://106279228

Diff Detail

Event Timeline

bulbazord created this revision.Mar 6 2023, 4:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 6 2023, 4:09 PM
bulbazord requested review of this revision.Mar 6 2023, 4:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 6 2023, 4:09 PM
DavidSpickett accepted this revision.Mar 7 2023, 1:17 AM
DavidSpickett added a subscriber: DavidSpickett.

A bit surprised there wasn't an existing test to just add an extra argument to, but looks good to me.

This revision is now accepted and ready to land.Mar 7 2023, 1:17 AM
This revision was automatically updated to reflect the committed changes.
labath added a subscriber: labath.Mar 14 2023, 9:41 AM
labath added inline comments.
lldb/source/Host/common/ProcessLaunchInfo.cpp
324–325

Shouldn't this belong inside Args::GetShellSafeArgument? I don't think there's any situation where the current behavior of the function would be correct (and this is the only caller of the function anyway...)

bulbazord added inline comments.Mar 14 2023, 10:39 AM
lldb/source/Host/common/ProcessLaunchInfo.cpp
324–325

As in, we should set safe_arg to \"\" when argv[I] is the empty string (e.g. safe_arg should never be empty)? If that's what you're suggesting, I think that would be a reasonable thing to do.

labath added inline comments.Mar 14 2023, 12:53 PM
lldb/source/Host/common/ProcessLaunchInfo.cpp
324–325

I think it is. What I'm saying is that Args::GetShellSafeArgument(???, "") should automatically return "\"\" instead of needing to fix this up afterwards...