pyocd / pyocd/pyOCD

Thread reporting behavior inconsistent

Open
#1,934 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.5k
Forks
560
Avg merge
1h 41m
Merged PRs (30d)
3

Description

The "threads disable" command is behaving inconsistently.

When using "threads disable" before the first resume, the command is ignored. This is in contrary to the command being described to be "manual control" for the "not perfect" logic of enabling reporting only after the first resume.

Expected: "monitor threads disable" disables thread reporting until "monitor threads enable"

But instead, since gdbserver.first_run_after_reset_or_flash is True, the manual action is ignored:
https://github.com/pyocd/pyOCD/blob/ff767fe8806434c04bab2b6c7b012ded4470732e/pyocd/gdbserver/gdbserver.py#L810-L813

I'm suggesting to change this behavior. Its unintuitiv that the manual action is silently ignored.

For now I solved this using a user script. But obviously, this is brittle, using internal, undocumented attributes and may become incompatible in the future. So this is not a final solution. I'm still leaving this here for anybody encountering the same issue:

@command(help="Prevent pyOCD from auto-enabling RTOS reads on the next first resume")
def clear_first_run(core: int = 0):
    gdbserver = session.gdbservers[core]
    gdbserver.first_run_after_reset_or_flash = False
    print(f"core {core}: first_run_after_reset_or_flash cleared")

and instead of continue, call

monitor threads disable
monitor clear_first_run 0
continue

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in pyocd/gdbserver/gdbserver.py at lines 810-813 and trace how first_run_after_reset_or_flash affects the threads disable command before the first resume. Verify that monitor threads disable remains effective until monitor threads enable, rather than being silently ignored, and check the relevant GDB-server behavior manually.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools, embedded-iot
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.