3

I have an application, which is running for a long time and then crash. I need to debug it several times to fix it and don't want to wait every time for an hour to reach the state, in which an error is occurred.

So, I want some tool to clone the whole process on a disk, then raise it, attach to it and debug.

I use Visual Studio 2012/2013 on (surprise) Windows.

For example:

for (int i = 0; i < 10000; ++i)
{
    if (i == 9999)
        throw MyExcept();
}

And I want to have a saved state of application (process) at 9998-th iteration to start debugging from it.

UPD 1: Visual Studio dump files are not admirable, because I can't get all functionality of debugger after opening it it VS. For example: I can't set breakpoints and even old ones don't work.

UPD 2: Also I need to have a possibility of duplicating this saves session of the app.

VALOD9
  • 566
  • 2
  • 6
  • 22
  • Possible duplicate to http://stackoverflow.com/questions/2956889/how-to-set-a-counter-for-a-gdb-breakpoint – Mine Aug 26 '14 at 09:15
  • @Mine, hm... That is definitely not a duplicate. Read my question more careful. I want to dump the state of the app on a hard disk not just a breakpoint to have a possibility of duplicating it to debug it many times starting from this state. – VALOD9 Aug 26 '14 at 09:28
  • OK... sorry I didn't notice that it's on VS. – Mine Aug 26 '14 at 09:30
  • @Mine, are you kidding me? If you can advice me such a tool on Mac or *nix, I'll be glad too. – VALOD9 Aug 26 '14 at 09:31
  • I doubt that this will be possible. Instead you should use logging. – JeffRSon Aug 26 '14 at 10:09
  • @JeffRSon, I doubt it's possible too, but if it is, I'll be very glad. Logging is not enough. – VALOD9 Aug 26 '14 at 10:12

2 Answers2

0

If I understood correctly, you want to accomplish two tasks:

1) Break the execution on a specific condition

You need to set a watchpoint with a condition to achieve this, or Data Breakpoint in Visual Studio terms. Have a look at this question: Can I set a breakpoint when variable is getting a specific value in .NET?

2) Dump a core file

Once you have set the watchpoint and your program reached that point, you can dump a core file. From that you can continue with the execution later on. There is an official FAQ entry entry on how to dump and load cores.

Community
  • 1
  • 1
jotrocken
  • 2,263
  • 3
  • 27
  • 38
  • I can't set new breakpoints and even old ones don't work. I need just THE SAME copy of a process. Without any restrictions. – VALOD9 Aug 26 '14 at 10:02
  • Strange enough. The core file *is* a copy of the process and its state. I am not that much into debugging with VS, but did you compile with debug information enabled (/g)? If the program executable changes (e.g. you change the code and recompile), you can most likely not use the core dump anymore. It works only with the binary it was created from. – jotrocken Aug 26 '14 at 10:24
  • Beside that, try to think of a minimal working example of what is going wrong. Isolate the problematic part of code and have it in a separate program which fails after a short time, such that you can run it over and over again. – jotrocken Aug 26 '14 at 10:27
  • if a could minimize working example, I do it by myself and will not ask about what I have asked:) I'm debugging complex multithreading app and I've already cut all unnecessary. About dump: Visual Studio says that such commands as "step in", "step over", "set breakpoint" are not available for a minidump. – VALOD9 Aug 26 '14 at 10:38
  • As I sad I am not that familiar with VS, but I see no reason why you should not be able to continue the execution from a core file. You could try another debugger (windbg (?)). Or, since you commented on the question that other platform suggestions are welcome as well, you can compile your program with *gcc* and debug it with *gdb*. But this may be troublesome if you are not familiar with those. – jotrocken Aug 26 '14 at 11:59
0

You need procdump from here

  1. Register as the Just-in-Time (AeDebug) debugger.
  2. Perhaps you should enable full local dumps.
  3. Crash you program
  4. Launch a process with procdump from full dump

But I think it is better to use DebugBreak API in your example without a crash. Usually crash will not allow you to start further - only postmortem analysis.

Sergei Nikulov
  • 5,029
  • 23
  • 36
  • No. I need all functionality of debugger after attaching to my saved process (to simplify we can call it "dump"). For example: I can't use breakpoints after attaching to a simple Visual Studio dump. – VALOD9 Aug 26 '14 at 10:06
  • @VALOD9 then conditional DebugBreak is your solution. And is nothing to do with dumps. – Sergei Nikulov Aug 26 '14 at 10:07
  • and if I would want to share this saved session of an app with someone else to let him start debugging from this saved state? So, one more time: I need a copy on a HARD DISK, to have a possibility of duplicating this session and to have a full functionality of the debugger. – VALOD9 Aug 26 '14 at 10:19
  • @VALOD9 Then use virtual machine to get full state from victim/debug computer. – Sergei Nikulov Aug 26 '14 at 10:20
  • I don't get it. Can you explain it a little? – VALOD9 Aug 26 '14 at 10:23