Fix: flt.lttng-utils.debug-info: Error in src line reporting
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Thu, 28 Mar 2019 22:20:52 +0000 (18:20 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 3 May 2019 22:19:39 +0000 (18:19 -0400)
commit54bc9710689c3c853e75c574948e0a99ce3430f4
tree0c14c60ab92638fcda6a8836fd84217136d29223
parentc8f0ea4fd4aa4cc3d6a7c62f3ae2795268355f4a
Fix: flt.lttng-utils.debug-info: Error in src line reporting

Issue
=====
A `debug-info` component does not print the `src` field of a tracepoint
properly when tracepoint is within a for loop.

  #include "tp.h"
  int main(int argc, char *argv[])
  {
      tracepoint(my_app, empty);
      for(int i = 0; i < 1; i++) {
          tracepoint(my_app, empty);
      }
      return 0;
  }

The problem derives from the DWARF information generated by the
compiler. The compiler may place the DWARF content of the for loop in
`DW_TAG_lexical_block` which the current `debug-info` design doesn't
expect.

Here is a summarized version of DWARF tree containing the first
tracepoint in the code above:
  DW_TAG_subprogram
    DW_TAG_inlined_subroutine
      /* tracepoint callsite info */

Here is a summarized version of the DWARF tree containing the tracepoint
in the for loop:
  DW_TAG_subprogram
    DW_TAG_lexical_block
      DW_TAG_inlined_subroutine
       /* tracepoint callsite info */

The current implementation doesn't expect the presence of a
`DW_TAG_lexical_block` entry as child of the `DW_TAG_inlined_subroutine`
entry and won't look any further down that branch to find the source
information for the current tracepoint. This results in the component
not finding the line number for such callsite and thus leaving the `src`
field empty. Also, on some occasions, the `src` field would contain the
tracepoint definition location (e.g. "tp.h:12") rather then the actual
callsite of that tracepoint.

Solution
========
When iterating over the Debugging Information Entries, if the current
entry contains the address to resolve _but_ is not a of the type
`DW_TAG_inlined_subroutine` try to iterate over the children of that
entry.

Known drawbacks
===============
None.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
plugins/lttng-utils/bin-info.c
plugins/lttng-utils/dwarf.c
plugins/lttng-utils/dwarf.h
This page took 0.025079 seconds and 4 git commands to generate.