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.
Dave Brolley [Tue, 10 Apr 2012 18:14:24 +0000 (14:14 -0400)]
Don't compile csclient.cxx and cscommon.cxx when HAVE_NSS is false.
- Don't compile the files at all (Makefile.am)
- #if HAVE_NSS added to the files in case another distro compiles
them anyway.
- Don't call functions in these files from elsewhere.
David Smith [Thu, 5 Apr 2012 19:27:51 +0000 (14:27 -0500)]
Added meta file for nfsdtop.stp and regenerated example index files.
* testsuite/systemtap.examples/network/nfsdtop.meta: New file.
* testsuite/systemtap.examples/network/nfsdtop.stp: Made executable and
added '#! /usr/bin/env stap' line at the top.
* testsuite/systemtap.examples/index.html: Regenerated.
* testsuite/systemtap.examples/index.txt: Ditto.
* testsuite/systemtap.examples/keyword-index.html: Ditto.
* testsuite/systemtap.examples/keyword-index.txt: Ditto.
David Smith [Wed, 4 Apr 2012 20:50:29 +0000 (15:50 -0500)]
Fix module build problem on ARM.
* runtime/vma.c (_stp_vma_match_vdso): Call __access_process_vm_noflush()
instead of __access_process_vm(). When reading user memory, the
__access_process_vm_noflush() and __access_process_vm() functions are
fairly equivalent and we're only reading here. (The write side of
__access_process_vm() calls non-exported functions on ia64, mips,
and arm.)
* runtime/sym.c (_stp_build_id_check): Ditto.
David Smith [Mon, 2 Apr 2012 19:24:21 +0000 (14:24 -0500)]
Fix module build problem on RHEL5 ia64.
* runtime/sym.c (_stp_build_id_check): Only call __access_process_vm()
when we're not using in-kernel utrace. On RHEL5 ia64 calling
__access_process_vm() doesn't work since it ends up calling
flush_icache_range(), which isn't exported.
* runtime/vma.c (_stp_vma_match_vdso): Ditto.
David Smith [Thu, 29 Mar 2012 20:31:33 +0000 (15:31 -0500)]
Fix stapiu cleanup to not hold rcu lock while decrementing semaphores.
* runtime/uprobes-inode.c (stapiu_decrement_process_semaphores): Unlock
rcu while writing semaphores. Otherwise we're atomic and we can't be in
atomic context while writing semaphores.
Wade Farnsworth [Wed, 28 Mar 2012 14:47:06 +0000 (07:47 -0700)]
Update sdt_misc.exp testcase for ARM
* Omit -m64 switch for wildcard tests, as ARM does not implement this
switch
* Mark a subset of the V1 and V2 tests as XFAIL, as they are known to fail
due to broken operand parsing on ARM. Note that this brokenness does
not affect V3.
David Smith [Fri, 23 Mar 2012 20:52:01 +0000 (15:52 -0500)]
Improve build-id checking when the task we're interested in isn't 'current'.
* translate.cxx (emit_module_init): Moved include files to
runtime/runtime.h.
* runtime/runtime.h: Moved includes here from translate.cxx. Rearranged
order a bit, to allow use of __access_process_vm() earlier.
* runtime/sym.c (_stp_build_id_check): Instead of passing in a flag to
indicate build-id checking a user module, instead pass a task_struct
pointer in. If the task_struct pointer isn't 'current', use
__access_process_vm() to read data.
(_stp_module_check): Update _stp_build_id_check() call.
(_stp_kmodule_check): Ditto.
(_stp_usermodule_check): Ditto.
* runtime/vma.c (_stp_vma_match_vdso): If the task we're trying to match
isn't 'current', use __access_process_vm() to read data.
Frank Ch. Eigler [Wed, 21 Mar 2012 01:02:19 +0000 (21:02 -0400)]
PR13876: avoid miscompilation of duplicated tapset function
It was found that the translator got confused if the same function was
defined by the tapset and the end-user script. The same problem can
also afflict global variables. Along the way, clean up error
formatting.
* staptree.h (semantic_error): Drop msg2 field, which was only ever
used for the perfunctory string "vs".
* elaborate.cxx (semantic_pass_symbols): Perform duplicate
global-variable & function testing and rejection.
(symresolution_info::find_function): Print an extra warning for
the case of mismatched function callee/caller arities.
(derive_probes): Prepare chained "while resolving
probe point" semantic_error instead of msg2 based additions.
* session.cxx (register_library_aliases): Ditto.
(print_error): Adjust to loss of msg2. Print tok1 / tok2
and source-context in a more readable way.
* tapsets.cxx (visit_target_symbol_context): Use const semantic_error*
temps to adjust to chaining changes.
* testsuite/systemtap.base/statement.exp: Adjust to changed error message.
* translate.cxx (*): Adjust to loss of semantic_error msg2.
Josh Stone [Tue, 20 Mar 2012 20:04:18 +0000 (13:04 -0700)]
PR13878: Mention the module in @cast "not found" message
To help understand when @cast fails to find a type, mention the module
that was searched. This may already hinted by the e->tok source
location, but stating the module explicitly is a useful hint if the user
left the module field to be implicitly filled in.
David Smith [Thu, 15 Mar 2012 18:04:35 +0000 (13:04 -0500)]
Fix PR13815 by fixing task_dentry_path() tapset function for RHEL5.
* tapset/dentry.stp (task_dentry_path): Fix for later RHEL5 kernels by
handling 'struct path' renamed to 'struct vfs_path' (problem first
noticed in kernel 2.6.18-308.el5).
Frank Ch. Eigler [Wed, 14 Mar 2012 19:16:37 +0000 (15:16 -0400)]
PR13847: simplify compiled-printf functions
* translate.cxx (emit_compiled_printfs): Emit flatter code, with
fewer { variables; } that a bad compiler can translate to a large
call frame. This appears to allow normal (non-noinline) functions.
Frank Ch. Eigler [Wed, 14 Mar 2012 17:10:38 +0000 (13:10 -0400)]
PR13847: don't build debuginfo for stap modules
Suppressing the -g (by default) for stap_*.ko reduces compile time
and greatly reduces resulting .ko file size. Since stap modules
are not usually probed themselves, this is a good default.
* buildrun.cxx (make_any_make_cmd): Prefix kbuildflags with CONFIG_DEBUG_INFO=.
William Cohen [Wed, 14 Mar 2012 15:43:50 +0000 (11:43 -0400)]
Allow sysroot_sysenv.exp to run correct on machines without uprobes
If the kernel does not have uprobes support, the sysroot_sysenv test
is untested. The catch and wait statements are only needed for the
case where the test is actually run. Having the catch statment run
when the test does not run causes an error.
Stan Cox [Wed, 14 Mar 2012 01:54:15 +0000 (21:54 -0400)]
Make the .library modifier aware of RPATH
* tapsets.cxx (base_query): Treat .library("lib") as a wildcard if it
isn't found in LD_LIBRARY_PATH
(query_modue): Likewise.
(query_one_library): Likewise.
dwarf_builder::build): Likewise.
Josh Stone [Mon, 12 Mar 2012 21:42:28 +0000 (14:42 -0700)]
Adapt to the inode-uprobes name change in tip
We now have the functions register_uprobe -> uprobe_register and
unregister_uprobe -> uprobe_unregister. The client API has otherwise
not changed.
I've made our code reflect the new names as much as possible, treating
the old names as the exceptional case, in case we ever want to remove
that compatibility. For now, it should work in all cases, although I
don't have a full complement of old/new & exported/!exported kernels to
test with.
Josh Stone [Fri, 9 Dec 2011 17:24:31 +0000 (09:24 -0800)]
Preliminary SDT semaphores with inode-uprobes
This adds mmap tracking to our inode-uprobes client, so we may
manipulate SDT semaphores as modules come and go. It seems to work ok,
though remaining sleepiness issues may need to be worked out in
task_finder2.
Wade Farnsworth [Thu, 8 Mar 2012 14:49:04 +0000 (07:49 -0700)]
PR12331: Introduce stap options --sysroot and --sysenv
This adds new command-line options to facilitate different file locations at
compile-time versus run-time when generating stap kernel modules for a remote
system:
1. --sysroot=DIR
Specifies a separate filesystem for the remote system on the local
system. The following stap functionalities will make use of this:
a. When compiling process and library probes with a remote filesystem path
(e.g. process("/bin/foo") with --sysroot=/bar/baz). In this case symbols
will be taken from the local filesystem (/bar/baz/bin/foo), but the
resulting .ko will still contain paths on the remote filesystem
(/bin/foo).
b. When passing a kernel release with -r (not a full path), the kernel
build directory will be expected in the sysroot.
c. When DWARF debug info is contained in a separate file from the
executable, the sysroot is used to find the debug info files.
d. All calls to find_executable() search the path passed in the
argument env_path relative to the sysroot. For example if
PATH=/bin/foo, and --sysroot=/bar/baz is provided, then
find_executable() called with env_path == "PATH" will search
/bar/baz/bin/foo.
e. stap attempts to detect if a path in a probe would be outside of the
sysroot and errors appropriately. This situation may occur, for
example, if the path contains several ".." directories.
2. --sysenv=VAR=VALUE
Specifies a different environment variable for the remote system as opposed
to the local one, and that the value on the remote system should be used.
Currently only valid env_path arguments to find_executable() are handled
(i.e. PATH, LD_LIBRARY_PATH). If --sysroot is provided and --sysenv
is omitted, then the local environment relative to the sysroot will
be used.
Mark Wielaard [Thu, 8 Mar 2012 14:20:08 +0000 (15:20 +0100)]
Select most specific CU srcfile that matches @var("var@src") specification.
dwarf_var_expanding_visitor::getcuscope: If there is a perfect match
select that CU, otherwise, select the CU srcfile that is most specific
(matching path/src file lenght is shortest).
Mark Wielaard [Wed, 7 Mar 2012 18:58:12 +0000 (19:58 +0100)]
PR13784 Allow defining a diffent CU source in @var.
Add cu_name to struct target_symbol. Set it in parse_target_symbol
to the string after @ in @var("somevar@some/src/file.c"). Make
target_symbol::sym_name() aware of @cu_name postfix (don't return it).
Add dwarf_var_expanding_visitor::getcuscope() which figures out the
CU DIE to use as scope if target_symbol has cu_name part. Extend
global_var.exp test to show new capability.
David Smith [Wed, 7 Mar 2012 18:05:39 +0000 (12:05 -0600)]
Remove CONFIG_UTRACE use in testsuite and just depend on utrace_p/uprobes_p.
* testsuite/buildok/pretty.stp: Moved uprobes tests to pretty-uprobes.stp.
* testsuite/buildok/pretty-uprobes.stp: New test.
* testsuite/buildok/ucontext-symbols-embedded.stp: Remove CONFIG_UTRACE
check and let buildok.exp kfail the test if no uprobes.
* testsuite/buildok/ucontext-unwind-embedded.stp: Ditto.
* testsuite/buildok/utrace.stp: Ditto.
* testsuite/semko/utrace.stp: Remove CONFIG_UTRACE check and let semko.exp
handle it.
* testsuite/semok/pretty.stp: Move uprobes tests to pretty-uprobes.stp.
* testsuite/semok/pretty-uprobes.stp: New test.
* testsuite/semok/thirtysix.stp: Move utrace tests to thirtysix-utrace.stp.
* testsuite/semok/thirtysix-utrace.stp: New test.
* testsuite/semok/utrace01.stp: Remove CONFIG_UTRACE check and let
semok.exp handle it.
* testsuite/systemtap.base/bz10294.stp: Remove CONFIG_UTRACE check and let
statement.exp handle it.
* testsuite/systemtap.base/bz6905.stp: Ditto.
* testsuite/systemtap.base/statement.exp: Handle no utrace by marking
tests as untested.
* testsuite/systemtap.base/func_alias.exp: If no utrace, mark test as
untested.
* testsuite/systemtap.pass1-4/buildok.exp: Kfail more utrace/uprobes tests.
* testsuite/systemtap.pass1-4/semko.exp: Ditto.
* testsuite/systemtap.pass1-4/semok.exp: Ditto.
Mark Wielaard [Tue, 6 Mar 2012 16:34:36 +0000 (17:34 +0100)]
Introduce @var("varname") as alternative syntax for $varname.
Adds a field target_name and a method sym_name() to struct target_symbol
to be used by the parser and tapsets translator so $name and @var("name")
can be used interchanably. Adds a testcase at_var.exp to test this for
various combinations of uprobes, kprobes, parameters, variables, arrays,
fields access, pretty printing and taking addresses.
Mark Wielaard [Wed, 7 Mar 2012 14:22:57 +0000 (15:22 +0100)]
Fix kallsyms_expand_symbol.exp regression after commit 4d51e8.
In dwflpp::find_variable_and_frame_base() when we do a search for a search
for an alternative vardie we need to saved the actual vardie content in
case we fail, no just copy the pointer to the vardie data...
Mark Wielaard [Wed, 7 Mar 2012 12:35:56 +0000 (13:35 +0100)]
PR10622. Better workaround for GCC PR51410. Find external var DIE location.
Some GCC versions would output duplicate external variables, one
without a location attribute. If so, try to find the other if it
exists in the same scope. This is a better solution than the previous
fallback solution of just trying to get the address in the symbol table.
That could result in picking the wrong external variable with the same
name (but from a different CU). Add test case to show this works better.