FAQs for Script Language PRACTICE
|Can I execute a PRACTICE script on a specific event e.g. program stop?|
You can use the command ON or GLOBALON for this. ON is suitable when there is still an active PRACTICE script controlling your test case. GLOBALON is suitable if you want a reaction on an event until you disable it again.
The general syntax is:
ON|GLOBALON <event> <action>Please refer to the description of the ON and GLOBALON commands respectively in the "General Commands Reference Guide O" and "General Commands Reference Guide G" for more information on the supported events and actions.
To disable the event handler use
ON|GLOBALON <event> inheritExamples:
1. Execute a PRACTICE script when the program execution is stopped:
GLOBALON PBREAK DO myscript.cmm2. Continue the PRACTICE script execution when an error happens:
ON ERROR CONTinue3. Execute the subroutine powerup_handler when target power is switched to on:
ON POWERUP GOSUB powerup_handler
|Can I set a breakpoint with a logical condition?|
The command Break.Set has an option /VarCONDition , which allows you to specify a condition under which the CPU stays stopped once it hits the corresponding breakpoint. (In the dialog for setting breakpoints you'll find also the field "Condition" for that, when you click on "advanced".)
Example: set a breakpoint on function MyFunc with the condition that the variable x==10 and y==11
Break.Set MyFunc /VarCONDition (x==10 && y==11)
As a result the CPU is stopped every time the function MyFunc is executed, but gets immediately restarted when condition "x==11 && y==11" is not met.
You can also specify a condition in the PRACTICE language by using the Break.Set option /CONDition instead of /VarCONDition
Break.Set MyFunc /CONDition (Register(R0)==0)
|How can I print the content of a TRACE32 window into a file?|
The commands PRinTer.FILE and WinPrint can be used to print a TRACE32 window into a file.
The /Append option of the PRinTer.FILE command can be used to append new data to the existing file e.g. in ASCII or XHTML. Without /Append , file contents are overwritten if the file already exists.
PRinTer.FILE output.txt /Append WinPrint.Trace.List WinPrint.Data.dump 0--0xfff PRinTer.FILE file01.html XHTML WinPrint.List.Mix func7--func17Please refer for more information to the "PowerView Command Reference"
|How can I read/write from/to memory in a PRACTICE script?|
Writing Raw Memory
Writing memory locations (or writing to memory mapped registers) from PRACTICE scripts works with the command
Data.Set <address> %<format> <value>Note, that hexadecimal values should be written with prefix "0x", while decimal values must end with a dot "."
Data.Set D:0x1000 %Long 0x12345678 Data.Set D:0x3000 %Long 42.Thereby "format" specifies the width of the data to be written, where...
Instead of using a fixed address you can also uses a label if you have loaded your ELF file already. E.g.:
Data.Set _IntVec1 %Long 0x800000Note, that for writing of high level variables (which have been declared in the C/C++ code of your application), it is more convenient to use command Var.set. (See below)
Reading Raw Memory
Reading memory locations (or reading to memory mapped registers) from PRACTICE scripts works with the PRACTICE function
Data.<value_width>()where value_width stands again for Byte, Word, Long, Quad (see above).
PRACTICE functions must be used within a PRACTICE command or have to be assigned to a PRACTICE macro.
ECHO DATA.Long(D:0x1000) PRIVATE &myvalue &myvalue=DATA.Word(D:0x4020) ECHO "My value is " &myvalue Data.Set D:0x1000 %Long DATA.Long(D:0x1000)|1The third example shows a way to do a read-modify-write with the purpose to set the least significant bit in the 32-bit value at address 0x1000.
Note, that for reading of high level variables (which have been declared in the C/C++ code of your application), it is more convenient to use function Var.VALUE() (See below)
Writing a variable of you application via a PRACTICE script (after loading the ELF) works with the command
Var.set myvar=0x100 Var.set flags=flags|0x10The second example performs a read-modify-write with the purpose to set bit 8 of a variable named "flags".
Note, that all commands staring with "Var." are special in the way that they deal with "High Level Language" expressions, which basically means "Like you would do it in C/C++". So here it is not needed that decimal values are followed by a dot. See also chapter "Change a Variable Value" in the PDF "Training HLL Debugging" (training_hll.pdf, see link below)
Reading a variable of you application via a PRACTICE script (after loading the ELF) works with the function
ECHO Var.VALUE(myvar) WAIT (Var.VALUE(flags)&0x10)==0x10The second example stalls the execution of the script until in the variable named "flags" the bit 8 is set.
Training for the PRACTICE script language
Training HLL Debugging
General Commands Reference Guide D (with details about command Data.Set)
General Commands Reference Guide V (with details about command Var.set)
General Function Reference (with details about functions Data.<value_width>() and Var.VALUE())
|How to check the return value of a function in a PRACTICE script?|
Every function has usually a pseudo-variable called return . You can see that in window sYmbol.Browse.Var \\*\*\<myfunc>\* (where myfunc is the name of your function). Of any variable you can get its value with PRACTICE function Var.VALUE(<variable>).
So you get the return value of function myfunc() with
GO sYmbol.EXIT(myfunc) // go to return statement of myfunc PRINT Var.VALUE(return) // get the return valueIn case you would like to do a module test, then you can use the Var.set command and Var.VALUE(<varname>) PRACTICE function.
Example: to call the function int func3(int a, int b) with random arguments (e.g. 5 and 3) and get the return value, do the following:
Var.NEWLOCAL \x // create artificial variable on the PRACTICE stack Var.set \x=func3(5,3) // execute func3() with arguments 5 and 3 on your CPU PRINT Var.VALUE(\x) // get the return value
|How to put a breakpoint on a specific source code line from a TRACE32 PRACTICE script?|
You can use the following syntax to set e.g. a breakpoint at line 42 of the file myfile.c located under c:\t32\myproject\ :
Break.Set \"c:\t32\myproject\myfile.c"\42or simply:
|Is it possible to execute a PRACTICE script when a breakpoint is hit?|
You can set the breakpoint with: Break.Set <addr> /Program /CMD "DO myScript.cmm"
To continue the execution of the target program, add the command Go to the end of the called PRACTICE script.
The Break.Set command knows also an option /RESUME , but this is not suitable in this case, since it won't wait until the called PRACTICE script has finished.
|Is it possible to run an external program from within TRACE32 PowerView?|
Depending on what you actually want to do, one of the following commands should be suitable to run any external program or batch file:
|Is it possible to stop the program execution when a CPU register is written with a specific value?|
It is not possible to stop the program execution on a CPU register read or write since this is not supported by any processor on-chip debug implementations. It is only possible to set breakpoints on program execution or memory accesses (read/write). It is thus possible to set an on-chip breakpoint on an access to a memory mapped peripheral register.
|Is it possible to use PRACTICE macros inside dialogs?|
Yes. You should add the character "&" at the beginning of thr dialog block, otherwise macros won't be expanded inside that block.
|What's the long form and meaning of abbreviated TRACE32 commands in CMM scripts? Which shorter syntax is available?|
PRCTICE commands are not case sensitive. Each command has a long and short form. The significant letters are always written in upper case letters.
Example: the short form of SYStem.Up is SYS.U
You can execute this command as SYStem.Up, system.up, sys.up, system.u, ...
You can get open the documentation of a TRACE32 command by typing the command in long or short for in the TRACE32 command line then type space and press the F1 key. The corresponding PDF document will open at the correct location.
|WinPrint doesn't print the whole content of a TRACE32 window (e.g. FPU.view) to a file, I only get a part of the window printed.|
If the window you want to print is bigger that the screen, then you will get only the upper part of it using WinPrint.
To get the whole window, you should use WinPRT and WINPAN instead.
PRINTER.FILE fpu.txt /APPEND ; fpu.txt should be empty
WINPOS ,,180. 40. ,,, MYWIN FPU
WINPAN 0. -999.
SCREEN.WAIT ; necessary to update the screen after WINPAN if executing within a PRACTICE script
WINPRT MYWIN ; print first part
WINPAN 0 40. ; scroll down
SCREEN.WAIT ; update screen
WINPRT MYWIN ; print second part
Copyright © 2020 Lauterbach GmbH, Altlaufstr.40, 85635 Höhenkirchen-Siegertsbrunn, Germany
The information presented is intended to give overview information only.
Changes and technical enhancements or modifications can be made without notice. Report Errors
Last generated/modified: 24-Sep-2020