David Smith [Thu, 2 Feb 2012 16:36:44 +0000 (10:36 -0600)]
Fix PR13641 by not calling a sleeping function from an invalid context.
* testsuite/systemtap.examples/process/pfiles.stp: To avoid the
possibility of sleeping while holding a lock, change GFP_KERNEL
allocation to GFP_ATOMIC allocation. Also convert i_mode2str() from an
embedded-C function.
Mark Wielaard [Tue, 31 Jan 2012 22:06:30 +0000 (23:06 +0100)]
Use UTRACE_ATTACH_ATOMIC when calling utrace create under lock.
UTRACE_ATTACH_ATOMIC is very new, but we need it when calling
utrace create while holding a lock or in interrupt context.
If it doesn't exist we do as before (define it as zero).
See http://sourceware.org/ml/systemtap/2011-q4/msg00340.html
William Cohen [Tue, 31 Jan 2012 15:50:53 +0000 (10:50 -0500)]
Add the stopwatch.stp tapset
The stopwatch.stp tapset provides multiple, independent timers to user
scripts. Stopwatches can be created by the user script at
anytime. The created stopwatches can be stopped and started by the
user script. The times from the stopwatches can be read in seconds,
milliseconds, microsecons, and nanoseconds.
Dave Brolley [Mon, 30 Jan 2012 18:40:16 +0000 (13:40 -0500)]
PR 13631 and other rework of multi-privilege level support
- PR 13631 - Detection of Reqested Privilege Level in stap-server
- Parsing of the client's command now uses getopt_long and shares
the getopt input with session.cxx
- cmdline.cxx, cmdline.h
- Do not allow multiple privilege-setting options to specify
different privilege levels.
- No longer a need for stap-serverd to generate a --privilege
option for the spawned stap.
- stap-serverd cannot (and no longer does) rely on knowledge of
the highest signed privilege level when evaluating the user's
credentials.
- Simplified user credentials test against those required by the module
in stap-serverd.
- Some kernel.* probes were being registered for use by stapdev only.
Corrected to be stapdev | stapsys.
- Corrected testsuite problem which was hiding this bug.
Josh Stone [Sat, 28 Jan 2012 00:16:56 +0000 (16:16 -0800)]
task_finder2: update an unprivileged check for stapsys
* runtime/task_finder2.c (stap_start_task_finder): Update the macro
around the "only probe their own threads" check to exempt both stapdev
and stapsys modules (as __stp_utrace_attach_match_filename does).
Mark Wielaard [Thu, 26 Jan 2012 22:58:38 +0000 (23:58 +0100)]
PR13626 Add extra whitespace in sdt.h to deal with C11/C++11 UDF.
gcc 4.7 supports C11/C++11 user defined literals (UDF):
https://en.wikipedia.org/wiki/C%2B%2B11#User-defined_literals
In std=c++0x mode one now needs to add whitespace between string literals.
See http://gcc.gnu.org/gcc-4.7/porting_to.html
Chris Meek [Thu, 26 Jan 2012 18:56:07 +0000 (13:56 -0500)]
PR13546 Cont'd: Fixed failing test cases
Since we introduced a random seed to the hash function,
certain tests that printed results in an unordered
fashion could now fail, since the order is not necessarily
the same from run to run. These tests have been fixed and now
print in a certain order as to avoid those errors.
Chris Meek [Thu, 26 Jan 2012 18:48:46 +0000 (13:48 -0500)]
PR13546 - Improve Map Hashing
- Made str_hash() in map.c more hashy.
- Introduced a runtime random seed to the hash calculations
to reduce the chance of deliberate hash collision inducing
attacks.
- Made the HASH_TABLE_SIZE depend on MAXMAPENTRIES, rather than
just a static 256. This effectivly increases the size of the
hash table.
Josh Stone [Thu, 26 Jan 2012 18:11:23 +0000 (10:11 -0800)]
Don't squash to pass 4 when using --remote
Our native_build check is a little too zealous, squashing runs to pass 4
when the local kernel doesn't match the command-line arguments. When
we're running on a remote host, the local kernel is irrelevant.
This issue only cropped up if the user provided explicit -r/-a arguments
to match the remote -- otherwise the implicit searching was doing the
right thing with matching each kernel.
* session.cxx (systemtap_session::check_options): Remote targets don't
care a whit whether the local kernel matches the build.
While I still cannot see a reason how uprobe_{free,put}_process can
race uprobe_report_{exit,exec}, I certainly think somebit of cleanup
can be done. However I am dont think we need to do a utask or uproc lookup
from the table. Especially in case of callbacks.
Mostly similar to what Jim proposed.
I haven't tested this patch myself and I couldn't reproduce the problem.
[fche corrected some typos and removed meddlesome printk's]
William Cohen [Tue, 24 Jan 2012 16:58:39 +0000 (11:58 -0500)]
Add the pstrace function to tapset with documentation and example test
The pstrace function generates a string that traces the processes from
the task_struct passed in back to the ancestor spawned by init(1).
This allows you to determine what processes are ancestors for a particular
process.
Mark Wielaard [Tue, 24 Jan 2012 13:55:35 +0000 (14:55 +0100)]
dump_symbol_tables: kernel entry functions are NOTYPE.
Commit a09fc5 restricted symbol inclusion of STT_NOTYPE to ET_REL files
(kernel modules) to get fn-desc in .odp which don't occur anywhere else.
But kernel entry functions are also not STT_FUNC but are marked STT_NOTYPE.
William Cohen [Thu, 19 Jan 2012 14:50:08 +0000 (09:50 -0500)]
Improve extraction of kernel version for unprivileged_embedded_C.exp
The tcl code to extract the kernel version from the "uname -r" would
include extraneous characters for some cases, for example "3.2.0+"
would end up with "+" character in something that should only be a number.
This change eliminates the extraneous characters.
William Cohen [Thu, 19 Jan 2012 14:50:08 +0000 (09:50 -0500)]
Improve extraction of kernel version for unprivileged_embedded_C.exp
The tcl code to extract the kernel version from the "uname -r" would
include extraneous characters for some cases, for example "3.2.0+"
would end up with "+" chaacter in something that should only be a number.
This change eliminates the extraneous characters.
William Cohen [Tue, 17 Jan 2012 21:28:20 +0000 (16:28 -0500)]
Improve extraction of kernel version for bz6503.exp
The tcl code to extract the kernel version from the "uname -r" would
include extraneous characters for some cases, for example "3.2.0+"
would end up with "+" chaacter in something that should only be a number.
This change eliminates the extraneous characters.
David Smith [Thu, 5 Jan 2012 17:16:27 +0000 (11:16 -0600)]
Fix gcc 4.7 compile issues (most related to gcc PR49745).
* cache.cxx: Include <unistd.h>
* session.cxx: Ditto.
* setupdwfl.cxx: Ditto.
* translate.cxx (emit_symbol_data): Set correct type on structure
initialization to avoid gcc 4.7 error.
* runtime/autoconf-fs_supers-hlist.c: New test.
* buildrun.cxx (compile_pass): Run it.
* runtime/transport/transport.c (_stp_get_root_dir): Use
hlist_entry etc. if needed.
* runtime/autoconf-relay-umode_t.c: New test.
* buildrun.cxx (compile_pass): Run it.
* runtime/transport/relay_v2.c (__stp_relay_create_buf_file_callback):
Change int -> umode_t if needed.
Mark Wielaard [Sun, 25 Dec 2011 19:56:53 +0000 (20:56 +0100)]
Use function.call and function.return in all thread_indent() examples.
If the .call modifier isn't used the function probes will match both .call
and .inline, but .return doesn't match any inlined functions leading to
unbalanced thread_indent output.
Frank Ch. Eigler [Fri, 23 Dec 2011 19:49:56 +0000 (14:49 -0500)]
$SYSTEMTAP_SYNC: new environment variable for staprun
If set, it runs a sync(2) before the stap init_module(2)s. This is
only for helping bring up stap on unstable environments, so is not
formally documented.
Frank Ch. Eigler [Thu, 22 Dec 2011 02:06:24 +0000 (21:06 -0500)]
tapset: separate env_var() from context.stp
If it's left in context.stp, it will drag in tokenize.stp, which in
turns drags in an unoptimizable %{ #define STAP_NEED_CONTEXT_TOKENIZE 1 %}
which in turns enlarges the context.
* tapset/context-envvar.stp: New file. Steal env_var() from ...
* tapset/context.stp: ... from here.
(Note that there is no security impact to this change. The worst that
could happen before were unnecessary staprun startup errors.)
* runtime/staprun/staprun_funcs.c (insert_module): Return a nontrivial
error return code in some cases. (More needed!) Don't kvetch about
a failing init_module(2).
* runtime/staprun/staprun.c (enable_uprobes): Don't grep kallsyms for
an optimistic early abort. Just call insert_module. Don't freak upon
an EEXIST.
(insert_stap_module): Kvetch about a failing insert_module().
* testsuite/systemtap.base/buildid.exp: Stop using that profane artefact
of an obsolete past, "staprun -u".
Chris Meek [Tue, 20 Dec 2011 22:14:50 +0000 (17:14 -0500)]
PR13274 related: Added class to save and restore variables
Added a class save_and_restore to automatically save the value of
a variable, and restore it and the end of the calling function.
Can optionally take a variable to initialize the value to something
after saving it.
Changed warning printing to use session.print_warning(),
and cleaned up warnings being printed.
Also changed the logic in semantic_pass_optimize1 and 2
to either print all warnings if the verbosity is high enough
or suppress all warnings after the 1st itteration.
Changed it so we always use session.print_warning() rather than
an explicit call to clog or cerr. (There are a few cases where
the session is not available, so they were left as is, but
marked up with an // XXX needs-session comment.)
Also changed print_warning() to check for suppress_warnings, so
we no longer have to explicitly check for it when calling
print_warning(). There are a few cases where I left in the
explicit check, specifically when there was more code than
just a simple call to print_warning() within it.
Also standardized the use of "WARNING:". All warnings should now
use "WARNING:" rather than "Warning:" or "warning:".
Frank Ch. Eigler [Tue, 20 Dec 2011 20:49:35 +0000 (15:49 -0500)]
PR13489: don't confuse staprun's "is uprobes in the kernel?" logic
After recent commits associated with PR13489, a stap module may
include a few symbols named kallsyms_*, specifically
*unregister_uprobe. This confused staprun's simpleminded grep on
/proc/kallsyms to guess that uprobes per se was in the kernel, even
though it was just some peer stap module. So now grep for a more
picky regexp, including all-important whitespace.
* runtime/staprun/staprun.c (enable_uprobes): Look for
" unregister_uprobe\t" instead of "unregister_uprobe".
William Cohen [Fri, 16 Dec 2011 18:40:01 +0000 (13:40 -0500)]
Add the speculative.stp tapset
The speculative.stp tapset allow one to speculative add things to
output buffers and then later commit or discard the information in the
buffers. Four functions in the tapset:
speculation() - function to give an id for speculative buffer
speculate() - add output to a speculative buffer
discard() - remove output for a speculative buffer
commit() - output data for a speculative buffer
Frank Ch. Eigler [Mon, 19 Dec 2011 14:03:58 +0000 (09:03 -0500)]
PR13489, the neverending kludge story. Resolve RHEL5's old utrace conflicts.
RHEL5's old utrace uses utrace_native_view() instead of
task_user_regset_view(), so we shouldn't be so stuck on trying to find
it. To add insult to injury, any attempt to use kallsyms* to look up
the latter results in an unloadable module since kallsyms* is not
exported in these old kernels.
* transport/transport.c (_stp_transport_init): Only look for
task_user_regset_view for other than old rhel5 utrace.