unicorn-engine / unicorn

Unicorn CPU emulator framework (ARM, AArch64, M68K, Mips, Sparc, PowerPC, RiscV, S390x, TriCore, X86)
http://www.unicorn-engine.org
GNU General Public License v2.0
7.34k stars 1.31k forks source link

How to generate a coredump when emulation hits a crash? #1858

Closed c01dkit closed 11 months ago

c01dkit commented 11 months ago

Hi there, Does unicorn support generate a coredump (to save memory data, registers, environment variables, etc.) when emulation hits a crash ( such as UC_ERR_READ_UNMAPPED) ? A coredump can automatically generates in normal linux system. I'm wondering if unicorn has already support the same feature, or one needs to implement such mechanism manually (in exit handler) ?

wtdcode commented 11 months ago

Coredump is generated when a process exits abnormally, e.g. abort() was called. UC_ERR_READ_UNMAPPED means a normal exit, not an abort().

To save a "coredump", you may look at context API.

c01dkit commented 11 months ago

Thanks for reply! I found functions like uc_context_*, uc_mem_* and uc_reg_*. However, it seems that there is no single function aims to save all information. ( I'm not sure ) Maybe I should try to combine them.

wtdcode commented 11 months ago

uc_context will include both cpu registers and memory if you tweak it by uc_ctl api.


From: Boyu Chang @.> Sent: Wednesday, August 2, 2023 9:56:26 AM To: unicorn-engine/unicorn @.> Cc: lazymio @.>; Comment @.> Subject: Re: [unicorn-engine/unicorn] How to generate a coredump when emulation hits a crash? (Issue #1858)

Thanks for reply! I found functions like uccontext, ucmem and ucreg*. However, it seems that there is no single function aims to save all information. ( I'm not sure ) Maybe I should try to combine them.

― Reply to this email directly, view it on GitHubhttps://github.com/unicorn-engine/unicorn/issues/1858#issuecomment-1661369546, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AHJULO54XXW7HMWGLYI64IDXTGXUVANCNFSM6AAAAAA27URECY. You are receiving this because you commented.Message ID: @.***>

c01dkit commented 11 months ago

Thanks for reply! I think this issue could be closed : )