How to start debugging from application? [modified]
-
My application (32 bit) starts next process instance of itself. In new process I need to start debugging so I'm using __asm int 3; It worked good in WinXP/VS2008, it stopped the app and gave me selection whether start new VS instance or use existing VS instance to debug. I've switched to Win 7 64 bit and it does not work anymore. It offers nothing, app just hangs for some time, then exits, I cannot even attach debugger to the process manually. How can I solve this? Thank you. In VS options, the "Jst-in-time" I have all options active (managed,native,script)
modified on Friday, January 21, 2011 5:46 AM
-
My application (32 bit) starts next process instance of itself. In new process I need to start debugging so I'm using __asm int 3; It worked good in WinXP/VS2008, it stopped the app and gave me selection whether start new VS instance or use existing VS instance to debug. I've switched to Win 7 64 bit and it does not work anymore. It offers nothing, app just hangs for some time, then exits, I cannot even attach debugger to the process manually. How can I solve this? Thank you. In VS options, the "Jst-in-time" I have all options active (managed,native,script)
modified on Friday, January 21, 2011 5:46 AM
try
#include "CrtDbg.h"
//code ...
_CrtDbgBreak(); -
try
#include "CrtDbg.h"
//code ...
_CrtDbgBreak(); -
_CrtDbgBreak() is a valid function under Win64. Perhaps it expects a debugger to be attached. Perhaps you could use something like:
while (!IsDebuggerPresent()) {
Sleep(1000);
}It is quite a hack up, but if it is just for testing it doesn't really matter.
-
_CrtDbgBreak() is a valid function under Win64. Perhaps it expects a debugger to be attached. Perhaps you could use something like:
while (!IsDebuggerPresent()) {
Sleep(1000);
}It is quite a hack up, but if it is just for testing it doesn't really matter.
-
Thank you for tip.
while (!IsDebuggerPresent()) {
Sleep(1000);
}
__asm int 3;works, but now I have to attach debugger to correct process manually :( It would me more convenient if it would work like before so other ideas are still welcome :)
Perhaps it is something wrong with your JIT settings. I just ran
#include <Windows.h>
#include <CrtDbg.h>int main() {
OutputDebugString(TEXT("Hello\n"));
_CrtDbgBreak();
OutputDebugString(TEXT("World\n"));
return 0;
}Compiled in debug mode on VS 2008. It came up with the crashed message, 1 of the options was to debug the program. This gave me an idea, if
_CrtDbgBreak()
doesn't work for you, just crash you program and attach the JIT then. Once attached you can just drag the instruction pointer (the yellow arrow to the left of the code) to the next line and hit continue. Something simple to crash your program would bechar *p = NULL;
*p = 0; //Write 0 to an invalid address -
Perhaps it is something wrong with your JIT settings. I just ran
#include <Windows.h>
#include <CrtDbg.h>int main() {
OutputDebugString(TEXT("Hello\n"));
_CrtDbgBreak();
OutputDebugString(TEXT("World\n"));
return 0;
}Compiled in debug mode on VS 2008. It came up with the crashed message, 1 of the options was to debug the program. This gave me an idea, if
_CrtDbgBreak()
doesn't work for you, just crash you program and attach the JIT then. Once attached you can just drag the instruction pointer (the yellow arrow to the left of the code) to the next line and hit continue. Something simple to crash your program would bechar *p = NULL;
*p = 0; //Write 0 to an invalid address