NVlabs / NVBit

198 stars 18 forks source link

Cannot inject to all the instructions #82

Open xinyi-li7 opened 2 years ago

xinyi-li7 commented 2 years ago

Hi, I'm trying to inject a function record_reg_val to some specific instructions. I have an id_to_ssa_map to keep a map from opcode_id to sass string like the example code.

I record the map right before nvbit_insert_call:

image

And then, I print the opcode_id in each thread (by calling printf inside the record_reg_val injection function) and the map id_to_ssa_map at the termination. It gives the following result:

opcode_id = 24
opcode_id = 25
opcode_id = 2
opcode_id = 26
opcode_id = 18
opcode_id = 27
opcode_id = 4
opcode_id = 6
opcode_id = 28
opcode_id = 24
opcode_id = 25
opcode_id = 2
opcode_id = 26
opcode_id = 18
opcode_id = 27
opcode_id = 4
opcode_id = 6
opcode_id = 28
opcode_id = 24
opcode_id = 25
opcode_id = 2
opcode_id = 26
opcode_id = 18
opcode_id = 27
opcode_id = 4
opcode_id = 6
opcode_id = 28
dot: 4.000000
done
0,FFMA R5, R6, -R5, 1 ;
1,FFMA R5, R5, R6, 0.28571429848670959473 ;
2,FMUL R8, R3, R4 ;
3,FFMA R4, R8, R5, RZ ;
4,FFMA R3, R4, -3.5, R8 ;
5,FFMA R4, R5, R3, R4 ;
6,FFMA R3, R5, R3, R4 ;
7,FADD R2, R2, R3 ;
8,FFMA R7, R6, -R7, 1 ;
9,FFMA R7, R7, R6, 0.28571429848670959473 ;
10,FMUL R8, R4, R5 ;
11,FFMA R4, R7, R8, RZ ;
12,FFMA R5, R4, -3.5, R8 ;
13,FFMA R5, R7, R5, R4 ;
14,FFMA R4, R5, -3.5, R8 ;
15,FFMA R5, R7, R4, R5 ;
16,FADD R2, R2, R5 ;
17,FFMA R3, R7, R8, RZ ;
18,FFMA R4, R3, -3.5, R8 ;
19,FFMA R4, R7, R4, R3 ;
20,FFMA R3, R7, R3, R4 ;
21,FADD R13, R2, R3 ;
22,FFMA R2, R7, R4, R5 ;
23,FADD R2, R13, R2 ;
24,FFMA R6, R5, -R6, 1 ;
25,FFMA R5, R6, R5, 0.28571429848670959473 ;
26,FFMA R3, R5, R8, RZ ;
27,FFMA R4, R5, R4, R3 ;
28,FADD R2, R3, R2 ;
29,@!P0 FFMA R3, R8, 1.84467440737095516160e+19, RZ ;
30,@!P1 FFMA R6, R6, 1.84467440737095516160e+19, RZ ;
31,FADD.FTZ R10, -R7, -RZ ;
32,MUFU.RCP R8, R7 ;
33,FFMA R9, R8, R10, 1 ;
34,FFMA R14, R8, R9, R8 ;
35,FFMA R8, R3, R14, RZ ;
36,FFMA R9, R10, R8, R3 ;
37,FFMA R9, R14, R9, R8 ;
38,FFMA R10, R10, R9, R3 ;
39,FFMA R8, R14, R10, R9 ;
40,FFMA.RZ R3, R14.reuse, R10.reuse, R9.reuse ;
41,FFMA.RM R4, R14.reuse, R10.reuse, R9.reuse ;
42,FFMA.RP R3, R14, R10, R9 ;
43,MUFU.RSQ R8, -QNAN  ;
44,FADD.FTZ R8, R8, R6 ;

As you can see, not all the instructions call the inject function record_reg_val, but they are supposed to do that (Notice I fill the map just before nvbit_insert_call). Do you know what caused this problem?

Thanks!