Download Simics User Guide for Unix
Transcript
12.1. Breakpoints 12.1.7 Magic Instructions and Magic Breakpoints For each simulated processor architecture, a special no-operation instruction has been chosen to be a magic instruction for the simulator. When the simulator executes such an instruction, it triggers a Core_Magic_Instruction hap and calls all the callbacks functions registered on this hap (see chapter 8 to get more information about haps). If the architecture makes it possible, an immediate value is encoded in the magic instruction. When the hap is triggered, this value is passed as an argument to the hap handlers. This provides the user with a rudimentary way of passing information from the simulated system to the hap handler. Magic instructions have to be compiled in the binary files that are executed on the target. The file magic-instruction.h in [simics]/src/include/simics/ defines a MAGIC(n) macro that can be used to place magic instructions in your program, where n is the immediate value to use. Note: The declaration of the macros are heavily dependent on the compiler used, so you may get an error message telling you that your compiler is not supported. You will need to write by yourself the inline assembly corresponding to the magic instruction you want to use. The GCC compiler should always be supported. Note: Using magic instructions in other languages than C requires the ability to insert inline assembler in a program, or at least the ability to call arbitrary functions written in assembly. For example, in Java it would be necessary to use the JNI interface. As always, check your compiler and language documentation for details on how to enter inline assembly. A complete definition of magic instructions and the values the parameter n can take is provided in figure 12.1. Target Alpha ARM IA-64 MIPS MSP430 PowerPC 32-bit PowerPC 64-bit SPARC x86 Magic instruction binary: 0x70000000 orreq rn, rn, rn nop (0x100000 + n) li %zero, n bis r0,r0 mr n, n fmr n, n sethi n, %g0 xchg %bx, %bx Conditions on n n=0 0 6 n < 15 0 6 n < 0x100000 0 6 n < 0x10000 n=0 0 6 n < 32 0 6 n < 32 1 6 n < 0x400000 n=0 Figure 12.1: Magic instructions for different Simics Targets Here is a simple pseudo-code example: 143