[Lldb-commits] [lldb] e2a6c08 - [lldb] fix --source-quietly
Lawrence D'Anna via lldb-commits
lldb-commits at lists.llvm.org
Tue Nov 2 11:02:22 PDT 2021
Author: Lawrence D'Anna
Date: 2021-11-02T11:01:55-07:00
New Revision: e2a6c08bbc385b38e02f4e5d31d1cf6d4403f066
URL: https://github.com/llvm/llvm-project/commit/e2a6c08bbc385b38e02f4e5d31d1cf6d4403f066
DIFF: https://github.com/llvm/llvm-project/commit/e2a6c08bbc385b38e02f4e5d31d1cf6d4403f066.diff
LOG: [lldb] fix --source-quietly
Jim says:
lldb has a -Q or --source-quietly option, which supposedly does:
--source-quietly Tells the debugger to execute this one-line lldb command before any file has been loaded.
That seems like a weird description, since we don't generally use source for one line entries, but anyway, let's try it:
> $LLDB_LLVM/clean-mono/build/Debug/bin/lldb -Q "script print('I should be quiet')" a.out -O "script print('I should be before')" -o "script print('I should be after')"
(lldb) script print('I should be before')
I should be before
(lldb) target create "script print('I should be quiet')"
error: unable to find executable for 'script print('I should be quiet')'
That was weird. The first real -O gets sourced but not quietly, then the argument to the -Q gets treated as the target.
> $LLDB_LLVM/clean-mono/build/Debug/bin/lldb -Q a.out -O "script print('I should be before')" -o "script print('I should be after')"
(lldb) script print('I should be before')
I should be before
(lldb) target create "a.out"
Current executable set to '/tmp/a.out' (x86_64).
(lldb) script print('I should be after')
I should be after
Well, that's a little better, but the -Q option seems to have done nothing.
---
This fixes the description of --source-quietly, as well as causing it
to actually suppress echoing while executing the initialization
commands.
Reviewed By: jingham
Differential Revision: https://reviews.llvm.org/D112988
Added:
lldb/test/Shell/Driver/TestQuiet.test
Modified:
lldb/docs/man/lldb.rst
lldb/tools/driver/Driver.cpp
lldb/tools/driver/Options.td
Removed:
################################################################################
diff --git a/lldb/docs/man/lldb.rst b/lldb/docs/man/lldb.rst
index b75288db380de..35db1dc68c129 100644
--- a/lldb/docs/man/lldb.rst
+++ b/lldb/docs/man/lldb.rst
@@ -111,7 +111,7 @@ COMMANDS
.. option:: --source-quietly
- Tells the debugger to execute this one-line lldb command before any file has been loaded.
+ Tells the debugger not to echo commands while sourcing files or one-line commands provided on the command line.
.. option:: --source <file>
diff --git a/lldb/test/Shell/Driver/TestQuiet.test b/lldb/test/Shell/Driver/TestQuiet.test
new file mode 100644
index 0000000000000..8598792aeba07
--- /dev/null
+++ b/lldb/test/Shell/Driver/TestQuiet.test
@@ -0,0 +1,7 @@
+RUN: %lldb -b -Q -o "expr 40 + 2" | FileCheck %s
+RUN: %lldb -b -Q -O "expr 40 + 2" | FileCheck %s
+
+CHECK-NOT: expr
+CHECK-NOT: lldb
+CHECK-NOT: source
+CHECK: 42
\ No newline at end of file
diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp
index a6a4a2a1b80b8..df070ebe4db8d 100644
--- a/lldb/tools/driver/Driver.cpp
+++ b/lldb/tools/driver/Driver.cpp
@@ -609,6 +609,7 @@ int Driver::MainLoop() {
options.SetSpawnThread(false);
options.SetStopOnError(true);
options.SetStopOnCrash(m_option_data.m_batch);
+ options.SetEchoCommands(!m_option_data.m_source_quietly);
SBCommandInterpreterRunResult results =
m_debugger.RunCommandInterpreter(options);
diff --git a/lldb/tools/driver/Options.td b/lldb/tools/driver/Options.td
index 8bcb0e7bc52e9..be2b4bfa30044 100644
--- a/lldb/tools/driver/Options.td
+++ b/lldb/tools/driver/Options.td
@@ -110,7 +110,7 @@ def: Flag<["-"], "b">,
Group<grp_command>;
def source_quietly: F<"source-quietly">,
- HelpText<"Tells the debugger to execute this one-line lldb command before any file has been loaded.">,
+ HelpText<"Tells the debugger not to echo commands while sourcing files or one-line commands provided on the command line.">,
Group<grp_command>;
def: Flag<["-"], "Q">,
Alias<source_quietly>,
More information about the lldb-commits
mailing list