<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>13722</bug_id>
          
          <creation_ts>2019-12-22 22:28:28 +0000</creation_ts>
          <short_desc>Debugging With the GNU Project Debugger enhancements</short_desc>
          <delta_ts>2022-05-20 15:07:29 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>9</classification_id>
          <classification>Documentation</classification>
          <product>Development Manual</product>
          <component>development</component>
          <version>3.0.1</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard>NIR 04/15 - NEWCOMER</status_whiteboard>
          <keywords></keywords>
          <priority>Medium+</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>4.1 M1</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>anon2313</reporter>
          <assigned_to name="Sundeep KOKKONDA">sundeep.kokkonda</assigned_to>
          <cc>akuster</cc>
    
    <cc>john.kaldas.enpj</cc>
    
    <cc>michael.opdenacker</cc>
    
    <cc>pgowda.cve</cc>
    
    <cc>randy.macleod</cc>
    
    <cc>richard.purdie</cc>
    
    <cc>sundeep.kokkonda</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Yes (doc changes required)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>85956</commentid>
    <comment_count>0</comment_count>
    <who name="">anon2313</who>
    <bug_when>2019-12-22 22:28:28 +0000</bug_when>
    <thetext>I really appreciate that these steps are included in the documentation. I made some mistakes and other parts I didn&apos;t understand why it would be necessary and maybe could be clarified.

3.30.13. Debugging With the GNU Project Debugger (GDB) Remotely

I think the tip &quot;install debug (-dbg) packages for the applications you are going to debug.&quot; belongs to section &quot;3.30.14. Debugging with the GNU Project Debugger (GDB) on the Target&quot;.

1) Configure your build system to construct the companion debug filesystem:

Is this necessary if you build and use the SDK?  I think the SDK already includes debug files without setting these values.  IMAGE_GEN_DEBUGFS isn&apos;t in the reference guide so it&apos;s hard to know what it is supposed to do.

2) Configure the system to include gdbserver in the target filesystem:

Mention the following also includes the debugger
EXTRA_IMAGE_FEATURES_append = &quot; tools-debug&quot;

4) Set up the debugfs

Not necessary when using the SDK as it has sources in it? But when not using the SDK untaring the wrong file system like &quot;core-image-minimal-initramfs-genericx86-64-dbg.tar.bz2&quot; can happen.  I did this the first time through and it took awhile for me to understand the mistake I made. Maybe just a note to prevent new users from making the stupid mistake I made.

There is a typo in the documentation &quot;build-dir/tmp-glibc/deploy/images/machine/image.rootfs.tar.bz2&quot;. &quot;tmp-glibc&quot; should just be &quot;tmp&quot;.


5) Set up GDB

Modify the sentence to read &quot;Sourcing the environment file puts the SDK in your PATH environment variable and sets $GDB to the SDK&apos;s debugger&quot;.  gdb by itself is the host tool.

7) Debug a program:

&quot;set substitute-path /usr/src/debug debugfs/usr/src/debug&quot;.  I don&apos;t know what circumstances this works with but not with any application I tried debugging.  With a fresh Poky build all applications I tried debugging uses relative paths.  &quot;substitue-path&quot; doesn&apos;t work with files that start with relative paths (there doesn&apos;t seem to be a way for gdb to strip relative paths (https://stackoverflow.com/questions/37330688/how-can-i-set-a-gdb-source-mapping-for-a-relative-path).

For example debugging less:
(gdb) l
68	../less-551/main.c: No such file or directory.


But the &quot;dir&quot; command does work when adding the programs build directory as a base directory to use.  This seems to be primarily the case when something is built with autotools with a separate build directory.  The file path is relative from the build folder to the source folder.  

8) Deploying without a full image rebuild:

When using &quot;devtool modify recipe&quot; and &quot;devtool build recipe&quot; the &quot;-src&quot; package and folder is empty.  I guess this is due to using external sources.  Again for this to work with gdb I had to use the &quot;dir&quot; command so that the sources could be found.  Also maybe the SDK manual should point to these sections in &quot;Deploy the Build Output&quot; if you need to perform debugging.

The major problem I had was trying to find a front-end to gdb that worked.  I don&apos;t know what the problem is but the debugger keeps having issues with a failure.  When using VS Code or Eclipse with the debugger in Jethro worked fine but with Zeus I keep seeing the error and it kills the debug session:

warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code. 

I mention this because local.conf has &quot;eclipse-debug&quot; but I didn&apos;t understand from the documentation if it was still relevant as eclipse support was said to be removed.

I eventually found that gdbgui works without any problems with the debugger that is built with Yocto. I guess that gdb has a builtin interface called tui but it is disabled.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>85958</commentid>
    <comment_count>1</comment_count>
    <who name="">anon2313</who>
    <bug_when>2019-12-22 22:45:50 +0000</bug_when>
    <thetext>Also Maybe the tip to make a .gdbinit file should include that the commands can be in any file and use $GDB -ix file.init.  I used this instead because .gdbinit is run for every every use of gdb (Yocto related or not).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>85965</commentid>
    <comment_count>2</comment_count>
    <who name="">anon2313</who>
    <bug_when>2019-12-23 14:51:45 +0000</bug_when>
    <thetext>Maybe repeat the DEBUG_BUILD = &quot;1&quot; tip from the bottom of 7.30.14 in section 7.30.13.  I think it&apos;s kind of easy to miss.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>85995</commentid>
    <comment_count>3</comment_count>
    <who name="Armin Kuster">akuster</who>
    <bug_when>2020-01-09 15:41:22 +0000</bug_when>
    <thetext>Thanks for providing the details.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87524</commentid>
    <comment_count>4</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2020-06-19 10:49:24 +0000</bug_when>
    <thetext>I don&apos;t think this is done and M1 is over so bumping to M2.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>89271</commentid>
    <comment_count>5</comment_count>
    <who name="John Kaldas">john.kaldas.enpj</who>
    <bug_when>2021-02-16 15:46:25 +0000</bug_when>
    <thetext>I would like to work on this ticket.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>89272</commentid>
    <comment_count>6</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2021-02-16 15:59:31 +0000</bug_when>
    <thetext>Thanks for signing up John.

Are you on the docs list: https://lists.yoctoproject.org/g/docs
Have you cloned: http://git.yoctoproject.org/cgit/cgit.cgi/yocto-docs/
I haven&apos;t worked with the new sphinx docs but I hear that it&apos;s easier and likely even documented somewhere. Just ask if you need help and I&apos;ll find someone who is better informed on docs than I am! -- Randy</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>89409</commentid>
    <comment_count>7</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2021-02-25 17:12:56 +0000</bug_when>
    <thetext>Any news or problems John?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>89556</commentid>
    <comment_count>8</comment_count>
    <who name="John Kaldas">john.kaldas.enpj</who>
    <bug_when>2021-03-09 16:30:21 +0000</bug_when>
    <thetext>I had a couple of questions which were more related to the workflow and docs generation, I have had answers to it through the mail list.

I will keep the ticket updated with the progress.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91228</commentid>
    <comment_count>9</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2021-08-19 15:14:10 +0000</bug_when>
    <thetext>Any news John? Do you need help?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91968</commentid>
    <comment_count>10</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2021-11-11 16:05:38 +0000</bug_when>
    <thetext>Add Naveen who might have time to work on this in a month or so. 

John, Any news?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>92780</commentid>
    <comment_count>11</comment_count>
    <who name="Sundeep KOKKONDA">sundeep.kokkonda</who>
    <bug_when>2022-03-15 07:57:38 +0000</bug_when>
    <thetext>Hello,


I analyzed the suggested doc changes, a few changes can be considered in doc update and for a few I need some more details. See my analysis/comments below for each doc change requested (Each number corresponds to the item number used by the issue reporter in the initial bug ticket).

1) IMAGE_GEN_DEBUGFS is in the documentation. The doc says &apos;set IMAGE_GEN_DEBUGFS to “1”, which will generate a companion debug image containing unstripped binaries and associated debug sources alongside the image.&apos;

2) Doc will be updated as suggested.

4) The &apos;tmp&apos; directory is configurable in conf/local.conf with TMPDIR switch. Anyway, the doc will be updated with default directory name &apos;tmp&apos;.

5) Doc will be updated as suggested.

7) I followed the exact steps in document and I&apos;m able to establish the gdbserver connection for debugging.

Regarding the &apos;substitute-path&apos; usage refer the below page.
https://sourceware.org/gdb/onlinedocs/gdb/Source-Path.html#:~:text=set%20substitute%2Dpath%20is%20also,at%20the%20rewritten%20location%20instead.

Let me know what is the exact issue and what change is expected in doc?

8) Can you provide here more detailed steps of your issue. I presume you&apos;re facing an issue with debugging. Can you use below switches in local.conf and try to work with gdb? (These pkgs appends debugging related info into the generated image)

IMAGE_INSTALL:append = &quot; gcc g++ binutils libgcc libgcc-dev libstdc++ libstdc++-dev libstdc++-staticdev nfs-export-root libc-mtrace gdb gdbserver openssh openssl kexec-tools&quot;
EXTRA_IMAGE_FEATURES:append = &quot; dbg-pkgs debug-tweaks dev-pkgs eclipse-debug package-management src-pkgs tools-debug tools-sdk&quot;


Let me know your inputs for my analysis to finalize the doc changes.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>92882</commentid>
    <comment_count>12</comment_count>
    <who name="Sundeep KOKKONDA">sundeep.kokkonda</who>
    <bug_when>2022-03-28 09:41:12 +0000</bug_when>
    <thetext>Hi,

Can you update me on listed queries.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93115</commentid>
    <comment_count>13</comment_count>
    <who name="Sundeep KOKKONDA">sundeep.kokkonda</who>
    <bug_when>2022-04-18 05:29:16 +0000</bug_when>
    <thetext>Hello,

The docs corrections which can be corrected/updated are considered and below is the patch.
https://lists.yoctoproject.org/g/docs/message/2778</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93217</commentid>
    <comment_count>14</comment_count>
    <who name="Sundeep KOKKONDA">sundeep.kokkonda</who>
    <bug_when>2022-05-01 17:32:21 +0000</bug_when>
    <thetext>https://lists.yoctoproject.org/g/docs/message/2786
Changes are in &apos;master&apos; branch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93220</commentid>
    <comment_count>15</comment_count>
    <who name="Sundeep KOKKONDA">sundeep.kokkonda</who>
    <bug_when>2022-05-04 04:40:42 +0000</bug_when>
    <thetext>Commit ID - 7116c349b5074913df37aa3a7633226f42480f0d

bft1@bft1-OptiPlex-7060:~/skokkonda/docs/yocto-docs$ git branch -a --contains 7116c349b5074913df37aa3a7633226f42480f0d
* master</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93221</commentid>
    <comment_count>16</comment_count>
    <who name="Sundeep KOKKONDA">sundeep.kokkonda</who>
    <bug_when>2022-05-04 14:05:25 +0000</bug_when>
    <thetext>The patch not taken to master.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93249</commentid>
    <comment_count>17</comment_count>
    <who name="Sundeep KOKKONDA">sundeep.kokkonda</who>
    <bug_when>2022-05-11 05:59:12 +0000</bug_when>
    <thetext>Patch taken to master &amp; master-next branch. Below is the commit links.
https://git.yoctoproject.org/yocto-docs/commit/?id=48c96378fd5edd587025f3ca138bc5114e927f2f</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93291</commentid>
    <comment_count>18</comment_count>
    <who name="Michael Opdenacker">michael.opdenacker</who>
    <bug_when>2022-05-20 15:07:29 +0000</bug_when>
    <thetext>Changes merged in master:
https://git.yoctoproject.org/yocto-docs/commit/?h=master-next&amp;id=48c96378fd5edd587025f3ca138bc5114e927f2f</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>