Skip to content

fix(tools): StubProbe missing capabilities property breaks pyocd list --targets --pack=... (closes #1959)#1986

Open
seam0814 wants to merge 1 commit into
pyocd:mainfrom
seam0814:fix-stubprobe-missing-capabilities-1959
Open

fix(tools): StubProbe missing capabilities property breaks pyocd list --targets --pack=... (closes #1959)#1986
seam0814 wants to merge 1 commit into
pyocd:mainfrom
seam0814:fix-stubprobe-missing-capabilities-1959

Conversation

@seam0814

Copy link
Copy Markdown

Summary

`DebugProbe.capabilities` is declared as an abstract property that
raises `NotImplementedError` in the base class. `StubProbe` —
instantiated by `ListGenerator.list_targets()` whenever a CMSIS-Pack
file is passed via `--pack=...` so that targets can be enumerated
without a real probe — did not override it.

The result is that any invocation of

```
pyocd list --targets --pack=<any_pack_file>
```

fails silently with a stripped error line and no traceback:

```
0000626 C Error: [main]
```

making the failure essentially undiagnosable. Reported in #1959 with
the root cause already pinpointed.

Closes #1959.

Change

```diff
class StubProbe(DebugProbe):
@Property
def unique_id(self) -> str:
return "0"
+

  • @Property
  • def capabilities(self):
  •    return set()
    

```

An empty set is the truthful stub value — the placeholder probe has
no real features — and matches the expected `Set[Capability]` type
declared by the base class, so any downstream
`Capability.X in probe.capabilities` membership check now behaves as
"probe lacks every feature" rather than crashing.

Test

Added `test/unit/test_stub_probe.py` with two regression cases:

  • `capabilities` returns `set()` (the contract this PR establishes)
  • the returned value is iterable + membership-testable so downstream
    consumers don't change behaviour

```
$ python -m pytest test/unit/
1097 passed, 41 skipped in 1.87s
```

Scope

Two-file change. No public API change. `StubProbe` is only used
internally by `ListGenerator` for offline pack inspection; no
behavioural change to real probes (`CMSISDAPv1Probe`,
`CMSISDAPv2Probe`, `JLinkProbe`, etc.) all of which already provide
their own `capabilities`.

…ist --targets --pack=...` (closes pyocd#1959)

`DebugProbe.capabilities` is declared as an abstract property that
raises `NotImplementedError` in the base class. `StubProbe` —
instantiated by `ListGenerator.list_targets()` whenever a CMSIS-Pack
file is passed via `--pack=...` so that targets can be enumerated
without a real probe — did not override it.

The result was that any invocation of

    pyocd list --targets --pack=<any_pack_file>

failed silently with a stripped error line and no traceback:

    0000626 C Error:  [__main__]

making the failure essentially undiagnosable for the user. Reported in
pyocd#1959 with root cause already pinpointed.

Override the property on `StubProbe` to return an empty `set()`:

    @Property
    def capabilities(self):
        return set()

An empty set is the truthful stub value — the placeholder probe has
no real features — and matches the expected `Set[Capability]` type
declared by the base class, so any downstream
`Capability.X in probe.capabilities` membership check now behaves as
"probe lacks every feature" rather than crashing.

Added `test/unit/test_stub_probe.py` with two regression cases:
* `capabilities` returns `set()` (the contract this PR establishes)
* the returned value is iterable + membership-testable so downstream
  consumers don't change behaviour

Full unit test suite: 1097 passed, 41 skipped.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

StubProbe missing capabilities property causes pyocd list --targets to fail with CMSIS-Pack

1 participant