How can I debug my static simulations (built using op_mksim) using the Microsoft Visual C++ debugger?

Categories:
Solution Number:
S20609
Last Modified:
2013-10-08
Issue

How can I debug my static simulations (built using op_mksim) using the Microsoft Visual C++ debugger?

Solution

The following describes how to use MSVC++ to debug static simulations built using op_mksim. It is often less error prone to debug dynamic simulations such as those launched from the OPNET GUI. For instructions on using MSVC++ to debug dynamic simulations, read tS20983 'How do I use Microsoft Visual C++ debugger to attach to a running simulation?'

The following describes the environment settings and the procedure for using Microsoft Visual C++ Developer Studio debugger for OPNET simulations on Windows NT and Windows 2000. Note that there are two different sections: One for MSVC++ 4.0 and one for MSVC++ 5.0 and 6.0. Follow the instructions that correspond to your version of MSVC++.
 

A: Microsoft Visual C++ version 5.0 and 6.0

Section I: Prerequisite for using Visual C++ Debugger
The process model needs to be compiled with debugging information. In order to do this for OPNET models, please edit the environment database file (HOMEop_adminenv_db<rel>) to include the following attributes:

comp_flags_devel: "/Zi /Od"
bind_static_flags_devel: "/Zi /Od"

Note for versions earlier than 10.0, use:

comp_flags: "/Zi /Od"
bind_static_flags: "/Zi /Od"

For OPNET 10.0 and higher:
(Note that the "O" in "/Od" is a capital "O" as in OPNET.)

To attach the debugger to a simulation run from the OPNET graphical user interface you should also add:bind_shobj_flags: "/DEBUG /DEBUGTYPE:BOTH"

Create a static simulation by executing the following:

Prompt> op_mksim -net_name <network model name> -c

This will produce a executable (*.sim) file which will be used for debugging.

Section II: Using Microsoft Visual C++ Environment:

  1. Execute the following for running Microsoft Developer Studio on the following versions of Windows/NT:
    - Windows/NT 3.51
    - Double-click on the Program Manager icon.
    - Double click on Microsoft Visual C++ 5.0 icon.
    - Double click on Microsoft Developer Studio.
    - Windows/NT 4.0 - From the Start menu, select Programs, then Microsoft Visual C++ and then Microsoft Developer Studio.
     
  2. Execute the following for creating workspace:
    - Select the New... item from the File menu. This will give you a new dialog box.
    - Select the Projects tab. The 'New Project Workspace' page will appear.
    - Select Win32 Console Application from the list of possible applications.
    - Specify <project name> in the Name field for the Project workspace.
    - Set the Location: field to the directory which contains the .sim file (This field has a browse button to make it easier). (Note: If you set the location prior to selecting a project name, VC++ 5.0 will append the name of the project to the path.)
    - Select OK.
     
  3. Set the active configuration to be Debug
    The Build Toolbar should be visible. If not, then right-click in the empty area of the screen. Select the Build option. In this toolbar, the 'Active Configuration' field (second from the left) should be Win32 Debug. If not, select that option.
     
  4. Execute the following for setting the environment:
    - Use Project|Settings... menu item to bring up the Project Settings dialog box.
    - Select the Debug tab.
    - Set the 'Executable for debug session:' field to <DRIVE>:<full path><your project name>.i0.sim (or whatever is the simulation executable name)
    - Set the 'Program arguments:' field (for duration, ef files, etc.)
     
  5. Setting Breakpoints
    - Open a pr.c or ex.c file using the tool button or File|Open.
    - Set breakpoints by highlighting a line of code and selecting the Insert/Remove Breakpoint button (the one that looks like a hand).
     
  6. Running the Simulation
    - Run the simulation to the breakpoint by selecting the Go button (the one that looks like a file with a down-arrow next to it).
    - This may give you a dialog box asking if you want to build one or more files which do not exist. Click No.

After this point, the control is transferred transferred to the Microsoft Visual C++ debugger. Refer to the Microsoft Visual C++ manuals for any further problems.

 

B: Microsoft Visual C++ version 4.0

Section I: Prerequisite for using Visual C++ Debugger:
The process model needs to be compiled with debugging information. In order to do this for OPNET models, please edit the environment database file (HOMEop_adminenv_db<release>) to include the following attributes:

comp_flags_devel: "/Zi /Od"
bind_static_flags_devel: "/Zi /Od"

Note for versions earlier than 10.0, use:

comp_flags: "/Zi /Od"
bind_static_flags: "/Zi /Od"

(Note that the "O" in "/Od" is a capital "O" as in OPNET )

To attach the debugger to a simulation run from the OPNET graphical user interface (which is not covered in this FAQ) you should also add:bind_shobj_flags: "/DEBUG /DEBUGTYPE:BOTH"

Create a static simulation by executing the following:

Prompt> op_mksim -net_name <network model name> -c

This will produce a executable (*.sim) file which will be used for debugging.

Section II: Using Microsoft Visual C++ Environment:

  1. Execute the following for running Microsoft Developer Studio on the following versions of Windows/NT:
    - Windows/NT 3.51
    - Double-click on the Program Manager icon.
    - Double-click on Microsoft Visual C++ 4.0 icon.
    - Double click on Microsoft Developer Studio.
    - Windows/NT 4.0 - From the Start menu, select Programs, then Microsoft Visual C++ and then Microsoft Developer Studio.

    This may display a dialog box if Visual C++ Books on-line are not found. Click Cancel.
     
  2. Execute the following for creating workspace:
    - Select the New... item from the File menu. This will give you a New dialog box.
    - Select Project Workspace from the list of options for file formats. Click OK. The New Project Workspace dialog box will display.
    - Select Console Application from Type list.
    - Specify <project name> in the Name field for the Project workspace.
    - Click OK.
     
  3. Execute the following for setting the environment:
    - Select Settings... item from the Build menu. The Project Setting window will display.
    - Select Debug tab.
    - Specify the full path for the executable file in the 'Executable for Debug Session' field.
    - Specify any flags which you want to pass in the simulation in the 'Program Arguments' field (such as duration, ef files, etc). -
    Click OK.
     
  4. Execute the following for running the simulation:
    - Set one or more breakpoints by selecting Breakpoints... from the Edit menu.
    - Select Debug->Go from the Build menu. This will give you a dialog box asking if you want to build one or more files which do not exist. Click No.

After this point, the control is transferred to the Microsoft Visual C++ debugger. Refer to the Microsoft Visual C++ manuals for any further problems.

Environment

Compiling/Linking

Attachments
NOTICE: Riverbed® product names have changed. Please refer to the Product List for a complete list of product names.
Can't find an answer? Create a case