[Lldb-commits] [lldb] 601583e - [lldb/Utility] Fix layering violation caused by ScriptedMetadata

Med Ismail Bennani via lldb-commits lldb-commits at lists.llvm.org
Mon Mar 6 13:14:37 PST 2023


Author: Med Ismail Bennani
Date: 2023-03-06T13:14:15-08:00
New Revision: 601583e5a3083b87b48bc6747c12dc0027b09481

URL: https://github.com/llvm/llvm-project/commit/601583e5a3083b87b48bc6747c12dc0027b09481
DIFF: https://github.com/llvm/llvm-project/commit/601583e5a3083b87b48bc6747c12dc0027b09481.diff

LOG: [lldb/Utility] Fix layering violation caused by ScriptedMetadata

This patch moves `ScriptedMetadata.h` from the `Interpreter` directory to
the `Utility` sub-directory since `ProcessInfo.h` depends on it.

It also gets rid of the unused `OptionGroupPythonClassWithDict`
constructor for `ScriptedMetadata` which would address the layering
violation.

Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>

Added: 
    lldb/include/lldb/Utility/ScriptedMetadata.h

Modified: 
    lldb/source/API/SBAttachInfo.cpp
    lldb/source/API/SBLaunchInfo.cpp
    lldb/source/Commands/CommandObjectPlatform.cpp
    lldb/source/Commands/CommandObjectProcess.cpp
    lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
    lldb/source/Plugins/Process/scripted/ScriptedProcess.h
    lldb/source/Utility/ProcessInfo.cpp

Removed: 
    lldb/include/lldb/Interpreter/ScriptedMetadata.h


################################################################################
diff  --git a/lldb/include/lldb/Interpreter/ScriptedMetadata.h b/lldb/include/lldb/Utility/ScriptedMetadata.h
similarity index 82%
rename from lldb/include/lldb/Interpreter/ScriptedMetadata.h
rename to lldb/include/lldb/Utility/ScriptedMetadata.h
index a4dfe54b762f4..945e9c4031ad8 100644
--- a/lldb/include/lldb/Interpreter/ScriptedMetadata.h
+++ b/lldb/include/lldb/Utility/ScriptedMetadata.h
@@ -9,8 +9,6 @@
 #ifndef LLDB_INTERPRETER_SCRIPTEDMETADATA_H
 #define LLDB_INTERPRETER_SCRIPTEDMETADATA_H
 
-#include "OptionGroupPythonClassWithDict.h"
-
 #include "lldb/Host/Host.h"
 #include "lldb/Utility/ProcessInfo.h"
 #include "lldb/Utility/StructuredData.h"
@@ -30,12 +28,6 @@ class ScriptedMetadata {
     }
   }
 
-  ScriptedMetadata(const OptionGroupPythonClassWithDict &option_group) {
-    auto opt_group = const_cast<OptionGroupPythonClassWithDict &>(option_group);
-    m_class_name = opt_group.GetName();
-    m_args_sp = opt_group.GetStructuredData();
-  }
-
   explicit operator bool() const { return !m_class_name.empty(); }
 
   llvm::StringRef GetClassName() const { return m_class_name; }

diff  --git a/lldb/source/API/SBAttachInfo.cpp b/lldb/source/API/SBAttachInfo.cpp
index ffc61b5860d05..0d2dacbf9c78c 100644
--- a/lldb/source/API/SBAttachInfo.cpp
+++ b/lldb/source/API/SBAttachInfo.cpp
@@ -11,9 +11,9 @@
 #include "lldb/API/SBFileSpec.h"
 #include "lldb/API/SBListener.h"
 #include "lldb/API/SBStructuredData.h"
-#include "lldb/Interpreter/ScriptedMetadata.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Utility/Instrumentation.h"
+#include "lldb/Utility/ScriptedMetadata.h"
 
 using namespace lldb;
 using namespace lldb_private;

diff  --git a/lldb/source/API/SBLaunchInfo.cpp b/lldb/source/API/SBLaunchInfo.cpp
index 5800ac63dddb6..21ae84b4e3cc4 100644
--- a/lldb/source/API/SBLaunchInfo.cpp
+++ b/lldb/source/API/SBLaunchInfo.cpp
@@ -17,7 +17,7 @@
 #include "lldb/API/SBStructuredData.h"
 #include "lldb/Core/StructuredDataImpl.h"
 #include "lldb/Host/ProcessLaunchInfo.h"
-#include "lldb/Interpreter/ScriptedMetadata.h"
+#include "lldb/Utility/ScriptedMetadata.h"
 
 using namespace lldb;
 using namespace lldb_private;

diff  --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp
index 213631a250bd7..60d37121844b4 100644
--- a/lldb/source/Commands/CommandObjectPlatform.cpp
+++ b/lldb/source/Commands/CommandObjectPlatform.cpp
@@ -20,11 +20,11 @@
 #include "lldb/Interpreter/OptionGroupFile.h"
 #include "lldb/Interpreter/OptionGroupPlatform.h"
 #include "lldb/Interpreter/OptionGroupPythonClassWithDict.h"
-#include "lldb/Interpreter/ScriptedMetadata.h"
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Target/Platform.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Utility/Args.h"
+#include "lldb/Utility/ScriptedMetadata.h"
 
 #include "llvm/ADT/SmallString.h"
 

diff  --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index 4362b25f9663c..5b578454f1ad6 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -25,7 +25,6 @@
 #include "lldb/Interpreter/OptionArgParser.h"
 #include "lldb/Interpreter/OptionGroupPythonClassWithDict.h"
 #include "lldb/Interpreter/Options.h"
-#include "lldb/Interpreter/ScriptedMetadata.h"
 #include "lldb/Target/Platform.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/StopInfo.h"
@@ -33,6 +32,7 @@
 #include "lldb/Target/Thread.h"
 #include "lldb/Target/UnixSignals.h"
 #include "lldb/Utility/Args.h"
+#include "lldb/Utility/ScriptedMetadata.h"
 #include "lldb/Utility/State.h"
 
 #include "llvm/ADT/ScopeExit.h"

diff  --git a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
index c5a68271c75f0..e26d5f3a2d7cf 100644
--- a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
+++ b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
@@ -18,11 +18,11 @@
 #include "lldb/Interpreter/OptionArgParser.h"
 #include "lldb/Interpreter/OptionGroupBoolean.h"
 #include "lldb/Interpreter/ScriptInterpreter.h"
-#include "lldb/Interpreter/ScriptedMetadata.h"
 #include "lldb/Target/MemoryRegionInfo.h"
 #include "lldb/Target/Queue.h"
 #include "lldb/Target/RegisterContext.h"
 #include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/ScriptedMetadata.h"
 #include "lldb/Utility/State.h"
 
 #include <mutex>

diff  --git a/lldb/source/Plugins/Process/scripted/ScriptedProcess.h b/lldb/source/Plugins/Process/scripted/ScriptedProcess.h
index 73b28a3f39fd0..fd8e3132b620a 100644
--- a/lldb/source/Plugins/Process/scripted/ScriptedProcess.h
+++ b/lldb/source/Plugins/Process/scripted/ScriptedProcess.h
@@ -9,9 +9,9 @@
 #ifndef LLDB_SOURCE_PLUGINS_SCRIPTED_PROCESS_H
 #define LLDB_SOURCE_PLUGINS_SCRIPTED_PROCESS_H
 
-#include "lldb/Interpreter/ScriptedMetadata.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/ScriptedMetadata.h"
 #include "lldb/Utility/Status.h"
 
 #include "ScriptedThread.h"

diff  --git a/lldb/source/Utility/ProcessInfo.cpp b/lldb/source/Utility/ProcessInfo.cpp
index 9ffc409a46959..595c0b090401a 100644
--- a/lldb/source/Utility/ProcessInfo.cpp
+++ b/lldb/source/Utility/ProcessInfo.cpp
@@ -8,8 +8,8 @@
 
 #include "lldb/Utility/ProcessInfo.h"
 
-#include "lldb/Interpreter/ScriptedMetadata.h"
 #include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/ScriptedMetadata.h"
 #include "lldb/Utility/Stream.h"
 #include "lldb/Utility/StreamString.h"
 #include "lldb/Utility/UserIDResolver.h"


        


More information about the lldb-commits mailing list