Skip to content

Commit 3fbd3b8

Browse files
committed
[lldb/Plugins] Clean-up Scripted Process interface requirements (NFC)
The goal of the simple patch is to clean-up the scripted process interface by removing methods that were introduced with the interface originally, but that were never really implemented (get_thread_with_id & get_registers_for_thread). This patch also changes `get_memory_region_containing_address` to have a base implementation (that retunrs `None`), instead of forcing the user to override it in their derived class. Signed-off-by: Med Ismail Bennani <[email protected]>
1 parent 2362f11 commit 3fbd3b8

File tree

8 files changed

+2
-95
lines changed

8 files changed

+2
-95
lines changed

lldb/examples/python/scripted_process/crashlog_scripted_process.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,6 @@ def __init__(self, target: lldb.SBTarget, args : lldb.SBStructuredData):
9494
self.extended_thread_info = None
9595
self.parse_crashlog()
9696

97-
def get_memory_region_containing_address(self, addr: int) -> lldb.SBMemoryRegionInfo:
98-
return None
99-
100-
def get_thread_with_id(self, tid: int):
101-
return {}
102-
103-
def get_registers_for_thread(self, tid: int):
104-
return {}
105-
10697
def read_memory_at_address(self, addr: int, size: int, error: lldb.SBError) -> lldb.SBData:
10798
# NOTE: CrashLogs don't contain any memory.
10899
return lldb.SBData()

lldb/examples/python/scripted_process/scripted_process.py

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ def get_capabilities(self):
5555
"""
5656
return self.capabilities
5757

58-
@abstractmethod
5958
def get_memory_region_containing_address(self, addr):
6059
""" Get the memory region for the scripted process, containing a
6160
specific address.
@@ -68,7 +67,7 @@ def get_memory_region_containing_address(self, addr):
6867
lldb.SBMemoryRegionInfo: The memory region containing the address.
6968
None if out of bounds.
7069
"""
71-
pass
70+
return None
7271

7372
def get_threads_info(self):
7473
""" Get the dictionary describing the process' Scripted Threads.
@@ -80,35 +79,6 @@ def get_threads_info(self):
8079
"""
8180
return self.threads
8281

83-
@abstractmethod
84-
def get_thread_with_id(self, tid):
85-
""" Get the scripted process thread with a specific ID.
86-
87-
Args:
88-
tid (int): Thread ID to look for in the scripted process.
89-
90-
Returns:
91-
Dict: The thread represented as a dictionary, with the
92-
tid thread ID. None if tid doesn't match any of the scripted
93-
process threads.
94-
"""
95-
pass
96-
97-
@abstractmethod
98-
def get_registers_for_thread(self, tid):
99-
""" Get the register context dictionary for a certain thread of
100-
the scripted process.
101-
102-
Args:
103-
tid (int): Thread ID for the thread's register context.
104-
105-
Returns:
106-
Dict: The register context represented as a dictionary, for the
107-
tid thread. None if tid doesn't match any of the scripted
108-
process threads.
109-
"""
110-
pass
111-
11282
@abstractmethod
11383
def read_memory_at_address(self, addr, size, error):
11484
""" Get a memory buffer from the scripted process at a certain address,

lldb/include/lldb/Interpreter/ScriptedProcessInterface.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,6 @@ class ScriptedProcessInterface : virtual public ScriptedInterface {
4949

5050
virtual StructuredData::DictionarySP GetThreadsInfo() { return {}; }
5151

52-
virtual StructuredData::DictionarySP GetThreadWithID(lldb::tid_t tid) {
53-
return {};
54-
}
55-
56-
virtual StructuredData::DictionarySP GetRegistersForThread(lldb::tid_t tid) {
57-
return {};
58-
}
59-
6052
virtual lldb::DataExtractorSP
6153
ReadMemoryAtAddress(lldb::addr_t address, size_t size, Status &error) {
6254
return {};

lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -119,25 +119,6 @@ StructuredData::DictionarySP ScriptedProcessPythonInterface::GetThreadsInfo() {
119119
return dict;
120120
}
121121

122-
StructuredData::DictionarySP
123-
ScriptedProcessPythonInterface::GetThreadWithID(lldb::tid_t tid) {
124-
Status error;
125-
StructuredData::ObjectSP obj = Dispatch("get_thread_with_id", error, tid);
126-
127-
if (!CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, error))
128-
return {};
129-
130-
StructuredData::DictionarySP dict{obj->GetAsDictionary()};
131-
132-
return dict;
133-
}
134-
135-
StructuredData::DictionarySP
136-
ScriptedProcessPythonInterface::GetRegistersForThread(lldb::tid_t tid) {
137-
// TODO: Implement
138-
return {};
139-
}
140-
141122
lldb::DataExtractorSP ScriptedProcessPythonInterface::ReadMemoryAtAddress(
142123
lldb::addr_t address, size_t size, Status &error) {
143124
Status py_error;

lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,9 @@ class ScriptedProcessPythonInterface : public ScriptedProcessInterface,
4646

4747
StructuredData::DictionarySP GetThreadsInfo() override;
4848

49-
StructuredData::DictionarySP GetThreadWithID(lldb::tid_t tid) override;
50-
51-
StructuredData::DictionarySP GetRegistersForThread(lldb::tid_t tid) override;
52-
5349
lldb::DataExtractorSP ReadMemoryAtAddress(lldb::addr_t address, size_t size,
5450
Status &error) override;
51+
5552

5653
StructuredData::ArraySP GetLoadedImages() override;
5754

lldb/test/API/functionalities/scripted_process/dummy_scripted_process.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,6 @@ def __init__(self, target: lldb.SBTarget, args : lldb.SBStructuredData):
1111
super().__init__(target, args)
1212
self.threads[0] = DummyScriptedThread(self, None)
1313

14-
def get_memory_region_containing_address(self, addr: int) -> lldb.SBMemoryRegionInfo:
15-
return None
16-
17-
def get_thread_with_id(self, tid: int):
18-
return {}
19-
20-
def get_registers_for_thread(self, tid: int):
21-
return {}
22-
2314
def read_memory_at_address(self, addr: int, size: int, error: lldb.SBError) -> lldb.SBData:
2415
debugger = self.target.GetDebugger()
2516
index = debugger.GetIndexOfTarget(self.target)

lldb/test/API/functionalities/scripted_process/invalid_scripted_process.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,6 @@ def __init__(self, target: lldb.SBTarget, args : lldb.SBStructuredData):
1111
super().__init__(target, args)
1212
self.threads[0] = InvalidScriptedThread(self, None)
1313

14-
def get_memory_region_containing_address(self, addr: int) -> lldb.SBMemoryRegionInfo:
15-
return None
16-
17-
def get_thread_with_id(self, tid: int):
18-
return {}
19-
20-
def get_registers_for_thread(self, tid: int):
21-
return {}
22-
2314
def read_memory_at_address(self, addr: int, size: int, error: lldb.SBError) -> lldb.SBData:
2415
error.SetErrorString("This is an invalid scripted process!")
2516
return lldb.SBData()

lldb/test/API/functionalities/scripted_process/stack_core_scripted_process.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,6 @@ def get_memory_region_containing_address(self, addr: int) -> lldb.SBMemoryRegion
5959
return None
6060
return mem_region
6161

62-
def get_thread_with_id(self, tid: int):
63-
return {}
64-
65-
def get_registers_for_thread(self, tid: int):
66-
return {}
67-
6862
def read_memory_at_address(self, addr: int, size: int, error: lldb.SBError) -> lldb.SBData:
6963
data = lldb.SBData()
7064
bytes_read = self.corefile_process.ReadMemory(addr, size, error)

0 commit comments

Comments
 (0)