Quiet command regex instructions during batch execution

Summary:
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
benefits.

For example:

    command regex <command-name>
    s/pat1/repl1/
    s/pat2/repl2/
    ...

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`.

Reviewers: clayborg, jingham

Reviewed By: clayborg

Subscribers: jdoerfert, kastiglione, xiaobai, keith, lldb-commits

Differential Revision: https://reviews.llvm.org/D48752

llvm-svn: 355793
This commit is contained in:
Dave Lee
2019-03-10 23:15:48 +00:00
parent 26e06e859e
commit 0affb5822f
13 changed files with 24 additions and 24 deletions

View File

@@ -442,7 +442,7 @@ lldb_private::ConstString ScriptInterpreterPython::GetPluginName() {
uint32_t ScriptInterpreterPython::GetPluginVersion() { return 1; }
void ScriptInterpreterPython::IOHandlerActivated(IOHandler &io_handler) {
void ScriptInterpreterPython::IOHandlerActivated(IOHandler &io_handler, bool interactive) {
const char *instructions = nullptr;
switch (m_active_io_handler) {
@@ -463,7 +463,7 @@ def function (frame, bp_loc, internal_dict):
if (instructions) {
StreamFileSP output_sp(io_handler.GetOutputStreamFile());
if (output_sp) {
if (output_sp && interactive) {
output_sp->PutCString(instructions);
output_sp->Flush();
}