diff options
author | Jo-Philipp Wich <jo@mein.io> | 2022-02-03 17:01:20 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2022-02-03 17:03:59 +0100 |
commit | 3e3f38de65f22db4497e0bff3f6b75354ae9463a (patch) | |
tree | 0ea34a1d682a3bad9a3131849cb45bc57b6d6944 /vm.c | |
parent | 3600ded530cf099a922cbff73df37d7bcf3c3008 (diff) |
vm: ensure consistent trace output between gcc and clang compiled ucode
Clang emits code which evaluates function call argument expressions in a
different order, causing `uc_dump_insn()` to receive the instruction pointer
address after decoding the instruction, not before.
Avoid that problem by explicitly caching the pre-decode address in a
temporary variable which is then passed to `uc_dump_insn()`.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'vm.c')
-rw-r--r-- | vm.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -2294,12 +2294,17 @@ uc_vm_execute_chunk(uc_vm_t *vm) uc_chunk_t *chunk = uc_vm_frame_chunk(frame); uc_value_t *retval; uc_vm_insn_t insn; + uint8_t *ip; while (chunk) { - if (vm->trace) - uc_dump_insn(vm, frame->ip, (insn = uc_vm_decode_insn(vm, frame, chunk))); - else + if (vm->trace) { + ip = frame->ip; + insn = uc_vm_decode_insn(vm, frame, chunk); + uc_dump_insn(vm, ip, insn); + } + else { insn = uc_vm_decode_insn(vm, frame, chunk); + } switch (insn) { case I_LOAD: |