10

I'm making an application that will send step-over key-presses to Visual Studio to enable it to take screenshots of part of its own code being executed line-by-line.

But it seems when you hit a break-point in your code, ALL threads stop, even ones that haven't hit a break-point. Is there any way around this? Is there some way to get Visual Studio to keep other threads running when I hit a break-point? Or do I have to resort to starting a separate process?

EDIT: To clarify, when the breakpoint is hit, I need to have execution stop only on the thread that hit the breakpoint. I am not looking to have the breakpoint only activate when hit by a certain thread. In other words, I need to have part of my program keep executing while one thread is stopped at a breakpoint in the debugger.

Newell Clark
  • 345
  • 2
  • 13

2 Answers2

4

Okay, it seems that whenever you hit a break-point in a process, all threads in that process halt, and there doesn't seem to be any way of overriding that behavior. The only way to do what I'm trying to do is to create a second Process, and have that Process be responsible for sending the virtual key-presses to Visual Studio, via an external API call.

Obviously you'll have to have some way of communicating between the main process and the key-pressing process. I looked around and I found that Anonymous Pipes are probably the best method for communicating between two processes running on the same machine.

Newell Clark
  • 345
  • 2
  • 13
  • 1
    In fact it is possible to break in a single thread. Windows calls this "SuspendThread", Visual Studio calls it "freeze/thaw"ing, and you've called it halting... Open debug > windows > threads and play around. Also see https://stackoverflow.com/a/6513021/4250150 – sudo rm -rf slash May 09 '19 at 09:50
0

I know it's an old reference and my answer arrive a lot too late but just to let you know... I think it still apply: You can't debug yourself

Eric Ouellet
  • 10,996
  • 11
  • 84
  • 119