summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/tools/lldb/source/Interpreter/CommandInterpreter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/tools/lldb/source/Interpreter/CommandInterpreter.cpp')
-rw-r--r--contrib/llvm/tools/lldb/source/Interpreter/CommandInterpreter.cpp51
1 files changed, 25 insertions, 26 deletions
diff --git a/contrib/llvm/tools/lldb/source/Interpreter/CommandInterpreter.cpp b/contrib/llvm/tools/lldb/source/Interpreter/CommandInterpreter.cpp
index d44eb25..986be7f 100644
--- a/contrib/llvm/tools/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/contrib/llvm/tools/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -42,12 +42,12 @@
#include "../Commands/CommandObjectWatchpoint.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/State.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/Timer.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/Timer.h"
#ifndef LLDB_DISABLE_LIBEDIT
#include "lldb/Host/Editline.h"
@@ -169,7 +169,8 @@ bool CommandInterpreter::GetSpaceReplPrompts() const {
}
void CommandInterpreter::Initialize() {
- Timer scoped_timer(LLVM_PRETTY_FUNCTION, LLVM_PRETTY_FUNCTION);
+ static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
+ Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
CommandReturnObject result;
@@ -391,7 +392,8 @@ const char *CommandInterpreter::ProcessEmbeddedScriptCommands(const char *arg) {
}
void CommandInterpreter::LoadCommandDictionary() {
- Timer scoped_timer(LLVM_PRETTY_FUNCTION, LLVM_PRETTY_FUNCTION);
+ static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
+ Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
lldb::ScriptLanguage script_language = m_debugger.GetScriptLanguage();
@@ -645,8 +647,8 @@ void CommandInterpreter::LoadCommandDictionary() {
"gdb-remote [<hostname>:]<portnum>", 2, 0, false));
if (connect_gdb_remote_cmd_ap.get()) {
if (connect_gdb_remote_cmd_ap->AddRegexCommand(
- "^([^:]+:[[:digit:]]+)$",
- "process connect --plugin gdb-remote connect://%1") &&
+ "^([^:]+|\\[[0-9a-fA-F:]+.*\\]):([0-9]+)$",
+ "process connect --plugin gdb-remote connect://%1:%2") &&
connect_gdb_remote_cmd_ap->AddRegexCommand(
"^([[:digit:]]+)$",
"process connect --plugin gdb-remote connect://localhost:%1")) {
@@ -1373,7 +1375,7 @@ CommandObject *CommandInterpreter::BuildAliasResult(
return alias_cmd_obj;
}
-Error CommandInterpreter::PreprocessCommand(std::string &command) {
+Status CommandInterpreter::PreprocessCommand(std::string &command) {
// The command preprocessor needs to do things to the command
// line before any parsing of arguments or anything else is done.
// The only current stuff that gets preprocessed is anything enclosed
@@ -1381,7 +1383,7 @@ Error CommandInterpreter::PreprocessCommand(std::string &command) {
// the result of the expression must be a scalar that can be substituted
// into the command. An example would be:
// (lldb) memory read `$rsp + 20`
- Error error; // Error for any expressions that might not evaluate
+ Status error; // Status for any expressions that might not evaluate
size_t start_backtick;
size_t pos = 0;
while ((start_backtick = command.find('`', pos)) != std::string::npos) {
@@ -1533,8 +1535,8 @@ bool CommandInterpreter::HandleCommand(const char *command_line,
if (log)
log->Printf("Processing command: %s", command_line);
- Timer scoped_timer(LLVM_PRETTY_FUNCTION, "Handling command: %s.",
- command_line);
+ static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
+ Timer scoped_timer(func_cat, "Handling command: %s.", command_line);
if (!no_context_switching)
UpdateExecutionContext(override_context);
@@ -1601,7 +1603,7 @@ bool CommandInterpreter::HandleCommand(const char *command_line,
return true;
}
- Error error(PreprocessCommand(command_string));
+ Status error(PreprocessCommand(command_string));
if (error.Fail()) {
result.AppendError(error.AsCString());
@@ -2018,8 +2020,8 @@ void CommandInterpreter::BuildAliasCommandArgs(CommandObject *alias_cmd_obj,
}
for (auto entry : llvm::enumerate(cmd_args.entries())) {
- if (!used[entry.Index] && !wants_raw_input)
- new_args.AppendArgument(entry.Value.ref);
+ if (!used[entry.index()] && !wants_raw_input)
+ new_args.AppendArgument(entry.value().ref);
}
cmd_args.Clear();
@@ -2355,8 +2357,8 @@ void CommandInterpreter::HandleCommandsFromFile(
StreamFileSP input_file_sp(new StreamFile());
std::string cmd_file_path = cmd_file.GetPath();
- Error error = input_file_sp->GetFile().Open(cmd_file_path.c_str(),
- File::eOpenOptionRead);
+ Status error = input_file_sp->GetFile().Open(cmd_file_path.c_str(),
+ File::eOpenOptionRead);
if (error.Success()) {
Debugger &debugger = GetDebugger();
@@ -2473,7 +2475,7 @@ void CommandInterpreter::HandleCommandsFromFile(
}
ScriptInterpreter *CommandInterpreter::GetScriptInterpreter(bool can_create) {
- std::lock_guard<std::mutex> locker(m_script_interpreter_mutex);
+ std::lock_guard<std::recursive_mutex> locker(m_script_interpreter_mutex);
if (!m_script_interpreter_sp) {
if (!can_create)
return nullptr;
@@ -2542,14 +2544,6 @@ void CommandInterpreter::OutputFormattedHelpText(Stream &strm,
OutputFormattedHelpText(strm, prefix_stream.GetString(), help_text);
}
-LLVM_ATTRIBUTE_ALWAYS_INLINE
-static size_t nextWordLength(llvm::StringRef S) {
- size_t pos = S.find_first_of(' ');
- if (pos == llvm::StringRef::npos)
- return S.size();
- return pos;
-}
-
void CommandInterpreter::OutputHelpText(Stream &strm, llvm::StringRef word_text,
llvm::StringRef separator,
llvm::StringRef help_text,
@@ -2568,6 +2562,11 @@ void CommandInterpreter::OutputHelpText(Stream &strm, llvm::StringRef word_text,
uint32_t chars_left = max_columns;
+ auto nextWordLength = [](llvm::StringRef S) {
+ size_t pos = S.find_first_of(' ');
+ return pos == llvm::StringRef::npos ? S.size() : pos;
+ };
+
while (!text.empty()) {
if (text.front() == '\n' ||
(text.front() == ' ' && nextWordLength(text.ltrim(' ')) < chars_left)) {
@@ -2656,7 +2655,7 @@ size_t CommandInterpreter::GetProcessOutput() {
char stdio_buffer[1024];
size_t len;
size_t total_bytes = 0;
- Error error;
+ Status error;
TargetSP target_sp(m_debugger.GetTargetList().GetSelectedTarget());
if (target_sp) {
ProcessSP process_sp(target_sp->GetProcessSP());
OpenPOWER on IntegriCloud