fix(rtos/zephyr): place current thread first in thread list (OCD-1334) #391
+14
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Workaround for Thread 1 displaying incorrect backtraces when debugging Zephyr applications.
Problem
When GDB connects to OpenOCD with RTOS awareness:
Result: Thread 1 "stats" shows idle's backtrace (
arch_cpu_idle()).Fix
Reorder the thread list so the current thread is always first. This ensures:
This is a Workaround
This fix addresses the symptom, not the root cause. A proper fix would require changes to GDB:
Since GDB protocol changes would require upstream GDB maintainer buy-in and could take significant time, this workaround provides immediate relief. The resulting behavior (Thread 1 = current thread) also matches most users' expectations.
Verification
Before:
After:
Related
This complements PR #390 which fixes register values for non-current threads.
Both issues were discovered while debugging Zephyr on ESP32-S3.