Debugging Creo TOOLKIT Applications
This section describes how to debug Creo TOOLKIT applications.
Building a Creo TOOLKIT Application for Debugging
The following tables list commonly used changes for sample makefiles that allow debugging of a Creo TOOLKIT application. Consult your compiler documentation for more information on the flags specified below and other debugging options.
On Windows
Compile Line Changes
Link Line Changes
Change CCFLAGS or CPPFLAGS to add /Od /Z7.
Change the /debug flag to /debug:full. Remove or comment the lines that delete $(OBJS) after a successful build.
Debugging Techniques
Depending on the type and implementation for your application, you can use one of the following debugging techniques:
•  If your application is a DLL that creates user interface and notification callbacks to be used by the interactive user, refer to the following section on Debugging an Interactive DLL.
•  If your application is a DLL that runs in batch mode (from user_initialize()), refer to Debugging an Interactive DLL.
•  If your application is a spawn or asynchronous application, refer to Debugging a Multiprocess Application.
Debugging an Interactive DLL
1. Start Creo Parametric with the DLL registered and loaded.
2. Use the debugger to attach to the process xtop.exe.
3. Set breakpoints in the callback functions that you wish to debug.
Debugging a Batch Mode DLL
Debugging Without Setting Breakpoints Before Loading Code
The following steps outline the procedure to debug applications using a debugger such as dbx that does not allow breakpoints to be set before the code is loaded.
1. Setup a Creo Parametric start command that uses the debugger as follows:
a. Edit the parametric.psf file (or the related psf. file for the given command).
b. In this file change the RUN line for xtop, to invoke the debugger first, as:
RUN="$PRO_DIRECTORY/bin/parametric1"
RUN="dbx $PRO_DIRECTORY/bin/parametric1"
2. Run the Creo Parametric start command. The debugger starts.
3. Set up a breakpoint that triggers when the DLL is loaded.
In dbx, enter stop dlopen <DLL name> For example, stop dlopen pt_inst_test.dll.
If you are using a graphical debugger such as Sun’s Workshop, the same procedure is possible. Workshop allows a “CUSTOM” breakpoint using dbx syntax, such as dlopenpt_inst_test.dll.
4. Enter run. The program runs to the point of loading the DLL.
5. When the dlopen breakpoint is triggered, add a breakpoint to user_initialize(). At this point, the DLL is loaded and the user_initialize() function is in memory.
Debugging With Breakpoints Set Before Loading Code
The following steps outline the procedure to debug applications using a debugger such as Microsoft Visual Studio that allows breakpoints to be set before the code is loaded.
1. Setup a Creo Parametric start command that uses the debugger as follows:
a. Edit the parametric.psf file (or the related psf. file for the given command).
b. In this file, change the RUN line for xtop, to invoke the debugger first as:
RUN="%PRO_DIRECTORY%\%PRO_MACHINE_TYPE%\obj\
xtop.exe"
RUN=devenv
"%PRO_DIRECTORY%\%PRO_MACHINE_TYPE%\obj\
xtop.exe"
2. Run the Creo Parametric start command. The debugger starts.
3. Load the source file containing the functions into the debugger, and graphically set a breakpoint to the start of user_initialize().
4. Run the program from the debugger User Interface. Even if the debugger indicates that no debugger information is available for xtop.exe, continue debugging.
When the DLL is loaded, the program will stop in the DLL’s user_initialize().
Debugging Creo TOOLKIT DLLs on Windows
The Creo Parametric executable contains a default exception handler on Windows. This handler will catch and react to exceptions generated by a Creo TOOLKIT DLL by default.
To allow debugging on Windows without using the Creo Parametric exception handler, set the environment variable ALLOW_MS_DEBUG to true in the Control Panel.
Setting ALLOW_MS_DEBUG to true forces Creo Parametric executable not to execute the exception handler and thus the process will stop in the debugger on any exception. Alternatively, it is possible to set exception handling in the debugger to stop on the first occurrence of the exception, even for exceptions that are handled.
Debugging a Multiprocess Application
Debugging a Synchronous Spawn Mode Application
1. Start Creo Parametric with the application registered and started.
2. Use the debugger to attach to the application process, for example pt_inst_test.exe.
3. Set breakpoints in the callback functions that you wish to debug.
Debugging an Asynchronous Spawn Mode Application
1. Start the application from the debugger. Set a breakpoint to stop the application before the call to ProEngineerStart() or ProEngineerConnect().