mib updated this revision to Diff 480157.
mib retitled this revision from "[lldb/Utility] Make ScriptedProcessInfo more
generic" to "[lldb/Interpreter] Make ScriptedProcessInfo more generic".
mib edited the summary of this revision.
mib added a comment.
Move class from `Utility` to `Interpreter`
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D139247/new/
https://reviews.llvm.org/D139247
Files:
lldb/include/lldb/Interpreter/ScriptedMetadata.h
lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
lldb/source/Plugins/Process/scripted/ScriptedProcess.h
lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
Index: lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
===================================================================
--- lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
+++ lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
@@ -57,8 +57,8 @@
ExecutionContext exe_ctx(process);
StructuredData::GenericSP owned_script_object_sp =
scripted_thread_interface->CreatePluginObject(
- thread_class_name, exe_ctx,
- process.m_scripted_process_info.GetArgsSP(), script_object);
+ thread_class_name, exe_ctx, process.m_scripted_metadata.GetArgsSP(),
+ script_object);
if (!owned_script_object_sp)
return llvm::createStringError(llvm::inconvertibleErrorCode(),
Index: lldb/source/Plugins/Process/scripted/ScriptedProcess.h
===================================================================
--- lldb/source/Plugins/Process/scripted/ScriptedProcess.h
+++ lldb/source/Plugins/Process/scripted/ScriptedProcess.h
@@ -9,6 +9,7 @@
#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/Status.h"
@@ -18,24 +19,7 @@
#include <mutex>
namespace lldb_private {
-
class ScriptedProcess : public Process {
-protected:
- class ScriptedProcessInfo {
- public:
- ScriptedProcessInfo(const ProcessLaunchInfo &launch_info) {
- m_class_name = launch_info.GetScriptedProcessClassName();
- m_args_sp = launch_info.GetScriptedProcessDictionarySP();
- }
-
- std::string GetClassName() const { return m_class_name; }
- StructuredData::DictionarySP GetArgsSP() const { return m_args_sp; }
-
- private:
- std::string m_class_name;
- StructuredData::DictionarySP m_args_sp;
- };
-
public:
static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp,
lldb::ListenerSP listener_sp,
@@ -90,8 +74,7 @@
protected:
ScriptedProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
- const ScriptedProcess::ScriptedProcessInfo &launch_info,
- Status &error);
+ const ScriptedMetadata &scripted_metadata, Status &error);
Status DoStop();
@@ -111,7 +94,7 @@
static bool IsScriptLanguageSupported(lldb::ScriptLanguage language);
// Member variables.
- const ScriptedProcessInfo m_scripted_process_info;
+ const ScriptedMetadata m_scripted_metadata;
lldb_private::ScriptInterpreter *m_interpreter = nullptr;
lldb_private::StructuredData::ObjectSP m_script_object_sp = nullptr;
//@}
Index: lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
===================================================================
--- lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
+++ lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
@@ -18,6 +18,7 @@
#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/RegisterContext.h"
#include "lldb/Utility/LLDBLog.h"
@@ -58,12 +59,11 @@
!IsScriptLanguageSupported(target_sp->GetDebugger().GetScriptLanguage()))
return nullptr;
- Status error;
- ScriptedProcess::ScriptedProcessInfo scripted_process_info(
- target_sp->GetProcessLaunchInfo());
+ ScriptedMetadata scripted_metadata(target_sp->GetProcessLaunchInfo());
- auto process_sp = std::shared_ptr<ScriptedProcess>(new ScriptedProcess(
- target_sp, listener_sp, scripted_process_info, error));
+ Status error;
+ auto process_sp = std::shared_ptr<ScriptedProcess>(
+ new ScriptedProcess(target_sp, listener_sp, scripted_metadata, error));
if (error.Fail() || !process_sp || !process_sp->m_script_object_sp ||
!process_sp->m_script_object_sp->IsValid()) {
@@ -79,12 +79,11 @@
return true;
}
-ScriptedProcess::ScriptedProcess(
- lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
- const ScriptedProcess::ScriptedProcessInfo &scripted_process_info,
- Status &error)
- : Process(target_sp, listener_sp),
- m_scripted_process_info(scripted_process_info) {
+ScriptedProcess::ScriptedProcess(lldb::TargetSP target_sp,
+ lldb::ListenerSP listener_sp,
+ const ScriptedMetadata &scripted_metadata,
+ Status &error)
+ : Process(target_sp, listener_sp), m_scripted_metadata(scripted_metadata) {
if (!target_sp) {
error.SetErrorStringWithFormat("ScriptedProcess::%s () - ERROR: %s",
@@ -104,8 +103,8 @@
ExecutionContext exe_ctx(target_sp, /*get_process=*/false);
StructuredData::GenericSP object_sp = GetInterface().CreatePluginObject(
- m_scripted_process_info.GetClassName().c_str(), exe_ctx,
- m_scripted_process_info.GetArgsSP());
+ m_scripted_metadata.GetClassName().c_str(), exe_ctx,
+ m_scripted_metadata.GetArgsSP());
if (!object_sp || !object_sp->IsValid()) {
error.SetErrorStringWithFormat("ScriptedProcess::%s () - ERROR: %s",
Index: lldb/include/lldb/Interpreter/ScriptedMetadata.h
===================================================================
--- /dev/null
+++ lldb/include/lldb/Interpreter/ScriptedMetadata.h
@@ -0,0 +1,45 @@
+//===-- ScriptedMetadata.h ------------------------------------ -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_SOURCE_PLUGINS_SCRIPTED_METADATA_H
+#define LLDB_SOURCE_PLUGINS_SCRIPTED_METADATA_H
+
+#include "OptionGroupPythonClassWithDict.h"
+
+#include "lldb/Host/Host.h"
+#include "lldb/Host/ProcessLaunchInfo.h"
+#include "lldb/Utility/StructuredData.h"
+
+namespace lldb_private {
+class ScriptedMetadata {
+public:
+ ScriptedMetadata(llvm::StringRef class_name,
+ StructuredData::DictionarySP dict_sp)
+ : m_class_name(class_name.data()), m_args_sp(dict_sp) {}
+
+ ScriptedMetadata(const ProcessLaunchInfo &launch_info) {
+ m_class_name = launch_info.GetScriptedProcessClassName();
+ m_args_sp = launch_info.GetScriptedProcessDictionarySP();
+ }
+
+ 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();
+ }
+
+ std::string GetClassName() const { return m_class_name; }
+ StructuredData::DictionarySP GetArgsSP() const { return m_args_sp; }
+
+private:
+ std::string m_class_name;
+ StructuredData::DictionarySP m_args_sp;
+};
+} // namespace lldb_private
+
+#endif // LLDB_SOURCE_PLUGINS_SCRIPTED_PROCESS_H
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits