I'm trying to piece together a thread awareness script for SES as outlined here: https://studio.segger.com/ide_threads_window.htm
I've got an extremely basic script that I know still has bugs, but at least enumerates all threads and their states:
function init()
{
Threads.setColumns("Name", "Handle", "Priority", "State");
Threads.setSortByNumber("Priority");
Threads.setSortByNumber("State");
Threads.setSortByNumber("Handle");
}
// Depends on CONFIG_THREAD_MONITOR in your prj.conf
function update()
{
Threads.clear();
var z_thread = Debug.evaluate("_kernel.threads");
var count = 0;
while (z_thread && count < 20)
{
var td = Debug.evaluate("*(k_thread*)"+z_thread);
Threads.add(td.name, z_thread, td.base.prio, td.base.thread_state, z_thread);
z_thread = td.next_thread;
count++;
}
}
function getregs(x)
{
// TODO - This function needs a lot of help ... it is very incomplete ...
var td = Debug.evaluate("*(k_thread*)"+x);
return [ 0, 1, 2, 3, td.callee_saved.v1, td.callee_saved.v2, td.callee_saved.v3, td.callee_saved.v4, td.callee_saved.v5, td.callee_saved.v6, td.callee_saved.v7, td.callee_saved.v8, 12, td.callee_saved.psp, 14, 15 ];
}
One thing i couldn't figure out is how to have it automatically imported into the SES project? I can do it manually before I use it, but that's going to get annoying in the long run. I'm not sure what bit of scripts generate the *.emProject files in the build directory and how to inject a file into them. Anyone know?
Also, please feel free to suggest improvements to the script itself. Getting all the registers is the another mystery I'm trying to solve.