Community
cancel
Showing results for 
Search instead for 
Did you mean: 
David_Mccabe
Beginner
99 Views

debug .exe process from .exe

Hi there.

I have a Fortran .exe which is run from a C++ .exe using the winapi CreateProcessA command.  In order to debug the Fortran code I currently run the executable stand alone.

Q. Is it possible to debug the Fortran from the C++, perhaps stepping into the Fortran code from the CreateProcessA statement for example?  If so could somebody please tell me how to implement this or point me to any appropriate material.

Thanks

 

0 Kudos
2 Replies
David_Mccabe
Beginner
99 Views

forgot to mention: I am working on windows and using visual studio 2010 Update: I have discovered I can hook up the Fortran.exe process using windows api calls and have taken the following route: 1) create the Fortran process using: [cpp] BOOL WINAPI CreateProcess( _In_opt_ LPCTSTR lpApplicationName, _Inout_opt_ LPTSTR lpCommandLine, _In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes, _In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes, _In_ BOOL bInheritHandles, _In_ DWORD dwCreationFlags, _In_opt_ LPVOID lpEnvironment, _In_opt_ LPCTSTR lpCurrentDirectory, _In_ LPSTARTUPINFO lpStartupInfo, _Out_ LPPROCESS_INFORMATION lpProcessInformation ); [/cpp] ...process now running... 2) get process ID [cpp] id = lpProcessInformation.dwProcessId; [/cpp] 3) use attach vs2010 debugger to process Id [cpp] std::ostringstream stream; stream << "VsJITDebugger.exe -p "; stream << id; std::string debugCMD = stream.str(); system(debugCMD.c_str()); [/cpp] ...debugger attached to the Fortran process. Ideally I would like to have the debugger ready in anticipation of the new process being created, rather than attaching after it has started.
SergeyKostrov
Valued Contributor II
99 Views

Hi David, As soon as Win32 API function 'CreateProcess' creates a Fortran process ( from a C/C++ code ) you could use a Visual Studio feature 'Attach to Process...': VS Menu -> 'Debug' -> 'Attach to Process...' You could also get more technical details related to Fortran on a dedicated forum: Forum: Intel® Visual Fortran Compiler for Windows* Web-link: http://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows Best regards, Sergey
Reply