This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

dwarf_getsrc_file Question


Hello,

 

I am using libdw for some ELF/DWARF file handling for a program that I am
working on.  I am still in the early stages of this project and I am by no
means an expert on the internal ELF/DWARF formats (thus the desire to use a
standard package that will abstract these details away).

 

In the process of working on this project, I used the attached ELF file
(Measure.axf).  When I tried to call dwarf_getsrc_file for any file and line
number, I was getting a return value of -1 with no error code set.  The
issue appears to be that in dwarf_getsrc_file, it calls dwarf_getsrclines
and if this returns an error, then dwarf_getsrc_file also returns an error.
However, (again, I'm not expert) it appears that the same file can have
multiple compile units, so dwarf_getsrc_file should iterate through the
various CUs to see if it can find the source lines for a file.

 

I believe that a very simple change to fix this problem is to change the
return -1 on line 92 of dwarf_getsrc_file.c to continue to the next CU.
Essentially, change:

 

  /* Get the line number information for this file.  */

  Dwarf_Lines *lines;

  size_t nlines;

  if (INTUSE(dwarf_getsrclines) (cudie, &lines, &nlines) != 0) {

    return -1;

  }

 

To

 

  /* Get the line number information for this file.  */

  Dwarf_Lines *lines;

  size_t nlines;

  if (INTUSE(dwarf_getsrclines) (cudie, &lines, &nlines) != 0) {

    off = noff;

    continue;

  } 

 

I'm working off of the 0.141 tag, so it is possible that the line numbers
may differ slightly in the trunk.

 

Can you please take a look at this change and whether it makes sense to
integrate into the project?  I can probably put together a simple test case
if needed, but I don't have a simple application to do this with at this
point.

 

Please let me know if there is any other information that I can provide to
help you understand the problem I'm seeing and the potential solution I've
proposed.

 

Thanks for your help!

--Mike

Hello,

 

I am using libdw for some ELF/DWARF file handling for a program that I am working on.  I am still in the early stages of this project and I am by no means an expert on the internal ELF/DWARF formats (thus the desire to use a standard package that will abstract these details away).

 

In the process of working on this project, I used the attached ELF file (Measure.axf).  When I tried to call dwarf_getsrc_file for any file and line number, I was getting a return value of -1 with no error code set.  The issue appears to be that in dwarf_getsrc_file, it calls dwarf_getsrclines and if this returns an error, then dwarf_getsrc_file also returns an error.  However, (again, I’m not expert) it appears that the same file can have multiple compile units, so dwarf_getsrc_file should iterate through the various CUs to see if it can find the source lines for a file.

 

I believe that a very simple change to fix this problem is to change the return -1 on line 92 of dwarf_getsrc_file.c to continue to the next CU.  Essentially, change:

 

  /* Get the line number information for this file.  */

  Dwarf_Lines *lines;

  size_t nlines;

  if (INTUSE(dwarf_getsrclines) (cudie, &lines, &nlines) != 0) {

    return -1;

  }

 

To

 

  /* Get the line number information for this file.  */

  Dwarf_Lines *lines;

  size_t nlines;

  if (INTUSE(dwarf_getsrclines) (cudie, &lines, &nlines) != 0) {

    off = noff;

    continue;

  }

 

I’m working off of the 0.141 tag, so it is possible that the line numbers may differ slightly in the trunk.

 

Can you please take a look at this change and whether it makes sense to integrate into the project?  I can probably put together a simple test case if needed, but I don’t have a simple application to do this with at this point.

 

Please let me know if there is any other information that I can provide to help you understand the problem I’m seeing and the potential solution I’ve proposed.

 

Thanks for your help!

--Mike

Attachment: Measure.zip
Description: Zip compressed data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]