{"id":11586,"date":"2016-02-05T11:36:01","date_gmt":"2016-02-05T17:36:01","guid":{"rendered":"http:\/\/www.multitech.net\/developer\/?page_id=11586"},"modified":"2019-09-03T23:54:29","modified_gmt":"2019-09-04T04:54:29","slug":"debugging-a-cc-application","status":"publish","type":"page","link":"https:\/\/www.multitech.net\/developer\/software\/mlinux\/mlinux-software-development\/debugging-a-cc-application\/","title":{"rendered":"Debugging a C\/C++ Application"},"content":{"rendered":"<p>To debug any C\/C++ application on the device, first install <strong>gdbserver<\/strong> (after an Internet connection has been set up).<\/p>\n<p>To install <strong>gdbserver<\/strong>:<\/p>\n<ol>\n<li>Using a terminal emulator, open a terminal to the device (SSH, debug console or similar).<\/li>\n<li>At the command line, enter <strong>opkg update<\/strong><br \/>\n\u2022\u00a0After files are downloaded and extracted successfully, the system displays this message: Updated list of available packages in <strong>\/var\/lib\/opkg\/mlinux-mtcdt<\/strong><\/li>\n<li>Then enter <strong>opkg install gdbserver<\/strong><br \/>\n\u2022\u00a0After files are installed successfully, the system displays these messages:<br \/>\n<strong>Configuring libthread-db1.<\/strong><br \/>\n<strong>Configuring gdbserver.<\/strong><\/li>\n<\/ol>\n<p>Once <strong>gdbserver<\/strong> is installed,\u00a0you must copy your application to the\u00a0Conduit<sup>\u00ae<\/sup> and then run it under gdbserver using\u00a0 the <b>gdbserver-attach<\/b> command.\u00a0 To use <strong>gdbserver<\/strong> to run your program on the device:<\/p>\n<ol>\n<li>Log on to the target system and run the <strong>gdbserver<\/strong> program. Enter this command:\u00a0\u00a0\u00a0<strong> target&gt; gdbserver comm program [args &#8230;]<\/strong><br \/>\na.\u00a0<strong>comm:<\/strong> how to communicate with GDB<br \/>\nb.<strong>\u00a0program:<\/strong> the name of your program<br \/>\nc.\u00a0<strong>args:<\/strong> its arguments<\/li>\n<li>Attach your application to the<strong> gdbserver<\/strong> using <strong>arm-mlinux-linux-gnueabi-gdb<\/strong> on your development workstation (included with the\u00a0mLinux<sup>\u2122<\/sup> toolchain). To do this, enter the command:\u00a0<strong> (gdb) target remote &lt;target_ip&gt;:&lt;port&gt;\u00a0\u00a0 <\/strong><\/li>\n<li>Refer to this information for more details on how to use <strong>gdb<\/strong> and<strong> gdbserver<\/strong>:<br \/>\n<a href=\"https:\/\/sourceware.org\/gdb\/onlinedocs\/gdb\/gdbserver-man.html\">https:\/\/sourceware.org\/gdb\/onlinedocs\/gdb\/gdbserver-man.html<\/a><\/li>\n<\/ol>\n<p><a href=\"https:\/\/www.multitech.net\/developer\/wp-content\/uploads\/2016\/09\/How-gdb-and-gdbserver-works-to-help-debug-CC++-apps.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-14965\" alt=\"How-gdb-and-gdbserver-works-to-help-debug-CC++-apps\" src=\"https:\/\/www.multitech.net\/developer\/wp-content\/uploads\/2016\/09\/How-gdb-and-gdbserver-works-to-help-debug-CC++-apps.png\" width=\"572\" height=\"260\" srcset=\"https:\/\/www.multitech.net\/developer\/wp-content\/uploads\/2016\/09\/How-gdb-and-gdbserver-works-to-help-debug-CC++-apps.png 572w, https:\/\/www.multitech.net\/developer\/wp-content\/uploads\/2016\/09\/How-gdb-and-gdbserver-works-to-help-debug-CC++-apps-300x136.png 300w\" sizes=\"auto, (max-width: 572px) 100vw, 572px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>To debug any C\/C++ application on the device, first install gdbserver (after an Internet connection has been set up). To install gdbserver: Using a terminal emulator, open a terminal to the device (SSH, debug console or similar). At the command line, enter opkg update \u2022\u00a0After files are downloaded and extracted successfully, the system displays this [&hellip;]<\/p>\n","protected":false},"author":1478,"featured_media":0,"parent":9192,"menu_order":8,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"class_list":["post-11586","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.multitech.net\/developer\/wp-json\/wp\/v2\/pages\/11586","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.multitech.net\/developer\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.multitech.net\/developer\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.multitech.net\/developer\/wp-json\/wp\/v2\/users\/1478"}],"replies":[{"embeddable":true,"href":"https:\/\/www.multitech.net\/developer\/wp-json\/wp\/v2\/comments?post=11586"}],"version-history":[{"count":17,"href":"https:\/\/www.multitech.net\/developer\/wp-json\/wp\/v2\/pages\/11586\/revisions"}],"predecessor-version":[{"id":11597,"href":"https:\/\/www.multitech.net\/developer\/wp-json\/wp\/v2\/pages\/11586\/revisions\/11597"}],"up":[{"embeddable":true,"href":"https:\/\/www.multitech.net\/developer\/wp-json\/wp\/v2\/pages\/9192"}],"wp:attachment":[{"href":"https:\/\/www.multitech.net\/developer\/wp-json\/wp\/v2\/media?parent=11586"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}