hase-project / hase

Timeless debugging with symbolic execution and processor trace
BSD 2-Clause "Simplified" License
74 stars 8 forks source link

Fix bugs preventing hase from running #91

Closed bet4it closed 5 years ago

bet4it commented 5 years ago

This project is awesome🤩. However, it can't run on my computer correctly🙃.

This pull request fixes some bugs which prevent hase from running.

According to https://github.com/torvalds/linux/blob/v4.19/arch/x86/events/intel/pt.c#L1404-L1407, when we map AUX buffer read only, which means that it is in the snapshot mode, aux_size of PERF_RECORD_AUX event will be set to the size of AUX buffer, which is useless for us. This pull request also add PROT_WRITE flag when mmap AUX buffer, so we can only save meaningful AUX buffer to file.

Mic92 commented 5 years ago

Fixes looks good to me. Regarding the recording: The idea was to eventually switch to snapshot recording at some point. E.g to only record the last x instruction to reproduce a crash. Unfortunately we have not implemented that in our replay engine. For now it might be good to have an option to support both continuous recording and snapshots

Mic92 commented 5 years ago

I cherry picked the fixes: https://github.com/hase-project/hase/commit/6838f154fdb12b079556729bb47378977ede2362

bet4it commented 5 years ago

It seems that currently events and traces are only collected when the recorded program exits, and we assume the size of collected records will not greater than the buffer holds them, in other words, continuous recording is not supported now. So there is no difference between using normal mode and snapshot mode. And the way we collect traces currently is really weird, the size of cpu-n.trace is always 64M and the psb instruction is not in the head of cpu-n.trace file. This commit is a temporary fix for it.

I will return to using snapshot mode in following pull request.

Mic92 commented 5 years ago

But would the different in that case not be that we would either record the head of the execution or in the other case the tail of the execution? The trace will contain padding in case the actual recording is smaller then the allocated size. You can use ptdump to visualize that.