24.03.2013 Views

ModelSim SE User's Manual - Electrical and Computer Engineering

ModelSim SE User's Manual - Electrical and Computer Engineering

ModelSim SE User's Manual - Electrical and Computer Engineering

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Debugging PLI/VPI/DPI application code<br />

HP-UX specific warnings<br />

PLI/VPI tracing UM-601<br />

<strong>ModelSim</strong> Versions 5.7 <strong>and</strong> later offer the optional C Debug feature. This tool allows you<br />

to interactively debug SystemC/C/C++ source code with the open-source gdb debugger.<br />

See Chapter 16 - C Debug for details. If you don’t have access to C Debug, continue<br />

reading for instructions on how to attach to an external C debugger.<br />

In order to debug your PLI/VPI/DPI application code in a debugger, you must first:<br />

1 Compile the application code with debugging information (using the -g option) <strong>and</strong><br />

without optimizations (for example, don’t use the -O option).<br />

2 Load vsim into a debugger.<br />

Even though vsim is stripped, most debuggers will still execute it. You can invoke the<br />

debugger directly on vsimk, the simulation kernal where your application code is loaded<br />

(for example, "ddd `which vsimk`"), or you can attach the debugger to an already<br />

running vsim process. In the second case, you must attach to the PID for vsimk, <strong>and</strong> you<br />

must specify the full path to the vsimk executable (for example, "gdb $MTI_HOME/<br />

sunos5/vsimk 1234").<br />

On Solaris, AIX, <strong>and</strong> Linux systems you can use either gdb or ddd. On HP-UX systems<br />

you can use the wdb debugger from HP. You will need version 1.2 or later.<br />

3 Set an entry point using breakpoint.<br />

Since initially the debugger recognizes only vsim's PLI/VPI/DPI function symbols,<br />

when invoking the debugger directly on vsim you need to place a breakpoint in the first<br />

PLI/VPI/DPI function that is called by your application code. An easy way to set an entry<br />

point is to put a call to acc_product_version() as the first executable statement in your<br />

application code. Then, after vsim has been loaded into the debugger, set a breakpoint in<br />

this function. Once you have set the breakpoint, run vsim with the usual arguments.<br />

When the breakpoint is reached, the shared library containing your application code has<br />

been loaded.<br />

4 In some debuggers, you must use the share comm<strong>and</strong> to load the application's symbols.<br />

At this point all of the application's symbols should be visible. You can now set breakpoints<br />

in <strong>and</strong> single step through your application code.<br />

On HP-UX you might see some warning messages that vsim does not have debugging<br />

information available. This is normal. If you are using Exceed to access an HP machine<br />

from Windows NT, it is recommended that you run vsim in comm<strong>and</strong> line or batch mode<br />

because your NT machine may hang if you run vsim in GUI mode. Click on the "go"<br />

button, or use F5 or the go comm<strong>and</strong> to execute vsim in wdb.<br />

You might also see a warning about not finding "__dld_flags" in the object file. This<br />

warning can be ignored. You should see a list of libraries loaded into the debugger. It<br />

should include the library for your PLI/VPI/DPI application. Alternatively, you can use<br />

share to load only a single library.<br />

<strong>ModelSim</strong> <strong>SE</strong> User’s <strong>Manual</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!