Jeff
Jeff

Reputation: 757

Writing NSPrintForDebugger in GDB to print objects in C

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 <objectname>, 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:

  1. UserData

    typedef struct { realtype dx, hdcoef, hacoef; int npes, my_pe MPI_Comm comm; realtype z[100]; } *UserData; UserData data;

  2. N_Vector (part of SUNDIALS, may have varying definitions).

  3. void *cvode_mem (any pointer to void)
  4. realtype (floats of varying size, also part of SUNDIALS)
  5. 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.

Upvotes: 1

Views: 778

Answers (1)

user149341
user149341

Reputation:

The NSPrintForDebugger function that the GDB print-object command is calling is part of the Objective-C runtime. Since you aren't using Objective-C, ignore it.

Upvotes: 2

Related Questions