Lauterbach TRACE32 Remote Control Library
The `lauterbach-trace32-rcl` library provides a Python interface to control Lauterbach TRACE32 debuggers via their Remote Control Protocol (RCP). It enables automation of debugging tasks, script execution, and data extraction from TRACE32. The current version is 1.1.5, with releases typically tied to significant feature additions or TRACE32 protocol updates, implying a moderate release cadence.
Warnings
- breaking Breaking change in v1.1.0: The return types for `T32Api.cmd()` and `T32Api.variable_read()` changed from `(bool, str)` or `(bool, Any)` tuples to dedicated `T32CmdResult` and `T32VarResult` objects, respectively.
- breaking Breaking change in v1.0.0: The `T32Api` constructor signature was updated to explicitly accept `host` and `port` arguments, defaulting to `localhost` and `20000`.
- gotcha This library requires a running Lauterbach TRACE32 debugger with the Remote Control Protocol (RCP) server enabled and accessible. Connection attempts will fail with a `T32Error` if the server is not active or configured correctly.
- gotcha Communication with TRACE32 can lead to `T32Error` exceptions due to connection issues, timeouts, or invalid responses. The error messages from the library might be general.
Install
-
pip install lauterbach-trace32-rcl
Imports
- T32Api
from lauterbach_trace32_rcl import T32Api
- T32Error
from lauterbach_trace32_rcl import T32Error
- T32CmdResult
from lauterbach_trace32_rcl import T32CmdResult
Quickstart
import os
from lauterbach_trace32_rcl import T32Api, T32Error
# Ensure a TRACE32 instance with RCP server is running on localhost:20000.
# For example, in TRACE32: MENU.OPTION RCPSERVER
# or launch TRACE32 with the -RCL option: t32mppc.exe -RCL
host = os.environ.get("T32_HOST", "localhost")
port = int(os.environ.get("T32_PORT", "20000"))
t32 = None
try:
print(f"Connecting to TRACE32 RCP server at {host}:{port}...")
t32 = T32Api(host=host, port=port)
t32.connect()
print("Connected successfully.")
# Execute a simple TRACE32 command
# The result is a T32CmdResult object since v1.1.0
result = t32.cmd("SYStem.CPU PowerPC")
if result.ok:
print(f"Command 'SYStem.CPU PowerPC' successful: {result.result_string}")
else:
print(f"Command failed: {result.result_string}")
# Read a system variable (example: Program Counter)
# Note: Requires the debugger to be in a state where PC is valid
# The result is a T32VarResult object since v1.1.0
try:
pc_value = t32.variable_read("PC")
if pc_value.ok:
print(f"PC value: {pc_value.result_value:#010x}")
else:
print(f"Failed to read PC: {pc_value.result_string}")
except T32Error as e:
print(f"Error reading PC: {e}")
except T32Error as e:
print(f"Error connecting or communicating with TRACE32: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")
finally:
if t32 and t32.is_connected():
t32.disconnect()
print("Disconnected from TRACE32.")