[Lldb-commits] [PATCH] D48752: Quiet command regex instructions during batch execution

Dave Lee via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Jun 28 16:38:15 PDT 2018

kastiglione created this revision.
kastiglione added reviewers: clayborg, jingham.

Within .lldbinit, regex commands can be structured as a list of substitutions over
multiple lines. It's possible that this is uninentional, but it works and has

For example:

  command regex <command-name>

I use this form of `command regex` in my `~/.lldbinit`, because it makes it
clearer to write and read compared to a single line definition, because
multiline substitutions don't need to be quoted, and are broken up one per line.

However, multiline definitions result in usage instructions being printed for
each use. The result is that every time I run `lldb`, I get a dozen or more
lines of noise. With this change, the instructions are only printed when
`command regex` is invoked interactively, or from a terminal, neither of which
are true when lldb is sourcing `~/.lldbinit`.



Index: source/Commands/CommandObjectCommands.cpp
--- source/Commands/CommandObjectCommands.cpp
+++ source/Commands/CommandObjectCommands.cpp
@@ -1009,9 +1009,12 @@
   void IOHandlerActivated(IOHandler &io_handler) override {
+    if (!io_handler.GetIsInteractive() && !io_handler.GetIsRealTerminal())
+      // Don't print instructions during batch execution, such as .lldbinit.
+      return;
     StreamFileSP output_sp(io_handler.GetOutputStreamFile());
     if (output_sp) {
-      output_sp->PutCString("Enter one of more sed substitution commands in "
+      output_sp->PutCString("Enter one or more sed substitution commands in "
                             "the form: 's/<regex>/<subst>/'.\nTerminate the "
                             "substitution list with an empty line.\n");
Index: packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py
--- packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py
+++ packages/Python/lldbsuite/test/functionalities/command_regex/TestCommandRegex.py
@@ -24,7 +24,7 @@
         """Test a simple scenario of 'command regex' invocation and subsequent use."""
         import pexpect
         prompt = "(lldb) "
-        regex_prompt = "Enter one of more sed substitution commands in the form: 's/<regex>/<subst>/'.\r\nTerminate the substitution list with an empty line.\r\n"
+        regex_prompt = "Enter one or more sed substitution commands in the form: 's/<regex>/<subst>/'.\r\nTerminate the substitution list with an empty line.\r\n"
         regex_prompt1 = "\r\n"
         child = pexpect.spawn('%s %s' %

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48752.153423.patch
Type: text/x-patch
Size: 1785 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20180628/9b1cd7a4/attachment.bin>

More information about the lldb-commits mailing list