This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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]

Re: [msp430-elf] Dwarf line numbers not being encoded properly?


Greetings,

Thank you for your reply. At the moment, I have a patch which was kindly
given to me by Simon Marchi which makes GDB utilize the readelf
algorithm to obtain line numbers from the binary. We were never sure
which tool was at fault (if gdb for not reading dwarf information
properly, binutils for not encoding it properly, or gcc for not
generating it properly), so I did not pursue the issue for a while.

With the new release of binutils, I decided to "reopen" the case, as the
distribution I am doing this for prefers using pristine sources from
upstream rather than applying patches to work around issues. Besides, if
there is something I am doing incorrectly or a bug in a tool, I would
rather have that fixed instead.

For reference, I have attached the patch that Simon Marchi provided. It
applies cleanly to the GDB sources but if the problem is elsewhere, I
would have it fixed correctly (hence the temporary workaround comment in
there). Again, thank you.

Cheers,
Orlando.

On 01/27/2016 03:08 PM, Kevin Buettner wrote:
> On Wed, 27 Jan 2016 13:35:29 -0500
> Orlando Arias <orlandoarias@gmail.com> wrote:
> 
>> I am not sure if this is the proper place to ask, but I have been
>> playing with the msp430-elf port of gcc/binutils/newlib/gdb and I have
>> been presenting an issue for a while now. Last September, I e-mailed the
>> GDB mailing list but the message went largely ignored. The bug report I
>> filed with GDB went ignored as well and remains open. To be honest, I am
>> not sure if the issue is with GDB, binutils or gcc, but GDB is unable to
>> read dwarf line numbers from binaries generated by binutils. When asking
>> about it in the GDB IRC channel, I was told it was because there was
>> some conflicting information on how these symbols were generated.
>> readelf is able to correctly identify the symbols because it uses a
>> different algorithm from GDB when reading them.
> 
> Hi Orlando,
> 
> This problem can be fixed in at least two different ways.  At the moment,
> I'm testing a change to gas.
> 
> The other approach is to make GDB read addresses associated with line
> numbers in a manner similar to that used by readelf.  I looked at doing
> this one time, but that complicated the code more than I found to be
> acceptable at the time.
> 
> I hope to post a patch for this problem later today.
> 
> Kevin
> 
diff -rupN gdb-7.10-pristine/gdb/dwarf2read.c gdb-7.10-modified/gdb/dwarf2read.c
--- gdb-7.10-pristine/gdb/dwarf2read.c	2015-08-28 17:22:07.000000000 -0400
+++ gdb-7.10-modified/gdb/dwarf2read.c	2015-10-02 10:16:58.959920909 -0400
@@ -17845,8 +17845,21 @@ dwarf_decode_lines_1 (struct line_header
 		  break;
 		case DW_LNE_set_address:
 		  {
-		    CORE_ADDR address
-		      = read_address (abfd, line_ptr, cu, &bytes_read);
+			/* temporary fix until
+			 * https://sourceware.org/bugzilla/show_bug.cgi?id=19033
+			 * is resolved.
+			 *
+			 * Contributed by:
+			 * Simon Marchi <simon.marchi@ericsson.com>
+			 * Wed, 30 Sep 2015 17:25:43 -0400
+			 */
+			unsigned char oplen = extended_end - line_ptr, old_address_size;
+			CORE_ADDR address;
+			old_address_size = cu->header.addr_size;
+			cu->header.addr_size = oplen;
+			address = read_address(abfd, line_ptr, cu, &bytes_read);
+			cu->header.addr_size = old_address_size;
+			/* end fix */
 
 		    line_ptr += bytes_read;
 		    check_line_address (cu, &state_machine, line_ptr,

Attachment: signature.asc
Description: OpenPGP digital signature


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