This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Escape semicolons for all shells
ClosedPublic

Authored by teemperor on Jun 21 2021, 3:29 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 missing semicolon character to the escape list for all currently supported
shells. Without this having a semicolon in the binary path or having a semicolon in the launch
arguments will cause the argdumping process to fail. E.g., lldb -- ./calc "a;b" was failing before
but is working now.

Fixes rdar://55776943

Diff Detail

Event Timeline

teemperor requested review of this revision.Jun 21 2021, 3:29 AM
teemperor created this revision.
This revision is now accepted and ready to land.Jun 21 2021, 7:39 AM
This revision was landed with ongoing or failed builds.Apr 12 2022, 6:14 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2022, 6:14 PM

This is good in general, but I'm not sure we want to escape $. One of the uses of shell expansion is to get shell variables expanded.