[DPI]: How to debug a hung C function, invoked with DPI, from SystemVerilog

Hi All,

I have a SystemVerilog-based test-bench, which interfaces with C functions, using a DPI, and invokes a C function to return a value from C to SV.

However, all things being fine, the code hangs at the end of the C function, before returning to the calling thread (in SV).
There is no other sub-routine called at the end of the main C function, and hence, it is difficult to the debug the cause of the hang.

Literature on the internet, particularly on C forums, suggest using a gdb debugger to debug hung C code, which is targeted mainly at standalone executable C models. I am not aware of how a gdb debugger can be incorporated in my SV-to-C DPI test-bench.

Can anyone suggest a way to facilitate C debugging in DPI, particularly hung C code, apart from the routine “printf” statements? As mentioned earlier, my C function executes up to the end, which is a “printf” statement, but fails to return to the calling thread.

Thanks and Regards,
AP

In reply to kautilya87:

Some simulators provide methods to debug C code using GDB while running simulations. I recommend reviewing your tool documentation and contact your vendor support team for additional assistance.