evmar / retrowin32

windows emulator
https://evmar.github.io/retrowin32/
Apache License 2.0
539 stars 24 forks source link

Visual debugging and profiling. #36

Open mateli opened 4 weeks ago

mateli commented 4 weeks ago
  1. A machine code debugger that allows for live viewing of memory, current CPU registers, disassembly etc. This would be similar to many applications that use x86 debugging instructions to step trough an exe file although by integrating it with an emulator it can be used to figure out what an program actually are doing.
  2. A profiler that counts instruction executions to figure out where a program spends time.
  3. A live patcher. A patch specifies a memory location or a function call to replace with a call to a target native dll/so file. This can be used both to speed up programs and also to modify their behavior. Potentially this can be done in a way that is invisible to the guest application by having the emulator just recognize where the program counter enters the code to replace.
  4. For live patching it is useful to be able to replace parts of a function. For example the beginning of main could be replaced with native code that does something that is useful to do in native host-optimized code but then still run parts of the main function. It could also call some of the functions that are called from the original main functions while replacing others with target native code. This would allow an application to be gradually rewritten and translated to a modern programming language. Although it will only make sense to patch parts where features or performance can be improved.
mateli commented 4 weeks ago

Something like this for debugging: https://x64dbg.com/ Other inspirations (emulator based): https://syncsim.sourceforge.net/index.php?show=screenshots https://github.com/slatinsky/x86sim

evmar commented 4 weeks ago

If you click one of the samples linked from the home page, there is a "view in debugger" button at the top. Click 'step' a few times to see some asm.

I can't tell from this if you are sharing a general idea, or requesting something specific, could you clarify?

mateli commented 2 weeks ago

I will do a bit more thinking on the debugger part of this issue as I see that there are a primitive debugger already implemented. The first thing that comes to mind is that there are no restart button. Also neither register content nor memory can be edited. Saving the application state (think action replay) in a format that can be reloaded would also be useful both in the debugger and directly from the emulator.

As for profiling that doesn't seem to be implemented at all. All I can think of here is to count how often the program counter visits a memory location and run an instruction.