Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
976 views
in Technique[技术] by (71.8m points)

lauterbach - Trace32 practice script: DATA.SET how to use

What does the following command mean? What does EA mean?

&HEAD=0x146BF94C
DATA.SET  EA:&HEAD+0x4  %LONG  DATA.LONG(EA:&HEAD+0x4)&0xFFFFFF
question from:https://stackoverflow.com/questions/65854935/trace32-practice-script-data-set-how-to-use

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The command Data.Set writes raw data to your target's memory at the given address.

The command follows this schema:
? Data.Set <address> <access width> <data>
where

  • <address> has the form <access class> : <address offset>
    where the "access class" are several letters specifying which memory is accessed in which way.
  • <access width> is %Byte for 8-bit, %Word for 16-bit, %Long for 32-bit or %Quad for 64-bit
  • <data> is the data you actually want to write.

For the "access class" check the chapter Access Classes in your Processor Architecture Manual (menu → Help → Processor Architecture Manual). The types of available access classes vary from the used processor architecture. (e.g. different classes for ARM and PowerPC)

The "access class" EA: means:

  • Access the memory while the CPU is running (E).
  • Access the memory via absolute (physical) memory addresses (A) bypassing the MMU.

Finally the data (<data>) you want to write to the memory can be a fixed value (e.g. 0x42) or calculated via an expression (0x40+0x02). Such an expression can also use so called "PRACTICE functions". The function used in your example is Data.Long(<address>), which reads 32-bit from the given address. (Note: Expressions may not contain blanks.)

And then you have a macro &HEAD= which contains the string "0x146BF94C". This means that any &HEAD appearing in any later command gets replaces by the content of the macro. This similar to the C-Preprossor.

Thus, your commands

&HEAD=0x146BF94C
DATA.SET EA:&HEAD+0x4 %LONG DATA.LONG(EA:&HEAD+0x4)&0xFFFFFF

have the same meaning than

Data.Set  EA:0x146BF950  %LONG  Data.Long(EA:0x146BF950)&0x00FFFFFF

and that defines actually a read-modify-write on the 32-bit value at address EA:0x146BF950: The value is read from memory, the upper 8-bit are set to zero and than the result gets written back to the same memory location.

It has (almost) the same meaning than the C code expression

*((volatile uint32_t*) 0x146BF950)  &=  0x00FFFFFF;

It is just "almost the same" because the C code expression would not bypass the MMU, like your Data.Set command does, thanks to the "A" in the memory access class of the addresses.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...