11.07.2015 Views

CrossWorks for ARM User Guide

CrossWorks for ARM User Guide

CrossWorks for ARM User Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

clicking on one of the entries in the threads window the debugger is located to it'ssaved execution context - you can put the debugger back into the default executioncontext using Show Next Statement.Writing threads.jsThe JavaScript program contained in threads.js must be have a named function calledupdate which is called when the threads window is refreshed. The threads window isupdated using the following JavaScript interfaceThreads.newqueue("queuename")Threads.add("threadname", threadpriority, "threadstate", registers)The Threads.newqueue function takes a string argument and creates a new top levelentry in the threads window. Subsequent threads that are added to this window willgo under this.The Threads.add function takes a string argument <strong>for</strong> the thread name, an integerargument <strong>for</strong> the thread priority, a string argument <strong>for</strong> the current state of the threadand finally an array (or null) containing the execution context of the thread (registers).The array containing the registers should contain the entries in the order they aredisplayed in the CPU registers display—typically this will be in register number ordere.g. r0, r1, and so on.To generate the thread lists you need to access the debugger from the JavaScriptprogram. To do this you can use the JavaScript interfaceDebug.evaluate("expression");which will evaluate the string argument as a debug expression and return the result.The returned result will be an object if you evaluate an expression that denotes astructure or an array. If the expression denotes an structure then each field can beaccessed using the JavaScript array notation, <strong>for</strong> example:c = Debug.evaluate("complex");i = c["i"];j = c["j"];Because JavaScript is a dynamic language, you can write the above in a more naturalfashion:c = Debug.evaluate("complex");i = c.i;j = c.j;You can access arbitrary memory locations using C style casts, <strong>for</strong> example:v = Debug.evaluate("*(unsigned*)0x200");and similarly you can cast to user-defined types:Chapter 12Threads window121

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!