Files
clang-p2996/lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp
Raphael Isemann 4d51a90297 Get rid of the C-string parameter in DoExecute
Summary:
This patch gets rid of the C-string parameter in the RawCommandObject::DoExecute function,
making the code simpler and less memory unsafe.

There seems to be a assumption in some command objects that this parameter could be a nullptr,
but from what I can see the rest of the API doesn't actually allow this (and other command
objects and related code pieces dereference this parameter without any checks).

Especially CommandObjectRegexCommand has error handling code for a nullptr that is now gone.

Reviewers: davide, jingham, teemperor

Reviewed By: teemperor

Subscribers: jingham, lldb-commits

Differential Revision: https://reviews.llvm.org/D49207

llvm-svn: 336955
2018-07-12 22:28:52 +00:00

74 lines
2.3 KiB
C++

//===-- ScriptInterpreterNone.cpp -------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "ScriptInterpreterNone.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/StringList.h"
#include "llvm/Support/Threading.h"
#include <mutex>
using namespace lldb;
using namespace lldb_private;
ScriptInterpreterNone::ScriptInterpreterNone(CommandInterpreter &interpreter)
: ScriptInterpreter(interpreter, eScriptLanguageNone) {}
ScriptInterpreterNone::~ScriptInterpreterNone() {}
bool ScriptInterpreterNone::ExecuteOneLine(llvm::StringRef command,
CommandReturnObject *,
const ExecuteScriptOptions &) {
m_interpreter.GetDebugger().GetErrorFile()->PutCString(
"error: there is no embedded script interpreter in this mode.\n");
return false;
}
void ScriptInterpreterNone::ExecuteInterpreterLoop() {
m_interpreter.GetDebugger().GetErrorFile()->PutCString(
"error: there is no embedded script interpreter in this mode.\n");
}
void ScriptInterpreterNone::Initialize() {
static llvm::once_flag g_once_flag;
llvm::call_once(g_once_flag, []() {
PluginManager::RegisterPlugin(GetPluginNameStatic(),
GetPluginDescriptionStatic(),
lldb::eScriptLanguageNone, CreateInstance);
});
}
void ScriptInterpreterNone::Terminate() {}
lldb::ScriptInterpreterSP
ScriptInterpreterNone::CreateInstance(CommandInterpreter &interpreter) {
return std::make_shared<ScriptInterpreterNone>(interpreter);
}
lldb_private::ConstString ScriptInterpreterNone::GetPluginNameStatic() {
static ConstString g_name("script-none");
return g_name;
}
const char *ScriptInterpreterNone::GetPluginDescriptionStatic() {
return "Null script interpreter";
}
lldb_private::ConstString ScriptInterpreterNone::GetPluginName() {
return GetPluginNameStatic();
}
uint32_t ScriptInterpreterNone::GetPluginVersion() { return 1; }