Skip to main content

How can I evaluate values displayed within a TRACE32 window in a PRACTICE script? - Knowledgebase / PRACTICE - Lauterbach Support

How can I evaluate values displayed within a TRACE32 window in a PRACTICE script?

The default method that always works is to print the TRACE32 window into a file, and then parse this file using specific PRACTICE commands and functions.

Example: Parsing a TASK.STacK window

let’s consider that you want to get the different values displayed in the following TASK.STacK window:

The first step is to print the window into a file using the PRinTer.FILE and WinPrint commands:

PRinTer.FILE test.txt  // redirect the printer output to the file test.txt
WinPrint.TASK.STack // send the content of the window to the printer

The next step is to parse the file using the PRACTICE commands OPEN, READ and CLOSE as well as the STRing.* PRACTICE functions

// declare macros
PRIVATE &stack_line
PRIVATE &task_name &low &high &sp &lowest &spare &max &tmp

// open the file for reading and writing
OPEN #1 test.txt  
// read the first line of the file, which corresponds to the command name, into the macro &stack_line
READ #1 %LINE &stack_line  
// read the second line of the file, which corresponds to the column names, into the macro &stack_line
READ #1 %LINE &stack_line

// iterate over the rest of lines until the end of the file is reached:
RePeaT
(
  // read one line
  READ #1 %LINE &stack_line
  // Abort when reading an empty line
  IF "&stack_line"==""
    ENDDO

  // extract name and emove unnecessary spaces
  &task_name=STRing.SPLIT("&stack_line","|",0)
  &task_name=STRING.TRIM("&task_name")
  
  // extract low and high values
  &tmp=STRing.SPLIT("&stack_line","|",1)
  &low=STRing.SPLIT("&tmp"," ",0)
  &high=STRing.SPLIT("&tmp"," ",1)
  
  // extract sp
  &sp=STRing.SPLIT("&stack_line","|",2)
  &sp=STRing.SPLIT("&sp"," ",0)
  
  // extract lowest, spare and max 
  &tmp=STRing.SPLIT("&stack_line","|",3)
  &lowest=STRing.SPLIT("&tmp"," ",0)
  &spare=STRing.SPLIT("&tmp"," ",1)
  &max=STRing.SPLIT("&tmp"," ",-1)
  
  // print results
  AREA.view
  PRINT "------------------------------------------"
  PRINT "Task name:                  &task_name"
  PRINT "Low stack address:          &low"
  PRINT "High stack address:         &high"
  PRINT "SP value:                   &sp"
  PRINT "Lowest used stack address:  &lowest"
  PRINT "Spare bytes:                &spare"
  PRINT "Max stack space used:       &max"

) 
WHILE !FILE.EOFLASTREAD()

// close the file
CLOSE #1

Final Results

Here is an example of the parsed output displayed in the AREA.view window:

References

The PRACTICE commands and functions used in this script are described in the following documentation:

Alternative Approach

It is possible to get the values displayed in some TRACE32 windows using specific PRACTICE functions directly. For example, refer to the description of the sYmbol.List.MAP.<x>() functions in General Function Reference.


Helpful Unhelpful

1 of 1 people found this page helpful

Add a comment

ID-0
To prove you are a human, please tell us the text you see in the CAPTCHA image