I would like to get the opcode of an i386 instruction that is executed in my QEMU guest. I found that cpu_memory_rw_debug(env, pc, buf, size, is_write);
can access the memory. Yet, I don't know how much memory I have to read. In other words, what value to assign to size
. I learned in this SO post that the
x86 instruction set (16, 32 or 64 bit, all variants/modes) is guaranteed to fit in 15 bytes
If I read 15 bytes each time, I need to somehow determine where the opcode ends, because most opcodes are less than 15 bytes.
I guess there must be a qemu function for this. There is probably a better qemu feature to do what I want without fiddling with opcodes lengths. Unfortunately, I couldn't find either of the two.
A I missing something conceptually?
All hints are appreciated.