Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-6331: oops GP-6331: lose the param GP-6331: better GP-6331: fields GP-6331: version

d-millare2b1d2f2d482
diff --git a/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/commands.py b/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/commands.py
index 49f9853c2d..edc4dfdaf9 100644
--- a/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/commands.py
+++ b/Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/commands.py
@@ -1065,14 +1065,9 @@ def ghidra_trace_put_inferiors(*, is_mi: bool, **kwargs) -> None:
put_inferiors()
-def put_available(availables: Optional[List[util.Available]] = None) -> List[util.Available]:
+def put_available() -> List[util.Available]:
trace = STATE.require_trace()
- inf = gdb.selected_inferior()
- if availables is None:
- try:
- availables = util.AVAILABLE_INFO_READER.get_availables()
- except Exception:
- availables = []
+ availables = util.AVAILABLE_INFO_READER.get_availables()
keys = []
for proc in availables:
ppath = AVAILABLE_PATTERN.format(pid=proc.pid)
diff --git a/Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/commands.py b/Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/commands.py
index f112091531..0fa5cea709 100644
--- a/Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/commands.py
+++ b/Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/commands.py
@@ -1473,7 +1473,7 @@ def ghidra_trace_put_processes(debugger: lldb.SBDebugger, command: str,
put_processes()
-def put_available(availables: Optional[List[util.Available]] = None) -> List[util.Available]:
+def put_available() -> List[util.Available]:
trace = STATE.require_trace()
availables = util.AVAILABLE_INFO_READER.get_availables()
keys = []
@@ -1482,8 +1482,12 @@ def put_available(availables: Optional[List[util.Available]] = None) -> List[uti
procobj = trace.create_object(ppath)
keys.append(AVAILABLE_KEY_PATTERN.format(pid=proc.pid))
procobj.set_value('PID', proc.pid)
- procobj.set_value('Name', proc.name)
- procobj.set_value('_display', f'{proc.pid} {proc.command}')
+ if isinstance(proc, util.Available):
+ procobj.set_value('Name', proc.name)
+ procobj.set_value('_display', f'{proc.pid} {proc.command}')
+ else:
+ procobj.set_value('Name', proc.name())
+ procobj.set_value('_display', f'{proc.pid} {proc.name()}')
procobj.insert()
trace.proxy_object_path(AVAILABLES_PATH).retain_values(keys)
diff --git a/Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/util.py b/Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/util.py
index e47f2a0c63..bd714ab6c7 100644
--- a/Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/util.py
+++ b/Ghidra/Debug/Debugger-agent-lldb/src/main/py/src/ghidralldb/util.py
@@ -43,6 +43,8 @@ def _compute_lldb_ver() -> LldbVersion:
LLDB_VERSION = _compute_lldb_ver()
+if LLDB_VERSION.major < 18:
+ import psutil
GNU_DEBUGDATA_PREFIX = ".gnu_debugdata for "
@@ -196,14 +198,18 @@ class AvailableInfoReader(object):
availables = []
platform = get_debugger().GetPlatformAtIndex(0)
err = lldb.SBError()
- proclist = platform.GetAllProcesses(err)
- for i in range(0, proclist.GetSize()):
- info = lldb.SBProcessInfo()
- success = proclist.GetProcessInfoAtIndex(i, info)
- if success:
- a = self.available_from_sbprocinfo(info)
- availables.append(a)
- return availables
+ # Quite a hack, but only needed for type annotations
+ if hasattr(platform, 'GetAllProcesses'):
+ proclist = platform.GetAllProcesses(err)
+ for i in range(0, proclist.GetSize()):
+ info = lldb.SBProcessInfo()
+ success = proclist.GetProcessInfoAtIndex(i, info)
+ if success:
+ a = self.available_from_sbprocinfo(info)
+ availables.append(a)
+ return availables
+ else:
+ return psutil.process_iter()
def _choose_available_info_reader() -> AvailableInfoReader: