{"id":901,"date":"2023-08-09T13:55:55","date_gmt":"2023-08-09T11:55:55","guid":{"rendered":"https:\/\/codevision.net.pl\/?p=901"},"modified":"2023-08-10T07:49:04","modified_gmt":"2023-08-10T05:49:04","slug":"gdb-can-be-your-friend","status":"publish","type":"post","link":"https:\/\/codevision.net.pl\/index.php\/2023\/08\/09\/gdb-can-be-your-friend\/","title":{"rendered":"GDB can be your friend"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"901\" class=\"elementor elementor-901\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-2ee98723 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"2ee98723\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-247cc716\" data-id=\"247cc716\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-440faf8d elementor-widget elementor-widget-text-editor\" data-id=\"440faf8d\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><\/p>\n<p>Maintenance and bug fixing is a usual part of every project. We, developers, would like to code all the time, but unfortunately it is not possible in commercial projects.<\/p>\n<p><\/p>\n<p>Based on my own experience, the most common way of analysing the bugs is checking (or adding) the logs to find out the root cause of the issue. Such an approach often works, but there are cases where logs are not giving any useful hint and the only way to proceed is trying to reproduce the issue and debugging the code. Another common case in large software projects is getting the core dump generated by software component in target environment, which should be properly analysed.<\/p>\n<p><\/p>\n<p>In such cases tools like gdb (<em>GNU debugger<\/em>) or lldb (debugger for <em>LLVM<\/em>) can be your friends! If you have any IDE integrated with debugger, then you can use it quite easily. If you do not like IDEs or you are limited to console, then knowing how to use gdb or lldb may be beneficial. You should see my genuine joy once in the past, when I realized that gdb is available in DUT when investigating a nasty bug!<\/p>\n<p><\/p>\n<p><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-f927321 elementor-widget elementor-widget-image\" data-id=\"f927321\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t<figure class=\"wp-caption\">\n\t\t\t\t\t\t\t\t\t\t<img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"731\" src=\"https:\/\/codevision.net.pl\/wp-content\/uploads\/2023\/08\/bug_fixing-1024x731.jpg\" class=\"attachment-large size-large wp-image-1060\" alt=\"\" srcset=\"https:\/\/codevision.net.pl\/wp-content\/uploads\/2023\/08\/bug_fixing-1024x731.jpg 1024w, https:\/\/codevision.net.pl\/wp-content\/uploads\/2023\/08\/bug_fixing-300x214.jpg 300w, https:\/\/codevision.net.pl\/wp-content\/uploads\/2023\/08\/bug_fixing-768x549.jpg 768w, https:\/\/codevision.net.pl\/wp-content\/uploads\/2023\/08\/bug_fixing-1536x1097.jpg 1536w, https:\/\/codevision.net.pl\/wp-content\/uploads\/2023\/08\/bug_fixing-2048x1463.jpg 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/>\t\t\t\t\t\t\t\t\t\t\t<figcaption class=\"widget-image-caption wp-caption-text\"><a href=\"https:\/\/pl.freepik.com\/darmowe-wektory\/ilustracja-koncepcja-naprawiania-bledow_9558584.htm#query=bugfixing&amp;position=9&amp;from_view=search&amp;track=ais\">Obraz autorstwa storyset<\/a> na Freepik<\/figcaption>\n\t\t\t\t\t\t\t\t\t\t<\/figure>\n\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-8d7ec26 elementor-widget elementor-widget-text-editor\" data-id=\"8d7ec26\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Some time ago I did some simple C++ code examples with instructions on how to use basic gdb commands in Linux environment with gcc. Maybe you&#8217;ll find it useful for starting adventure with gdb or just recall some commands:<\/p>\n<p><!-- \/wp:paragraph --><!-- wp:paragraph --><\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/pstanisz\/dev_tutorials\/tree\/main\/debugging\/gdb_basics\">gdb_basics<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/pstanisz\/dev_tutorials\/tree\/main\/debugging\/gdb_coredumps\">gdb_coredumps<\/a><\/li>\n<\/ul>\n<p>I encourage to get familiar with <a href=\"https:\/\/lldb.llvm.org\/man\/lldb.html\">lldb<\/a> or <a href=\"https:\/\/ftp.gnu.org\/old-gnu\/Manuals\/gdb\/html_chapter\/gdb_toc.html\">gdb<\/a>, you can never know when it might save your day.<\/p>\n<p>Finally, a curiosity that a colleague from the project once shared: have you ever tried the <em><a href=\"https:\/\/ftp.gnu.org\/old-gnu\/Manuals\/gdb\/html_chapter\/gdb_19.html\">TUI mode<\/a><\/em> in gdb (i.e.: <em>wh<\/em> command or <em>Ctrl + x<\/em>, <em>Ctrl + a<\/em>)?<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Maintenance and bug fixing is a usual part of every project. We, developers, would like to code all the time, but unfortunately it is not possible in commercial projects. Based on my own experience, the most common way of analysing the bugs is checking (or adding) the logs to find out the root cause of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"zakra_sidebar_layout":"customizer","zakra_remove_content_margin":false,"zakra_sidebar":"customizer","zakra_transparent_header":"customizer","zakra_logo":0,"zakra_main_header_style":"default","zakra_menu_item_color":"","zakra_menu_item_hover_color":"","zakra_menu_item_active_color":"","zakra_menu_active_style":"","zakra_page_header":true,"_eb_attr":"","om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[17,16],"tags":[8,7],"class_list":["post-901","post","type-post","status-publish","format-standard","hentry","category-c","category-development","tag-development","tag-software"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/codevision.net.pl\/index.php\/wp-json\/wp\/v2\/posts\/901","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codevision.net.pl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codevision.net.pl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codevision.net.pl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codevision.net.pl\/index.php\/wp-json\/wp\/v2\/comments?post=901"}],"version-history":[{"count":47,"href":"https:\/\/codevision.net.pl\/index.php\/wp-json\/wp\/v2\/posts\/901\/revisions"}],"predecessor-version":[{"id":1076,"href":"https:\/\/codevision.net.pl\/index.php\/wp-json\/wp\/v2\/posts\/901\/revisions\/1076"}],"wp:attachment":[{"href":"https:\/\/codevision.net.pl\/index.php\/wp-json\/wp\/v2\/media?parent=901"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codevision.net.pl\/index.php\/wp-json\/wp\/v2\/categories?post=901"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codevision.net.pl\/index.php\/wp-json\/wp\/v2\/tags?post=901"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}