{"id":5331,"date":"2014-03-30T20:48:47","date_gmt":"2014-03-30T20:48:47","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/writing-nsprintfordebugger-in-gdb-to-print-objects-in-c-collection-of-common-programming-errors\/"},"modified":"2014-03-30T20:48:47","modified_gmt":"2014-03-30T20:48:47","slug":"writing-nsprintfordebugger-in-gdb-to-print-objects-in-c-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/writing-nsprintfordebugger-in-gdb-to-print-objects-in-c-collection-of-common-programming-errors\/","title":{"rendered":"Writing NSPrintForDebugger in GDB to print objects in C-Collection of common programming errors"},"content":{"rendered":"<p>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 <code>print-object<\/code> , I get the message<\/p>\n<blockquote>\n<p>evaluation of this expression requires the program to have a function &#8220;_NSPrintForDebugger&#8221;<\/p>\n<\/blockquote>\n<p>I can&#8217;t find any documentation or examples (is it me, or is Linux documentation very short on examples?) of how to create such a function. <em>I would like an example(s) of NSPrintForDebugger functions for gdb that I can model.<\/em> Note that I am new to C, Linux, MPI, emacs, and gdb.<\/p>\n<p>To make this a little more difficult, I can&#8217;t find the definition of all the objects I want to print.<\/p>\n<p>If it helps make an example, some of the objects I&#8217;d like to <code>print-object<\/code> are:<\/p>\n<ol>\n<li>\n<p>UserData<\/p>\n<p>typedef struct { realtype dx, hdcoef, hacoef; int npes, my_pe MPI_Comm comm; realtype z[100]; } *UserData; UserData data;<\/p>\n<\/li>\n<li>\n<p>N_Vector (part of SUNDIALS, may have varying definitions).<\/p>\n<\/li>\n<li>void *cvode_mem (any pointer to void)<\/li>\n<li>realtype (floats of varying size, also part of SUNDIALS)<\/li>\n<li>MPI_Comm (which might be just an integer)<\/li>\n<\/ol>\n<p>P.S. I have noticed that, for instance, <code>p *data<\/code> displays a lot of information. But I want more.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 &#8220;_NSPrintForDebugger&#8221; I can&#8217;t find any documentation or examples (is it [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5331","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5331","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5331"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5331\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5331"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5331"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5331"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}