Writing NSPrintForDebugger in GDB to print objects in C-Collection of common programming errors
When using GDB (using text interface, TTY, and SSH on Gentoo Linux) for debugging C code, I want to print the data in objects. When I try using print-object
, I get the message
evaluation of this expression requires the program to have a function “_NSPrintForDebugger”
I can’t find any documentation or examples (is it me, or is Linux documentation very short on examples?) of how to create such a function. I would like an example(s) of NSPrintForDebugger functions for gdb that I can model. Note that I am new to C, Linux, MPI, emacs, and gdb.
To make this a little more difficult, I can’t find the definition of all the objects I want to print.
If it helps make an example, some of the objects I’d like to print-object
are:
-
UserData
typedef struct { realtype dx, hdcoef, hacoef; int npes, my_pe MPI_Comm comm; realtype z[100]; } *UserData; UserData data;
-
N_Vector (part of SUNDIALS, may have varying definitions).
- void *cvode_mem (any pointer to void)
- realtype (floats of varying size, also part of SUNDIALS)
- MPI_Comm (which might be just an integer)
P.S. I have noticed that, for instance, p *data
displays a lot of information. But I want more.