Bug 616 - readelf doesn't add "cu_offset" for printing DW_OP_call4 operand
Summary: readelf doesn't add "cu_offset" for printing DW_OP_call4 operand
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks: 615
  Show dependency treegraph
 
Reported: 2004-12-22 18:55 UTC by H.J. Lu
Modified: 2005-01-04 10:27 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Proposed patch to pass the cu_offset to decode_location_expression (2.38 KB, patch)
2004-12-23 12:49 UTC, Nick Clifton
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2004-12-22 18:55:43 UTC
We have this for call4 (and other DW_OP_calls)

 case DW_OP_call4:
          printf ("DW_OP_call4: <%lx>", (long) byte_get (data, 4));
          data += 4;
          break;

It should really print byte_get(data,4)+cu_offset.. as done for DW_FORM_ref4
 
 case DW_FORM_ref4:
    case DW_FORM_data4:
      uvalue = byte_get (data, 4);
      data += 4;
      break;
...
    case DW_FORM_ref1:
    case DW_FORM_ref2:
    case DW_FORM_ref4:
    case DW_FORM_ref_udata:
      printf (" <%lx>", uvalue + cu_offset);
      break;
Comment 1 Nick Clifton 2004-12-23 12:49:39 UTC
Created attachment 322 [details]
Proposed patch to pass the cu_offset to decode_location_expression
Comment 2 Nick Clifton 2004-12-23 12:50:35 UTC
Hi H.J.

  Attached is a patch that should do this.  What do you think ?

Cheers
  Nick

binutils/ChangeLog
2004-12-23  Nick Clifton  <nickc@redhat.com>

	PR binutils/616
	* readelf.c (debug_info): Add 'cu_offset' field.
	(get+pointer_size_of_comp_unit): Rename to
	'get_pointer_size_and_offset_of_comp_unit'.  Add code to return
	the offset of the comp_unit if requested.
	(get_debug_info): Record comp_unit offsets as well.
	(display_debug_lines): Call get_pointer_size_of_comp_unit.
	(decode_location_expression): Add an extra parameter - the offset
	of the current comp-unit.  Use this when decoding the DW_OP_call2
	and DW_OP_call4 operators.
	(display_debug_loc): Call get_pointer_size_of_comp_unit, pass the
	comp_unit offset on the decode_location_expression.
	(read_and_display_attr_value): Pass the	comp_unit offset on the
	decode_location_expression.
	(display_debug_frames): Pass 0 as the comp_unit offset to
	decode_location_expression.
Comment 3 H.J. Lu 2004-12-25 23:34:44 UTC
It looks OK to me. Should we also update DW_OP_call_ref to make it similar to
DW_FORM_ref_addr?
Comment 4 Nick Clifton 2005-01-04 10:27:30 UTC
Yes - but that is not really the subject of this bug report though.  Feel free
to submit a patch to do it - it should be relatively straightforward I think.