[Lldb-commits] [lldb] r362544 - [Target] Remove Process::GetCPPLanguageRuntime
Alex Langford via lldb-commits
lldb-commits at lists.llvm.org
Tue Jun 4 13:14:33 PDT 2019
Author: xiaobai
Date: Tue Jun 4 13:14:33 2019
New Revision: 362544
URL: http://llvm.org/viewvc/llvm-project?rev=362544&view=rev
Log:
[Target] Remove Process::GetCPPLanguageRuntime
Summary:
I want to remove this method because I think that Process should be
language agnostic, or at least, not have knowledge about specific language
runtimes. There is "GetLanguageRuntime()" which should be used instead. If the
caller a CPPLanguageRuntime, they should cast it as needed. Ideally, this
should only happen in plugins that need C++ specific knowledge.
The next step I would like to do is remove "GetObjCLanguageRuntime()" as well.
There are a lot more instances of that function being used, so I wanted to
upload this one first to get the general reception to this idea.
Reviewers: compnerd, davide, JDevlieghere, jingham, clayborg, labath, aprantl
Subscribers: lldb-commits
Differential Revision: https://reviews.llvm.org/D62755
Modified:
lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h
lldb/trunk/include/lldb/Target/Process.h
lldb/trunk/include/lldb/lldb-forward.h
lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxx.cpp
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
lldb/trunk/source/Target/Process.cpp
Modified: lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h?rev=362544&r1=362543&r2=362544&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h (original)
+++ lldb/trunk/include/lldb/Target/CPPLanguageRuntime.h Tue Jun 4 13:14:33 2019
@@ -43,6 +43,11 @@ public:
return lldb::eLanguageTypeC_plus_plus;
}
+ static CPPLanguageRuntime *GetCPPLanguageRuntime(Process &process) {
+ return static_cast<CPPLanguageRuntime *>(
+ process.GetLanguageRuntime(lldb::eLanguageTypeC_plus_plus));
+ }
+
virtual bool IsVTableName(const char *name) = 0;
bool GetObjectDescription(Stream &str, ValueObject &object) override;
Modified: lldb/trunk/include/lldb/Target/Process.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=362544&r1=362543&r2=362544&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Tue Jun 4 13:14:33 2019
@@ -2184,8 +2184,6 @@ public:
LanguageRuntime *GetLanguageRuntime(lldb::LanguageType language,
bool retry_if_null = true);
- CPPLanguageRuntime *GetCPPLanguageRuntime(bool retry_if_null = true);
-
ObjCLanguageRuntime *GetObjCLanguageRuntime(bool retry_if_null = true);
bool IsPossibleDynamicValue(ValueObject &in_value);
Modified: lldb/trunk/include/lldb/lldb-forward.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=362544&r1=362543&r2=362544&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-forward.h (original)
+++ lldb/trunk/include/lldb/lldb-forward.h Tue Jun 4 13:14:33 2019
@@ -43,7 +43,6 @@ class BreakpointSiteList;
class BroadcastEventSpec;
class Broadcaster;
class BroadcasterManager;
-class CPPLanguageRuntime;
class ClangASTContext;
class ClangASTImporter;
class ClangASTMetadata;
Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxx.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxx.cpp?rev=362544&r1=362543&r2=362544&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxx.cpp (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxx.cpp Tue Jun 4 13:14:33 2019
@@ -67,7 +67,8 @@ bool lldb_private::formatters::LibcxxFun
if (process == nullptr)
return false;
- CPPLanguageRuntime *cpp_runtime = process->GetCPPLanguageRuntime();
+ CPPLanguageRuntime *cpp_runtime =
+ CPPLanguageRuntime::GetCPPLanguageRuntime(*process);
if (!cpp_runtime)
return false;
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp?rev=362544&r1=362543&r2=362544&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp Tue Jun 4 13:14:33 2019
@@ -462,7 +462,7 @@ lldb::SearchFilterSP AppleObjCRuntime::C
ValueObjectSP AppleObjCRuntime::GetExceptionObjectForThread(
ThreadSP thread_sp) {
- auto cpp_runtime = m_process->GetCPPLanguageRuntime();
+ auto *cpp_runtime = m_process->GetLanguageRuntime(eLanguageTypeC_plus_plus);
if (!cpp_runtime) return ValueObjectSP();
auto cpp_exception = cpp_runtime->GetExceptionObjectForThread(thread_sp);
if (!cpp_exception) return ValueObjectSP();
Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=362544&r1=362543&r2=362544&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Tue Jun 4 13:14:33 2019
@@ -1598,16 +1598,6 @@ LanguageRuntime *Process::GetLanguageRun
return runtime;
}
-CPPLanguageRuntime *Process::GetCPPLanguageRuntime(bool retry_if_null) {
- std::lock_guard<std::recursive_mutex> guard(m_language_runtimes_mutex);
- LanguageRuntime *runtime =
- GetLanguageRuntime(eLanguageTypeC_plus_plus, retry_if_null);
- if (!runtime)
- return nullptr;
-
- return static_cast<CPPLanguageRuntime *>(runtime);
-}
-
ObjCLanguageRuntime *Process::GetObjCLanguageRuntime(bool retry_if_null) {
std::lock_guard<std::recursive_mutex> guard(m_language_runtimes_mutex);
LanguageRuntime *runtime =
More information about the lldb-commits
mailing list