mbox series

[v2,dwarves,0/2] Check DW_OP_[GNU_]entry_value for possible parameter matching

Message ID 20241114155822.898466-1-alan.maguire@oracle.com (mailing list archive)
Headers show
Series Check DW_OP_[GNU_]entry_value for possible parameter matching | expand

Message

Alan Maguire Nov. 14, 2024, 3:58 p.m. UTC
Currently, pahole relies on DWARF to find whether a particular func
has its parameter mismatched with standard or optimized away.
In both these cases, the func will not be put in BTF and this
will prevent fentry/fexit tracing for these functions.

The current parameter checking focuses on the first location/expression
to match intended parameter register. But in some cases, the first
location/expression does not have expected matching information,
but further location like DW_OP_[GNU_]entry_value can provide
information which matches the expected parameter register.

Patch 1 supports this; patch 2 adds locking around dwarf_getlocation*
as it is unsafe in a multithreaded environment.

Run ~4000 times without observing a segmentation fault (as compared
to without patch 2, where a segmentation fault is observed approximately
every 200 invokations).

Changes since v1:

- used Eduard's approach of using a __dwarf_getlocations()
  internal wrapper (Eduard, patch 1).
- renamed function to parameter__reg(); did not rename
  __dwarf_getlocations() since its functionality is based around
  retrieving DWARF location info rather than parameter register
  indices (Yonghong, patch 2)
- added locking around dwarf_getlocation*() usage in dwarf_loader
  to avoid segmentation faults reported by Eduard (Jiri, Arnaldo,
  patch 2)

Alan Maguire (1):
  dwarf_loader: use libdw__lock for dwarf_getlocation(s)

Eduard Zingerman (1):
  dwarf_loader: Check DW_OP_[GNU_]entry_value for possible parameter
    matching

 dwarf_loader.c | 121 +++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 96 insertions(+), 25 deletions(-)