Bug 18389 - gcc5 code folding breaks tracepoint queries
Summary: gcc5 code folding breaks tracepoint queries
Status: RESOLVED FIXED
Alias: None
Product: systemtap
Classification: Unclassified
Component: translator (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Josh Stone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-08 19:49 UTC by Josh Stone
Modified: 2015-05-08 20:18 UTC (History)
0 users

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Josh Stone 2015-05-08 19:49:25 UTC
GCC5 now has Identical Code Folding, -fipa-icf, and it's enabled by default at -O2 or higher.

SystemTap's tracepoint queries use stub functions like:
  void stapprobe_##name(proto) {}

When multiple tracepoint's proto is the same in a given object, GCC5 is merging them, so we only find one of them in debuginfo.

For instance, sys_enter takes (struct pt_regs *regs, long id), and sys_exit takes (struct pt_regs *regs, long reg).  These are identical as far as gcc is concerned, so they're merged.  So stap -l 'kernel.trace("sys_*")' only shows me sys_exit.

The "winner" may not be deterministic, but for now it appears to be the last one declared.  Another example is that there are 8 "ext4_*" tracepoints which take just (struct inode *inode), and only ext4_load_inode shows up in stap.

Adding -fno-ipa-icf will disable this, if we can do that in a compatible way.

Another possibility is to force uniqueness, perhaps something like:
  int stapprobe_##name(proto) {
    static int i = 0;
    return ++i;
  }

(The tracepoint query objects are never linked or executed, so the function body is irrelevant as long as they all show up in debuginfo.)
Comment 1 Josh Stone 2015-05-08 20:18:50 UTC
commit 8bb62408827f88d3694cb519eb5bb48ed6216092