Bug 22000 - Unable to read $path in chown_common on CentOS 7 due to lack of DW_OP_GNU_parameter_ref support
Summary: Unable to read $path in chown_common on CentOS 7 due to lack of DW_OP_GNU_par...
Status: RESOLVED DUPLICATE of bug 16596
Alias: None
Product: systemtap
Classification: Unclassified
Component: translator (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-23 22:09 UTC by Bartosz Kwitniewski
Modified: 2017-09-12 17:10 UTC (History)
1 user (show)

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


Attachments
stap-report script output (11.56 KB, text/plain)
2017-08-23 22:09 UTC, Bartosz Kwitniewski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bartosz Kwitniewski 2017-08-23 22:09:11 UTC
Created attachment 10363 [details]
stap-report script output

SystemTap returns error listed below for the following code on CentOS 7 (booth default stap package and git version):
----------
probe kernel.function("chown_common") {
    printf("%x\n", $path->dentry)
}
----------

[Default CentOS 7 package] Systemtap translator/driver (version 3.0/0.166, rpm 3.0-7.el7):
----------
semantic error: while processing probe kernel.function("chown_common@fs/open.c:556") from: kernel.function("chown_common")

semantic error: unrecognized operation in DWARF expression [0] at 0 (0xfa: 65037, 0): identifier '$path' at ./test.stp:4:20
        dieoffset: 0x1af00cd from /usr/lib/debug/lib/modules/3.10.0-514.26.2.el7.x86_64/vmlinux
        function: chown_common at fs/open.c:556
        source:     printf("%x\n", $path->dentry)
                                   ^

Pass 2: analysis failed.  [man error::pass2]
----------


[GIT version] Systemtap translator/driver (version 3.2/0.166, commit release-3.1-234-g51987fd93657):
----------
semantic error: while processing probe kernel.function("chown_common@fs/open.c:556") from: kernel.function("chown_common")

semantic error: unhandled DW_OP operation in DWARF expression [0] at 0 (250: 65037, 0): identifier '$path' at ./test.stp:4:20
        source:     printf("%x\n", $path->dentry)
                                   ^

Pass 2: analysis failed.  [man error::pass2]
----------

Problematic DWARF atom is 0xfa (DW_OP_GNU_parameter_ref).

The same probe works fine for chmod_common, which uses the same $path struct.

Everything was installed from base CentOS 7 repository, with exception for additional stap version in /opt/systemtap, which was pulled from git.
Comment 1 Bartosz Kwitniewski 2017-08-25 01:50:28 UTC
I have tried to use Jprobes directly for chown_common and I have received kernel paging fault while accessing path->dentry->d_inode, which is used by chown_common itself.

Jprobes, just like systemtap works fine with chmod_common. I have noticed this in /proc/kallsyms:
ffffffff811fc3a0 t chmod_common
ffffffff811fc1f0 t chown_common.isra.15

It seems chown_common is optimized by gcc -fipa-sra flag and it is causing problems in Jprobes directly, so it might not be related to systemtap itself.
Comment 2 Bartosz Kwitniewski 2017-08-26 03:20:19 UTC
On my CentOS 7 system I have recompiled distribution kernel with -fno-ipa-sra and probes attach successfully to chown_common.

On the following system:
---
Linux archlinux 4.12.8-2-ARCH #1 SMP PREEMPT Sat Aug 26 02:19:38 UTC 2017 x86_64 GNU/Linux
gcc version 7.1.1 20170630 (GCC) 
Systemtap translator/driver (version 3.1/0.169, non-git sources)
---

SystemTap gives the following error for may_linkat, which is ipa-sra optimized:
---
semantic error: while processing probe kernel.function("may_linkat@fs/namei.c:999") from: kernel.function("may_linkat")

semantic error: failed to retrieve location attribute for 'link' [man error::dwarf]: identifier '$link' at ./test.stp:4:20
        dieoffset: 0x27bcbf4 from /lib/modules/4.12.8-2-ARCH/build/vmlinux
        function: may_linkat at fs/namei.c:999
        source:     printf("%x\n", $link->dentry)
---

but it works fine with proc_getdriver (also ipa-sra optimized).
Comment 3 David Smith 2017-09-12 17:10:10 UTC
Unfortunately we still don't have DW_OP_GNU_* support. We've just got to find the time to implement it.

*** This bug has been marked as a duplicate of bug 16596 ***