FAQs for Script Language PRACTICE

The embedded tools company

Search FAQs

PDF document ( 187KB / 27-Mar-2022 )

"PRACTICE Stack Overflow" when using Break.Set < address > /CMD "DO script.cmm" /RESUME.
Ref: 0569

This happens if the breakpoint if frequently hit. The /RESUME option re-starts the program execution after the script is launched and do not wait for the end of the script execution. On the next breakpoint hit, the second script is started while the first one is still running. If the breakpoint is frequently hit and the number of parallel script executions exceeds a certain maximum, the error "PRACTICE Stack Overflow" is returned. To solve this problem, you can use one of the following solutions:
  • Remove the /RESUME option and inset a "Go" command at the end of the script. The execution will be resumed in this case at the end of the script. The breakpoint is however hit too frequently, the "PRACTICE Stack Overflow" error can still occur.

  • Replace the "DO" command with single PRACTICE commands i.e. instead of using
    Break.Set <address> /CMD "DO script.cmm" /RESUME
    Break.Set <address> /CMD "<command1>" /CMD "<command2>" ... /RESUME
  • Replace the "DO" command with a "JUMPTO" inside a script, for example:
    Break.Set <address> /CMD "JUMPTO do_it"
Moreover, you can use as an alternative to the /CMD option the following inside a PRACTICE script:
  Break.Set < address >
    < break handling >

Can I execute a PRACTICE script on a specific event e.g. program stop?
Ref: 0508

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> inherit

1. Execute a PRACTICE script when the program execution is stopped:
2. Continue the PRACTICE script execution when an error happens:
3. 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?
Ref: 0507

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?
Ref: 0504

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.Data.dump 0--0xfff

PRinTer.FILE file01.html XHTML
WinPrint.List.Mix func7--func17

Please refer for more information to the "PowerView Command Reference"

How can I read/write from/to memory in a PRACTICE script?
Ref: 0550

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...
  • %Byte stands for 8-bit
  • %Word stands for 16-bit
  • %Long stands for 32-bit
  • %Quad stands for 64-bit
(There are also format specifier for a width of 3,5,6,7 bytes)
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  0x800000
Note, 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
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
    ECHO "My value is " &myvalue

    Data.Set  D:0x1000  %Long  DATA.Long(D:0x1000)|1
The 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 Variables

Writing a variable of you application via a PRACTICE script (after loading the ELF) works with the command
    Var.set <variable_name>=<value>
    Var.set myvar=0x100

    Var.set flags=flags|0x10
The 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 Variables

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)==0x10
The second example stalls the execution of the script until in the variable named "flags" the bit 8 is set.

How to check the return value of a function in a PRACTICE script?
Ref: 0512

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 value
In 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?
Ref: 0511

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"\42
or simply:
Break.Set \myfile\42

Is it possible to execute a PRACTICE script when a breakpoint is hit?
Ref: 0505

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?
Ref: 0510

Depending on what you actually want to do, one of the following commands should be suitable to run any external program or batch file:
  • OS.Area <cmdline> : Output in AREA window (blocking)
  • OS.Window <cmdline> : Output in "OS.Window" window (blocking) inside PowerView
  • OS.screen <cmdline> : On Windows the command gets directly executed without a shell. The output of a console application is shown in a temporary command window. On Linux the output is in the shell, which started the TRACE32 GUI (non-blocking)
  • OS.Hidden <cmdline> : No output anywhere (blocking)
  • OS.Command <cmdline> : Output in system shell, which allows redirects (non-blocking on Windows / blocking on Linux unless you add an ampersand &)
Please refr to the "PowerView Function Reference" for more information.

Is it possible to stop the program execution when a CPU register is written with a specific value?
Ref: 0509

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?
Ref: 0466

Yes. You should add the character "&" at the beginning of the 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?
Ref: 0403

PRACTICE 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.
Ref: 0459

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 © 2022 Lauterbach GmbH, Altlaufstr.40, 85635 Höhenkirchen-Siegertsbrunn, Germany   Impressum     Privacy Policy
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: 30-Sep-2022