Attach to Process
Use the "Attach to Process" dialog to identify a DataFlex process that is running outside of the Studio debugging environment and "Attach" the Studio debugger to it.
Once you have attached to the process, you can start debugging it as if the executable was originally launched from within the Studio.
Pre-Requisites to a Successful Attach
The Studio debugger has dependencies on files within the workspace of the executable that is being debugged. When you launch an executable from within the Studio, all of these dependencies are automatically handled in a way that is transparent to the developer. When you wish to attach the debugger to a process that was not launched from the Studio, you must ensure that the debugging environment correctly matches the executable to be debugged. Specifically, you must ensure the following:
- The Studio must be installed on the same machine where the debugging will take place. See Studio Location (below).
- The source that is available to the Studio must be the same version of the source code that was compiled into the executable. This includes the DataFlex package files, all libraries imported to your workspace, and the workspace's own source code.
- The location of each source file (as specified by the full path to each file) must be as it was at compile time. See Source Location (below).
- You must have a "matching" debugger symbol file (.dbg file) for the executable you want to debug. The symbol file is created each time the project is compiled.
- The matching symbol file (.dbg file) must be in the same folder as the executable.
Studio Location
If you deploy an executable to a different machine, you will not be able to debug it remotely from your development machine. You would need to run the Studio locally on the same deployment machine.
Source Location
If you deploy an executable to a different machine, you must store it in a directory folder that has the same path and drive letter as it had on the development machine where it was compiled.
All of the executable's source code, including the DataFlex package files, all libraries imported to your workspace, and the workspace's own source code must also have the same path and drive letter on the deployment machine that they had on the development machine where the project was compiled.
For example, if the project's source file has the following filename and location on the development machine:
C:\My Projects\Order Entry\AppSrc\Order.src
Then, if you move this source to a deployment machine, it must have the same path and drive letter on this machine before you can successfully attach the executable to the Studio's debugger.
Attaching the Debugger to a DataFlex Application
The following describes the necessary sequence of steps to attach the debugger to a DataFlex application:
- Launch the application.
- Get to the point you want to be in the application where the debugging will start.
- Launch the Studio.
- Load the workspace belonging to the application you wish to debug.
- Make sure the application you are debugging is the current project.
- Open the Attach to Process dialog and select the process belonging to the application you wish to debug.
- Begin normal debugging.
Recommended Debugging Practices
Contrast the above steps and pre-conditions to simply starting an application from within the Studio, where the application is ready for debugging just by launching it.
We recommend that you perform all of your planned debugging by launching applications directly from the Studio environment. In addition to being more convenient, this also promotes better practices. When you debug from within the Studio, you can use the debugger to explicitly step through the code that you wish to test, providing positive verification that the code is working or not working. Relying on Attach to Process debugging means that you are merely operating the application and waiting for a problem to reveal itself. In this scenario, there is no positive verification that the code is working as expected.
Keep in mind that the Studio fully supports the ability to pass command-line parameters to any application that it launches. This eliminates the need to launch an application outside the Studio for this purpose. For more information, see Project Properties - Parameters.
Attach to Process can be useful when an application is being run outside of the normal development and debugging procedures (during deployment, for example) and an unexpected error occurs that cannot be reproduced by any known repeatable steps. This usefulness is limited somewhat by the necessary pre-conditions; however, with proper planning, this can usually be overcome.
Whenever an 'unhandled' error occurs in a DataFlex application, the ErrorSystem activates a special dialog that displays the error information and a complete message stack dump. The information can be copied to the clipboard and sent to your development team. This information, plus the user's description of what happened, is often all that is needed to identify the source of a problem. This is much more convenient than trying to maintain a correct debugging environment on every site where your applications are deployed. For more information, see User Errors and Unhandled Errors.
User Interface
Process List
The grid control lists each running DataFlex application within reach of the Studio. Other Studio instances are filtered from this list. The Windows Process ID and the full path and filename of each executable are listed.
Refresh
Click the Refresh button to update the list of processes. You would use this when a process is started after the dialog was activated.
OK
Click the OK button to attach to the currently selected process in the Process List. You can also attach to a process by double-clicking it with the mouse.
Cancel
Click Cancel to close the dialog without attaching to any process.