forked from OSchip/llvm-project
[lldb/Interpreter] Make `ScriptedInterface::ErrorWithMessage` static (NFC)
This patch changes the `ScriptedInterface::ErrorWithMessage` method to make it `static` which makes it easier to call. The patch also updates its various call sites to reflect this change. Differential Revision: https://reviews.llvm.org/D117374 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
This commit is contained in:
parent
45148bfe8a
commit
91bb116190
|
@ -31,8 +31,8 @@ public:
|
||||||
StructuredData::Generic *script_obj = nullptr) = 0;
|
StructuredData::Generic *script_obj = nullptr) = 0;
|
||||||
|
|
||||||
template <typename Ret>
|
template <typename Ret>
|
||||||
Ret ErrorWithMessage(llvm::StringRef caller_name, llvm::StringRef error_msg,
|
static Ret ErrorWithMessage(llvm::StringRef caller_name,
|
||||||
Status &error,
|
llvm::StringRef error_msg, Status &error,
|
||||||
uint32_t log_caterogy = LIBLLDB_LOG_PROCESS) {
|
uint32_t log_caterogy = LIBLLDB_LOG_PROCESS) {
|
||||||
LLDB_LOGF(GetLogIfAllCategoriesSet(log_caterogy), "%s ERROR = %s",
|
LLDB_LOGF(GetLogIfAllCategoriesSet(log_caterogy), "%s ERROR = %s",
|
||||||
caller_name.data(), error_msg.data());
|
caller_name.data(), error_msg.data());
|
||||||
|
|
|
@ -222,8 +222,8 @@ bool ScriptedProcess::IsAlive() {
|
||||||
size_t ScriptedProcess::DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
|
size_t ScriptedProcess::DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
|
||||||
Status &error) {
|
Status &error) {
|
||||||
if (!m_interpreter)
|
if (!m_interpreter)
|
||||||
return GetInterface().ErrorWithMessage<size_t>(LLVM_PRETTY_FUNCTION,
|
return ScriptedInterface::ErrorWithMessage<size_t>(
|
||||||
"No interpreter.", error);
|
LLVM_PRETTY_FUNCTION, "No interpreter.", error);
|
||||||
|
|
||||||
lldb::DataExtractorSP data_extractor_sp =
|
lldb::DataExtractorSP data_extractor_sp =
|
||||||
GetInterface().ReadMemoryAtAddress(addr, size, error);
|
GetInterface().ReadMemoryAtAddress(addr, size, error);
|
||||||
|
@ -235,7 +235,7 @@ size_t ScriptedProcess::DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
|
||||||
0, data_extractor_sp->GetByteSize(), buf, size, GetByteOrder());
|
0, data_extractor_sp->GetByteSize(), buf, size, GetByteOrder());
|
||||||
|
|
||||||
if (!bytes_copied || bytes_copied == LLDB_INVALID_OFFSET)
|
if (!bytes_copied || bytes_copied == LLDB_INVALID_OFFSET)
|
||||||
return GetInterface().ErrorWithMessage<size_t>(
|
return ScriptedInterface::ErrorWithMessage<size_t>(
|
||||||
LLVM_PRETTY_FUNCTION, "Failed to copy read memory to buffer.", error);
|
LLVM_PRETTY_FUNCTION, "Failed to copy read memory to buffer.", error);
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
|
@ -293,7 +293,7 @@ bool ScriptedProcess::DoUpdateThreadList(ThreadList &old_thread_list,
|
||||||
ScriptLanguage language = m_interpreter->GetLanguage();
|
ScriptLanguage language = m_interpreter->GetLanguage();
|
||||||
|
|
||||||
if (language != eScriptLanguagePython)
|
if (language != eScriptLanguagePython)
|
||||||
return GetInterface().ErrorWithMessage<bool>(
|
return ScriptedInterface::ErrorWithMessage<bool>(
|
||||||
LLVM_PRETTY_FUNCTION,
|
LLVM_PRETTY_FUNCTION,
|
||||||
llvm::Twine("ScriptInterpreter language (" +
|
llvm::Twine("ScriptInterpreter language (" +
|
||||||
llvm::Twine(m_interpreter->LanguageToString(language)) +
|
llvm::Twine(m_interpreter->LanguageToString(language)) +
|
||||||
|
@ -304,7 +304,7 @@ bool ScriptedProcess::DoUpdateThreadList(ThreadList &old_thread_list,
|
||||||
StructuredData::DictionarySP thread_info_sp = GetInterface().GetThreadsInfo();
|
StructuredData::DictionarySP thread_info_sp = GetInterface().GetThreadsInfo();
|
||||||
|
|
||||||
if (!thread_info_sp)
|
if (!thread_info_sp)
|
||||||
return GetInterface().ErrorWithMessage<bool>(
|
return ScriptedInterface::ErrorWithMessage<bool>(
|
||||||
LLVM_PRETTY_FUNCTION,
|
LLVM_PRETTY_FUNCTION,
|
||||||
"Couldn't fetch thread list from Scripted Process.", error);
|
"Couldn't fetch thread list from Scripted Process.", error);
|
||||||
|
|
||||||
|
@ -312,13 +312,13 @@ bool ScriptedProcess::DoUpdateThreadList(ThreadList &old_thread_list,
|
||||||
[this, &old_thread_list, &error,
|
[this, &old_thread_list, &error,
|
||||||
&new_thread_list](ConstString key, StructuredData::Object *val) -> bool {
|
&new_thread_list](ConstString key, StructuredData::Object *val) -> bool {
|
||||||
if (!val)
|
if (!val)
|
||||||
return GetInterface().ErrorWithMessage<bool>(
|
return ScriptedInterface::ErrorWithMessage<bool>(
|
||||||
LLVM_PRETTY_FUNCTION, "Invalid thread info object", error);
|
LLVM_PRETTY_FUNCTION, "Invalid thread info object", error);
|
||||||
|
|
||||||
lldb::tid_t tid = LLDB_INVALID_THREAD_ID;
|
lldb::tid_t tid = LLDB_INVALID_THREAD_ID;
|
||||||
if (!llvm::to_integer(key.AsCString(), tid))
|
if (!llvm::to_integer(key.AsCString(), tid))
|
||||||
return GetInterface().ErrorWithMessage<bool>(LLVM_PRETTY_FUNCTION,
|
return ScriptedInterface::ErrorWithMessage<bool>(
|
||||||
"Invalid thread id", error);
|
LLVM_PRETTY_FUNCTION, "Invalid thread id", error);
|
||||||
|
|
||||||
if (ThreadSP thread_sp =
|
if (ThreadSP thread_sp =
|
||||||
old_thread_list.FindThreadByID(tid, false /*=can_update*/)) {
|
old_thread_list.FindThreadByID(tid, false /*=can_update*/)) {
|
||||||
|
@ -331,7 +331,7 @@ bool ScriptedProcess::DoUpdateThreadList(ThreadList &old_thread_list,
|
||||||
auto thread_or_error = ScriptedThread::Create(*this, val->GetAsGeneric());
|
auto thread_or_error = ScriptedThread::Create(*this, val->GetAsGeneric());
|
||||||
|
|
||||||
if (!thread_or_error)
|
if (!thread_or_error)
|
||||||
return GetInterface().ErrorWithMessage<bool>(
|
return ScriptedInterface::ErrorWithMessage<bool>(
|
||||||
LLVM_PRETTY_FUNCTION, toString(thread_or_error.takeError()), error);
|
LLVM_PRETTY_FUNCTION, toString(thread_or_error.takeError()), error);
|
||||||
|
|
||||||
ThreadSP thread_sp = thread_or_error.get();
|
ThreadSP thread_sp = thread_or_error.get();
|
||||||
|
@ -339,7 +339,7 @@ bool ScriptedProcess::DoUpdateThreadList(ThreadList &old_thread_list,
|
||||||
|
|
||||||
RegisterContextSP reg_ctx_sp = thread_sp->GetRegisterContext();
|
RegisterContextSP reg_ctx_sp = thread_sp->GetRegisterContext();
|
||||||
if (!reg_ctx_sp)
|
if (!reg_ctx_sp)
|
||||||
return GetInterface().ErrorWithMessage<bool>(
|
return ScriptedInterface::ErrorWithMessage<bool>(
|
||||||
LLVM_PRETTY_FUNCTION,
|
LLVM_PRETTY_FUNCTION,
|
||||||
llvm::Twine("Invalid Register Context for thread " +
|
llvm::Twine("Invalid Register Context for thread " +
|
||||||
llvm::Twine(key.AsCString()))
|
llvm::Twine(key.AsCString()))
|
||||||
|
|
Loading…
Reference in New Issue