003 File Manager
Current Path:
/usr/src/contrib/llvm-project/lldb/source/Interpreter
usr
/
src
/
contrib
/
llvm-project
/
lldb
/
source
/
Interpreter
/
📁
..
📄
CommandAlias.cpp
(7.86 KB)
📄
CommandHistory.cpp
(3 KB)
📄
CommandInterpreter.cpp
(115 KB)
📄
CommandObject.cpp
(51.13 KB)
📄
CommandObjectRegexCommand.cpp
(3.78 KB)
📄
CommandObjectScript.cpp
(2.37 KB)
📄
CommandObjectScript.h
(966 B)
📄
CommandOptionValidators.cpp
(1.14 KB)
📄
CommandReturnObject.cpp
(5.06 KB)
📄
InterpreterProperties.td
(1.32 KB)
📄
OptionArgParser.cpp
(7.56 KB)
📄
OptionGroupArchitecture.cpp
(1.8 KB)
📄
OptionGroupBoolean.cpp
(2.22 KB)
📄
OptionGroupFile.cpp
(2.92 KB)
📄
OptionGroupFormat.cpp
(8.4 KB)
📄
OptionGroupOutputFile.cpp
(1.9 KB)
📄
OptionGroupPlatform.cpp
(4.6 KB)
📄
OptionGroupPythonClassWithDict.cpp
(5.51 KB)
📄
OptionGroupString.cpp
(1.88 KB)
📄
OptionGroupUInt64.cpp
(1.87 KB)
📄
OptionGroupUUID.cpp
(1.51 KB)
📄
OptionGroupValueObjectDisplay.cpp
(7.67 KB)
📄
OptionGroupVariable.cpp
(5.05 KB)
📄
OptionGroupWatchpoint.cpp
(3.19 KB)
📄
OptionValue.cpp
(17.49 KB)
📄
OptionValueArch.cpp
(2.39 KB)
📄
OptionValueArgs.cpp
(769 B)
📄
OptionValueArray.cpp
(9.99 KB)
📄
OptionValueBoolean.cpp
(2.8 KB)
📄
OptionValueChar.cpp
(1.85 KB)
📄
OptionValueDictionary.cpp
(10.06 KB)
📄
OptionValueEnumeration.cpp
(3.94 KB)
📄
OptionValueFileSpec.cpp
(4.28 KB)
📄
OptionValueFileSpecList.cpp
(5.38 KB)
📄
OptionValueFormat.cpp
(1.89 KB)
📄
OptionValueFormatEntity.cpp
(4.02 KB)
📄
OptionValueLanguage.cpp
(2.53 KB)
📄
OptionValuePathMappings.cpp
(6.95 KB)
📄
OptionValueProperties.cpp
(22.56 KB)
📄
OptionValueRegex.cpp
(1.95 KB)
📄
OptionValueSInt64.cpp
(2.48 KB)
📄
OptionValueString.cpp
(4.3 KB)
📄
OptionValueUInt64.cpp
(2.3 KB)
📄
OptionValueUUID.cpp
(2.66 KB)
📄
Options.cpp
(47.68 KB)
📄
Property.cpp
(11 KB)
📄
ScriptInterpreter.cpp
(7.53 KB)
📄
embedded_interpreter.py
(4.31 KB)
Editing: CommandObjectRegexCommand.cpp
//===-- CommandObjectRegexCommand.cpp -------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "lldb/Interpreter/CommandObjectRegexCommand.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" using namespace lldb; using namespace lldb_private; // CommandObjectRegexCommand constructor CommandObjectRegexCommand::CommandObjectRegexCommand( CommandInterpreter &interpreter, llvm::StringRef name, llvm::StringRef help, llvm::StringRef syntax, uint32_t max_matches, uint32_t completion_type_mask, bool is_removable) : CommandObjectRaw(interpreter, name, help, syntax), m_max_matches(max_matches), m_completion_type_mask(completion_type_mask), m_entries(), m_is_removable(is_removable) {} // Destructor CommandObjectRegexCommand::~CommandObjectRegexCommand() {} bool CommandObjectRegexCommand::DoExecute(llvm::StringRef command, CommandReturnObject &result) { EntryCollection::const_iterator pos, end = m_entries.end(); for (pos = m_entries.begin(); pos != end; ++pos) { llvm::SmallVector<llvm::StringRef, 4> matches; if (pos->regex.Execute(command, &matches)) { std::string new_command(pos->command); char percent_var[8]; size_t idx, percent_var_idx; for (uint32_t match_idx = 1; match_idx <= m_max_matches; ++match_idx) { if (match_idx < matches.size()) { const std::string match_str = matches[match_idx].str(); const int percent_var_len = ::snprintf(percent_var, sizeof(percent_var), "%%%u", match_idx); for (idx = 0; (percent_var_idx = new_command.find( percent_var, idx)) != std::string::npos;) { new_command.erase(percent_var_idx, percent_var_len); new_command.insert(percent_var_idx, match_str); idx += percent_var_idx + match_str.size(); } } } // Interpret the new command and return this as the result! if (m_interpreter.GetExpandRegexAliases()) result.GetOutputStream().Printf("%s\n", new_command.c_str()); // Pass in true for "no context switching". The command that called us // should have set up the context appropriately, we shouldn't have to // redo that. return m_interpreter.HandleCommand( new_command.c_str(), eLazyBoolCalculate, result, nullptr, true, true); } } result.SetStatus(eReturnStatusFailed); if (!GetSyntax().empty()) result.AppendError(GetSyntax()); else result.GetOutputStream() << "Command contents '" << command << "' failed to match any " "regular expression in the '" << m_cmd_name << "' regex "; return false; } bool CommandObjectRegexCommand::AddRegexCommand(const char *re_cstr, const char *command_cstr) { m_entries.resize(m_entries.size() + 1); // Only add the regular expression if it compiles m_entries.back().regex = RegularExpression(llvm::StringRef::withNullAsEmpty(re_cstr)); if (m_entries.back().regex.IsValid()) { m_entries.back().command.assign(command_cstr); return true; } // The regex didn't compile... m_entries.pop_back(); return false; } void CommandObjectRegexCommand::HandleCompletion(CompletionRequest &request) { if (m_completion_type_mask) { CommandCompletions::InvokeCommonCompletionCallbacks( GetCommandInterpreter(), m_completion_type_mask, request, nullptr); } }
Upload File
Create Folder