Enhance trace_iokit command to utilize the current LLDB target/process if no PID or executable path is specified

This commit is contained in:
Karol Mazurek
2025-06-10 18:53:50 +02:00
parent 3f1f2e6228
commit 1962ab10ef

View File

@@ -153,7 +153,15 @@ def trace_iokit(debugger, command, result, internal_dict):
print(f"Attached to PID {pid}. IOKit tracer is active.")
debugger.HandleCommand('continue')
else: result.PutCString(f"Error: Failed to attach to PID {pid}")
else: result.PutCString("Error: Specify --pid <PID> or --executable_path <path>")
else:
# Try to use the currently selected target and process
target = debugger.GetSelectedTarget()
process = target.GetProcess() if target else None
if target and process and process.IsValid() and process.GetState() in [lldb.eStateStopped, lldb.eStateRunning]:
setup_breakpoints(target)
print("Using current LLDB target/process. IOKit tracer is active.")
else:
result.PutCString("Error: Specify --pid <PID> or --executable_path <path>, or attach to a process first.")
def __lldb_init_module(debugger, internal_dict):
"""Registers the 'trace_iokit' command with LLDB."""