This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Add support for escaping zsh arguments
ClosedPublic

Authored by teemperor on Jun 21 2021, 3:07 AM.

Details

Summary

LLDB supports having globbing regexes in the process launch arguments that will be resolved
using the user's shell. This requires that we pass the launch args to the shell and then read
back the expanded arguments using LLDB's argdumper utility.

As the shell will not just expand the globbing regexes but all special characters, we need to
escape all non-globbing charcters such as $, &, <, >, etc. as those otherwise are interpreted and
removed in the step where we expand the globbing characters. Also because the special characters
are shell-specific, LLDB needs to maintain a list of all the characters that need to be escaped for
each specific shell.

This patch adds the list of special characters that need to be escaped for zsh. Without this patch
on systems where zsh is the user's shell (like on all macOS systems) having any of these special
characters in your arguments or path to the binary will cause the process launch to fail. E.g.,
lldb -- ./calc 1<2 is failing without this patch. The same happens if the absolute path to calc is
in a directory that contains for example parentheses or other special characters.

Diff Detail

Event Timeline

teemperor created this revision.Jun 21 2021, 3:07 AM
teemperor requested review of this revision.Jun 21 2021, 3:07 AM
teemperor updated this revision to Diff 353316.Jun 21 2021, 3:13 AM
  • Remove $ so that env variables will be expanded.
JDevlieghere accepted this revision.Jun 21 2021, 7:33 AM

LGTM.

lldb/source/Utility/Args.cpp
390

What about fish?

This revision is now accepted and ready to land.Jun 21 2021, 7:33 AM
JDevlieghere added inline comments.Jun 21 2021, 7:38 AM
lldb/source/Utility/Args.cpp
390

I see D104635

teemperor updated this revision to Diff 353375.Jun 21 2021, 7:53 AM
  • Add pipe and backslash
This revision was landed with ongoing or failed builds.Jun 21 2021, 10:47 AM
This revision was automatically updated to reflect the committed changes.