diff options
author | Felipe de Azevedo Piovezan <fpiovezan@apple.com> | 2023-07-14 13:34:27 -0400 |
---|---|---|
committer | Felipe de Azevedo Piovezan <fpiovezan@apple.com> | 2023-07-19 09:14:02 -0400 |
commit | 8bc97a3ee4f411e583a13e0966239848080d753d (patch) | |
tree | 348246fc8c8872a3bfefeae4318fabdd237e477d /lldb/source/Commands/CommandObjectFrame.cpp | |
parent | 32ed3031fa48c49ead3b5288cbea6937c557a470 (diff) | |
download | llvm-8bc97a3ee4f411e583a13e0966239848080d753d.zip llvm-8bc97a3ee4f411e583a13e0966239848080d753d.tar.gz llvm-8bc97a3ee4f411e583a13e0966239848080d753d.tar.bz2 |
[lldb][NFC] Factor out CommandObject code filtering results based on scope
We will need this code in a subsequent commit.
Differential Revision: https://reviews.llvm.org/D155332
Diffstat (limited to 'lldb/source/Commands/CommandObjectFrame.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectFrame.cpp | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp index 3f68425..7638076 100644 --- a/lldb/source/Commands/CommandObjectFrame.cpp +++ b/lldb/source/Commands/CommandObjectFrame.cpp @@ -480,6 +480,25 @@ protected: return llvm::StringRef(); } + /// Returns true if `scope` matches any of the options in `m_option_variable`. + bool ScopeRequested(lldb::ValueType scope) { + switch (scope) { + case eValueTypeVariableGlobal: + case eValueTypeVariableStatic: + return m_option_variable.show_globals; + case eValueTypeVariableArgument: + return m_option_variable.show_args; + case eValueTypeVariableLocal: + return m_option_variable.show_locals; + case eValueTypeInvalid: + case eValueTypeRegister: + case eValueTypeRegisterSet: + case eValueTypeConstResult: + case eValueTypeVariableThreadLocal: + return false; + } + } + bool DoExecute(Args &command, CommandReturnObject &result) override { // No need to check "frame" for validity as eCommandRequiresFrame ensures // it is valid @@ -630,27 +649,8 @@ protected: if (num_variables > 0) { for (size_t i = 0; i < num_variables; i++) { var_sp = variable_list->GetVariableAtIndex(i); - switch (var_sp->GetScope()) { - case eValueTypeVariableGlobal: - if (!m_option_variable.show_globals) - continue; - break; - case eValueTypeVariableStatic: - if (!m_option_variable.show_globals) + if (!ScopeRequested(var_sp->GetScope())) continue; - break; - case eValueTypeVariableArgument: - if (!m_option_variable.show_args) - continue; - break; - case eValueTypeVariableLocal: - if (!m_option_variable.show_locals) - continue; - break; - default: - continue; - break; - } std::string scope_string; if (m_option_variable.show_scope) scope_string = GetScopeString(var_sp).str(); |