开发者

debugging a dynamically loaded executable

开发者 https://www.devze.com 2023-02-20 18:06 出处:网络
I\'ve been handed an application to support, and I\'m trying to figure out how to do it. I do have the source, and can make some changes, but I obviously don\'t want to completely change the architect

I've been handed an application to support, and I'm trying to figure out how to do it. I do have the source, and can make some changes, but I obviously don't want to completely change the architecture of the application.

The app is in a VS2010 solution composed of 9 different projects. The main one is a Windows Form application, but it spins off others in other threads.

Her开发者_如何学JAVAe's the difficulty. Even though the different projects are parts of the same solution, they are separate executables, not DLLs. When the main program starts one of the other projects, it does so by creating a new process, setting the filename of the executeable, the startup arguments and other assorted parameters into the process.StartInfo object, and then calls process.Start().

How can I set breakpoints and debug subordinate executables? I can't attach to them until they are loaded, but they don't get loaded until process.Start() is called, and by then it's too late. Is there a method call I can insert into the main program to get it to load the executable (so I can set breakpoints in it) before it actually begins execution?

Thanks.


Are you able to recompile the other executables? If so, have you tried putting DebugBreak in suitable places? (or _asm int 3).

You can't load the process (usefully), since by definition it will be run in a different addres space from the one you are debugging before it starts.


One simple solution could be adding a call to DebugActiveProcess function to the "main" function of every process which participates in your application.

0

精彩评论

暂无评论...
验证码 换一张
取 消