Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions pyocd/target/csolution/ctrace_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ class CTraceRun:
def __init__(self, session: "Session") -> None:
self._lock = threading.RLock()
self._last_applied_digest: Optional[bytes] = None
self._last_capture_digest: Optional[bytes] = None
self._last_error: Optional[str] = None

cbuild_run = session.cbuild_run
Expand All @@ -302,7 +303,7 @@ def __init__(self, session: "Session") -> None:
session.subscribe(self._trace_restart_handler, session.Event.TRACE_RESTART, session)

def apply(self, target: "SoCTarget", force: bool = False) -> bool:
"""Apply new or explicitly reloaded configuration and return whether it was applied."""
"""Apply configuration and report success or whether it changed for this capture."""
with self._lock:
try:
loaded = self._parser.load(force=force)
Expand All @@ -312,13 +313,17 @@ def apply(self, target: "SoCTarget", force: bool = False) -> bool:
return False

digest, data = loaded
if not force and digest == self._last_applied_digest:
return False
if force or digest != self._last_applied_digest:
self._apply_to_target(target, data)
self._last_applied_digest = digest
self._last_error = None

if force:
return True

self._apply_to_target(target, data)
self._last_applied_digest = digest
self._last_error = None
return True
changed = digest != self._last_capture_digest
self._last_capture_digest = digest
return changed
except exceptions.Error as err:
self._report_error(err)
return False
Expand Down
6 changes: 2 additions & 4 deletions pyocd/trace/sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ def __init__(self, session: Any, trace_buffers: Mapping[str, Any]) -> None:
self._session = session
self._trace_buffers = trace_buffers
self._outputs: Dict[str, TraceDataSink] = {}
self._capture_changed = True
for name, sink in trace_buffers.items():
if not sink.enabled:
continue
Expand All @@ -140,10 +139,9 @@ def shutdown(self) -> None:

def _trace_data_handler(self, notification: Any) -> None:
if notification.event == self._session.Event.TRACE_DATA_CAPTURE:
self._capture_changed = bool(notification.data)
for name, output in tuple(self._outputs.items()):
try:
output.start(self._capture_changed)
output.start(changed=True)
except OSError as err:
LOG.warning("Failed to start TB '%s' output: %s", name, err)
del self._outputs[name]
Expand All @@ -160,7 +158,7 @@ def write(self, name: str, data: bytes) -> int:
try:
if output is None:
output = self._create_output(sink)
output.start(self._capture_changed)
output.start(changed=True)
self._outputs[name] = output
return output.write(data)
except OSError as err:
Expand Down
Loading