How can I use gdb, dbx or other UNIX source level debuggers to debug simulations?

Categories:
Solution Number:
S20818
Last Modified:
2014-03-30
Issue

How can I use gdb, dbx or other UNIX source level debuggers to debug simulations?

Solution

On UNIX platforms:0. In order to view model source code in debugger, compile all model code with -g option for comp_flags_devel OPNET preference.

  1. Run the development simulation kernel with ODB turned on.
  2. Once simulation stops at the initial ODB prompt, from a separate unix shell, figure out the process id of the op_runsim_dev (or op_runsim_dev64 if running a 64-bit kernel) process:
    % ps -ef | grep op_runsim_dev
  3. Run gdb or other symbolic debugger of your choice.
  4. Attach symbolic debugger to a running simulation.  Use attach <process_id_obtained_in_step_2> for both GDB and DBX
  5. At this point, source debugger controls the simulation.  You can set breakpoints, examine variable, source code and do other operation.
  6. In order to pass control to ODB, let source level debugger continue execution with cont command.
  7. Now ODB controls the simulation execution and you can use ODB commands to move on.
  8. If you had set breakpoints in a source debugger, control will go back to source debugger if that is hit. Otherwise, simulation control remains with ODB.
  9. If you want to defer setting breakpoints in a source debugger (e.g., after a certain event number), navigate using ODB to go to the event of interest. Then, in order to pass control to the source debugger, hit <Control>+<c> in a source debugger shell window;
  10. Special note for process model code debugging:  In order to check the values of model state variables use the following convention:
    (gdb) print op_sv_ptr-><state_var_name>
Environment

Compiling/Linking,DES Kernel->Other

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