Bug 23391 - support {,foo,bar} alternation in wildcards
Summary: support {,foo,bar} alternation in wildcards
Status: RESOLVED FIXED
Alias: None
Product: systemtap
Classification: Unclassified
Component: translator (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Unassigned
URL:
Keywords:
Depends on:
Blocks: 23160
  Show dependency treegraph
 
Reported: 2018-07-09 18:16 UTC by Frank Ch. Eigler
Modified: 2018-10-18 17:23 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 Frank Ch. Eigler 2018-07-09 18:16:11 UTC
The systemtap script language supports wildcards in a variety of settings:
- process probe file names
- module names
- function names
- file names
... and many others.  See calls to glob() and fnmatch() in the source tree.

In most or all of these cases, the {,a,b} csh-style alternation syntax would come in handy.  In particular, but #23160 needs a way of intercepting "__$arch_sys_$syscall" functions, where $arch is the alternation of "ia32" and "x64" (on x86-64), but excludes "do" (which is an arch-sensitive lower level handler we do NOT want to probe).

So what we'd like, in the end, is this to work:

@define arch_syscall_prefix "{ia32,x64}"  # arch-specific macro

probe kprobe.function("__" @arch_syscall_prefix "_sys_read") { .... }  # generic

To do this, in contexts where glob(3) is used, we simply need to add the GLOB_BRACE flag bit.  In contexts where fnmatch(3) is used, it's not so simple, because this uses a different syntax in FNM_EXTMATCH mode.  So we need a csh-to-ksh transformation function that takes

    fo*o{,bar,ba{do,doo}}ba[xyz]r

and maps them to

    fo*o@(|bar|ba@(do|doo))ba[xyz]r

strings, just before passing them to fnmatch(... FNM_EXTMATCH).  These can be
done probably throughout the code base, maybe subject to --compatible=4,
maybe not.
Comment 1 Frank Ch. Eigler 2018-10-18 17:23:04 UTC
done earlier as part of syscall 4.17 rework