Understood with your KVM/TCG snapshot comment. I thought it was worth a try.

NOTE: I do not yet understand how gdb interacts with the virtual machine. I have experience with GDB, but only at a linux app-debug level. I don't grok how gdb on a linux host works with QEMU running a windows guest.
My *assumption* is that the VM continues to run while an app is being debugged with GDB can be stopped, stepped, etc. If this is the case, I would expect that the VM's sense of time will continue to move forward while the app is paused. This would be an issue for my time-sensitive app.

If I slow down the entire QEMU system with my hacks, then my expectation is that the time for both the VM and the app will slow down similarly (if I decouple the VM time from real-world time using the -rtc command-line argument).

So...
   1) Are my assumptions close?
   2) Can someone point me to information on using gdb with QEMU/KVM?

Thanks!
-S




On Thu, Jun 24, 2021 at 11:23 AM Peter Maydell <peter.maydell@linaro.org> wrote:
On Wed, 23 Jun 2021 at 22:10, Steven Raasch <sraasch@gmail.com> wrote:
> I have used KVM to create a snapshot of a windows-10 guest running a graphics-intensive app. The *original* issue is that the app does not execute correctly when re-started from the snapshot using TCG (it doesn't crash, but it doesn't run correctly, either).

I'm not sure that taking a snapshot with KVM and then resuming under TCG
is really tested. So I'm not very surprised that it doesn't work.

> I'm setting DEBUG & single-step modes by calling cpu_single_step() from the top of kvm_vcpu_thread_fn().
> in kvm_cpu_exec() I wait until I get a KVM_EXIT_DEBUG signal before logging the instruction.

If your app can cope with the slowdown involved in taking a VM exit
after every instruction (which will be massive), then it can probably
also handle the extra overhead on top of that of the gdbstub communication
protocol. So it's probably simplest just to connect to QEMU's gdbstub and
do the single-stepping that way.

The other approach to this would be to see if intel's perf monitor
stuff (which I know nothing about) has some kind of execution-trace
capture support and if that works when passing through the PMU to a
KVM guest.

thanks
-- PMM