<?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>6626</bug_id>
          
          <creation_ts>2014-08-12 12:33:20 +0000</creation_ts>
          <short_desc>Add an example for debugging software with the corresponding -dbg package</short_desc>
          <delta_ts>2020-05-06 10:21:25 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>9</classification_id>
          <classification>Documentation</classification>
          <product>General Docs</product>
          <component>docs-general</component>
          <version>unspecified</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></status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Future</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Laszlo Papp">lpapp</reporter>
          <assigned_to name="Mark Morton">mark.morton</assigned_to>
          <cc>bluelightning</cc>
    
    <cc>jefro</cc>
    
    <cc>mark.morton</cc>
    
    <cc>mhalstead</cc>
    
    <cc>srifenbark</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>45093</commentid>
    <comment_count>0</comment_count>
    <who name="Laszlo Papp">lpapp</who>
    <bug_when>2014-08-12 12:33:20 +0000</bug_when>
    <thetext>I can speak from experience here. I have been an embedded developer for several years now and when I have had to debug software, I have been using a &quot;drop-in&quot; replacement as the debug binary instead of the release binary. That means, we built the release with -O2, and the debug with -g(gdb) -O0. I have been trying to get a bug fixed in my software since yesterday, but up to now, all I found was a broken binary due to my expectation. gdbserver said format/exec error for /usr/bin/.debug/foo.

It took me a day to figure out using objdump and reading on material in this area that Yocto seems to generate the debug binary as _additional_ content to the release binary as opposed to be a drop-in replacement. While, I can see the point of it - at least now-, this has not been obvious to me losing relatively long time on it.

Thereby, what I would advice is to extend the documentation here:

http://www.yoctoproject.org/docs/1.6.1/dev-manual/dev-manual.html#platdev-gdb-remotedebug-launch-gdbserver

With a concrete one-liner example how to use debug package (foo-dbg) with Yocto for debugging purposes, either when one uses gdbserver or gdb directly on the target. It is bonus point in my eyes to get 2 x one-liner examples for each of them.

Currently, I am yet to figure out what exactly to do to achieve this, so I may be able to provide concrete examples in a follow-up comment, but it is yet to be seen. If someone can suggest an example, that would be great.

Also, the aforementioned documentation section unfortunately misses mentioning anything about generated -dbg packages which are vital in this scenario in my opinion.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>45096</commentid>
    <comment_count>1</comment_count>
    <who name="Laszlo Papp">lpapp</who>
    <bug_when>2014-08-12 16:12:02 +0000</bug_when>
    <thetext>This is my commands that I ended up using, but I expect it to be pretty similar for any developers:

Target:

    gdbserver 192.168.0.32:2345 auth -c testuser &lt;password&gt; user

Host:

./tmp/sysroots/x86_64-linux/usr/bin/armv5te-foo-linux-gnueabi/cgdb -d ./tmp/sysroots/x86_64-linux/usr/bin/armv5te-foo-linux-gnueabi/arm-foo-linux-gnueabi-gdb
-s ./tmp/work/armv5te-foo-linux-gnueabi/foo/$myver/packages-split/foo-dbg/usr/bin/.debug/foo -e ./tmp/work/armv5te-foo-linux-gnueabi/foo/$myver/packages-split/foo/usr/bin/foo -ex &quot;tar rem 192.168.0.1:2345&quot;

The latter is quite ugly, but could be essentially made scriptable or alias, so it is not a big deal. The concept is however.

Here is my recap:

1) foo-dbg is additional info (symbol table and source code), not replacement.

2) Options (-s symbol-file and -e executable) have to be used on the host since the debug package is not installed there into the sysroot for obvious reasons.

3) gdbserver remains as is without changes. It can be run on the target binary which is stripped, but the optimization level has to be the same as the debug binary.

4) If both are installed on the target, then there is no need to use the aforementioned options, since they will be recognized in their default locations.

5) If one tries to run gdb or gdbserver on the debug binary, that will end up in format/exec error since it is just meant to be the symbol file. This is known and expected, although not quite obvious for a newcomer.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>45097</commentid>
    <comment_count>2</comment_count>
    <who name="Laszlo Papp">lpapp</who>
    <bug_when>2014-08-12 16:28:34 +0000</bug_when>
    <thetext>Assigning to security due to accidental content being entered. At least, it will be less visible for the world (hopefully).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46344</commentid>
    <comment_count>3</comment_count>
    <who name="Scott Rifenbark">srifenbark</who>
    <bug_when>2014-10-15 18:01:43 +0000</bug_when>
    <thetext>I spoke with Paul on this bug and there is more to it than I can get to for the upcoming 1.7 release.  I am bumping the target out to 1.8.  I am also setting the status to ACCEPTED.

Scott</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46996</commentid>
    <comment_count>4</comment_count>
    <who name="Scott Rifenbark">srifenbark</who>
    <bug_when>2014-11-13 17:54:24 +0000</bug_when>
    <thetext>Setting this to 1.8 M2.  I need some information from Paul Eggleton to proceed on this one. Adding self and Paul to CC list.  Set milestone to 1.8 M2.

Scott</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>47616</commentid>
    <comment_count>5</comment_count>
    <who name="Paul Eggleton">bluelightning</who>
    <bug_when>2014-12-18 15:38:16 +0000</bug_when>
    <thetext>I&apos;m just marking this as NEW rather than NEEDINFO; it&apos;s just another task I need to look into.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87157</commentid>
    <comment_count>6</comment_count>
    <who name="Mark Morton">mark.morton</who>
    <bug_when>2020-05-06 10:21:25 +0000</bug_when>
    <thetext>Marking as resolved as the Dev manual has a comprehensive section on remote debugging here: https://www.yoctoproject.org/docs/3.1/dev-manual/dev-manual.html#platdev-gdb-remotedebug 

If something is still missing, please create a new bug with specific information.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>