mib updated this revision to Diff 320250.
mib added a comment.

Fix typo in swig wrapper.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95712/new/

https://reviews.llvm.org/D95712

Files:
  lldb/bindings/python/python-scripted-process.swig
  lldb/bindings/python/python.swig
  lldb/examples/python/scripted_process.py

Index: lldb/examples/python/scripted_process.py
===================================================================
--- /dev/null
+++ lldb/examples/python/scripted_process.py
@@ -0,0 +1,40 @@
+#!/usr/bin/env python3
+
+from typing import List
+
+import lldb
+from lldb import ScriptedProcess
+
+class ScriptedMachCoreProcess(ScriptedProcess):
+    def __init__(self, target: lldb.SBTarget, args : lldb.SBStructuredData):
+        super().__init__(target, args)
+
+    ### Main functionalities
+    def get_num_memory_regions(self) -> int:
+        return len(self.memory_regions)
+    def get_memory_region_at_index(self, idx: int) -> lldb.SBMemoryRegionInfo:
+        return self.memory_regions[idx]
+    def get_num_threads(self) -> int:
+        return len(self.threads)
+    def get_thread_at_index(self, idx: int) -> lldb.SBThread:
+        return self.threads[idx]
+    def get_register_for_thread(self, tid: int):
+        return tid
+    def read_memory_at_address(self, addr: int) -> lldb.SBData:
+        return addr
+    def get_loaded_images(self) -> List[str]:
+        return self.loaded_images
+    def get_process_id(self) -> int:
+        return 42
+
+    ### Process state
+    def can_debug(self) -> bool:
+        return True
+    def is_alive(self) -> bool:
+        return True
+
+def __lldb_init_module(debugger, dict):
+    debugger.HandleCommand(
+        "process launch -S -C %s.%s" % (__name__,
+                                        ScriptedMachCoreProcess.__name__))
+
Index: lldb/bindings/python/python.swig
===================================================================
--- lldb/bindings/python/python.swig
+++ lldb/bindings/python/python.swig
@@ -130,6 +130,7 @@
 %include "interfaces.swig"
 %include "python-extensions.swig"
 %include "python-wrapper.swig"
+%include "python-scripted-process.swig"
 
 %pythoncode%{
 _initialize = True
Index: lldb/bindings/python/python-scripted-process.swig
===================================================================
--- /dev/null
+++ lldb/bindings/python/python-scripted-process.swig
@@ -0,0 +1,65 @@
+%pythoncode %{
+from abc import ABC, abstractmethod
+from typing import List
+
+import lldb
+
+class ScriptedProcess(ABC):
+    @abstractmethod
+    def __init__(self, target: lldb.SBTarget, args : lldb.SBStructuredData):
+        self.process_id = 0
+        self.memory_regions = []
+        self.threads = []
+        self.loaded_images = []
+        self.stops = []
+        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
+
+    ### Main funcitonnalities
+    @abstractmethod
+    def get_num_memory_regions(self) -> int:
+        pass
+
+    @abstractmethod
+    def get_memory_region_at_index(self, idx: int) -> lldb.SBMemoryRegionInfo:
+        pass
+
+    @abstractmethod
+    def get_num_threads(self):
+        pass
+
+    @abstractmethod
+    def get_thread_at_index(self, idx: int) -> lldb.SBThread:
+        pass
+
+    @abstractmethod
+    def get_register_for_thread(self, tid:int):
+        pass
+
+    @abstractmethod
+    def read_memory_at_address(self, addr:int) -> lldb.SBData:
+        pass
+
+    @abstractmethod
+    def get_loaded_images(self) -> List[str]: # -> List[lldb.SBModule]:
+        pass
+
+    def get_process_id(self) -> int:
+        return self.process_id
+
+    ### Process state
+    def launch(self) -> lldb.SBError:
+        return lldb.SBError()
+
+    @abstractmethod
+    def can_debug(self) -> bool:
+        pass
+
+    @abstractmethod
+    def is_alive(self) -> bool:
+        pass
+%}
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to