debug .exe process from .exe

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.



3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

forgot to mention: I am working on windows and using visual studio 2010


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:

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


...process now running...

2) get process ID

id = lpProcessInformation.dwProcessId;

3) use attach vs2010 debugger to process Id

  std::ostringstream stream;

  stream << "VsJITDebugger.exe -p ";

  stream << id;

  std::string debugCMD = stream.str();

...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.

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*

Best regards,

Leave a Comment

Please sign in to add a comment. Not a member? Join today