Open stevielavern opened 7 months ago
I meet the same problem on M2 pro. I test arm64 arch
Verified the read operations are inlined. Arm64 backend tends to inline read/write operations.
See: https://github.com/unicorn-engine/unicorn/wiki/FAQ#memory-hooks-are-skipped
1200003E0: F4 03 10 32 orr w20, wzr, #0x10000
1200003E4: 60 06 7E A9 ldp x0, x1, [x19, #-0x20]
1200003E8: 00 18 54 8A and x0, x0, x20, lsr #6
1200003EC: 21 00 00 8B add x1, x1, x0
1200003F0: 20 00 40 F9 ldr x0, [x1] # <--- Optimized as a single instruction, x1 = 0x100000
Same problem here, M2 :(
I'm emulating UC_ARCH_ARM/UC_CPU_ARM_CORTEX_M4 and on Mac M1 host, and I'm not seeing UC_MEM_READ events. Is there a way to overcome this limitation, e.g. recompile the lib with the TCG inlining disabled? I'm trying to emulate peripherals and things needs to take action on read events.
you may try this, not tested full functionalities , since I only need the address and value of reads. https://github.com/saicao/unicorn/commit/026f4c447e944cd855fd0d44fea52ac31bc3a372 @keroblabs
@saicao Would you like to submit a PR for that?
From: SAI @.> Sent: Friday, April 12, 2024 11:23:13 AM To: unicorn-engine/unicorn @.> Cc: lazymio @.>; Comment @.> Subject: Re: [unicorn-engine/unicorn] UC_HOOK_MEM_READ only triggered once (x86 64 emulated on mac M1) (Issue #1908)
you may try this, not tested full functionalities , since I only need the address and value of reads. @.***https://github.com/saicao/unicorn/commit/026f4c447e944cd855fd0d44fea52ac31bc3a372 @keroblabshttps://github.com/keroblabs
― Reply to this email directly, view it on GitHubhttps://github.com/unicorn-engine/unicorn/issues/1908#issuecomment-2050896270, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AHJULO4YKUHK5KBRAGYLUUTY45HSDAVCNFSM6AAAAAA7MLCXI6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANJQHA4TMMRXGA. You are receiving this because you commented.Message ID: @.***>
@saicao Awesome! I applied the patch locally, rebuilt the lib and now all read events are coming through.
Hello,
Description
I'm facing a strange issue where my UC_HOOK_MEM_READ is only called the first time a memory read is encountered. All subsequent reads do not trigger the callback.
Setup
Unicorn has been compiled as per recommendations in the documentation. Unicorn python bindings were installed in a fresh python venv.
Test case
Test case output
As can be seen above,
hook_mem_access
is only called once for READ while it is expected to be called 10 times. Strangely, this does not affect writes.