Returning partly to an older model of parser input processing: the
parser::input_contents goes back to a plain string, which may be
modified gradually by $/@ expansion etc. While string_refs cannot be
made based on that, they don't need to be either, since the
input_contents is a temporary member variable and will be disposed of
when the parser dies.
So we switch back to the prior general logic of
lexer::input_{put,get,peek}, which worked OK. To populate token
content string_refs, we use a global stringtable (a *set<string>)
against which long-lived string_refs may be issued with a new intern()
call. The input file contents are amongst those strings interned.
(Many other repeated string uses in the translator could probably
benefit from intern/string_ref'ing, and there are optimization
opportunities within the stringtable implementation proper.)
(While en route, mass-dropped a bunch of unnecessary namespace
prefixes in some affected files. Sorry for the diff noise.)
parse::parse_probe_point(): store new token's content
in parse_porbe_point() the content for a new token is created by
appending to an existing token's content. the string for the new
token's content needs to be stored somewhere, so we'll store it in
the the probe_point, since we can't access the (private) stapfile.
store file contents as strings in systemtap_session
since we need input_contents and file_contents to last longer
than the lexer, store the input_contents in a vector in a
systemtap_session. change lexer->input_contents and
stapfile->file_contents to string* so they will point to part of
some string in session->input_contents. will need to change to
string_ref in another commit
parse.cxx: new append_to_content() and set_token_content() to hide
the logic of work of setting up a token's content.
staptree.h: a vector to contain all the mangled strings that tok->content
will point to
since tok->content are now boost::string_refs, some portions of the
code don't play well with the fact that string_refs can't be
automatically converted into a std::string, so we need to manually add
in a to_string() call to do the conversion.
Note: can't use .data() since the string_ref is proabably not null terminated.
session.*: store lex_cast() versions of the stap arguments passed
through the command line.
parse.cxx: if the scanner encounters [$|@]<NN> in a stap script, use
the pre-lex_cast() stap arguments instead of calling lex_cast() each
time the scanner encounters [$|@]<NN>.
parse.cxx: instead of keeping track of a seperate set of file_contents
(lexer->input_contents) in which [$|@]<NN> are replaced by script args,
we'll keep file_contents and input_contents identical to one another
and parse the scripts args strings when we encouter [$|@]<NN>
Felix Lu [Wed, 5 Aug 2015 17:55:53 +0000 (13:55 -0400)]
PR12151: Fix recursion problem, add stable synthetic var reading functions
elaborate.cxx - When checking for stable flag, does not follow
functioncall chains. All stable functions are now identified at beginning
of semantic_pass_opt_7.
tapsets.cxx - In non guru-mode, context variable reading functions
are cached. Moved optimization step 7 after duplicate functioncall
pass to remove duplicate synthetic functions first.
Felix Lu [Thu, 30 Jul 2015 20:09:05 +0000 (16:09 -0400)]
Add testcases for stable optimization
* testsuite/systemtap.base/stable* - Testing to make sure that
the result of optimized script matches nonoptimized.
Also checks that the embedded-c functions are called the correct
number of times.
Martin Cermak [Mon, 3 Aug 2015 13:24:24 +0000 (15:24 +0200)]
Update file mode for testsuite/buildok/stap_staticmarkers-detailed.stp
Missing the 'execute' perm on stap_staticmarkers-detailed.stp causes
`ERROR: tcl error sourcing ./systemtap.pass1-4/buildok.exp` during
make installcheck.
Martin Cermak [Fri, 31 Jul 2015 15:40:18 +0000 (17:40 +0200)]
Fix PR18711 by updating the netfilter code for new rhel-7.2 kernels.
* buildrun.cxx (compile_pass): Add new netfilter autoconf test.
* runtime/linux/autoconf-netfilter-313b.c: New autoconf test.
* tapset-netfilter.cxx: (emit_module_decls): Add support for new
netfilter code backported to kernel-3.10.0-284.el7.
Martin Cermak [Thu, 16 Jul 2015 14:33:31 +0000 (16:33 +0200)]
Update rename.c syscall test for 3.10.0-294.el7 kernels.
On ppc64le, 'renameat2' syscall is unimplemented as defined in the
arch/powerpc/include/asm/systbl.h file. This change also allows
'renameat2' syscall to succeed when renaming a directory to a file
in case RENAME_EXCHANGE is defined.
David Smith [Tue, 14 Jul 2015 21:19:11 +0000 (16:19 -0500)]
Update the [nd_]syscall.clone probe aliases for rawhide.
* tapset/linux/syscalls.stp: Add '_do_fork' as an alternate probe point
for syscall.fork. Kernel commit 3033f14ab78c32 renamed 'do_fork' to
'_do_fork'.
* tapset/linux/nd_syscalls.stp: Ditto.
Martin Cermak [Tue, 14 Jul 2015 06:05:50 +0000 (08:05 +0200)]
PR18630: New testcase for dwarfless parameters from a uprobe.
* tapset/s390/registers.stp: Remove constraint added by commit eefd579b blocking data acquistion from a uprobe. This is per
PR18649#c1 and subsequent IRC chat with dsmith, the author
of the constraint.
* testsuite/systemtap.base/uprobe_nd_params.exp: New testcase.
David Smith [Tue, 7 Jul 2015 19:01:27 +0000 (14:01 -0500)]
Fixed PR18634 by getting timer probes to compile on rawhide.
* runtime/linux/timer.c (_stp_hrtimer_init): If STAPCONF_HRTIMER_GET_RES
isn't defined, meaning hrtimer_get_res() doesn't exist, just use the
'hrtimer_resolution' variable.
* buildrun.cxx (compile_pass): Add an export test for hrtimer_get_res().
* translate.cxx (emit_common_header): Remove generated inclusion of
linux/hrtimer.h.
* runtime/linux/timer.h: Add inclusion of linux/hrtimer.h.
David Smith [Tue, 7 Jul 2015 15:41:43 +0000 (10:41 -0500)]
Fixed BZ1240682 by fixing a rawhide compile problem.
* translate.cxx (translate_pass): Move the inclusion of runtime.h up
before the declaration of the module refresh mutex, to avoid compilation
problems on rawhide.
Josh Stone [Mon, 6 Jul 2015 18:35:51 +0000 (11:35 -0700)]
PR18555: prefer linkage_name to match the symtab
DW_AT_name is usually only the same as the symbol table for C. C++
names are mangled, which may be given by DW_AT_linkage_name. So if we
want to compare a DWARF subprogram to the symbol table by name, we
should prefer the linkage name when it's available.
This mattered especially for ppc64le, where query_dwarf_func was trying
to apply the global/local symbol offset. When we took a DWARF C++
function and tried to find that name in the symbol table for its offset,
there was no match, so the function wouldn't be resolved at all.
Now that lookup uses the linkage name. If there's still no match, like
with a stripped symbol table, then it falls through to just use DWARF's
entrypc as usual.
This patch also maintains the raw "addr" and offset "entrypc" separately
for symbol table functions, so for instance update_symtab can still
compare the original address.
David Smith [Thu, 2 Jul 2015 19:18:52 +0000 (14:18 -0500)]
Simplify a few syscall probes and handle RHEL5 kernels a bit better.
* tapset/linux/nd_syscalls.stp (nd_syscall.truncate): Simplified with fix
to long_arg() properly returning negative values.
(nd_syscall.keyctl): Ditto.
* tapset/linux/nd_syscalls2.stp (nd_syscall.quotactl): Only skip calls if
we're on a kernel >= 2.623, when sys32_quotactl() was introduced.
(syscall.truncate): Simplified.
* tapset/linux/syscalls2.stp (syscall.quotactl): Only skip calls if we're
on a kernel >= 2.623, when sys32_quotactl() was introduced.
(syscall.truncate): Matches more closely with the nd_syscall version,
which fixed a problem on RHEL5.
* tapset/linux/x86_64/syscalls.stp (syscall.get_thread_area): Added
support for RHEL5 kernels.
(syscall.set_thread_area): Ditto.
* tapset/linux/x86_64/nd_syscalls.stp: Ditto.
* testsuite/systemtap.syscall/fallocate.c: Properly handle ppc calls.
* testsuite/systemtap.syscall/keyctl.c: Handle keyctl() being
non-implemented.
* testsuite/systemtap.syscall/readahead.c: Handle ppc problems and glibc <
2.8 problems.
* testsuite/systemtap.syscall/readdir.c: Handle readdir() being
non-implemented.
* testsuite/systemtap.syscall/rt_signal.c (main): Handle
rt_tgsigqueueinfo() being non-implemented.
* testsuite/systemtap.syscall/uselib.c: Make sure we're on kernel >=
2.6.22, since before that uselib() could call quiet_ni_syscall(), which
we can't probe since it is in assembly.
David Smith [Wed, 1 Jul 2015 17:27:21 +0000 (12:27 -0500)]
Fixed PR18597 by returning negative values correctly from long_arg().
* tapset/powerpc/registers.stp (_stp_arg2): New function that fixes the
problem with _stp_arg() where long_arg() doesn't handle negative values
correctly. Callers can also force a 64-bit returned value.
(longlong_arg): Force a 64-bit return value.
* tapset/s390/registers.stp: Ditto.
* tapset/x86_64/registers.stp: Ditto.
* tapset/linux/nd_syscalls2.stp: Simplified nd_syscall.sync_file_range.
* tapset/linux/nd_syscalls.stp: Simplified nd_syscall.io_submit.
* testsuite/systemtap.syscall/pread.c: Add more 64-bit values to test.
* testsuite/systemtap.syscall/pwrite.c: Ditto.
Mark Wielaard [Tue, 30 Jun 2015 22:34:32 +0000 (00:34 +0200)]
Various fixes for test failures caused by implicit warnings.
Add various function and variable declarations and/or includes for
failures caused by new gcc warnings -Wimplicit-function-declaration
or -Wimplicit-int.
Mark Wielaard [Tue, 30 Jun 2015 19:54:28 +0000 (21:54 +0200)]
unwind.c (compute_expr): Don't fallthrough after div/mod/shr.
When processing DW_OP_div, DW_OP_mod or DW_OP_shr compute_expr
would accidentially fallthrough to the next case statement causing
the DWARF value stack to contain wrong values.
David Smith [Tue, 30 Jun 2015 20:24:54 +0000 (15:24 -0500)]
Two small stat code fixes found by source analysis.
* runtime/stat-common.c (_stp_stat_print_histogram_buf): Fixed small
potential overflow problem by widening values.
* runtime/stat.c (_stp_stat_init): Fixed missing 'va_end' call in an error
situation.
Martin Cermak [Fri, 26 Jun 2015 08:22:37 +0000 (10:22 +0200)]
PR18571: tapset support bpf and seccomp syscalls
NEWS: Deprecate seccomp's 'uargs' in favor of 'uargs_uaddr'.
tapset/linux/aux_syscalls.stp: New _seccomp_op_str() and _bpf_cmd_str().
tapset/linux/nd_syscalls.stp: New probe nd_syscall.bpf.
tapset/linux/nd_syscalls2.stp: Update probe nd_syscall.seccomp.
tapset/linux/syscalls.stp: New probe syscall.bpf.
tapset/linux/syscalls2.stp: Update probe syscall.seccomp.
testsuite/buildok/aux_syscalls-embedded.stp: Test _seccomp_op_str(), _bpf_cmd_str().
testsuite/buildok/nd_syscalls-detailed.stp: Test probe nd_syscall.bpf.
testsuite/buildok/nd_syscalls2-detailed.stp: Update test for probe nd_syscall.seccomp.
testsuite/buildok/syscalls-detailed.stp: Test probe syscall.bpf.
testsuite/buildok/syscalls2-detailed.stp: Update test for probe syscall.seccomp.
testsuite/systemtap.syscall/bpf.c: New testcase.
testsuite/systemtap.syscall/seccomp.c: New testcase.
David Smith [Thu, 25 Jun 2015 14:46:39 +0000 (09:46 -0500)]
Fixed PR18577 by making 'stap -l **' faster.
* tapsets.cxx (suggest_marks): Don't generate the suggestion list if we're
in either of the listing modes (-l/-L) and the verbose level is less
than 2.
(suggest_plt_functions): Ditto.
(suggest_dwarf_functions): Ditto.
* elaborate.cxx (suggest_functors): Ditto.
* elaborate.h: Updated suggest_functors declaration.
* tapset/linux/rpc.stp: Make some optional probes more optional.
* tapset/linux/scsi.stp: Ditto.
* tapset/linux/signal.stp: Ditto.
* tapset/linux/syscalls2.stp: Ditto.
* tapset/linux/nd_syscalls2.stp: Ditto.
Martin Cermak [Tue, 23 Jun 2015 06:36:46 +0000 (08:36 +0200)]
PR18462: Allow library macro deprecation
Parts of the tapset code can get deprecated using conditionals as
described in the HACKING file. This patch extends this to library
macros, which can now get deprecated too. Patch includes example
macro deprecation and a testcase.
Mark Wielaard [Mon, 22 Jun 2015 14:57:59 +0000 (16:57 +0200)]
runtime/unwind.c: Also sanity check DWARF regno for DW_CFA_restore[_extended].
When processCFI wanted to restore a register state to its initial value it
wasn't checking whether the register was actually interesting (or existing).
DWARF_REG_MAP might return a marker (9999) that we don't know or don't care
about this register. This was checked in all the set_*_rule functions, but
not in the case we reset the rule of the register. Add this check also for
DW_CFA_restore[_extended].
David Smith [Fri, 19 Jun 2015 18:08:23 +0000 (13:08 -0500)]
Fixed PR18562 by updating listing_mode.exp for systems without uprobes.
* testsuite/systemtap.base/listing_mode.exp: For systems without uprobes,
such as ia64 and some s390x kernels, mark probes requiring uprobes as
untested.
Frank Ch. Eigler [Fri, 19 Jun 2015 14:04:33 +0000 (10:04 -0400)]
PR17737 cont'd: switch to out-of-line xsl parameter file
The "generate.toc" parameter is a PITA to pass on the xmlto command
line with --stringparam, because it's whitespace-laden and structured.
So instead we switch to the "xmlto -m FRAGMENT.xml" mechanism.
David Smith [Thu, 18 Jun 2015 17:46:43 +0000 (12:46 -0500)]
Fixed PR17831 by making kprobes_onthefly.exp more robust.
* testsuite/systemtap.onthefly/kprobes_onthefly.exp: Switch from probing
'vfs.read' and 'vfs.read.return' to probing the underlying kernel
function to avoid inlines, which confused the output.
David Smith [Wed, 17 Jun 2015 18:13:09 +0000 (13:13 -0500)]
Fixed PR18554 by upating the list.exp test case.
* testsuite/systemtap.base/list.exp: Look for several inlined kernel
functions instead of just one (since on any particular kernel there
might not be an inlined version of that function).
David Smith [Wed, 17 Jun 2015 16:35:44 +0000 (11:35 -0500)]
Fixed PR18551 by updating the migrate.stp example script.
* testsuite/systemtap.examples/process/migrate.stp: Now prefers using the
'sched_migrate_task' tracepoint since its arguments will always be
available. Updated to use more of the functions from task.stp.
David Smith [Mon, 15 Jun 2015 16:34:08 +0000 (11:34 -0500)]
Fixed PR18538 by updating the scsi tapset.
* tapset/linux/scsi.stp: Fix problems on rawhide by removing source file
names from probe aliases. These don't appear to be needed and they cause
problems if functions get moved around.
David Smith [Fri, 12 Jun 2015 20:38:34 +0000 (15:38 -0500)]
Fixed PR18526 by updating the socket tapset.
* tapset/linux/socket.stp: Add support for socket_write_iter() and
socket_read_iter(), the replacements for socket_aio_write() and
socket_aio_read. Update socket.sendmsg for newer kernels. Update
_get_sock_addr() for newer kernels.
* testsuite/buildok/socket-detailed.stp: Updated and add tests for new
probes.
David Smith [Fri, 12 Jun 2015 14:07:05 +0000 (09:07 -0500)]
Fixed PR18518 by updating the vfs and nfs tapsets.
* tapset/linux/vfs.stp: Fix the vfs.do_sync_read and vfs.do_sync_write
probe aliases on rawhide kernels where the underlying probe points no
longer exist.
* tapset/linux/nfs.stp: Update probes that use vfs.do_sync_read and
vfs.do_sync_write.