[Lldb-commits] [lldb] 36254f1 - [lldb] Revert ScriptedProcess patches
Med Ismail Bennani via lldb-commits
lldb-commits at lists.llvm.org
Mon Mar 1 15:25:32 PST 2021
Author: Med Ismail Bennani
Date: 2021-03-01T23:23:27Z
New Revision: 36254f1a0f32e8a1db353efbe1f8c3a290e5b084
URL: https://github.com/llvm/llvm-project/commit/36254f1a0f32e8a1db353efbe1f8c3a290e5b084
DIFF: https://github.com/llvm/llvm-project/commit/36254f1a0f32e8a1db353efbe1f8c3a290e5b084.diff
LOG: [lldb] Revert ScriptedProcess patches
This patch reverts the following commits:
- 5a9c34918bb1526b7e8c29aa5e4fb8d8e27e27b4
- 46796762afe76496ec4dd900f64d0cf4cdc30e99
- 2cff3dec1171188ce04ab1a4373cc1885ab97be1
- 182f0d1a34419445bb19d67581d6ac1afc98b7fa
- d62a53aaf1d38a55d1affbd3a30d564a4e9d3171
Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>
Added:
Modified:
lldb/bindings/interface/SBLaunchInfo.i
lldb/bindings/python/CMakeLists.txt
lldb/bindings/python/python-wrapper.swig
lldb/include/lldb/API/SBData.h
lldb/include/lldb/API/SBError.h
lldb/include/lldb/API/SBLaunchInfo.h
lldb/include/lldb/API/SBStream.h
lldb/include/lldb/API/SBStructuredData.h
lldb/include/lldb/API/SBThreadPlan.h
lldb/include/lldb/Host/ProcessLaunchInfo.h
lldb/include/lldb/Interpreter/ScriptInterpreter.h
lldb/include/lldb/Target/Process.h
lldb/include/lldb/lldb-forward.h
lldb/source/API/SBLaunchInfo.cpp
lldb/source/API/SBTarget.cpp
lldb/source/Commands/CommandObjectPlatform.cpp
lldb/source/Commands/CommandObjectProcess.cpp
lldb/source/Commands/CommandOptionsProcessLaunch.cpp
lldb/source/Commands/CommandOptionsProcessLaunch.h
lldb/source/Host/common/ProcessLaunchInfo.cpp
lldb/source/Interpreter/ScriptInterpreter.cpp
lldb/source/Plugins/Process/CMakeLists.txt
lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
lldb/source/Target/Target.cpp
lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
Removed:
lldb/examples/python/scripted_process/my_scripted_process.py
lldb/examples/python/scripted_process/scripted_process.py
lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
lldb/source/Plugins/Process/scripted/CMakeLists.txt
lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
lldb/source/Plugins/Process/scripted/ScriptedProcess.h
lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.cpp
lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
lldb/test/API/functionalities/scripted_process/Makefile
lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
lldb/test/API/functionalities/scripted_process/main.c
################################################################################
diff --git a/lldb/bindings/interface/SBLaunchInfo.i b/lldb/bindings/interface/SBLaunchInfo.i
index 535ed3b79060..d76656ddd493 100644
--- a/lldb/bindings/interface/SBLaunchInfo.i
+++ b/lldb/bindings/interface/SBLaunchInfo.i
@@ -135,16 +135,6 @@ public:
void
SetDetachOnError(bool enable);
-
- const char *
- GetScriptedProcessClassName() const;
-
- void SetScriptedProcessClassName(const char *class_name);
-
- lldb::SBStructuredData
- GetScriptedProcessDictionary() const;
-
- void SetScriptedProcessDictionary(lldb::SBStructuredData dict);
};
} // namespace lldb
diff --git a/lldb/bindings/python/CMakeLists.txt b/lldb/bindings/python/CMakeLists.txt
index b5c75f5ab650..2b14ee339d0d 100644
--- a/lldb/bindings/python/CMakeLists.txt
+++ b/lldb/bindings/python/CMakeLists.txt
@@ -104,20 +104,6 @@ function(finish_swig_python swig_target lldb_python_bindings_dir lldb_python_tar
FILES "${LLDB_SOURCE_DIR}/examples/python/in_call_stack.py"
"${LLDB_SOURCE_DIR}/examples/python/symbolication.py")
- create_python_package(
- ${swig_target}
- ${lldb_python_target_dir}
- "plugins"
- FILES
- "${LLDB_SOURCE_DIR}/examples/python/scripted_process/scripted_process.py")
-
- create_python_package(
- ${swig_target}
- ${lldb_python_target_dir}
- "plugins"
- FILES
- "${LLDB_SOURCE_DIR}/examples/python/scripted_process/scripted_process.py")
-
if(APPLE)
create_python_package(
${swig_target}
diff --git a/lldb/bindings/python/python-wrapper.swig b/lldb/bindings/python/python-wrapper.swig
index cd9d3990daa2..443ddfb8dd20 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -258,72 +258,6 @@ LLDBSwigPythonCreateCommandObject
Py_RETURN_NONE;
}
-SWIGEXPORT void*
-LLDBSwigPythonCreateScriptedProcess
-(
- const char *python_class_name,
- const char *session_dictionary_name,
- const lldb::TargetSP& target_sp,
- lldb_private::StructuredDataImpl *args_impl,
- std::string &error_string
-)
-{
- if (python_class_name == NULL || python_class_name[0] == '\0' || !session_dictionary_name)
- Py_RETURN_NONE;
-
-
- PyErr_Cleaner py_err_cleaner(true);
-
- auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>(session_dictionary_name);
- auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(python_class_name, dict);
-
- if (!pfunc.IsAllocated()) {
- error_string.append("could not find script class: ");
- error_string.append(python_class_name);
- return nullptr;
- }
-
- // I do not want the SBTarget to be deallocated when going out of scope
- // because python has ownership of it and will manage memory for this
- // object by itself
- PythonObject target_arg(PyRefType::Owned, SBTypeToSWIGWrapper(new lldb::SBTarget(target_sp)));
-
- if (!target_arg.IsAllocated())
- Py_RETURN_NONE;
-
- llvm::Expected<PythonCallable::ArgInfo> arg_info = pfunc.GetArgInfo();
- if (!arg_info) {
- llvm::handleAllErrors(
- arg_info.takeError(),
- [&](PythonException &E) {
- error_string.append(E.ReadBacktrace());
- },
- [&](const llvm::ErrorInfoBase &E) {
- error_string.append(E.message());
- });
- Py_RETURN_NONE;
- }
-
- PythonObject result = {};
- if (arg_info.get().max_positional_args == 2) {
- if (args_impl != nullptr) {
- error_string.assign("args passed, but __init__ does not take an args dictionary");
- Py_RETURN_NONE;
- }
- result = pfunc(target_arg, dict);
- } else if (arg_info.get().max_positional_args >= 3) {
- PythonObject args_arg(PyRefType::Owned, SBTypeToSWIGWrapper(new lldb::SBStructuredData(args_impl)));
- result = pfunc(target_arg, args_arg, dict);
- } else {
- error_string.assign("wrong number of arguments in __init__, should be 2 or 3 (not including self)");
- Py_RETURN_NONE;
- }
-
- if (result.IsAllocated())
- return result.release();
- Py_RETURN_NONE;
-}
-
SWIGEXPORT void*
LLDBSwigPythonCreateScriptedThreadPlan
(
@@ -851,40 +785,6 @@ LLDBSwigPython_GetValueSynthProviderInstance
return ret_val;
}
-SWIGEXPORT void*
-LLDBSWIGPython_CastPyObjectToSBData
-(
- PyObject* data
-)
-{
- lldb::SBData* sb_ptr = nullptr;
-
- int valid_cast = SWIG_ConvertPtr(data, (void**)&sb_ptr, SWIGTYPE_p_lldb__SBData, 0);
-
- if (valid_cast == -1)
- return NULL;
-
- return sb_ptr;
-}
-
-
-SWIGEXPORT void*
-LLDBSWIGPython_CastPyObjectToSBError
-(
- PyObject* data
-)
-{
- lldb::SBError* sb_ptr = nullptr;
-
- int valid_cast = SWIG_ConvertPtr(data, (void**)&sb_ptr, SWIGTYPE_p_lldb__SBError, 0);
-
- if (valid_cast == -1)
- return NULL;
-
- return sb_ptr;
-}
-
-
SWIGEXPORT void*
LLDBSWIGPython_CastPyObjectToSBValue
(
diff --git a/lldb/examples/python/scripted_process/my_scripted_process.py b/lldb/examples/python/scripted_process/my_scripted_process.py
deleted file mode 100644
index d769e137d3f3..000000000000
--- a/lldb/examples/python/scripted_process/my_scripted_process.py
+++ /dev/null
@@ -1,42 +0,0 @@
-import os
-
-import lldb
-from lldb.plugins.scripted_process import ScriptedProcess
-
-class MyScriptedProcess(ScriptedProcess):
- def __init__(self, target: lldb.SBTarget, args : lldb.SBStructuredData):
- super().__init__(target, args)
-
- def get_memory_region_containing_address(self, addr: int) -> lldb.SBMemoryRegionInfo:
- return self.memory_regions[0]
-
- def get_thread_with_id(self, tid: int):
- return {}
-
- def get_registers_for_thread(self, tid: int):
- return {}
-
- def read_memory_at_address(self, addr: int, size: int) -> lldb.SBData:
- data = lldb.SBData().CreateDataFromCString(
- self.target.GetByteOrder(),
- self.target.GetCodeByteSize(),
- "Hello, world!")
- return data
-
- def get_loaded_images(self):
- return self.loaded_images
-
- def get_process_id(self) -> int:
- return 42
-
- def is_alive(self) -> bool:
- return True
-
-def __lldb_init_module(debugger, dict):
- if not 'SKIP_SCRIPTED_PROCESS_LAUNCH' in os.environ:
- debugger.HandleCommand(
- "process launch -C %s.%s" % (__name__,
- MyScriptedProcess.__name__))
- else:
- print("Name of the class that will manage the scripted process: '%s.%s'"
- % (__name__, MyScriptedProcess.__name__))
\ No newline at end of file
diff --git a/lldb/examples/python/scripted_process/scripted_process.py b/lldb/examples/python/scripted_process/scripted_process.py
deleted file mode 100644
index 354b20cfa7f9..000000000000
--- a/lldb/examples/python/scripted_process/scripted_process.py
+++ /dev/null
@@ -1,147 +0,0 @@
-from abc import ABCMeta, abstractmethod
-import six
-
-import lldb
-
- at six.add_metaclass(ABCMeta)
-class ScriptedProcess:
-
- """
- The base class for a scripted process.
-
- Most of the base class methods are `@abstractmethod` that need to be
- overwritten by the inheriting class.
-
- DISCLAIMER: THIS INTERFACE IS STILL UNDER DEVELOPMENT AND NOT STABLE.
- THE METHODS EXPOSED MIGHT CHANGE IN THE FUTURE.
- """
-
- @abstractmethod
- def __init__(self, target, args):
- """ Construct a scripted process.
-
- Args:
- target (lldb.SBTarget): The target launching the scripted process.
- args (lldb.SBStructuredData): A Dictionary holding arbitrary
- key/value pairs used by the scripted process.
- """
- self.target = None
- self.args = None
- if isinstance(target, lldb.SBTarget) and target.IsValid():
- self.target = target
- if isinstance(args, lldb.SBStructuredData) and args.IsValid():
- self.args = args
-
- @abstractmethod
- def get_memory_region_containing_address(addr):
- """ Get the memory region for the scripted process, containing a
- specific address.
-
- Args:
- addr (int): Address to look for in the scripted process memory
- regions.
-
- Returns:
- lldb.SBMemoryRegionInfo: The memory region containing the address.
- None if out of bounds.
- """
- pass
-
- @abstractmethod
- def get_thread_with_id(tid):
- """ Get the scripted process thread with a specific ID.
-
- Args:
- tid (int): Thread ID to look for in the scripted process.
-
- Returns:
- Dict: The thread represented as a dictionary, withr the
- tid thread ID. None if tid doesn't match any of the scripted
- process threads.
- """
- pass
-
- @abstractmethod
- def get_registers_for_thread(tid):
- """ Get the register context dictionary for a certain thread of
- the scripted process.
-
- Args:
- tid (int): Thread ID for the thread's register context.
-
- Returns:
- Dict: The register context represented as a dictionary, for the
- tid thread. None if tid doesn't match any of the scripted
- process threads.
- """
- pass
-
- @abstractmethod
- def read_memory_at_address(addr, size):
- """ Get a memory buffer from the scripted process at a certain address,
- of a certain size.
-
- Args:
- addr (int): Address from which we should start reading.
- size (int): Size of the memory to read.
-
- Returns:
- lldb.SBData: An `lldb.SBData` buffer with the target byte size and
- byte order storing the memory read.
- """
- pass
-
- @abstractmethod
- def get_loaded_images(self):
- """ Get the list of loaded images for the scripted process.
-
- ```
- class ScriptedProcessImage:
- def __init__(name, file_spec, uuid, load_address):
- self.name = name
- self.file_spec = file_spec
- self.uuid = uuid
- self.load_address = load_address
- ```
-
- Returns:
- List[ScriptedProcessImage]: A list of `ScriptedProcessImage`
- containing for each entry, the name of the library, a UUID,
- an `lldb.SBFileSpec` and a load address.
- None if the list is empty.
- """
- pass
-
- def get_process_id(self):
- """ Get the scripted process identifier.
-
- Returns:
- int: The scripted process identifier.
- """
- return 0
-
-
- def launch(self):
- """ Simulate the scripted process launch.
-
- Returns:
- lldb.SBError: An `lldb.SBError` with error code 0.
- """
- return lldb.SBError()
-
- def resume(self):
- """ Simulate the scripted process resume.
-
- Returns:
- lldb.SBError: An `lldb.SBError` with error code 0.
- """
- return lldb.SBError()
-
- @abstractmethod
- def is_alive(self):
- """ Check if the scripted process is alive.
-
- Returns:
- bool: True if scripted process is alive. False otherwise.
- """
- pass
diff --git a/lldb/include/lldb/API/SBData.h b/lldb/include/lldb/API/SBData.h
index 85c8110e181c..95c8086d5d47 100644
--- a/lldb/include/lldb/API/SBData.h
+++ b/lldb/include/lldb/API/SBData.h
@@ -11,10 +11,6 @@
#include "lldb/API/SBDefines.h"
-namespace lldb_private {
-class ScriptInterpreter;
-} // namespace lldb_private
-
namespace lldb {
class LLDB_API SBData {
@@ -151,8 +147,6 @@ class LLDB_API SBData {
friend class SBTarget;
friend class SBValue;
- friend class lldb_private::ScriptInterpreter;
-
lldb::DataExtractorSP m_opaque_sp;
};
diff --git a/lldb/include/lldb/API/SBError.h b/lldb/include/lldb/API/SBError.h
index f8289e2fcbb3..e1960ef9a983 100644
--- a/lldb/include/lldb/API/SBError.h
+++ b/lldb/include/lldb/API/SBError.h
@@ -11,10 +11,6 @@
#include "lldb/API/SBDefines.h"
-namespace lldb_private {
-class ScriptInterpreter;
-} // namespace lldb_private
-
namespace lldb {
class LLDB_API SBError {
@@ -76,8 +72,6 @@ class LLDB_API SBError {
friend class SBWatchpoint;
friend class SBFile;
- friend class lldb_private::ScriptInterpreter;
-
lldb_private::Status *get();
lldb_private::Status *operator->();
diff --git a/lldb/include/lldb/API/SBLaunchInfo.h b/lldb/include/lldb/API/SBLaunchInfo.h
index eb4f4a65833c..04ebb5707688 100644
--- a/lldb/include/lldb/API/SBLaunchInfo.h
+++ b/lldb/include/lldb/API/SBLaunchInfo.h
@@ -171,14 +171,6 @@ class LLDB_API SBLaunchInfo {
void SetDetachOnError(bool enable);
- const char *GetScriptedProcessClassName() const;
-
- void SetScriptedProcessClassName(const char *class_name);
-
- lldb::SBStructuredData GetScriptedProcessDictionary() const;
-
- void SetScriptedProcessDictionary(lldb::SBStructuredData dict);
-
protected:
friend class SBPlatform;
friend class SBTarget;
diff --git a/lldb/include/lldb/API/SBStream.h b/lldb/include/lldb/API/SBStream.h
index f39bf13f2bf7..f44b87bb4c98 100644
--- a/lldb/include/lldb/API/SBStream.h
+++ b/lldb/include/lldb/API/SBStream.h
@@ -72,7 +72,6 @@ class LLDB_API SBStream {
friend class SBFunction;
friend class SBInstruction;
friend class SBInstructionList;
- friend class SBLaunchInfo;
friend class SBLineEntry;
friend class SBMemoryRegionInfo;
friend class SBModule;
diff --git a/lldb/include/lldb/API/SBStructuredData.h b/lldb/include/lldb/API/SBStructuredData.h
index 07763f2de52b..44a86bdabe25 100644
--- a/lldb/include/lldb/API/SBStructuredData.h
+++ b/lldb/include/lldb/API/SBStructuredData.h
@@ -88,7 +88,6 @@ class SBStructuredData {
size_t GetStringValue(char *dst, size_t dst_len) const;
protected:
- friend class SBLaunchInfo;
friend class SBTraceOptions;
friend class SBDebugger;
friend class SBTarget;
diff --git a/lldb/include/lldb/API/SBThreadPlan.h b/lldb/include/lldb/API/SBThreadPlan.h
index 269cbc64a8ef..0dc48437a668 100644
--- a/lldb/include/lldb/API/SBThreadPlan.h
+++ b/lldb/include/lldb/API/SBThreadPlan.h
@@ -17,6 +17,8 @@ namespace lldb {
class LLDB_API SBThreadPlan {
+ friend class lldb_private::ThreadPlan;
+
public:
SBThreadPlan();
diff --git a/lldb/include/lldb/Host/ProcessLaunchInfo.h b/lldb/include/lldb/Host/ProcessLaunchInfo.h
index 883133776214..ee9755580825 100644
--- a/lldb/include/lldb/Host/ProcessLaunchInfo.h
+++ b/lldb/include/lldb/Host/ProcessLaunchInfo.h
@@ -20,7 +20,6 @@
#include "lldb/Host/PseudoTerminal.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/ProcessInfo.h"
-#include "lldb/Utility/StructuredData.h"
namespace lldb_private {
@@ -147,28 +146,6 @@ class ProcessLaunchInfo : public ProcessInfo {
return m_flags.Test(lldb::eLaunchFlagDetachOnError);
}
- bool IsScriptedProcess() const {
- return !m_scripted_process_class_name.empty();
- }
-
- std::string GetScriptedProcessClassName() const {
- return m_scripted_process_class_name;
- }
-
- void SetScriptedProcessClassName(std::string name) {
- m_scripted_process_class_name = name;
- }
-
- lldb_private::StructuredData::DictionarySP
- GetScriptedProcessDictionarySP() const {
- return m_scripted_process_dictionary_sp;
- }
-
- void SetScriptedProcessDictionarySP(
- lldb_private::StructuredData::DictionarySP dictionary_sp) {
- m_scripted_process_dictionary_sp = dictionary_sp;
- }
-
protected:
FileSpec m_working_dir;
std::string m_plugin_name;
@@ -184,11 +161,6 @@ class ProcessLaunchInfo : public ProcessInfo {
// meaning to the upper levels of lldb.
lldb::ListenerSP m_listener_sp;
lldb::ListenerSP m_hijack_listener_sp;
- std::string m_scripted_process_class_name; // The name of the class that will
- // manage a scripted process.
- StructuredData::DictionarySP
- m_scripted_process_dictionary_sp; // A dictionary that holds key/value
- // pairs passed to the scripted process.
};
}
diff --git a/lldb/include/lldb/Interpreter/ScriptInterpreter.h b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
index fa713e66d000..275d61a63f05 100644
--- a/lldb/include/lldb/Interpreter/ScriptInterpreter.h
+++ b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
@@ -9,15 +9,12 @@
#ifndef LLDB_INTERPRETER_SCRIPTINTERPRETER_H
#define LLDB_INTERPRETER_SCRIPTINTERPRETER_H
-#include "lldb/API/SBData.h"
-#include "lldb/API/SBError.h"
#include "lldb/Breakpoint/BreakpointOptions.h"
#include "lldb/Core/Communication.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Core/SearchFilter.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Host/PseudoTerminal.h"
-#include "lldb/Interpreter/ScriptedProcessInterface.h"
#include "lldb/Utility/Broadcaster.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/StructuredData.h"
@@ -86,9 +83,7 @@ class ScriptInterpreter : public PluginInterface {
eScriptReturnTypeOpaqueObject
};
- ScriptInterpreter(
- Debugger &debugger, lldb::ScriptLanguage script_lang,
- lldb::ScriptedProcessInterfaceUP scripted_process_interface_up = {});
+ ScriptInterpreter(Debugger &debugger, lldb::ScriptLanguage script_lang);
~ScriptInterpreter() override = default;
@@ -533,19 +528,9 @@ class ScriptInterpreter : public PluginInterface {
lldb::ScriptLanguage GetLanguage() { return m_script_lang; }
- ScriptedProcessInterface &GetScriptedProcessInterface() {
- return *m_scripted_process_interface_up;
- }
-
- lldb::DataExtractorSP
- GetDataExtractorFromSBData(const lldb::SBData &data) const;
-
- Status GetStatusFromSBError(const lldb::SBError &error) const;
-
protected:
Debugger &m_debugger;
lldb::ScriptLanguage m_script_lang;
- lldb::ScriptedProcessInterfaceUP m_scripted_process_interface_up;
};
} // namespace lldb_private
diff --git a/lldb/include/lldb/Interpreter/ScriptedProcessInterface.h b/lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
deleted file mode 100644
index 67fa8e3133cd..000000000000
--- a/lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
+++ /dev/null
@@ -1,64 +0,0 @@
-//===-- ScriptedProcessInterface.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_INTERPRETER_SCRIPTEDPROCESSINTERFACE_H
-#define LLDB_INTERPRETER_SCRIPTEDPROCESSINTERFACE_H
-
-#include "lldb/Core/StructuredDataImpl.h"
-#include "lldb/Interpreter/ScriptInterpreter.h"
-#include "lldb/lldb-private.h"
-
-#include <string>
-
-namespace lldb_private {
-class ScriptedProcessInterface {
-public:
- ScriptedProcessInterface() : m_object_instance_sp(nullptr) {}
-
- virtual ~ScriptedProcessInterface() = default;
-
- virtual StructuredData::GenericSP
- CreatePluginObject(const llvm::StringRef class_name, lldb::TargetSP target_sp,
- StructuredData::DictionarySP args_sp) {
- return nullptr;
- }
-
- virtual Status Launch() { return Status("ScriptedProcess did not launch"); }
-
- virtual Status Resume() { return Status("ScriptedProcess did not resume"); }
-
- virtual lldb::MemoryRegionInfoSP
- GetMemoryRegionContainingAddress(lldb::addr_t address) {
- return nullptr;
- }
-
- virtual StructuredData::DictionarySP GetThreadWithID(lldb::tid_t tid) {
- return nullptr;
- }
-
- virtual StructuredData::DictionarySP GetRegistersForThread(lldb::tid_t tid) {
- return nullptr;
- }
-
- virtual lldb::DataExtractorSP
- ReadMemoryAtAddress(lldb::addr_t address, size_t size, Status &error) {
- return nullptr;
- }
-
- virtual StructuredData::DictionarySP GetLoadedImages() { return nullptr; }
-
- virtual lldb::pid_t GetProcessID() { return LLDB_INVALID_PROCESS_ID; }
-
- virtual bool IsAlive() { return true; }
-
-private:
- StructuredData::ObjectSP m_object_instance_sp;
-};
-} // namespace lldb_private
-
-#endif // LLDB_INTERPRETER_SCRIPTEDPROCESSINTERFACE_H
diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h
index 127f03f3619c..fbdb5069b39f 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -2561,6 +2561,8 @@ void PruneThreadPlans();
virtual size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
Status &error) = 0;
+ void SetState(lldb::EventSP &event_sp);
+
lldb::StateType GetPrivateState();
/// The "private" side of resuming a process. This doesn't alter the state
diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h
index 3cf575486277..a297a928a3f4 100644
--- a/lldb/include/lldb/lldb-forward.h
+++ b/lldb/include/lldb/lldb-forward.h
@@ -174,7 +174,6 @@ class RichManglingContext;
class Scalar;
class ScriptInterpreter;
class ScriptInterpreterLocker;
-class ScriptedProcessInterface;
class ScriptedSyntheticChildren;
class SearchFilter;
class Section;
@@ -342,7 +341,6 @@ typedef std::shared_ptr<lldb_private::Listener> ListenerSP;
typedef std::weak_ptr<lldb_private::Listener> ListenerWP;
typedef std::shared_ptr<lldb_private::MemoryHistory> MemoryHistorySP;
typedef std::unique_ptr<lldb_private::MemoryRegionInfo> MemoryRegionInfoUP;
-typedef std::shared_ptr<lldb_private::MemoryRegionInfo> MemoryRegionInfoSP;
typedef std::shared_ptr<lldb_private::Module> ModuleSP;
typedef std::weak_ptr<lldb_private::Module> ModuleWP;
typedef std::shared_ptr<lldb_private::ObjectFile> ObjectFileSP;
@@ -393,8 +391,6 @@ typedef std::shared_ptr<lldb_private::ScriptSummaryFormat>
ScriptSummaryFormatSP;
typedef std::shared_ptr<lldb_private::ScriptInterpreter> ScriptInterpreterSP;
typedef std::unique_ptr<lldb_private::ScriptInterpreter> ScriptInterpreterUP;
-typedef std::unique_ptr<lldb_private::ScriptedProcessInterface>
- ScriptedProcessInterfaceUP;
typedef std::shared_ptr<lldb_private::Section> SectionSP;
typedef std::unique_ptr<lldb_private::SectionList> SectionListUP;
typedef std::weak_ptr<lldb_private::Section> SectionWP;
diff --git a/lldb/source/API/SBLaunchInfo.cpp b/lldb/source/API/SBLaunchInfo.cpp
index 70cd1c6ecf74..cda8134c9853 100644
--- a/lldb/source/API/SBLaunchInfo.cpp
+++ b/lldb/source/API/SBLaunchInfo.cpp
@@ -10,12 +10,8 @@
#include "SBReproducerPrivate.h"
#include "lldb/API/SBEnvironment.h"
-#include "lldb/API/SBError.h"
#include "lldb/API/SBFileSpec.h"
#include "lldb/API/SBListener.h"
-#include "lldb/API/SBStream.h"
-#include "lldb/API/SBStructuredData.h"
-#include "lldb/Core/StructuredDataImpl.h"
#include "lldb/Host/ProcessLaunchInfo.h"
using namespace lldb;
@@ -347,53 +343,6 @@ bool SBLaunchInfo::GetDetachOnError() const {
return m_opaque_sp->GetDetachOnError();
}
-const char *SBLaunchInfo::GetScriptedProcessClassName() const {
- LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBLaunchInfo,
- GetScriptedProcessClassName);
-
- // Constify this string so that it is saved in the string pool. Otherwise it
- // would be freed when this function goes out of scope.
- ConstString class_name(m_opaque_sp->GetScriptedProcessClassName().c_str());
- return class_name.AsCString();
-}
-
-void SBLaunchInfo::SetScriptedProcessClassName(const char *class_name) {
- LLDB_RECORD_METHOD(void, SBLaunchInfo, SetScriptedProcessClassName,
- (const char *), class_name);
-
- m_opaque_sp->SetScriptedProcessClassName(class_name);
-}
-
-lldb::SBStructuredData SBLaunchInfo::GetScriptedProcessDictionary() const {
- LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBStructuredData, SBLaunchInfo,
- GetScriptedProcessDictionary);
-
- lldb_private::StructuredData::DictionarySP dict_sp =
- m_opaque_sp->GetScriptedProcessDictionarySP();
-
- SBStructuredData data;
- data.m_impl_up->SetObjectSP(dict_sp);
-
- return LLDB_RECORD_RESULT(data);
-}
-
-void SBLaunchInfo::SetScriptedProcessDictionary(lldb::SBStructuredData dict) {
- LLDB_RECORD_METHOD(void, SBLaunchInfo, SetScriptedProcessDictionary,
- (lldb::SBStructuredData), dict);
-
- SBStream stream;
- SBError error = dict.GetAsJSON(stream);
-
- if (error.Fail())
- return;
-
- StructuredData::DictionarySP dict_sp;
- llvm::json::OStream s(stream.ref().AsRawOstream());
- dict_sp->Serialize(s);
-
- m_opaque_sp->SetScriptedProcessDictionarySP(dict_sp);
-}
-
namespace lldb_private {
namespace repro {
@@ -454,14 +403,6 @@ void RegisterMethods<SBLaunchInfo>(Registry &R) {
());
LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetDetachOnError, (bool));
LLDB_REGISTER_METHOD_CONST(bool, SBLaunchInfo, GetDetachOnError, ());
- LLDB_REGISTER_METHOD_CONST(const char *, SBLaunchInfo,
- GetScriptedProcessClassName, ());
- LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetScriptedProcessClassName,
- (const char *));
- LLDB_REGISTER_METHOD_CONST(lldb::SBStructuredData, SBLaunchInfo,
- GetScriptedProcessDictionary, ());
- LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetScriptedProcessDictionary,
- (lldb::SBStructuredData));
LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetEnvironment,
(const lldb::SBEnvironment &, bool));
LLDB_REGISTER_METHOD(lldb::SBEnvironment, SBLaunchInfo, GetEnvironment, ());
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index d5a2354ec0e6..b376bc4bd756 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -446,7 +446,6 @@ SBProcess SBTarget::Launch(SBLaunchInfo &sb_launch_info, SBError &error) {
if (arch_spec.IsValid())
launch_info.GetArchitecture() = arch_spec;
- target_sp->SetProcessLaunchInfo(launch_info);
error.SetError(target_sp->Launch(launch_info, nullptr));
sb_launch_info.set_ref(launch_info);
sb_process.SetSP(target_sp->GetProcessSP());
diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp
index d0c58ac807ff..f306da3c8543 100644
--- a/lldb/source/Commands/CommandObjectPlatform.cpp
+++ b/lldb/source/Commands/CommandObjectPlatform.cpp
@@ -1009,14 +1009,11 @@ class CommandObjectPlatformProcessLaunch : public CommandObjectParsed {
"Launch a new process on a remote platform.",
"platform process launch program",
eCommandRequiresTarget | eCommandTryTargetAPILock),
- m_options(), m_all_options() {
- m_all_options.Append(&m_options);
- m_all_options.Finalize();
- }
+ m_options() {}
~CommandObjectPlatformProcessLaunch() override = default;
- Options *GetOptions() override { return &m_all_options; }
+ Options *GetOptions() override { return &m_options; }
protected:
bool DoExecute(Args &args, CommandReturnObject &result) override {
@@ -1088,7 +1085,6 @@ class CommandObjectPlatformProcessLaunch : public CommandObjectParsed {
}
CommandOptionsProcessLaunch m_options;
- OptionGroupOptions m_all_options;
};
// "platform process list"
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index 06d2f54c2481..c21c499536f2 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -17,7 +17,6 @@
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
-#include "lldb/Interpreter/OptionGroupPythonClassWithDict.h"
#include "lldb/Interpreter/Options.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
@@ -109,12 +108,7 @@ class CommandObjectProcessLaunch : public CommandObjectProcessLaunchOrAttach {
interpreter, "process launch",
"Launch the executable in the debugger.", nullptr,
eCommandRequiresTarget, "restart"),
- m_options(), m_class_options("scripted process"), m_all_options() {
- m_all_options.Append(&m_options);
- m_all_options.Append(&m_class_options, LLDB_OPT_SET_1 | LLDB_OPT_SET_2,
- LLDB_OPT_SET_1);
- m_all_options.Finalize();
-
+ m_options() {
CommandArgumentEntry arg;
CommandArgumentData run_args_arg;
@@ -141,7 +135,7 @@ class CommandObjectProcessLaunch : public CommandObjectProcessLaunchOrAttach {
request, nullptr);
}
- Options *GetOptions() override { return &m_all_options; }
+ Options *GetOptions() override { return &m_options; }
const char *GetRepeatCommand(Args ¤t_command_args,
uint32_t index) override {
@@ -186,15 +180,6 @@ class CommandObjectProcessLaunch : public CommandObjectProcessLaunchOrAttach {
disable_aslr = target->GetDisableASLR();
}
- if (!m_class_options.GetName().empty()) {
- m_options.launch_info.SetProcessPluginName("ScriptedProcess");
- m_options.launch_info.SetScriptedProcessClassName(
- m_class_options.GetName());
- m_options.launch_info.SetScriptedProcessDictionarySP(
- m_class_options.GetStructuredData());
- target->SetProcessLaunchInfo(m_options.launch_info);
- }
-
if (disable_aslr)
m_options.launch_info.GetFlags().Set(eLaunchFlagDisableASLR);
else
@@ -268,8 +253,6 @@ class CommandObjectProcessLaunch : public CommandObjectProcessLaunchOrAttach {
}
CommandOptionsProcessLaunch m_options;
- OptionGroupPythonClassWithDict m_class_options;
- OptionGroupOptions m_all_options;
};
#define LLDB_OPTIONS_process_attach
diff --git a/lldb/source/Commands/CommandOptionsProcessLaunch.cpp b/lldb/source/Commands/CommandOptionsProcessLaunch.cpp
index a618796156a6..dfc4887fec26 100644
--- a/lldb/source/Commands/CommandOptionsProcessLaunch.cpp
+++ b/lldb/source/Commands/CommandOptionsProcessLaunch.cpp
@@ -30,7 +30,7 @@ Status CommandOptionsProcessLaunch::SetOptionValue(
uint32_t option_idx, llvm::StringRef option_arg,
ExecutionContext *execution_context) {
Status error;
- const int short_option = g_process_launch_options[option_idx].short_option;
+ const int short_option = m_getopt_table[option_idx].val;
switch (short_option) {
case 's': // Stop at program entry point
diff --git a/lldb/source/Commands/CommandOptionsProcessLaunch.h b/lldb/source/Commands/CommandOptionsProcessLaunch.h
index d18a23245080..e0ece8a5159d 100644
--- a/lldb/source/Commands/CommandOptionsProcessLaunch.h
+++ b/lldb/source/Commands/CommandOptionsProcessLaunch.h
@@ -1,4 +1,4 @@
-//===-- CommandOptionsProcessLaunch.h ---------------------------*- C++ -*-===//
+//===-- CommandOptionsProcessLaunch.h -------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -16,9 +16,9 @@ namespace lldb_private {
// CommandOptionsProcessLaunch
-class CommandOptionsProcessLaunch : public lldb_private::OptionGroup {
+class CommandOptionsProcessLaunch : public lldb_private::Options {
public:
- CommandOptionsProcessLaunch() : lldb_private::OptionGroup() {
+ CommandOptionsProcessLaunch() : lldb_private::Options() {
// Keep default values of all options in one place: OptionParsingStarting
// ()
OptionParsingStarting(nullptr);
diff --git a/lldb/source/Host/common/ProcessLaunchInfo.cpp b/lldb/source/Host/common/ProcessLaunchInfo.cpp
index d42687e9a4e3..1b4b2c6c3ac2 100644
--- a/lldb/source/Host/common/ProcessLaunchInfo.cpp
+++ b/lldb/source/Host/common/ProcessLaunchInfo.cpp
@@ -32,8 +32,7 @@ ProcessLaunchInfo::ProcessLaunchInfo()
: ProcessInfo(), m_working_dir(), m_plugin_name(), m_flags(0),
m_file_actions(), m_pty(new PseudoTerminal), m_resume_count(0),
m_monitor_callback(nullptr), m_monitor_callback_baton(nullptr),
- m_monitor_signals(false), m_listener_sp(), m_hijack_listener_sp(),
- m_scripted_process_class_name(), m_scripted_process_dictionary_sp() {}
+ m_monitor_signals(false), m_listener_sp(), m_hijack_listener_sp() {}
ProcessLaunchInfo::ProcessLaunchInfo(const FileSpec &stdin_file_spec,
const FileSpec &stdout_file_spec,
@@ -43,8 +42,7 @@ ProcessLaunchInfo::ProcessLaunchInfo(const FileSpec &stdin_file_spec,
: ProcessInfo(), m_working_dir(), m_plugin_name(), m_flags(launch_flags),
m_file_actions(), m_pty(new PseudoTerminal), m_resume_count(0),
m_monitor_callback(nullptr), m_monitor_callback_baton(nullptr),
- m_monitor_signals(false), m_listener_sp(), m_hijack_listener_sp(),
- m_scripted_process_class_name(), m_scripted_process_dictionary_sp() {
+ m_monitor_signals(false), m_listener_sp(), m_hijack_listener_sp() {
if (stdin_file_spec) {
FileAction file_action;
const bool read = true;
@@ -173,8 +171,6 @@ void ProcessLaunchInfo::Clear() {
m_resume_count = 0;
m_listener_sp.reset();
m_hijack_listener_sp.reset();
- m_scripted_process_class_name.clear();
- m_scripted_process_dictionary_sp.reset();
}
void ProcessLaunchInfo::SetMonitorProcessCallback(
diff --git a/lldb/source/Interpreter/ScriptInterpreter.cpp b/lldb/source/Interpreter/ScriptInterpreter.cpp
index d822ea23a10a..2c55d08497ab 100644
--- a/lldb/source/Interpreter/ScriptInterpreter.cpp
+++ b/lldb/source/Interpreter/ScriptInterpreter.cpp
@@ -26,12 +26,9 @@
using namespace lldb;
using namespace lldb_private;
-ScriptInterpreter::ScriptInterpreter(
- Debugger &debugger, lldb::ScriptLanguage script_lang,
- lldb::ScriptedProcessInterfaceUP scripted_process_interface_up)
- : m_debugger(debugger), m_script_lang(script_lang),
- m_scripted_process_interface_up(
- std::move(scripted_process_interface_up)) {}
+ScriptInterpreter::ScriptInterpreter(Debugger &debugger,
+ lldb::ScriptLanguage script_lang)
+ : m_debugger(debugger), m_script_lang(script_lang) {}
void ScriptInterpreter::CollectDataForBreakpointCommandCallback(
std::vector<BreakpointOptions *> &bp_options_vec,
@@ -72,19 +69,6 @@ std::string ScriptInterpreter::LanguageToString(lldb::ScriptLanguage language) {
llvm_unreachable("Unhandled ScriptInterpreter!");
}
-lldb::DataExtractorSP
-ScriptInterpreter::GetDataExtractorFromSBData(const lldb::SBData &data) const {
- return data.m_opaque_sp;
-}
-
-Status
-ScriptInterpreter::GetStatusFromSBError(const lldb::SBError &error) const {
- if (error.m_opaque_up)
- return *error.m_opaque_up.get();
-
- return Status();
-}
-
lldb::ScriptLanguage
ScriptInterpreter::StringToLanguage(const llvm::StringRef &language) {
if (language.equals_lower(LanguageToString(eScriptLanguageNone)))
diff --git a/lldb/source/Plugins/Process/CMakeLists.txt b/lldb/source/Plugins/Process/CMakeLists.txt
index bea5bac9eb21..fdeb211fe7a2 100644
--- a/lldb/source/Plugins/Process/CMakeLists.txt
+++ b/lldb/source/Plugins/Process/CMakeLists.txt
@@ -12,7 +12,6 @@ elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_subdirectory(MacOSX-Kernel)
endif()
-add_subdirectory(scripted)
add_subdirectory(gdb-remote)
add_subdirectory(Utility)
add_subdirectory(elf-core)
diff --git a/lldb/source/Plugins/Process/scripted/CMakeLists.txt b/lldb/source/Plugins/Process/scripted/CMakeLists.txt
deleted file mode 100644
index e2cfd058e278..000000000000
--- a/lldb/source/Plugins/Process/scripted/CMakeLists.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-add_lldb_library(lldbPluginScriptedProcess PLUGIN
- ScriptedProcess.cpp
-
- LINK_LIBS
- lldbCore
- lldbTarget
- lldbUtility
- lldbPluginProcessUtility
- LINK_COMPONENTS
- BinaryFormat
- Object
- Support
- )
diff --git a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp b/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
deleted file mode 100644
index 445aa026bd8a..000000000000
--- a/lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
+++ /dev/null
@@ -1,242 +0,0 @@
-//===-- ScriptedProcess.cpp -----------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#include "ScriptedProcess.h"
-
-#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Module.h"
-#include "lldb/Core/PluginManager.h"
-
-#include "lldb/Host/OptionParser.h"
-
-#include "lldb/Interpreter/OptionArgParser.h"
-#include "lldb/Interpreter/OptionGroupBoolean.h"
-#include "lldb/Interpreter/ScriptInterpreter.h"
-#include "lldb/Target/MemoryRegionInfo.h"
-
-LLDB_PLUGIN_DEFINE(ScriptedProcess)
-
-using namespace lldb;
-using namespace lldb_private;
-
-ConstString ScriptedProcess::GetPluginNameStatic() {
- static ConstString g_name("ScriptedProcess");
- return g_name;
-}
-
-const char *ScriptedProcess::GetPluginDescriptionStatic() {
- return "Scripted Process plug-in.";
-}
-
-lldb::ProcessSP ScriptedProcess::CreateInstance(lldb::TargetSP target_sp,
- lldb::ListenerSP listener_sp,
- const FileSpec *file,
- bool can_connect) {
- ScriptedProcess::LaunchInfo launch_info(target_sp->GetProcessLaunchInfo());
-
- auto process_sp =
- std::make_shared<ScriptedProcess>(target_sp, listener_sp, launch_info);
-
- if (!process_sp || !process_sp->m_script_object_sp ||
- !process_sp->m_script_object_sp->IsValid())
- return nullptr;
-
- return process_sp;
-}
-
-bool ScriptedProcess::CanDebug(lldb::TargetSP target_sp,
- bool plugin_specified_by_name) {
- return true;
-}
-
-ScriptedProcess::ScriptedProcess(lldb::TargetSP target_sp,
- lldb::ListenerSP listener_sp,
- const ScriptedProcess::LaunchInfo &launch_info)
- : Process(target_sp, listener_sp), m_launch_info(launch_info),
- m_interpreter(nullptr), m_script_object_sp(nullptr) {
- if (!target_sp)
- return;
-
- m_interpreter = target_sp->GetDebugger().GetScriptInterpreter();
-
- if (!m_interpreter)
- return;
-
- StructuredData::ObjectSP object_sp = GetInterface().CreatePluginObject(
- m_launch_info.GetClassName().c_str(), target_sp,
- m_launch_info.GetDictionarySP());
-
- if (object_sp && object_sp->IsValid())
- m_script_object_sp = object_sp;
-}
-
-ScriptedProcess::~ScriptedProcess() {
- Clear();
- // We need to call finalize on the process before destroying ourselves to
- // make sure all of the broadcaster cleanup goes as planned. If we destruct
- // this class, then Process::~Process() might have problems trying to fully
- // destroy the broadcaster.
- Finalize();
-}
-
-void ScriptedProcess::Initialize() {
- static llvm::once_flag g_once_flag;
-
- llvm::call_once(g_once_flag, []() {
- PluginManager::RegisterPlugin(GetPluginNameStatic(),
- GetPluginDescriptionStatic(), CreateInstance);
- });
-}
-
-void ScriptedProcess::Terminate() {
- PluginManager::UnregisterPlugin(ScriptedProcess::CreateInstance);
-}
-
-ConstString ScriptedProcess::GetPluginName() { return GetPluginNameStatic(); }
-
-uint32_t ScriptedProcess::GetPluginVersion() { return 1; }
-
-Status ScriptedProcess::DoLoadCore() {
- ProcessLaunchInfo launch_info = GetTarget().GetProcessLaunchInfo();
-
- return DoLaunch(nullptr, launch_info);
-}
-
-Status ScriptedProcess::DoLaunch(Module *exe_module,
- ProcessLaunchInfo &launch_info) {
- if (!m_interpreter)
- return Status("No interpreter.");
-
- if (!m_script_object_sp)
- return Status("No python object.");
-
- Status status = GetInterface().Launch();
-
- if (status.Success()) {
- SetPrivateState(eStateRunning);
- SetPrivateState(eStateStopped);
- }
-
- return status;
-};
-
-void ScriptedProcess::DidLaunch() {
- if (m_interpreter)
- m_pid = GetInterface().GetProcessID();
-}
-
-Status ScriptedProcess::DoResume() {
- if (!m_interpreter)
- return Status("No interpreter.");
-
- if (!m_script_object_sp)
- return Status("No python object.");
-
- Status status = GetInterface().Resume();
-
- if (status.Success()) {
- SetPrivateState(eStateRunning);
- SetPrivateState(eStateStopped);
- }
-
- return status;
-}
-
-Status ScriptedProcess::DoDestroy() { return Status(); }
-
-bool ScriptedProcess::IsAlive() {
- if (!m_interpreter)
- return false;
-
- return GetInterface().IsAlive();
-}
-
-size_t ScriptedProcess::ReadMemory(lldb::addr_t addr, void *buf, size_t size,
- Status &error) {
- return DoReadMemory(addr, buf, size, error);
-}
-
-size_t ScriptedProcess::DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
- Status &error) {
-
- auto error_with_message = [&error](llvm::StringRef message) {
- error.SetErrorString(message);
- return LLDB_INVALID_ADDRESS;
- };
-
- if (!m_interpreter)
- return error_with_message("No interpreter.");
-
- lldb::DataExtractorSP data_extractor_sp =
- GetInterface().ReadMemoryAtAddress(addr, size, error);
-
- if (!data_extractor_sp || error.Fail())
- return LLDB_INVALID_ADDRESS;
-
- if (data_extractor_sp->GetByteSize() != size)
- return error_with_message("Failed to read requested memory size.");
-
- if (data_extractor_sp->CopyData(0, size, buf) <= size)
- return error_with_message("Failed to copy read memory to buffer.");
-
- return size;
-}
-
-ArchSpec ScriptedProcess::GetArchitecture() {
- return GetTarget().GetArchitecture();
-}
-
-Status ScriptedProcess::GetMemoryRegionInfo(lldb::addr_t load_addr,
- MemoryRegionInfo ®ion) {
- return Status();
-}
-
-Status ScriptedProcess::GetMemoryRegions(MemoryRegionInfos ®ion_list) {
- Status error;
-
- if (!m_interpreter) {
- error.SetErrorString("No interpreter.");
- return error;
- }
-
- lldb::addr_t address = 0;
- lldb::MemoryRegionInfoSP mem_region_sp = nullptr;
-
- while ((mem_region_sp =
- GetInterface().GetMemoryRegionContainingAddress(address))) {
- auto range = mem_region_sp->GetRange();
- address += range.GetRangeBase() + range.GetByteSize();
- region_list.push_back(*mem_region_sp.get());
- }
-
- return error;
-}
-
-void ScriptedProcess::Clear() { Process::m_thread_list.Clear(); }
-
-bool ScriptedProcess::DoUpdateThreadList(ThreadList &old_thread_list,
- ThreadList &new_thread_list) {
- return new_thread_list.GetSize(false) > 0;
-}
-
-bool ScriptedProcess::GetProcessInfo(ProcessInstanceInfo &info) {
- info.Clear();
- info.SetProcessID(GetID());
- info.SetArchitecture(GetArchitecture());
- lldb::ModuleSP module_sp = GetTarget().GetExecutableModule();
- if (module_sp) {
- const bool add_exe_file_as_first_arg = false;
- info.SetExecutableFile(GetTarget().GetExecutableModule()->GetFileSpec(),
- add_exe_file_as_first_arg);
- }
- return true;
-}
-
-ScriptedProcessInterface &ScriptedProcess::GetInterface() const {
- return m_interpreter->GetScriptedProcessInterface();
-}
diff --git a/lldb/source/Plugins/Process/scripted/ScriptedProcess.h b/lldb/source/Plugins/Process/scripted/ScriptedProcess.h
deleted file mode 100644
index c4e76e50410f..000000000000
--- a/lldb/source/Plugins/Process/scripted/ScriptedProcess.h
+++ /dev/null
@@ -1,113 +0,0 @@
-//===-- ScriptedProcess.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_PROCESS_H
-#define LLDB_SOURCE_PLUGINS_SCRIPTED_PROCESS_H
-
-#include "lldb/Target/Process.h"
-#include "lldb/Utility/ConstString.h"
-#include "lldb/Utility/Status.h"
-
-namespace lldb_private {
-
-class ScriptedProcess : public Process {
-protected:
- class LaunchInfo {
- public:
- LaunchInfo(const ProcessLaunchInfo &launch_info) {
- m_class_name = launch_info.GetScriptedProcessClassName();
- m_dictionary_sp = launch_info.GetScriptedProcessDictionarySP();
- }
-
- std::string GetClassName() const { return m_class_name; }
- StructuredData::DictionarySP GetDictionarySP() const {
- return m_dictionary_sp;
- }
-
- private:
- std::string m_class_name;
- StructuredData::DictionarySP m_dictionary_sp;
- };
-
-public:
- static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp,
- lldb::ListenerSP listener_sp,
- const FileSpec *crash_file_path,
- bool can_connect);
-
- static void Initialize();
-
- static void Terminate();
-
- static ConstString GetPluginNameStatic();
-
- static const char *GetPluginDescriptionStatic();
-
- ScriptedProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
- const ScriptedProcess::LaunchInfo &launch_info);
-
- ~ScriptedProcess() override;
-
- bool CanDebug(lldb::TargetSP target_sp,
- bool plugin_specified_by_name) override;
-
- DynamicLoader *GetDynamicLoader() override { return nullptr; }
-
- ConstString GetPluginName() override;
-
- uint32_t GetPluginVersion() override;
-
- SystemRuntime *GetSystemRuntime() override { return nullptr; }
-
- Status DoLoadCore() override;
-
- Status DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info) override;
-
- void DidLaunch() override;
-
- Status DoResume() override;
-
- Status DoDestroy() override;
-
- void RefreshStateAfterStop() override{};
-
- bool IsAlive() override;
-
- size_t ReadMemory(lldb::addr_t addr, void *buf, size_t size,
- Status &error) override;
-
- size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
- Status &error) override;
-
- ArchSpec GetArchitecture();
-
- Status GetMemoryRegionInfo(lldb::addr_t load_addr,
- MemoryRegionInfo &range_info) override;
-
- Status
- GetMemoryRegions(lldb_private::MemoryRegionInfos ®ion_list) override;
-
- bool GetProcessInfo(ProcessInstanceInfo &info) override;
-
-protected:
- void Clear();
-
- bool DoUpdateThreadList(ThreadList &old_thread_list,
- ThreadList &new_thread_list) override;
-
-private:
- ScriptedProcessInterface &GetInterface() const;
-
- const LaunchInfo m_launch_info;
- lldb_private::ScriptInterpreter *m_interpreter;
- lldb_private::StructuredData::ObjectSP m_script_object_sp;
-};
-
-} // namespace lldb_private
-
-#endif // LLDB_SOURCE_PLUGINS_SCRIPTED_PROCESS_H
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt b/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
index 84115aae01a5..2cbf8bcbb229 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
@@ -11,8 +11,6 @@ add_lldb_library(lldbPluginScriptInterpreterPython PLUGIN
PythonDataObjects.cpp
PythonReadline.cpp
ScriptInterpreterPython.cpp
- ScriptedProcessPythonInterface.cpp
- SWIGPythonBridge.cpp
LINK_LIBS
lldbBreakpoint
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.cpp
deleted file mode 100644
index 7c7c5d73680a..000000000000
--- a/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-//===-- SWIGPythonBridge.cpp ----------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Host/Config.h"
-#include "lldb/lldb-enumerations.h"
-
-#if LLDB_ENABLE_PYTHON
-
-// LLDB Python header must be included first
-#include "lldb-python.h"
-
-#include "SWIGPythonBridge.h"
-
-using namespace lldb;
-
-namespace lldb_private {
-
-template <typename T> const char *GetPythonValueFormatString(T t);
-template <> const char *GetPythonValueFormatString(char *) { return "s"; }
-template <> const char *GetPythonValueFormatString(char) { return "b"; }
-template <> const char *GetPythonValueFormatString(unsigned char) {
- return "B";
-}
-template <> const char *GetPythonValueFormatString(short) { return "h"; }
-template <> const char *GetPythonValueFormatString(unsigned short) {
- return "H";
-}
-template <> const char *GetPythonValueFormatString(int) { return "i"; }
-template <> const char *GetPythonValueFormatString(unsigned int) { return "I"; }
-template <> const char *GetPythonValueFormatString(long) { return "l"; }
-template <> const char *GetPythonValueFormatString(unsigned long) {
- return "k";
-}
-template <> const char *GetPythonValueFormatString(long long) { return "L"; }
-template <> const char *GetPythonValueFormatString(unsigned long long) {
- return "K";
-}
-template <> const char *GetPythonValueFormatString(float) { return "f"; }
-template <> const char *GetPythonValueFormatString(double) { return "d"; }
-
-} // namespace lldb_private
-
-#endif // LLDB_ENABLE_PYTHON
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h b/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
deleted file mode 100644
index 1843d9237d82..000000000000
--- a/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
+++ /dev/null
@@ -1,56 +0,0 @@
-//===-- ScriptInterpreterPython.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_PLUGINS_SCRIPTINTERPRETER_PYTHON_SWIGPYTHONBRIDGE_H
-#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SWIGPYTHONBRIDGE_H
-
-#include <string>
-
-#include "lldb/Host/Config.h"
-
-#if LLDB_ENABLE_PYTHON
-
-#include "lldb/lldb-forward.h"
-#include "lldb/lldb-types.h"
-
-namespace lldb_private {
-
-// GetPythonValueFormatString provides a system independent type safe way to
-// convert a variable's type into a python value format. Python value formats
-// are defined in terms of builtin C types and could change from system to as
-// the underlying typedef for uint* types, size_t, off_t and other values
-// change.
-
-template <typename T> const char *GetPythonValueFormatString(T t);
-template <> const char *GetPythonValueFormatString(char *);
-template <> const char *GetPythonValueFormatString(char);
-template <> const char *GetPythonValueFormatString(unsigned char);
-template <> const char *GetPythonValueFormatString(short);
-template <> const char *GetPythonValueFormatString(unsigned short);
-template <> const char *GetPythonValueFormatString(int);
-template <> const char *GetPythonValueFormatString(unsigned int);
-template <> const char *GetPythonValueFormatString(long);
-template <> const char *GetPythonValueFormatString(unsigned long);
-template <> const char *GetPythonValueFormatString(long long);
-template <> const char *GetPythonValueFormatString(unsigned long long);
-template <> const char *GetPythonValueFormatString(float t);
-template <> const char *GetPythonValueFormatString(double t);
-
-extern "C" void *LLDBSwigPythonCreateScriptedProcess(
- const char *python_class_name, const char *session_dictionary_name,
- const lldb::TargetSP &target_sp, StructuredDataImpl *args_impl,
- std::string &error_string);
-
-extern "C" void *LLDBSWIGPython_CastPyObjectToSBData(void *data);
-extern "C" void *LLDBSWIGPython_CastPyObjectToSBError(void *data);
-extern "C" void *LLDBSWIGPython_CastPyObjectToSBValue(void *data);
-
-}; // namespace lldb_private
-
-#endif // LLDB_ENABLE_PYTHON
-#endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SWIGPYTHONBRIDGE_H
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index 1a9f7fd22531..b3f72066195b 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -16,11 +16,7 @@
#include "PythonDataObjects.h"
#include "PythonReadline.h"
-#include "SWIGPythonBridge.h"
#include "ScriptInterpreterPythonImpl.h"
-#include "ScriptedProcessPythonInterface.h"
-
-#include "lldb/API/SBError.h"
#include "lldb/API/SBFrame.h"
#include "lldb/API/SBValue.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
@@ -152,6 +148,8 @@ extern "C" void *LLDBSwigPython_GetChildAtIndex(void *implementor,
extern "C" int LLDBSwigPython_GetIndexOfChildWithName(void *implementor,
const char *child_name);
+extern "C" void *LLDBSWIGPython_CastPyObjectToSBValue(void *data);
+
extern lldb::ValueObjectSP
LLDBSWIGPython_GetValueObjectSPFromSBValue(void *data);
@@ -533,9 +531,6 @@ ScriptInterpreterPythonImpl::ScriptInterpreterPythonImpl(Debugger &debugger)
m_command_thread_state(nullptr) {
InitializePrivate();
- m_scripted_process_interface_up =
- std::make_unique<ScriptedProcessPythonInterface>(*this);
-
m_dictionary_name.append("_dict");
StreamString run_string;
run_string.Printf("%s = dict()", m_dictionary_name.c_str());
@@ -1708,6 +1703,35 @@ StructuredData::ArraySP ScriptInterpreterPythonImpl::OSPlugin_ThreadsInfo(
return StructuredData::ArraySP();
}
+// GetPythonValueFormatString provides a system independent type safe way to
+// convert a variable's type into a python value format. Python value formats
+// are defined in terms of builtin C types and could change from system to as
+// the underlying typedef for uint* types, size_t, off_t and other values
+// change.
+
+template <typename T> const char *GetPythonValueFormatString(T t);
+template <> const char *GetPythonValueFormatString(char *) { return "s"; }
+template <> const char *GetPythonValueFormatString(char) { return "b"; }
+template <> const char *GetPythonValueFormatString(unsigned char) {
+ return "B";
+}
+template <> const char *GetPythonValueFormatString(short) { return "h"; }
+template <> const char *GetPythonValueFormatString(unsigned short) {
+ return "H";
+}
+template <> const char *GetPythonValueFormatString(int) { return "i"; }
+template <> const char *GetPythonValueFormatString(unsigned int) { return "I"; }
+template <> const char *GetPythonValueFormatString(long) { return "l"; }
+template <> const char *GetPythonValueFormatString(unsigned long) {
+ return "k";
+}
+template <> const char *GetPythonValueFormatString(long long) { return "L"; }
+template <> const char *GetPythonValueFormatString(unsigned long long) {
+ return "K";
+}
+template <> const char *GetPythonValueFormatString(float t) { return "f"; }
+template <> const char *GetPythonValueFormatString(double t) { return "d"; }
+
StructuredData::StringSP
ScriptInterpreterPythonImpl::OSPlugin_RegisterContextData(
StructuredData::ObjectSP os_plugin_object_sp, lldb::tid_t tid) {
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
index b8b978118218..5a75c0a655e5 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
@@ -13,8 +13,6 @@
#if LLDB_ENABLE_PYTHON
-#include "ScriptedProcessPythonInterface.h"
-
#include "lldb/Breakpoint/BreakpointOptions.h"
#include "lldb/Core/IOHandler.h"
#include "lldb/Core/StructuredDataImpl.h"
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
index 93d5768d9279..45dad4217005 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
@@ -6,9 +6,6 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTINTERPRETERPYTHONIMPL_H
-#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTINTERPRETERPYTHONIMPL_H
-
#include "lldb/Host/Config.h"
#if LLDB_ENABLE_PYTHON
@@ -486,5 +483,4 @@ class IOHandlerPythonInterpreter : public IOHandler {
} // namespace lldb_private
-#endif // LLDB_ENABLE_PYTHON
-#endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTINTERPRETERPYTHONIMPL_H
+#endif
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
deleted file mode 100644
index 03f745eacd82..000000000000
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
+++ /dev/null
@@ -1,287 +0,0 @@
-//===-- ScriptedProcessPythonInterface.cpp --------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Host/Config.h"
-#include "lldb/lldb-enumerations.h"
-
-#if LLDB_ENABLE_PYTHON
-
-// LLDB Python header must be included first
-#include "lldb-python.h"
-
-#include "SWIGPythonBridge.h"
-#include "ScriptInterpreterPythonImpl.h"
-#include "ScriptedProcessPythonInterface.h"
-
-using namespace lldb;
-using namespace lldb_private;
-using namespace lldb_private::python;
-using Locker = ScriptInterpreterPythonImpl::Locker;
-
-StructuredData::GenericSP ScriptedProcessPythonInterface::CreatePluginObject(
- const llvm::StringRef class_name, lldb::TargetSP target_sp,
- StructuredData::DictionarySP args_sp) {
- if (class_name.empty())
- return {};
-
- std::string error_string;
- StructuredDataImpl *args_impl = nullptr;
- if (args_sp) {
- args_impl = new StructuredDataImpl();
- args_impl->SetObjectSP(args_sp);
- }
-
- void *ret_val;
-
- {
-
- Locker py_lock(&m_interpreter, Locker::AcquireLock | Locker::NoSTDIN,
- Locker::FreeLock);
-
- ret_val = LLDBSwigPythonCreateScriptedProcess(
- class_name.str().c_str(), m_interpreter.GetDictionaryName(), target_sp,
- args_impl, error_string);
- }
-
- m_object_instance_sp =
- StructuredData::GenericSP(new StructuredPythonObject(ret_val));
-
- return m_object_instance_sp;
-}
-
-Status ScriptedProcessPythonInterface::Launch() {
- return LaunchOrResume("launch");
-}
-
-Status ScriptedProcessPythonInterface::Resume() {
- return LaunchOrResume("resume");
-}
-
-Status
-ScriptedProcessPythonInterface::LaunchOrResume(llvm::StringRef method_name) {
- Locker py_lock(&m_interpreter, Locker::AcquireLock | Locker::NoSTDIN,
- Locker::FreeLock);
-
- if (!m_object_instance_sp)
- return Status("Python object ill-formed.");
-
- if (!m_object_instance_sp)
- return Status("Cannot convert Python object to StructuredData::Generic.");
- PythonObject implementor(PyRefType::Borrowed,
- (PyObject *)m_object_instance_sp->GetValue());
-
- if (!implementor.IsAllocated())
- return Status("Python implementor not allocated.");
-
- PythonObject pmeth(
- PyRefType::Owned,
- PyObject_GetAttrString(implementor.get(), method_name.str().c_str()));
-
- if (PyErr_Occurred())
- PyErr_Clear();
-
- if (!pmeth.IsAllocated())
- return Status("Python method not allocated.");
-
- if (PyCallable_Check(pmeth.get()) == 0) {
- if (PyErr_Occurred())
- PyErr_Clear();
- return Status("Python method not callable.");
- }
-
- if (PyErr_Occurred())
- PyErr_Clear();
-
- PythonObject py_return(PyRefType::Owned,
- PyObject_CallMethod(implementor.get(),
- method_name.str().c_str(),
- nullptr));
-
- if (PyErr_Occurred()) {
- PyErr_Print();
- PyErr_Clear();
- return Status("Python method could not be called.");
- }
-
- if (PyObject *py_ret_ptr = py_return.get()) {
- lldb::SBError *sb_error =
- (lldb::SBError *)LLDBSWIGPython_CastPyObjectToSBError(py_ret_ptr);
-
- if (!sb_error)
- return Status("Couldn't cast lldb::SBError to lldb::Status.");
-
- Status status = m_interpreter.GetStatusFromSBError(*sb_error);
-
- if (status.Fail())
- return Status("error: %s", status.AsCString());
-
- return status;
- }
-
- return Status("Returned object is null.");
-}
-
-size_t
-ScriptedProcessPythonInterface::GetGenericInteger(llvm::StringRef method_name) {
- Locker py_lock(&m_interpreter, Locker::AcquireLock | Locker::NoSTDIN,
- Locker::FreeLock);
-
- if (!m_object_instance_sp)
- return LLDB_INVALID_ADDRESS;
-
- if (!m_object_instance_sp)
- return LLDB_INVALID_ADDRESS;
- PythonObject implementor(PyRefType::Borrowed,
- (PyObject *)m_object_instance_sp->GetValue());
-
- if (!implementor.IsAllocated())
- return LLDB_INVALID_ADDRESS;
-
- PythonObject pmeth(
- PyRefType::Owned,
- PyObject_GetAttrString(implementor.get(), method_name.str().c_str()));
-
- if (PyErr_Occurred())
- PyErr_Clear();
-
- if (!pmeth.IsAllocated())
- return LLDB_INVALID_ADDRESS;
-
- if (PyCallable_Check(pmeth.get()) == 0) {
- if (PyErr_Occurred())
- PyErr_Clear();
- return LLDB_INVALID_ADDRESS;
- }
-
- if (PyErr_Occurred())
- PyErr_Clear();
-
- PythonObject py_return(PyRefType::Owned,
- PyObject_CallMethod(implementor.get(),
- method_name.str().c_str(),
- nullptr));
-
- if (PyErr_Occurred()) {
- PyErr_Print();
- PyErr_Clear();
- }
-
- if (py_return.get()) {
- auto size = py_return.AsUnsignedLongLong();
- return (size) ? *size : LLDB_INVALID_ADDRESS;
- }
- return LLDB_INVALID_ADDRESS;
-}
-
-lldb::MemoryRegionInfoSP
-ScriptedProcessPythonInterface::GetMemoryRegionContainingAddress(
- lldb::addr_t address) {
- // TODO: Implement
- return nullptr;
-}
-
-StructuredData::DictionarySP
-ScriptedProcessPythonInterface::GetThreadWithID(lldb::tid_t tid) {
- // TODO: Implement
- return nullptr;
-}
-
-StructuredData::DictionarySP
-ScriptedProcessPythonInterface::GetRegistersForThread(lldb::tid_t tid) {
- // TODO: Implement
- return nullptr;
-}
-
-lldb::DataExtractorSP ScriptedProcessPythonInterface::ReadMemoryAtAddress(
- lldb::addr_t address, size_t size, Status &error) {
- Locker py_lock(&m_interpreter, Locker::AcquireLock | Locker::NoSTDIN,
- Locker::FreeLock);
-
- auto error_with_message = [&error](llvm::StringRef message) {
- error.SetErrorString(message);
- return nullptr;
- };
-
- static char callee_name[] = "read_memory_at_address";
- std::string param_format = GetPythonValueFormatString(address);
- param_format += GetPythonValueFormatString(size);
-
- if (!m_object_instance_sp)
- return error_with_message("Python object ill-formed.");
-
- if (!m_object_instance_sp)
- return error_with_message("Python method not callable.");
-
- PythonObject implementor(PyRefType::Borrowed,
- (PyObject *)m_object_instance_sp->GetValue());
-
- if (!implementor.IsAllocated())
- return error_with_message("Python implementor not allocated.");
-
- PythonObject pmeth(PyRefType::Owned,
- PyObject_GetAttrString(implementor.get(), callee_name));
-
- if (PyErr_Occurred())
- PyErr_Clear();
-
- if (!pmeth.IsAllocated())
- return error_with_message("Python method not allocated.");
-
- if (PyCallable_Check(pmeth.get()) == 0) {
- if (PyErr_Occurred())
- PyErr_Clear();
- return error_with_message("Python method not callable.");
- }
-
- if (PyErr_Occurred())
- PyErr_Clear();
-
- PythonObject py_return(PyRefType::Owned,
- PyObject_CallMethod(implementor.get(), callee_name,
- param_format.c_str(), address,
- size));
-
- if (PyErr_Occurred()) {
- PyErr_Print();
- PyErr_Clear();
- return error_with_message("Python method could not be called.");
- }
-
- if (PyObject *py_ret_ptr = py_return.get()) {
- lldb::SBData *sb_data =
- (lldb::SBData *)LLDBSWIGPython_CastPyObjectToSBData(py_ret_ptr);
-
- if (!sb_data)
- return error_with_message(
- "Couldn't cast lldb::SBData to lldb::DataExtractor.");
-
- return m_interpreter.GetDataExtractorFromSBData(*sb_data);
- }
-
- return error_with_message("Returned object is null.");
-}
-
-StructuredData::DictionarySP ScriptedProcessPythonInterface::GetLoadedImages() {
- // TODO: Implement
- return nullptr;
-}
-
-lldb::pid_t ScriptedProcessPythonInterface::GetProcessID() {
- size_t pid = GetGenericInteger("get_process_id");
-
- return (pid >= std::numeric_limits<lldb::pid_t>::max())
- ? LLDB_INVALID_PROCESS_ID
- : pid;
-}
-
-bool ScriptedProcessPythonInterface::IsAlive() {
- return GetGenericInteger("is_alive");
- ;
-}
-
-#endif
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
deleted file mode 100644
index fc07c927be2d..000000000000
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
+++ /dev/null
@@ -1,61 +0,0 @@
-//===-- ScriptedProcessPythonInterface.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_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDPROCESSPYTHONINTERFACE_H
-#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDPROCESSPYTHONINTERFACE_H
-
-#include "lldb/Host/Config.h"
-
-#if LLDB_ENABLE_PYTHON
-
-#include "lldb/Interpreter/ScriptedProcessInterface.h"
-
-namespace lldb_private {
-class ScriptInterpreterPythonImpl;
-class ScriptedProcessPythonInterface : public ScriptedProcessInterface {
-public:
- ScriptedProcessPythonInterface(ScriptInterpreterPythonImpl &interpreter)
- : ScriptedProcessInterface(), m_interpreter(interpreter) {}
-
- StructuredData::GenericSP
- CreatePluginObject(const llvm::StringRef class_name, lldb::TargetSP target_sp,
- StructuredData::DictionarySP args_sp) override;
-
- Status Launch() override;
-
- Status Resume() override;
-
- lldb::MemoryRegionInfoSP
- GetMemoryRegionContainingAddress(lldb::addr_t address) override;
-
- StructuredData::DictionarySP GetThreadWithID(lldb::tid_t tid) override;
-
- StructuredData::DictionarySP GetRegistersForThread(lldb::tid_t tid) override;
-
- lldb::DataExtractorSP ReadMemoryAtAddress(lldb::addr_t address, size_t size,
- Status &error) override;
-
- StructuredData::DictionarySP GetLoadedImages() override;
-
- lldb::pid_t GetProcessID() override;
-
- bool IsAlive() override;
-
-protected:
- size_t GetGenericInteger(llvm::StringRef method_name);
- Status LaunchOrResume(llvm::StringRef method_name);
-
-private:
- // The lifetime is managed by the ScriptInterpreter
- ScriptInterpreterPythonImpl &m_interpreter;
- StructuredData::GenericSP m_object_instance_sp;
-};
-} // namespace lldb_private
-
-#endif // LLDB_ENABLE_PYTHON
-#endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDPROCESSPYTHONINTERFACE_H
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 4c41545e17e7..98f63a81ea17 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -2950,7 +2950,7 @@ Status Target::Launch(ProcessLaunchInfo &launch_info, Stream *stream) {
// If we're not already connected to the process, and if we have a platform
// that can launch a process for debugging, go ahead and do that here.
if (state != eStateConnected && platform_sp &&
- platform_sp->CanDebugProcess() && !launch_info.IsScriptedProcess()) {
+ platform_sp->CanDebugProcess()) {
LLDB_LOGF(log, "Target::%s asking the platform to debug the process",
__FUNCTION__);
diff --git a/lldb/test/API/functionalities/scripted_process/Makefile b/lldb/test/API/functionalities/scripted_process/Makefile
deleted file mode 100644
index 692ba1732285..000000000000
--- a/lldb/test/API/functionalities/scripted_process/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-C_SOURCES := main.c
-
-include Makefile.rules
-
diff --git a/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py b/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
deleted file mode 100644
index e73535f003d0..000000000000
--- a/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py
+++ /dev/null
@@ -1,97 +0,0 @@
-"""
-Test python scripted process in lldb
-"""
-
-import os
-
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-from lldbsuite.test import lldbtest
-
-
-class ScriptedProcesTestCase(TestBase):
-
- mydir = TestBase.compute_mydir(__file__)
-
- def setUp(self):
- TestBase.setUp(self)
- self.source = "main.c"
-
- def tearDown(self):
- TestBase.tearDown(self)
-
- def test_python_plugin_package(self):
- """Test that the lldb python module has a `plugins.scripted_process`
- package."""
- self.expect('script import lldb.plugins',
- substrs=["ModuleNotFoundError"], matching=False)
-
- self.expect('script dir(lldb.plugins)',
- substrs=["scripted_process"])
-
- self.expect('script import lldb.plugins.scripted_process',
- substrs=["ModuleNotFoundError"], matching=False)
-
- self.expect('script dir(lldb.plugins.scripted_process)',
- substrs=["ScriptedProcess"])
-
- self.expect('script from lldb.plugins.scripted_process import ScriptedProcess',
- substrs=["ImportError"], matching=False)
-
- self.expect('script dir(ScriptedProcess)',
- substrs=["launch"])
-
- def test_launch_scripted_process_sbapi(self):
- """Test that we can launch an lldb scripted process using the SBAPI,
- check its process ID and read string from memory."""
- self.build()
- target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
- self.assertTrue(target, VALID_TARGET)
-
- scripted_process_example_relpath = ['..','..','..','..','examples','python','scripted_process','my_scripted_process.py']
- os.environ['SKIP_SCRIPTED_PROCESS_LAUNCH'] = '1'
- self.runCmd("command script import " + os.path.join(self.getSourceDir(),
- *scripted_process_example_relpath))
-
- launch_info = lldb.SBLaunchInfo(None)
- launch_info.SetProcessPluginName('ScriptedProcess')
- launch_info.SetScriptedProcessClassName('my_scripted_process.MyScriptedProcess')
-
- error = lldb.SBError()
- process = target.Launch(launch_info, error)
- self.assertTrue(process, PROCESS_IS_VALID)
- self.assertEqual(process.GetProcessID(), 42)
-
- hello_world = 'Hello, world!'
- memory_read = process.ReadCStringFromMemory(0x50000000000,
- len(hello_world) + 1, # NULL byte
- error)
-
- self.assertTrue(error.Success(), "Failed to read memory from scripted process.")
- self.assertEqual(hello_world, memory_read)
-
- def test_launch_scripted_process_cli(self):
- """Test that we can launch an lldb scripted process from the command
- line, check its process ID and read string from memory."""
- self.build()
- target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
- self.assertTrue(target, VALID_TARGET)
-
- scripted_process_example_relpath = ['..','..','..','..','examples','python','scripted_process','my_scripted_process.py']
- self.runCmd("command script import " + os.path.join(self.getSourceDir(),
- *scripted_process_example_relpath))
-
- process = target.GetProcess()
- self.assertTrue(process, PROCESS_IS_VALID)
- self.assertEqual(process.GetProcessID(), 42)
-
- error = lldb.SBError()
- hello_world = 'Hello, world!'
- memory_read = process.ReadCStringFromMemory(0x50000000000,
- len(hello_world) + 1, # NULL byte
- error)
-
- self.assertTrue(error.Success(), "Failed to read memory from scripted process.")
- self.assertEqual(hello_world, memory_read)
diff --git a/lldb/test/API/functionalities/scripted_process/main.c b/lldb/test/API/functionalities/scripted_process/main.c
deleted file mode 100644
index 3e82b70c8f4d..000000000000
--- a/lldb/test/API/functionalities/scripted_process/main.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <stdlib.h>
-
-int main() {
- return 0; // break here
-}
diff --git a/lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp b/lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
index f93733b3a5b7..58ddf0c40a26 100644
--- a/lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
+++ b/lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
@@ -12,7 +12,6 @@
#include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h"
#include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h"
-#include "lldb/API/SBError.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostInfo.h"
@@ -154,14 +153,6 @@ extern "C" int LLDBSwigPython_GetIndexOfChildWithName(void *implementor,
return 0;
}
-extern "C" void *LLDBSWIGPython_CastPyObjectToSBData(void *data) {
- return nullptr;
-}
-
-extern "C" void *LLDBSWIGPython_CastPyObjectToSBError(void *data) {
- return nullptr;
-}
-
extern "C" void *LLDBSWIGPython_CastPyObjectToSBValue(void *data) {
return nullptr;
}
@@ -216,13 +207,6 @@ LLDBSWIGPythonCreateOSPlugin(const char *python_class_name,
return nullptr;
}
-extern "C" void *LLDBSwigPythonCreateScriptedProcess(
- const char *python_class_name, const char *session_dictionary_name,
- const lldb::TargetSP &target_sp, StructuredDataImpl *args_impl,
- std::string &error_string) {
- return nullptr;
-}
-
extern "C" void *
LLDBSWIGPython_CreateFrameRecognizer(const char *python_class_name,
const char *session_dictionary_name) {
More information about the lldb-commits
mailing list