zturner created this revision.
zturner added reviewers: labath, davide.
The REPL (which lives in Expression) was making use of the command options for
the expression command. It's arguable whether `REPL` should even live in
`Expression` to begin with, but it makes more sense for Command to depend on
REPL than the other way around. The command library should be thought of as a
UI library, low level engine stuff shouldn't depend on it, but the other way
around makes perfect sense.
Anyway, only about 3-4 of the fields of this structure were even used and the
rest were ignored, so we just give `REPL` its own custom structure and have the
command object fill this out and pass it in. This way `REPL` doesn't need to
reference one from a higher level library.
This breaks the cycle from Expression -> Commands -> Expression, reducing the
distinct cycle count to 36.
Note that no `CMakeLists.txt` file needs to be updated here, because
`Expression` was (incorrectly) not including `Commands` in its link list to
begin with.
https://reviews.llvm.org/D47232
Files:
lldb/include/lldb/Expression/REPL.h
lldb/source/Commands/CommandObjectExpression.cpp
lldb/source/Expression/REPL.cpp
Index: lldb/source/Expression/REPL.cpp
===================================================================
--- lldb/source/Expression/REPL.cpp
+++ lldb/source/Expression/REPL.cpp
@@ -32,12 +32,6 @@
auto exe_ctx = debugger.GetCommandInterpreter().GetExecutionContext();
m_format_options.OptionParsingStarting(&exe_ctx);
m_varobj_options.OptionParsingStarting(&exe_ctx);
- m_command_options.OptionParsingStarting(&exe_ctx);
-
- // Default certain settings for REPL regardless of the global settings.
- m_command_options.unwind_on_error = false;
- m_command_options.ignore_breakpoints = false;
- m_command_options.debug = false;
}
REPL::~REPL() = default;
@@ -283,18 +277,19 @@
EvaluateExpressionOptions expr_options;
expr_options.SetCoerceToId(m_varobj_options.use_objc);
- expr_options.SetUnwindOnError(m_command_options.unwind_on_error);
- expr_options.SetIgnoreBreakpoints(m_command_options.ignore_breakpoints);
+ expr_options.SetUnwindOnError(m_command_options.UnwindOnError);
+ expr_options.SetIgnoreBreakpoints(m_command_options.IgnoreBreakpoints);
expr_options.SetKeepInMemory(true);
expr_options.SetUseDynamic(m_varobj_options.use_dynamic);
- expr_options.SetTryAllThreads(m_command_options.try_all_threads);
+ expr_options.SetTryAllThreads(m_command_options.TryAllThreads);
expr_options.SetGenerateDebugInfo(true);
expr_options.SetREPLEnabled(true);
expr_options.SetColorizeErrors(colorize_err);
expr_options.SetPoundLine(m_repl_source_path.c_str(),
m_code.GetSize() + 1);
- if (m_command_options.timeout > 0)
- expr_options.SetTimeout(std::chrono::microseconds(m_command_options.timeout));
+ if (m_command_options.Timeout > 0)
+ expr_options.SetTimeout(
+ std::chrono::microseconds(m_command_options.Timeout));
else
expr_options.SetTimeout(llvm::None);
Index: lldb/source/Commands/CommandObjectExpression.cpp
===================================================================
--- lldb/source/Commands/CommandObjectExpression.cpp
+++ lldb/source/Commands/CommandObjectExpression.cpp
@@ -588,7 +588,13 @@
if (repl_sp) {
if (initialize) {
- repl_sp->SetCommandOptions(m_command_options);
+ REPL::CommandOptions Options;
+ Options.IgnoreBreakpoints =
+ m_command_options.ignore_breakpoints;
+ Options.Timeout = m_command_options.timeout;
+ Options.TryAllThreads = m_command_options.try_all_threads;
+ Options.UnwindOnError = m_command_options.unwind_on_error;
+ repl_sp->SetCommandOptions(Options);
repl_sp->SetFormatOptions(m_format_options);
repl_sp->SetValueObjectDisplayOptions(m_varobj_options);
}
Index: lldb/include/lldb/Expression/REPL.h
===================================================================
--- lldb/include/lldb/Expression/REPL.h
+++ lldb/include/lldb/Expression/REPL.h
@@ -16,14 +16,20 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/../../source/Commands/CommandObjectExpression.h"
+#include "lldb/Core/IOHandler.h"
#include "lldb/Interpreter/OptionGroupFormat.h"
#include "lldb/Interpreter/OptionGroupValueObjectDisplay.h"
namespace lldb_private {
class REPL : public IOHandlerDelegate {
public:
+ struct CommandOptions {
+ bool UnwindOnError = false;
+ bool IgnoreBreakpoints = false;
+ bool TryAllThreads = true;
+ uint32_t Timeout = 0;
+ };
//----------------------------------------------------------------------
// See TypeSystem.h for how to add subclasses to this.
//----------------------------------------------------------------------
@@ -73,8 +79,7 @@
m_varobj_options = options;
}
- void
- SetCommandOptions(const CommandObjectExpression::CommandOptions &options) {
+ void SetCommandOptions(const CommandOptions &options) {
m_command_options = options;
}
@@ -150,7 +155,7 @@
OptionGroupFormat m_format_options = OptionGroupFormat(lldb::eFormatDefault);
OptionGroupValueObjectDisplay m_varobj_options;
- CommandObjectExpression::CommandOptions m_command_options;
+ CommandOptions m_command_options;
std::string m_compiler_options;
bool m_enable_auto_indent = true;
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits