translate.cxx may model duplicate probe handlers by changing multiple
*_derived_probe ->name's to the same string, which upsets
tapset-netfilter.cxx code generation. Use an index for the contexts
where required.
* tapset-netfilter.cxx (netfilter_derived_probe ctor): Assign unique
nf_filter index.
(emit_module_decls, emit_module_init, emit_module_exit): Use when
appropriate.
Serguei Makarov [Wed, 23 May 2012 15:22:26 +0000 (11:22 -0400)]
Added section describing netfilter probes to stapprobes.3stap.
Note that the link to tapset::netfilter (3stap) is currently broken.
That man page is waiting on a fix for PR14146. If that bug gets delayed
indefinitely, it may be necessary to delete the reference for the time
being, and refer people to the Tapset Reference document instead.
Serguei Makarov [Tue, 22 May 2012 18:20:21 +0000 (14:20 -0400)]
Initial version of improved tapset for netfilters.
This tapset exposes the ability to track IPv4 network packets using the
netfilter hooks mechanism. Support for IPv6 is still very patchy, and
support for other protocols (ARP, bridge) is basically nonexistent.
Mark Wielaard [Mon, 21 May 2012 10:57:41 +0000 (12:57 +0200)]
Add testcase for PR14107 Bad user unwinding from kernel fatal signal handler.
This is really a kernel bug, see bug report, when the CFI for the assembly
code is missing we cannot properly recover the register state for the user
process and might give a bad/missing user backtrace.
Chris Meek [Fri, 18 May 2012 18:54:34 +0000 (14:54 -0400)]
PR13667: Fixed guru mode hook-not-defined bug
Before, when in guru mode, it would pass the hook/priority
strings across without checking/converting them to numbers. This
caused a bug where perfectly legal strings (such as NF_IP_PRE_ROUTING)
would be unrecognized in the generated code since their definitions
are not available in kernel space.
Now, it checks/converts all the strings to numbers whether in guru
mode or not, but only complains about mismatches if not in guru mode.
If in guru mode, it will still pass the initial string across if it
doesn't match anything else.
Chris Meek [Wed, 16 May 2012 20:52:35 +0000 (16:52 -0400)]
PR13667: Range checking for hooks and priorities
- Added more strict range checking for hook names
- Added support for arp and bridge netfilter hooks
- Added range checking of priority strings for ipv4
and ipv6 hooks, numerical checking for all
Mark Wielaard [Mon, 14 May 2012 10:39:10 +0000 (12:39 +0200)]
plt.exp: Don't count unreliable plt invocations.
Depending on gcc version and glibc used plt calls to malloc, free and
__cxa_finalize differ too much (or are just optimized away completely)
to rely on them in the test. Just take them out.
David Smith [Thu, 10 May 2012 20:04:17 +0000 (15:04 -0500)]
Update bz6503.exp testcase.
* testsuite/systemtap.base/bz6503.exp: Make the test work by non-root
users. Also add fat/vfat modules as suggested in BZ820487.
* testsuite/systemtap.base/bz6503.stp: Add fat/vfat modules as
alternatives as suggested in BZ820487.
David Smith [Tue, 8 May 2012 21:07:08 +0000 (16:07 -0500)]
Give good error messages for inodes uprobes registration errors.
* translate.cxx (c_unparser::emit_module_init): Only print an error if
'probe_point' isn't NULL.
* tapsets.cxx (uprobe_derived_probe_group::emit_module_inode_init): Let
stapiu_init() handle reporting errors by setting 'probe_point' to NULL.
* runtime/uprobes-inode.c (stapiu_get): Print errors when needed.
(stapiu_reg): Ditto.
Nitin A Kamble [Tue, 8 May 2012 18:13:49 +0000 (14:13 -0400)]
configury: automake 1.12 as deprecated automatic de-ANSI-fication support
Fix this issue with automake 1.12:
| configure.ac:23: error: automatic de-ANSI-fication support has been removed
[fche:] Note that the systemtap git repository and source releases include
autoconf- and automake-generated files, so this is only an issue for those
who have an unusual reason to regenerate them.
Signed-Off-by: Nitin A Kamble <nitin.a.kamble@intel.com>
Mark Wielaard [Tue, 8 May 2012 17:59:07 +0000 (19:59 +0200)]
PR14079 - caller() pass-4 error if no uretprobes in script
caller() is odd in that it tries to do both kernel and user caller.
There is no ucaller(). Move it into its own tapset and include the
right uprobes related structures.
* runtime/uprobes-inc.h: New include file to be included in ...
* runtime/stack.c: here and ...
* tapset/context-caller.stp: here. New tapset, with just the caller context
function, removed from ...
* tapset/context-unwind.stp: here.
* doc/SystemTap_Tapset_Reference/tapsets.tmpl: Also include context-caller.stp.
David Smith [Mon, 7 May 2012 21:40:38 +0000 (16:40 -0500)]
Improve the case-scope testcase output handling.
* testsuite/systemtap.base/cast-scope.stp: Print the probe strings in a
defined order (since the process.function and process.mark probes can
end up at the same address).
Mark Wielaard [Mon, 7 May 2012 08:20:21 +0000 (10:20 +0200)]
Cleanups and fixes for DWARF unwinder.
Add explict comments and set_*_rule functions for different states.
Do data alignment in processCFI, not afterwards in unwind_frame.
Remove unnecessary UNW_DEFAULT_RA. Make unwind_item state union
explicit about (unsigned) reg versus (signed) offset. Same for
unwind_reg_state cfa.
We now use tapset-mark.cxx style script/probe locals for incoming and
outgoing parameters. These are written/read during the probe prologue
function, and specially marked to prevent optimization/elision.
respond to pending_interrupts during sub-make sequence
* buildrun.cxx (run_make_cmd): If we already received a ^C as per
pending_interrupts, but some naive caller has tried to run yet
another inferior make, abort without even trying.
Mark Wielaard [Thu, 3 May 2012 19:49:11 +0000 (21:49 +0200)]
PR14057 - ERROR: Your privilege credentials (stapsys) are insufficient...
Initialize user_credentials to pr_unknown in init_staprun and set them
to pr_all when getuid() == 0 in assert_stap_module_permissions or
assert_uprobes_module_permissions.
David Smith [Thu, 3 May 2012 19:20:34 +0000 (14:20 -0500)]
Improved task_finder2 mmap tracking and better task_work cleanup.
* runtime/task_finder2.c (__stp_tf_alloc_task_work): New function.
(__stp_tf_free_task_work): Ditto.
(__stp_tf_cancel_task_work): Ditto.
(__stp_tf_quiesce_worker): Renamed from __stp_task_worker(). Uses
__stp_tf_free_task_work() to free the task_work structure.
(__stp_utrace_task_finder_target_quiesce): Uses
__stp_tf_alloc_task_work() to allocate a task_work structure.
(__stp_tf_mmap_worker): New task_work worker function.
(__stp_utrace_task_finder_target_syscall_exit): If we're in an atomic
context, use task_work_add() to call __stp_tf_mmap_worker().
(stap_stop_task_finder): Call __stp_tf_cancel_task_work() to cancel all
outstanding task work requests.
Mark Wielaard [Wed, 2 May 2012 19:13:30 +0000 (21:13 +0200)]
Fix PR13992 cont. Do iterate_over_modules, just not over libraries.
The original fix for PR13992 (commit 0ce08aa) failed to iterate of any
modules when no executable path was found, which made the exelib.exp
testcase fail. Refixed by iterating of modules, just not over libraries.
David Smith [Wed, 2 May 2012 17:51:13 +0000 (12:51 -0500)]
Removed EXPERIMENTAL_KPROBE_SDT support.
* tapsets.cxx (dwarf_derived_probe_group): Removed 'has_semaphores' member
variable.
(dwarf_derived_probe_group::enroll): Throw an error if we have a
semaphore.
(dwarf_derived_probe_group::emit_module_decls): No longer emit semaphore
support in struct stap_dwarf_probe or include kprobes-common.c.
(dwarf_derived_probe_group::emit_module_init): No longer initialize
semaphore info in struct stap_dwarf_probe.
(dwarf_derived_probe_group::emit_module_exit): No longer decrement
semaphores on module exit.
(sdt_query::have_kprobe): Remove kprobe2_type support.
(sdt_query::handle_probe_entry): Ditto.
(sdt_query::iterate_over_probe_entries): Ditto.
(sdt_query::convert_location): Ditto.
* sdt_types.h: Remove KPROBE2_TYPE define and kprobe2_type enum value.
* runtime/kprobes-common.c: Deleted.
* runtime/kprobes-common.h: Removed deleted function declarations.
* scripts/probe_perf/bench.sh: Remove EXPERIMENTAL_KPROBE_SDT test.
* testsuite/sys/sdt.h: Removed EXPERIMENTAL_KPROBE_SDT support.
* testsuite/systemtap.base/sdt.exp: Ditto.
* testsuite/systemtap.base/sdt_misc.exp: Ditto.
David Smith [Fri, 27 Apr 2012 20:43:16 +0000 (15:43 -0500)]
Use new task_work kernel feature to truly stop tasks.
* buildrun.cxx (compile_pass): Add STAPCONF_TASK_WORK_ADD_EXPORTED autoconf.
* runtime/autoconf-utrace-via-ftrace.c (__autoconf_func): Makes sure
<linux/task_work.h> is present and works.
* runtime/autoconf-utrace-via-tracepoints.c (__autoconf_func): Ditto.
* runtime/runtime.h: Added export kludge variables for task_work_add() and
task_work_cancel().
* runtime/stp_utrace.c (utrace_init): If the task_work_* functions aren't
exported, use kallsyms_lookup_name() to find them.
(utrace_cleanup): Cancel work function if necessary.
(utrace_task_alloc): Initialize task work structure.
(utrace_free): Cancel work function if necessary.
(utrace_do_stop): Use task_work_add() functionality to replace
set_notify_resume().
(utrace_stop): Ditto.
(utrace_control): Ditto.
(finish_report): Ditto.
(utrace_resume): Updated to work as task worker function.
* runtime/task_finder2.c (__stp_task_worker): New function.
(__stp_utrace_task_finder_target_quiesce): If we can't sleep, use
task_work_add() to truly stop the task.
* runtime/uprobes-inode.c (stapiu_change_plus): Check build-ids.
David Smith [Tue, 24 Apr 2012 16:04:35 +0000 (11:04 -0500)]
Updated and added syscall testsuite debug scripts.
* testsuite/systemtap.syscall/test-debug.tcl: Updated regexp that looks
for specially formatted comments in the test executable source.
* testsuite/systemtap.syscall/test-debug-cmd.tcl: New script, similar to
test-debug.tcl, but displays the output on the command line (instead of
in its own window).
* testsuite/systemtap.syscall/test-debug-cmd-nd.tcl: New script, similar to
test-debug-cmd.tcl, but used the nd_sycall tapset.
staprun is compiled single-threaded, but recent improvements to
util.cxx made it implicitly pthreads-dependent. Conditionalize
pthread_* calls with #ifndef SINGLE_THREADED throughout.
Josh Stone [Fri, 20 Apr 2012 00:11:14 +0000 (17:11 -0700)]
PR13999: Let "%#c" add escapes for nonprintables
The special '#' flag previously didn't do anything for characters. Now
it signals that non-printable characters should be escaped in the output
string, either using C shortcuts or octal values.
* runtime/vsprintf.c (_stp_vsprint_char_size, _stp_vsprint_char): New
functions to size and fill the buffer, accounting for escape chars.
(_stp_vsnprintf): Use the new char functions.
* translate.cxx (c_unparser::emit_compiled_printfs): Ditto.
* testsuite/systemtap.printf/char2.*: Test %#c
* NEWS, stap.1: Document it.
Josh Stone [Thu, 19 Apr 2012 21:11:00 +0000 (14:11 -0700)]
PR13998: pretty-print bit fields numerically
When a struct member has bit attributes, we should always pretty-print
it as a number, even if the underlying type is a character. Since these
attributes only show up in DWARF on the member, not the type die, we
need to treat it as a special case from the struct member iteration.
* tapsets.cxx (dwarf_pretty_print::recurse_bitfield): Print the incoming
type numerically, regardless of whether it's a char.
(dwarf_pretty_print::recurse_struct_members): If a member has a
bit_offset attribute, use recurse_bitfield instead of normal recurse.
* testsuite/systemtap.printf/pretty-bits.*: Test how bitfields are
pretty-printed, both for ints and chars underneath.
PR13992: let stap tolerate -d /foo/bad/path --ldd argument
* translate.cxx (add_unwindsym_ldd): Skip unresolvable path that
results in skeleton dwflpp. We'll get a warning later.
* testsuite/transok/eleven.stp: New test case.
Dave Brolley [Tue, 17 Apr 2012 19:16:47 +0000 (15:16 -0400)]
BZ 813323: stapusr-only users no longer able to run unsigned modules in /lib/modules/`uname -r`/systemtap
- Elevate the user's privilege level to stapdev when the module is loaded from
/lib/modules/`uname -r`/systemtap.
- Suppress error messages about failure to verify the module's signature
when a signature is not required.
Josh Stone [Thu, 12 Apr 2012 19:59:50 +0000 (12:59 -0700)]
Synchronize class/struct declarations
We are not very consistent about choosing struct vs class types, and in
some cases we have a mismatch between declaration and definition of a
given type. Gcc doesn't care, but clang -Wall complains:
CXX stap-main.o
In file included from ../main.cxx:12:
../staptree.h:489:1: error: struct 'vardecl' was previously declared
as a class [-Werror,-Wmismatched-tags]
struct vardecl: public symboldecl
^~~~~~
class
../staptree.h:218:7: note: previous use is here
class vardecl;
^
In all cases, I left the definition alone, and adjusted the declaration
to match, so it should be semantically unchanged.
Josh Stone [Thu, 12 Apr 2012 19:51:24 +0000 (12:51 -0700)]
sdt_query: initialize probe_type/loc as unknown.
The fields, probe_type and probe_loc, are meaningless to start, and are
later set as the queried module is examined. Commit 74fe61bc tried to
make sure that all POD types in this class are initialized, but these
two were essentially self-assigned. Gcc misses this uninitialized use,
but clang caught it:
CXX stap-tapsets.o
../tapsets.cxx:6058:38: error: field is uninitialized when used here [-Werror,-Wuninitialized]
base_query(dw, params), probe_type(probe_type), probe_loc(probe_loc), base_probe(base_probe),
^
../tapsets.cxx:6058:61: error: field is uninitialized when used here [-Werror,-Wuninitialized]
base_query(dw, params), probe_type(probe_type), probe_loc(probe_loc), base_probe(base_probe),
^
Values for "unknown" are now added to these enum types to initialize
with, and dealt with where needed.
Josh Stone [Thu, 12 Apr 2012 19:35:25 +0000 (12:35 -0700)]
dwflpp: Mark loc2c_error as noreturn
Clang complains thusly:
../dwflpp.cxx:2281:15: error: no matching function for call to
'c_translate_constant'
*tail = c_translate_constant (pool, &loc2c_error, this,
^~~~~~~~~~~~~~~~~~~~
In file included from ../dwflpp.cxx:54:
../loc2c.h:46:18: note: candidate function not viable: no known
conversion from 'void (*)(void *, const char *, ...)' to
'void (*)(void *, const char *, ...) __attribute__((noreturn))'
for 2nd argument
struct location *c_translate_constant (struct obstack *,
^
The declaration for loc2c_error just needs the matching attribute.
Josh Stone [Thu, 12 Apr 2012 19:26:41 +0000 (12:26 -0700)]
csclient: check directly for negative IPv4 pieces
As noted by clang, the code was looking for negative values of an
unsigned variable (which was read by strtoul).
CXX stap-csclient.o
../csclient.cxx:2638:44: error: comparison of unsigned expression < 0
is always false [-Werror,-Wtautological-compare]
if (errno != 0 || *estr != '\0' || p < 0 || p > 255)
~ ^ ~
This can never be negative, but strtoul will implicitly case negative-
looking strings to unsigned, which will make them fail p > 255 anyway.
But to be more direct, switch to [signed] long and use strtol.