Bug 847510

Summary: semantic error: dwarf_getlocation_addr failed, invalid DWARF: identifier... (DW_OP_GNU_parameter_ref)
Product: [Fedora] Fedora Reporter: Mark Wielaard <mjw>
Component: systemtapAssignee: Frank Ch. Eigler <fche>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: dsmith, fche, jakub, jan.kratochvil, law, lberk, mjw, scox, tsmetana, wcohen
Target Milestone: ---Keywords: FutureFeature
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: 847497 Environment:
Last Closed: 2019-08-23 20:43:46 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 847497    
Bug Blocks:    

Description Mark Wielaard 2012-08-12 12:39:38 UTC
After the GCC bug is resolved we should support DW_OP_GNU_parameter_ref in elfutils and systemtap. DW_OP_GNU_parameter_ref was only added recently to
elfutils (after 0.154 the latest release) as part of the DwarfExtensions overview: https://fedorahosted.org/elfutils/wiki/DwarfExtensions

+++ This bug was initially created as a clone of Bug #847497 +++

Description of problem:
Systemtap poorly parses dwarf and says "$SUMMARY".

Version-Release number of selected component (if applicable):
$ rpm -q bash bash-debuginfo systemtap
bash-4.2.37-2.fc17.x86_64
bash-debuginfo-4.2.37-2.fc17.x86_64
systemtap-1.8-4.fc17.x86_64


How reproducible:
100%

Steps to Reproduce:
1. stap -e 'probe process("bash").function("execute_builtin"){print("%p\n", $words)}'
2.
3.
  
Actual results:
$ stap -e 'probe process("bash").function("execute_builtin"){print("%p\n", $words)}'
semantic error: dwarf_getlocation_addr failed, invalid DWARF: identifier '$words' at <input>:1:65
        source: probe process("bash").function("execute_builtin"){print("%p\n", $words)}
                                                                                ^


Expected results:
semantic error: not accessible at this address (?)
The best would be if systemtap says the variable is optimized out, like GDB.

Additional info:

--- Additional comment from jan.kratochvil on 2012-08-12 06:50:50 EDT ---

GNU C 4.7.0 20120507 (Red Hat 4.7.0-5) -m64 -mtune=generic -march=x86-64 -g -O2 -fexceptions -fstack-protector --param ssp-buffer-size=4

GCC used DW_OP_GNU_parameter_ref at the callee but DW_OP_reg4 (rsi) at the caller.  Caller is inlined function.

(gdb) bt
#0  execute_builtin (..., words=<optimized out>) at execute_cmd.c:4047
#1  0x0000000000431873 in execute_builtin_or_function (words=0x6fb260)
                       at execute_cmd.c:4546
#2  execute_simple_command (...) at execute_cmd.c:3956
(gdb) set debug entry-values 1
(gdb) p words
Cannot find matching parameter at DW_TAG_GNU_call_site 0x431873 at execute_simple_command
$2 = <optimized out>

 <1><1c2c4>: Abbrev Number: 68 (DW_TAG_subprogram)
    <1c2c5>   DW_AT_abstract_origin: <0x1b17a>
         <1><1b17a>: Abbrev Number: 38 (DW_TAG_subprogram)
            <1b17b>   DW_AT_name        : execute_builtin
 <2><1c2fa>: Abbrev Number: 73 (DW_TAG_formal_parameter)
    <1c2fb>   DW_AT_abstract_origin: <0x1b197>
         <2><1b197>: Abbrev Number: 36 (DW_TAG_formal_parameter)
            <1b198>   DW_AT_name        : words
    <1c2ff>   DW_AT_location    : 6 byte block: fa d 18 0 0 9f
                         (DW_OP_GNU_parameter_ref: <0x1b197>; DW_OP_stack_value)
 <4><1eb7f>: Abbrev Number: 55 (DW_TAG_GNU_call_site)
    <1eb80>   DW_AT_low_pc      : 0x431873
 <5><1eb96>: Abbrev Number: 56 (DW_TAG_GNU_call_site_parameter)
    <1eb97>   DW_AT_location    : 1 byte block: 54      (DW_OP_reg4 (rsi))
    <1eb99>   DW_AT_GNU_call_site_value: 2 byte block: 73 0
                                                       (DW_OP_breg3 (rbx): 0)
        = it is really 'words'

Comment 1 Fedora End Of Life 2013-04-03 14:53:44 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 19 development cycle.
Changing version to '19'.

(As we did not run this process for some time, it could affect also pre-Fedora 19 development
cycle bugs. We are very sorry. It will help us with cleanup during Fedora 19 End Of Life. Thank you.)

More information and reason for this action is here:
https://fedoraproject.org/wiki/BugZappers/HouseKeeping/Fedora19

Comment 2 Fedora End Of Life 2015-01-09 17:18:53 UTC
This message is a notice that Fedora 19 is now at end of life. Fedora 
has stopped maintaining and issuing updates for Fedora 19. It is 
Fedora's policy to close all bug reports from releases that are no 
longer maintained. Approximately 4 (four) weeks from now this bug will
be closed as EOL if it remains open with a Fedora 'version' of '19'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 19 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 3 Mark Wielaard 2015-01-10 13:08:40 UTC
The elfutils libdw part has been made easier in elfutils 0.157 with the addition of:

/* Return the DIE associated with an operation such as
   DW_OP_GNU_implicit_pointer, DW_OP_GNU_parameter_ref, DW_OP_GNU_convert,
   DW_OP_GNU_reinterpret, DW_OP_GNU_const_type, DW_OP_GNU_regval_type or
   DW_OP_GNU_deref_type.  The OP pointer must point into an expression that
   dwarf_getlocation or dwarf_getlocation_addr has returned given the same
   ATTR.  The RESULT is a DIE that expresses a type or value needed by the
   given OP.  */
extern int dwarf_getlocation_die (Dwarf_Attribute *attr,
                                 const Dwarf_Op *op,
                                 Dwarf_Die *result)
  __nonnull_attribute__ (2, 3);

Comment 4 Frank Ch. Eigler 2019-08-23 20:43:46 UTC
release 4.1 included this support