Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core/sched: Provide thread state names for OpenOCD #18460

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

maribu
Copy link
Member

@maribu maribu commented Aug 17, 2022

Contribution description

This provides the thread state names as used in ps() as a symbol that OpenOCD can read out. This allows implementing OpenOCD's RIOT awareness in a way that changes to thread states can be picked up at runtime, without having to patch OpenOCD for every change. Apparently RIOT is a bit faster moving in this regard than other bare metal RTOSes.

Testing procedure

ps() should still work as before. In addition, OpenOCD with the patch at https://review.openocd.org/c/openocd/+/7133 should now display thread states with the exact spelling as in ps() (or shell comamnd ps), while the built-in thread state name lookup table is used for RIOT prior to this commit.

Issues/PRs references

Useful for #18454 which will break OpenOCD's RIOT-awareness. With this, at least future thread state changes should no longer require patching OpenOCD.

This provides the thread state names as used in ps() as a symbol that
OpenOCD can read out. This allows implementing OpenOCD's RIOT
awareness in a way that changes to thread states can be picked up at
runtime, without having to patch OpenOCD for every change. Apparently
RIOT is a bit faster moving in this regard than other bare metal RTOSes.
@maribu maribu requested a review from kaspar030 as a code owner August 17, 2022 11:31
@github-actions github-actions bot added the Area: core Area: RIOT kernel. Handle PRs marked with this with care! label Aug 17, 2022
@maribu
Copy link
Member Author

maribu commented Aug 17, 2022

Note: I think this should be fully reviewed as usual now. But before merging, IMO it would be best to wait for a positive signal from the OpenOCD side (at least in regard to the RIOT-side of the changes).

@benpicco
Copy link
Contributor

Instead of adding all those strings to ROM, I prefer the idea that @bergzand suggested: Just maintain a single OpenOCD ABI version field that is stored in ROM and that gets incremented when we make changes that break the OpenOCD ABI.

That would have the advantage that OpenOCD would still work with old RIOT versions before this change and future changes would be easier.

And it would save ROM.

@maribu
Copy link
Member Author

maribu commented Aug 18, 2022

Note that this would still require bumping OpenOCD every time we touch thread state names.

I wonder if we could move _tcb_name_offset and a second copy of thread state names into the debug section of the ELF file instead. Then we would not be restricted in size to what we provide to OpenOCD.

@benpicco
Copy link
Contributor

OpenOCD could just not show the names, only the numbers, if it detects a RIOT version that is too new.

@maribu
Copy link
Member Author

maribu commented Aug 18, 2022

There can be years of latency between a change in the RIOT state names, and an OpenOCD landing in the oldest still supported Ubuntu LTS version most people seem to use these days... And memorizing state numbers in the meantime is bit of a pita :)

@benpicco
Copy link
Contributor

I think a version marker still makes sense.
And we could only include the state string with DEVELHELP enabled.

@maribu
Copy link
Member Author

maribu commented Aug 18, 2022

I could add a version marker, but it would not be put to use as of now.

If the state names could indeed go into the debug section and would never be flashed to the device, I see no reason to restrict adding them to DEVELHELP. But I haven't checked whether this feasible to implement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: core Area: RIOT kernel. Handle PRs marked with this with care!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants