GP-6273: post-review

GP-6273: working
This commit is contained in:
d-millar
2026-01-09 13:09:53 -05:00
parent f9cee4d639
commit bcced66f18
6 changed files with 107 additions and 23 deletions

View File

@@ -38,7 +38,7 @@
<UL style="list-style-type: none">
<LI>
<PRE>
python3 -m pip install psutil protobuf>=3.20.3
python3 -m pip install protobuf>=3.20.3
</PRE>
</LI>
</UL>
@@ -54,7 +54,7 @@ python3 -m pip install psutil protobuf>=3.20.3
<PRE>
cd /path/to/ghidra_<EM>
version</EM>/Ghidra/Debug
python3 -m pip install --no-index -f Debugger-rmi-trace/pypkg/dist -f Debugger-agent-lldb/pypkg/dist psutil protobuf
python3 -m pip install --no-index -f Debugger-rmi-trace/pypkg/dist -f Debugger-agent-lldb/pypkg/dist protobuf
</PRE>
</LI>
</UL>

View File

@@ -26,11 +26,6 @@ import time
from typing import (Any, Callable, Dict, Generator, List, Literal,
Optional, Tuple, TypeVar, Union, cast)
try:
import psutil
except ImportError:
print("Unable to import 'psutil' - check that it has been installed")
from ghidratrace import sch
from ghidratrace.client import (Client, Address, AddressRange, Trace, Schedule,
TraceObject, Transaction)
@@ -1478,15 +1473,17 @@ def ghidra_trace_put_processes(debugger: lldb.SBDebugger, command: str,
put_processes()
def put_available() -> None:
def put_available(availables: Optional[List[util.Available]] = None) -> List[util.Available]:
trace = STATE.require_trace()
availables = util.AVAILABLE_INFO_READER.get_availables()
keys = []
for proc in psutil.process_iter():
for proc in availables:
ppath = AVAILABLE_PATTERN.format(pid=proc.pid)
procobj = trace.create_object(ppath)
keys.append(AVAILABLE_KEY_PATTERN.format(pid=proc.pid))
procobj.set_value('PID', proc.pid)
procobj.set_value('_display', f'{proc.pid} {proc.name()}')
procobj.set_value('Name', proc.name)
procobj.set_value('_display', f'{proc.pid} {proc.command}')
procobj.insert()
trace.proxy_object_path(AVAILABLES_PATH).retain_values(keys)

View File

@@ -178,6 +178,40 @@ def _choose_region_info_reader() -> RegionInfoReader:
REGION_INFO_READER = _choose_region_info_reader()
@dataclass
class Available:
pid: int
name: str
command: str
class AvailableInfoReader(object):
def available_from_sbprocinfo(self, info: lldb.SBProcessInfo) -> Available:
pid = info.GetProcessID()
name = info.GetName()
command = info.GetExecutableFile()
return Available(pid, name, command)
def get_availables(self) -> List[Available]:
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
def _choose_available_info_reader() -> AvailableInfoReader:
return AvailableInfoReader()
AVAILABLE_INFO_READER = _choose_available_info_reader()
BREAK_LOCS_CMD = 'breakpoint list {}'
BREAK_PATTERN = re.compile('')
BREAK_LOC_PATTERN = re.compile('')